@@ -144,19 +144,24 @@ namespace AIS
144144 std::string Message::getNMEATagBlock () const
145145 {
146146 static int groupId = 0 ;
147- groupId = (groupId % 9999 ) + 1 ; // Recycle 1-9999
148147
149148 std::string result;
150149 int total = NMEA.size ();
151150 int seq = 1 ;
152151
152+ if (total > 1 )
153+ groupId = (groupId % 9999 ) + 1 ; // Recycle 1-9999
154+
153155 // Use station ID with 's' prefix as source
154156 std::string src = " s" + std::to_string (station);
155157
156158 for (const auto &nmea : NMEA)
157159 {
158160 std::stringstream tb;
159- tb << " s:" << src << " ,c:" << rxtime << " ,g:" << seq << " -" << total << " -" << groupId;
161+ tb << " s:" << src << " ,c:" << rxtime;
162+
163+ if (total > 1 )
164+ tb << " ,g:" << seq << " -" << total << " -" << groupId;
160165
161166 // Calculate checksum for tag block
162167 std::string tbs = tb.str ();
@@ -715,43 +720,50 @@ namespace AIS
715720
716721 if (allow != all)
717722 {
718- if (!ret.empty ()) ret += " , " ;
723+ if (!ret.empty ())
724+ ret += " , " ;
719725 ret += " allowed {" + getAllowed () + " }" ;
720726 }
721727
722728 if (own_interval > 0 )
723729 {
724- if (!ret.empty ()) ret += " , " ;
730+ if (!ret.empty ())
731+ ret += " , " ;
725732 ret += " own_interval " + std::to_string (own_interval);
726733 }
727734
728735 if (position_interval > 0 )
729736 {
730- if (!ret.empty ()) ret += " , " ;
737+ if (!ret.empty ())
738+ ret += " , " ;
731739 ret += " position_interval " + std::to_string (position_interval);
732740 }
733741
734742 if (unique_interval > 0 )
735743 {
736- if (!ret.empty ()) ret += " , " ;
744+ if (!ret.empty ())
745+ ret += " , " ;
737746 ret += " unique_interval " + std::to_string (unique_interval);
738747 }
739748
740749 if (!MMSI_allowed.empty ())
741750 {
742- if (!ret.empty ()) ret += " , " ;
751+ if (!ret.empty ())
752+ ret += " , " ;
743753 ret += " mmsi_filter ON" ;
744754 }
745755
746756 if (!MMSI_blocked.empty ())
747757 {
748- if (!ret.empty ()) ret += " , " ;
758+ if (!ret.empty ())
759+ ret += " , " ;
749760 ret += " mmsi_block ON" ;
750761 }
751762
752763 if (!allowed_channels.empty ())
753764 {
754- if (!ret.empty ()) ret += " , " ;
765+ if (!ret.empty ())
766+ ret += " , " ;
755767 ret += " channel {" + allowed_channels + " }" ;
756768 }
757769
0 commit comments