signalk-vessels-to-ais 1.5.0 → 1.6.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.
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "npm" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
package/README.md CHANGED
@@ -9,6 +9,8 @@ User can configure:
9
9
  - Own data can be added to AIS sending
10
10
 
11
11
  New:
12
+ - v1.6.0, fix: enhance error handling for AIS timestamp retrieval
13
+ - v1.5.1, fix: fix: improve shipName type checking
12
14
  - v1.5.0, fix: callSign reading
13
15
  - v1.4.0, add: Event output name to user configurable
14
16
  - v1.3.0, add: Navigational Status variations
package/index.js CHANGED
@@ -211,25 +211,35 @@ module.exports = function createPlugin(app) {
211
211
  const numberAIS = Object.keys(jsonContent).length;
212
212
  for (i = 0; i < numberAIS; i++) {
213
213
  const jsonKey = Object.keys(jsonContent)[i];
214
-
215
214
  try {
216
215
  aisTime = jsonContent[jsonKey].sensors.ais.class.timestamp;
217
216
  } catch (error) {
218
- if (i === 0) {
219
- aisTime = jsonContent[jsonKey].navigation.position.timestamp;
220
- } else {
217
+ try {
218
+ if (i === 0) {
219
+ aisTime = jsonContent[jsonKey].navigation.position.timestamp;
220
+ } else {
221
+ aisTime = null;
222
+ }
223
+ } catch (error) {
221
224
  aisTime = null;
222
225
  }
223
226
  }
224
227
 
225
- aisDelay = (parseFloat((moment(new Date(Date.now()))
228
+ if (aisTime) {
229
+ aisDelay = (parseFloat((moment(new Date(Date.now()))
226
230
  .diff(aisTime) / 1000).toFixed(3))) < positionUpdate;
231
+ } else {
232
+ aisDelay = false;
233
+ }
234
+
227
235
 
228
236
  try {
229
237
  mmsi = jsonContent[jsonKey].mmsi;
230
238
  } catch (error) { mmsi = null; }
231
239
  try {
232
- shipName = jsonContent[jsonKey].name;
240
+ shipName = typeof jsonContent[jsonKey]?.name === 'string'
241
+ ? jsonContent[jsonKey].name
242
+ : jsonContent[jsonKey]?.name?.value || '';
233
243
  } catch (error) { shipName = ''; }
234
244
  try {
235
245
  lat = jsonContent[jsonKey].navigation.position.value.latitude;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signalk-vessels-to-ais",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "SignalK server plugin to convert other vessel data to NMEA0183 AIS format and forward it out to 3rd party applications",
5
5
  "main": "index.js",
6
6
  "scripts": {