@sailingnaturali/signalk-dsc 0.5.4 → 0.5.5

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 (2) hide show
  1. package/index.js +8 -19
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -35,6 +35,7 @@ const {
35
35
  captureOwnShip,
36
36
  buildObservations,
37
37
  unwrap,
38
+ writeLogbookEntry,
38
39
  } = require('@sailingnaturali/signalk-distress-core');
39
40
 
40
41
  const DSC_PGN = 129808;
@@ -185,26 +186,14 @@ module.exports = function makePlugin(app) {
185
186
  }
186
187
 
187
188
  async function postLogbook(event) {
188
- const observations = buildObservations(event.ownShip);
189
- const res = await fetch(options.logbookUrl, {
190
- method: 'POST',
191
- headers: {
192
- 'Content-Type': 'application/json',
193
- // signalk-server's auth gate reads the Authorization header; the
194
- // logbook plugin reads the author from the JAUTHENTICATION cookie.
195
- Authorization: `Bearer ${options.logbookToken}`,
196
- Cookie: `JAUTHENTICATION=${options.logbookToken}`,
197
- },
198
- body: JSON.stringify({
199
- text: buildLogbookText(event, messageContext(event)),
200
- ago: 0,
201
- category: 'radio',
202
- // DSC is received on VHF channel 70 by definition.
203
- vhf: '70',
204
- ...(observations ? { observations } : {}),
205
- }),
189
+ await writeLogbookEntry({
190
+ url: options.logbookUrl,
191
+ token: options.logbookToken,
192
+ text: buildLogbookText(event, messageContext(event)),
193
+ observations: buildObservations(event.ownShip),
194
+ // DSC is received on VHF channel 70 by definition.
195
+ extra: { vhf: '70' },
206
196
  });
207
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
208
197
  }
209
198
 
210
199
  /** Store a normalized call, alarm on it, and log it. Returns the stored event. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailingnaturali/signalk-dsc",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
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": {
@@ -49,6 +49,6 @@
49
49
  "node": ">=18"
50
50
  },
51
51
  "dependencies": {
52
- "@sailingnaturali/signalk-distress-core": "^0.1.0"
52
+ "@sailingnaturali/signalk-distress-core": "^0.2.0"
53
53
  }
54
54
  }