Skip to main content

Module anchor

Module anchor 

Source
Expand description

Setting the anchor watch, on the wire.

navigation.anchor.position and navigation.anchor.maxRadius are ordinary Signal K data-model paths, not Resources-API items: there is no list to fetch and no id the server mints. A client watches the delta stream for their current values, the same way it already watches navigation.position/design.draft/wind; this module provides only the write half, setting or clearing them.

Confirmed against a signalk-server running signalk-anchoralarm-plugin (the ecosystem’s reference anchor-alarm plugin): it registers real PUT action handlers for both paths (app.registerPutHandler), so a plain PUT /signalk/v1/api/vessels/self/navigation/anchor/{path} works, unlike a path nothing has claimed, which the server’s generic handler refuses with 405 PUT not supported. Setting navigation.anchor.position to null also nulls maxRadius: the plugin’s own getAnchorDelta nulls both together whenever no position is given. The read side’s whole contract is that “anchored” means navigation.anchor.position is currently non-null, nothing more.

The reply to one of these PUTs is the server’s plain requestResponse shape (state/statusCode/requestId/…), not the Resources API’s ActionResult (id/message on success); resources::read_action_response is the wrong reader for it. A captured reply: {"state":"COMPLETED","requestId":"...","statusCode":202,...}.

Structs§

Client
A client for setting one server’s own anchor watch.