@sailingnaturali/signalk-dsc 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +6 -2
  2. package/index.js +15 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -48,8 +48,12 @@ For every DSC call heard by a connected radio:
48
48
  Full detail (MMSI, coordinates, reported time, transport) goes to the call
49
49
  log and the logbook entry instead, so TTS pipelines stay terse.
50
50
  - **Remote-vessel deltas** — the caller's `navigation.position` (and a distress
51
- notification) under `vessels.urn:mrn:imo:mmsi:<caller>`, so chartplotters can
52
- show where the call came from.
51
+ notification) under the caller's context, so chartplotters can show where the
52
+ call came from. A **distress** caller is emitted under the Search-and-Rescue
53
+ context `sar.urn:mrn:imo:mmsi:<caller>` — which plotters like
54
+ [Freeboard-SK](https://github.com/SignalK/freeboard-sk) render as a distress
55
+ (SaR) target rather than an ordinary AIS vessel; every other category stays
56
+ under `vessels.urn:mrn:imo:mmsi:<caller>`.
53
57
  - Every stored call carries an `ownShip` snapshot of the moment it arrived —
54
58
  position, course, heading, speed, wind, pressure, and (when a source publishes them)
55
59
  sea state, visibility, and cloud coverage. Absent sensor, absent field.
package/index.js CHANGED
@@ -244,8 +244,14 @@ module.exports = function makePlugin(app) {
244
244
  return event;
245
245
  }
246
246
 
247
- function remoteContext(mmsi) {
248
- return `vessels.urn:mrn:imo:mmsi:${mmsi}`;
247
+ // The SignalK context the caller's position is emitted under. A distress
248
+ // caller is a vessel in extremis, so it goes under the Search-and-Rescue
249
+ // context (`sar.`) — which chartplotters (e.g. Freeboard-SK) render as a
250
+ // distress/SaR target rather than an ordinary AIS vessel. Every other
251
+ // category stays under `vessels.` like any AIS contact.
252
+ function callerContext(category, mmsi) {
253
+ const prefix = category === 'distress' ? 'sar' : 'vessels';
254
+ return `${prefix}.urn:mrn:imo:mmsi:${mmsi}`;
249
255
  }
250
256
 
251
257
  // Custom sentence parsers override the stock hooks (a superset of the
@@ -263,8 +269,8 @@ module.exports = function makePlugin(app) {
263
269
  receivedAt: input.tags && input.tags.timestamp,
264
270
  });
265
271
 
266
- // Upstream-compatible delta under the sender's context so chartplotters
267
- // and AIS-style consumers see the caller's position.
272
+ // Delta under the caller's context so chartplotters and AIS-style
273
+ // consumers see the caller's position (distress → SaR target).
268
274
  if (parsed.mmsi) {
269
275
  const values = [];
270
276
  if (parsed.position) {
@@ -281,7 +287,10 @@ module.exports = function makePlugin(app) {
281
287
  });
282
288
  }
283
289
  if (values.length) {
284
- return { context: remoteContext(parsed.mmsi), updates: [{ values }] };
290
+ return {
291
+ context: callerContext(parsed.category, parsed.mmsi),
292
+ updates: [{ values }],
293
+ };
285
294
  }
286
295
  }
287
296
  } catch (err) {
@@ -306,7 +315,7 @@ module.exports = function makePlugin(app) {
306
315
  const refined = refinePosition(target.position, ext);
307
316
  store.update(target.id, { position: refined, positionResolution: 'enhanced' });
308
317
  return {
309
- context: remoteContext(ext.mmsi),
318
+ context: callerContext(target.category, ext.mmsi),
310
319
  updates: [{ values: [{ path: 'navigation.position', value: refined }] }],
311
320
  };
312
321
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailingnaturali/signalk-dsc",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Receive, log, and alert on DSC (VHF digital selective calling) calls — distress, urgency, safety, routine — from NMEA 0183 ($CDDSC/$CDDSE) and NMEA 2000 (PGN 129808).",
5
5
  "main": "index.js",
6
6
  "scripts": {