Skip to content

[codex] SafetyNET/Inmarsat and NMEA amendment cleanup#11

Merged
mgrouch merged 38 commits into
mainfrom
codex/safetynet-phase1-model
Jul 6, 2026
Merged

[codex] SafetyNET/Inmarsat and NMEA amendment cleanup#11
mgrouch merged 38 commits into
mainfrom
codex/safetynet-phase1-model

Conversation

@mgrouch

@mgrouch mgrouch commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR now covers phases 1 through 4 of the SafetyNET/Inmarsat-C cleanup.

Phase 1 moves Inmarsat storage out of comm and into notifications.inmarsat.safetynet, while keeping NMEA sentence interpretation in the connector.

Phase 2 adds structured SM1, SM2, SM3, SM4, and SMB SafetyNET support, including header fields, area addressing, body assembly, completion state, duplicate tracking, and mandatory reception flags.

Phase 3 adds handlers for ABK, AGA, BCL, and MOB using existing typed model records. ABK maps into AIS acknowledgement and data-link status. AGA maps into AIS group assignment. BCL maps into AIS base-station location data. MOB maps into the existing special notification vessel-message record.

Phase 4 adds CR terminal/network handling for CRCAN, CRCRQ, CRDSM, and CRTMD. Cancel/query/status use existing notification event/text records, and CRTMD payloads are stored under notifications.inmarsat.safetynet with multipart assembly.

Validation

Latest CI passed: Linux build/test and Arduino AtomS3R compile are green. The Linux test step includes the fixture test target.

Summary by CodeRabbit

  • New Features

    • Added broader NMEA message support, including SafetyNET and several new terminal/control sentence types.
    • Improved parsing of tagged NMEA lines and fragmented SafetyNET messages.
    • Added support for storing and showing SafetyNET notification history and latest-message details.
  • Bug Fixes

    • Improved handling of message acknowledgements, duplicates, and fragment recovery.
    • Fixed acceptance of additional valid fixture and sentence formats, making real-world imports more reliable.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 835eabe8-8f42-4c60-bc96-dac8d559ecf6

📥 Commits

Reviewing files that changed from the base of the PR and between 0af448b and d39b693.

📒 Files selected for processing (15)
  • .github/workflows/ci.yml
  • CMakeLists.txt
  • modules/data-model/src/ship_data_model/comm/comm_data.hpp
  • modules/data-model/src/ship_data_model/notifications/notifications_data.hpp
  • modules/nmea0183/src/nmea0183_connector/nmea_inmarsat.hpp
  • modules/nmea0183/src/nmea0183_connector/nmea_inmarsat_cr.hpp
  • modules/nmea0183/src/nmea0183_connector/nmea_message_state.hpp
  • modules/nmea0183/src/nmea0183_connector/nmea_phase3_amendments.hpp
  • modules/nmea0183/src/nmea0183_connector/nmea_rx_connector.hpp
  • modules/nmea0183/src/nmea0183_connector/sentence_parser.hpp
  • tests/fixtures/nmea/safetynet_sm_actual.nmea
  • tests/test_nmea_inmarsat.cpp
  • tests/test_nmea_inmarsat_history.cpp
  • tests/test_nmea_phase3_amendments.cpp
  • tests/test_nmea_real_fixtures.cpp

📝 Walkthrough

Walkthrough

This PR replaces the comm.inmarsat data model with a new notifications.inmarsat.safetynet model, reworking Inmarsat SM/SMB header/body assembly, CR terminal sentence handling, and commit logic. It adds NMEA Phase 3 sentence support (ABK/AGA/BCL/MOB), extends the sentence parser for tag blocks and SMB fragments, updates RX connector dispatch wiring, and adjusts CI/build/test infrastructure.

Changes

Inmarsat SafetyNET Migration

