Open neillj opened 2 years ago
On further investigation I think actually you need to decode the part type in the parseStaticDataReport method so I've tried this change
export function parseStaticDataReport(
bitArray: Array<number>,
aisType: number,
repeat: number,
mmsi: string
): Static_Data_Report {
const messageType = fetchIntByAttr(bitArray, aisType, 'partno') == 0 ? 'A' : 'B'
if (messageType === 'A') {
which works with the messages I have. I removed the passing in of the part number and get it from the passed in message. This matches what https://www.navcen.uscg.gov/ais-class-b-reports shows for these.
Hope this helps
Hi Doron
I think I've found a bug in the src/lib/index.ts when receiving a message 24A. You have
but the session object for a 24A with a message of e.g. "!AIVDO,1,1,,B,H3P<........,2*46" won't necessarily have a session object defined at this point as the code relies on messageCounter>1 to define it and here that is 1. This results in it decoding part B by mistake in this case as the identity to 1 fails for an empty object. The message I've quoted is from messages recorded live so, even it isn't following the standard does exist 'in the wild'.
The fix that works for me is
where there's a check to make sure the session has been defined (multipart message) or hasn't been (single message).
Thanks for the plugin !
Neill