Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

panaaj
Copy link
Member

@panaaj panaaj commented Jun 8, 2024

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

  • navigation.courseRhumbline.nextPoint.position OR
  • navigation.courseGreatCircle.nextPoint.position

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.

Set / clear destination from NMEA  stream data.
@panaaj panaaj added the feature label Jun 8, 2024
@panaaj panaaj requested a review from tkurki June 8, 2024 02:28
@panaaj panaaj changed the title Feature: Add NMEA stream handling to Course API. feature: Add NMEA stream handling to Course API. Jun 8, 2024
Fixes issue of corrupted nextPoint  value when emitting v1 course delta.
Setting this param causes the stream input to be ignored until the endpoint is called again without specifying `force`.
Copy link
Member

@tkurki tkurki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

docs/src/develop/rest-api/course_api.md Outdated Show resolved Hide resolved
src/api/course/index.ts Outdated Show resolved Hide resolved
src/api/course/index.ts Outdated Show resolved Hide resolved
src/api/course/index.ts Show resolved Hide resolved
src/api/course/index.ts Outdated Show resolved Hide resolved
src/api/course/openApi.json Outdated Show resolved Hide resolved
src/api/course/openApi.json Show resolved Hide resolved
src/api/course/index.ts Outdated Show resolved Hide resolved
src/api/course/index.ts Outdated Show resolved Hide resolved
@panaaj
Copy link
Member Author

panaaj commented Jun 17, 2024

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.

src/api/course/openApi.json Outdated Show resolved Hide resolved
@panaaj panaaj requested a review from tkurki June 22, 2024 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants