@meri-imperiumi/signalk-meshtastic 1.2.2 → 1.2.3

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.
package/README.md CHANGED
@@ -91,6 +91,9 @@ Metrics used:
91
91
 
92
92
  ## Changes
93
93
 
94
+ * 1.2.3 (2024-10-15)
95
+ - Nodes that haven't been seen in last two days are no longer registered to Signal K data structure
96
+ - Added safeties for various non-numeric telemetry and coordinate values
94
97
  * 1.2.2 (2025-10-01)
95
98
  - Set "last seen" timestamp of nodes based on packet payloads, not the time they're received
96
99
  - Send timestamp with telemetry
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meri-imperiumi/signalk-meshtastic",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Signal K plugin for interfacing with the Meshtastic LoRa mesh network",
5
5
  "scripts": {
6
6
  "test": "eslint ."
@@ -47,7 +47,7 @@ module.exports = {
47
47
  latitudeI: Math.floor(waypointVessel.navigation.position.value.latitude / 1e-7),
48
48
  longitudeI: Math.floor(waypointVessel.navigation.position.value.longitude / 1e-7),
49
49
  expire: Math.floor((new Date().getTime() / 1000) + (length * 60 * 60)),
50
- name: waypointVessel.name,
50
+ name: waypointVessel.name || waypointVessel.mmsi,
51
51
  description: `AIS vessel ${waypointVessel.mmsi}`,
52
52
  icon: vesselIcon(waypointVessel),
53
53
  });
package/plugin/index.js CHANGED
@@ -101,7 +101,7 @@ function nodeToSignalK(app, node, nodeInfo, settings) {
101
101
  },
102
102
  ];
103
103
 
104
- if (nodeInfo.position) {
104
+ if (nodeInfo.position && Number.isFinite(nodeInfo.position.latitudeI)) {
105
105
  values.push({
106
106
  path: 'navigation.position',
107
107
  value: {
@@ -561,10 +561,13 @@ module.exports = (app) => {
561
561
  nodes[nodeInfo.num].publicKey = Buffer.from(nodeInfo.user.publicKey).toString('base64');
562
562
  }
563
563
  nodes[nodeInfo.num].seen = new Date(nodeInfo.lastHeard * 1000);
564
- const ctx = nodeToSignalK(app, nodes[nodeInfo.num], nodeInfo, settings);
565
- if (ctx && ctx.indexOf('vessels.urn:mrn:imo:mmsi:') === 0) {
566
- // We have an MMSI match, store it
567
- nodes[nodeInfo.num].mmsi = ctx.split(':').at(-1);
564
+ if (nodes[nodeInfo.num].seen > Date.now() - (1000 * 60 * 60 * 24 * 2)) {
565
+ // Node seen less than a two days ago, register with SK
566
+ const ctx = nodeToSignalK(app, nodes[nodeInfo.num], nodeInfo, settings);
567
+ if (ctx && ctx.indexOf('vessels.urn:mrn:imo:mmsi:') === 0) {
568
+ // We have an MMSI match, store it
569
+ nodes[nodeInfo.num].mmsi = ctx.split(':').at(-1);
570
+ }
568
571
  }
569
572
  setConnectionStatus();
570
573
  writeNodeDb();
@@ -754,7 +757,7 @@ module.exports = (app) => {
754
757
  },
755
758
  {
756
759
  path: 'navigation.gnss.antennaAltitude',
757
- value: position.data.altitude,
760
+ value: position.data.altitude || 0,
758
761
  },
759
762
  ];
760
763
  app.handleMessage('signalk-meshtastic', {
@@ -847,7 +850,8 @@ module.exports = (app) => {
847
850
  // Not connected to Meshtastic yet
848
851
  return;
849
852
  }
850
- if (v.value.latitude === null) {
853
+ if (!Number.isFinite(v.value.latitude)
854
+ || !Number.isFinite(v.value.longitude)) {
851
855
  // No position
852
856
  return;
853
857
  }
@@ -911,7 +915,7 @@ module.exports = (app) => {
911
915
  }
912
916
  }
913
917
  }
914
- if (!mobPosition || !mobPosition.latitude) {
918
+ if (!mobPosition || !Number.isFinite(mobPosition.latitude)) {
915
919
  return;
916
920
  }
917
921
  const setWaypointMessage = create(Protobuf.Mesh.WaypointSchema, {
@@ -14,16 +14,16 @@ class Telemetry {
14
14
 
15
15
  toMeshtastic() {
16
16
  const values = {};
17
- if (this.data['environment.outside.temperature']) {
17
+ if (Number.isFinite(this.data['environment.outside.temperature'])) {
18
18
  values.temperature = this.data['environment.outside.temperature'] - 273.15;
19
19
  }
20
- if (this.data['environment.outside.relativeHumidity']) {
20
+ if (Number.isFinite(this.data['environment.outside.relativeHumidity'])) {
21
21
  values.relativeHumidity = this.data['environment.outside.relativeHumidity'] * 100;
22
22
  }
23
- if (this.data['environment.outside.pressure']) {
23
+ if (Number.isFinite(this.data['environment.outside.pressure'])) {
24
24
  values.barometricPressure = this.data['environment.outside.pressure'] / 100;
25
25
  }
26
- if (this.data['environment.wind.directionTrue']) {
26
+ if (Number.isFinite(this.data['environment.wind.directionTrue'])) {
27
27
  values.windDirection = Math.floor(this.data['environment.wind.directionTrue'] * (180 / Math.PI));
28
28
  }
29
29
  if (this.data['environment.wind.speedOverGround'] && this.data['environment.wind.speedOverGround'].length) {
@@ -38,16 +38,16 @@ class Telemetry {
38
38
  // Clear wind history
39
39
  this.data['environment.wind.speedOverGround'] = [];
40
40
  }
41
- if (this.data['electrical.batteries.house.voltage']) {
41
+ if (Number.isFinite(this.data['electrical.batteries.house.voltage'])) {
42
42
  values.voltage = this.data['electrical.batteries.house.voltage'];
43
43
  }
44
- if (this.data['electrical.batteries.house.current']) {
44
+ if (Number.isFinite(this.data['electrical.batteries.house.current'])) {
45
45
  values.current = this.data['electrical.batteries.house.current'] * 1000;
46
46
  }
47
- if (this.data['navigation.anchor.distanceFromBow']) {
47
+ if (Number.isFinite(this.data['navigation.anchor.distanceFromBow'])) {
48
48
  // Using distance is a bit silly here as the unit is mm, but what can we do
49
49
  values.distance = this.data['navigation.anchor.distanceFromBow'] * 1000;
50
- } else if (this.data['environment.depth.belowSurface']) {
50
+ } else if (Number.isFinite(this.data['environment.depth.belowSurface'])) {
51
51
  // If not anchored, report depth as distance. Still mm.
52
52
  values.distance = this.data['environment.depth.belowSurface'] * 1000;
53
53
  }
@@ -55,6 +55,9 @@ class Telemetry {
55
55
  }
56
56
 
57
57
  updateWindSpeed(windSpeed) {
58
+ if (!Number.isFinite(windSpeed)) {
59
+ return;
60
+ }
58
61
  if (!this.data['environment.wind.speedOverGround']) {
59
62
  this.data['environment.wind.speedOverGround'] = [];
60
63
  }