After decoding AIVM sentences using gpsdecode I have a buch of json estructures, each one with all the data of a message type, for example:
{"class":"AIS","device":"stdin","type":1,"repeat":0,"mmsi":224047690,"scaled":true,"status":15,"status_text":"Not defined","turn":"nan","speed":0.0,"accuracy":false,"lon":-8.7296,"lat":42.2401,"course":231.9,"heading":511,"second":36,"maneuver":0,"raim":true,"radio":114776}
{"class":"AIS","device":"stdin","type":4,"repeat":0,"mmsi":2240998,"scaled":true,"timestamp":"2018-05-19T16:34:35Z","accuracy":true,"lon":-8.7877,"lat":42.1717,"epfd":7,"epfd_text":"Surveyed","raim":false,"radio":165192}
My problem is that position messages (type 1,2,3) doesn't have the complete UTC just a reference in seconds between 0-60, which is the correct way to obtain the complete UTC for this messages?
The timestamp is NOT present in the AIS message.
The AIS system was initially created as a collision avoidance system, and was supposed to be used in real time, hence there was no need to transmit a timestamp.
If you receive a live AIS feed, you need to add the current timestamp immediately when you receive the message, and potentially use a queue to postpone the rest of the treatment.
The UTC_seconds
field in the message is the second when the report was generated by the electronic position system, not a real timestamp. You can find all the fields transmitted in the messages 1, 2, 3 at https://www.navcen.uscg.gov/?pageName=AISMessagesA.