Layer / File(s) Summary
Data model: remove comm.inmarsat, add notifications.inmarsat.safetynet
modules/data-model/src/ship_data_model/comm/comm_data.hpp, modules/data-model/src/ship_data_model/notifications/notifications_data.hpp
Removes Inmarsat enums/structs and the inmarsat field from CommData, replaces the capacity constant with DSC_CALL_HISTORY_CAPACITY, and adds SafetyNET notification structs plus an inmarsat field on NotificationsData.
Message state: SafetyNET assembly record
modules/nmea0183/src/nmea0183_connector/nmea_message_state.hpp
Adds a text-size constant and NmeaSafetyNetAssemblyRecord, wired into NmeaMessageState for in-progress SM/SMB assembly.
Inmarsat SM/SMB parsing, commit, and routing
modules/nmea0183/src/nmea0183_connector/nmea_inmarsat.hpp
Replaces payload decoding with connector/header kind classification, label mapping, lat/lon parsing, SM1-SM4/SMB assembly, dedup/history storage, commit-into-notifications logic, and reworked apply_inmarsat routing.
CR terminal sentence handling
modules/nmea0183/src/nmea0183_connector/nmea_inmarsat_cr.hpp
New header adding terminal-source filtering, acknowledgement matching, and appliers for CAN/CRQ/DSM/TMD sentences updating safetynet/notification state.
Sentence parser: SMB classification and tag-block support
modules/nmea0183/src/nmea0183_connector/sentence_parser.hpp
Recognizes SMB as an Inmarsat SM sentence, adds SMB fragment-info detection, and refactors parse_line to strip optional leading tag blocks.
RX connector dispatch wiring for Inmarsat sentences
modules/nmea0183/src/nmea0183_connector/nmea_rx_connector.hpp
Adds dispatch entries for CAN/CRQ/DSM/TMD and includes the new CR header.
Inmarsat/SafetyNET tests and fixtures
tests/fixtures/nmea/safetynet_sm_actual.nmea, tests/test_nmea_inmarsat.cpp, tests/test_nmea_inmarsat_history.cpp
New fixture and rewritten tests validate notifications.inmarsat.safetynet storage, SM/SMB decoding, fragment/unsupported counts, and CR terminal sentence effects.

NMEA Phase 3 Amendments (ABK/AGA/BCL/MOB)

Layer / File(s) Summary
Phase 3 sentence appliers
modules/nmea0183/src/nmea0183_connector/nmea_phase3_amendments.hpp
New header implementing apply_abk, apply_aga, apply_bcl, apply_mob with field parsing, validation, and model updates.
RX connector dispatch wiring for Phase 3 sentences
modules/nmea0183/src/nmea0183_connector/nmea_rx_connector.hpp
Adds ABK/AGA/BCL/MOB dispatch entries and includes the new Phase 3 header.
Phase 3 tests and build wiring
CMakeLists.txt, tests/test_nmea_phase3_amendments.cpp, tests/test_nmea_real_fixtures.cpp
Registers a new test target, adds ABK/AGA/BCL/MOB tests, and updates fixture rejection/validation logic.

Build and CI Infrastructure

Layer / File(s) Summary
CI and CMake configuration
.github/workflows/ci.yml, CMakeLists.txt
Switches library.properties generation to printf commands and changes include directories to relative paths.

Estimated code review effort: 4 (Complex) | ~75 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RxConnector as Nmea0183RxConnector
  participant Inmarsat as apply_inmarsat
  participant Assembly as NmeaSafetyNetAssemblyRecord
  participant Model as notifications.inmarsat.safetynet

  RxConnector->>Inmarsat: apply_sentence(SM1..SM4 / SMB)
  Inmarsat->>Assembly: apply_safetynet_header / apply_safetynet_smb
  Assembly-->>Inmarsat: fragment/body state
  Inmarsat->>Model: commit_inmarsat_safetynet_message
  Model-->>Inmarsat: latest_message + history updated
Loading
sequenceDiagram
  participant RxConnector as Nmea0183RxConnector
  participant CrHandler as apply_inmarsat_can/crq/dsm/tmd
  participant SafetyNet as safetynet.latest_message

  RxConnector->>CrHandler: apply_sentence(CAN/CRQ/DSM/TMD)
  CrHandler->>SafetyNet: inmarsat_cr_mark_message_acknowledged / field updates
  SafetyNet-->>CrHandler: updated metadata/timestamps
Loading

Possibly related PRs

  • bareboat-necessities/signalk-mini#4: Both PRs modify comm_data.hpp around DSC history capacity and Inmarsat-related comm struct members, in opposite directions.
  • bareboat-necessities/signalk-mini#5: Directly connected Inmarsat decoding work in nmea_inmarsat.hpp and RX wiring, with storage moved from comm.inmarsat to notifications.inmarsat.safetynet.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/safetynet-phase1-model

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mgrouch mgrouch changed the title [codex] Phase 1 SafetyNET notification model cleanup [codex] SafetyNET/Inmarsat and NMEA amendment cleanup Jul 6, 2026
@mgrouch mgrouch marked this pull request as ready for review July 6, 2026 23:22
@mgrouch mgrouch merged commit 4099399 into main Jul 6, 2026
4 of 5 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

inline bool nmea_is_proprietary_sentence(const NmeaSentence& s) {

P2 Badge Keep SMB out of the shared Inmarsat fragment state

When a multi-fragment SMB body arrives while an IMK/CRTMD multipart message is in progress, marking SMB as a generic fragment here makes apply_sentence() feed it through update_multipart_message_state() before the dedicated SafetyNET assembler runs. That resets state_.inmarsat_message to the SMB identity, so the next fragment of the original Inmarsat/CRTMD message is treated as a bad non-first fragment and never commits. Since apply_safetynet_smb() already assembles SMB in state_.inmarsat_safetynet, avoid routing SMB through the shared multipart record or skip the generic update for it.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant