SignalK / signalk-server

An implementation of a Signal K central server for boats.
http://signalk.org
Apache License 2.0
307 stars 152 forks source link

feature: Add NMEA stream handling to Course API. #1750

Open panaaj opened 3 months ago

panaaj commented 3 months ago

Provide the ability for the Course API to set the destination based on the data received from NMEA connections.

Delta messages with a source.type of NMEA0183 or NMEA2000 containing path values for

will trigger invoke the course setDestination() method.

Source priorities:

The following priorities are applied when determining whether a destination will be set from an NMEA delta:

  1. Destination requests via Course API endpoints have the highest priority and will ALWAYS be actioned!
  2. If a destination is set, only updates from the same source are actioned (unless it is an API request)
  3. If no destination is currently set, the first NMEA delta containing nextPoint.position data will be used

Approach:

A subscription has been added to the Course API for the paths navigation.courseRhumbline.nextPoint.position OR navigation.courseGreatCircle.nextPoint.position to listen for deltas generated by NMEA data connections and set / clear the destination using API methods.

Clearing a destination using an API request, when an NMEA source still has an active destination, requires clearDestination(true) to force api only mode, which will cause delta messages to be ignored until:

  1. clearDestination() tis called OR
  2. DELETE ./course/commandSource HTTP request is made.
panaaj commented 3 months ago

Did I understand the idea here correctly: we don't touch the 0183 and N2K parsers and instead make course API act on the sk messages they produce?

Short answer is yes.

After considering a number of approaches I landed on this approach for the following reasons:

  1. NMEA PGNS / Sentences already parsed
  2. New PGNs added to N2K parser are immediately supported
  3. Passively "taps" into a single input stream of data (which includes all input sources)
  4. Provides option to "filter / change" the incoming message (if required)
  5. Does not introduce breaking changes for applications and plugins (as input stream remains unchanged)
  6. Provides a workable MVP which can facilitate a managed transition to an alternative approach.
panaaj commented 3 weeks ago

@tkurki is there anything further required here?