@meri-imperiumi/signalk-mob-notifier 1.1.1 → 1.1.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
@@ -11,6 +11,10 @@ Please note that this plugin aims to aid with noticing and locating crew overboa
11
11
 
12
12
  ## Changes
13
13
 
14
+ * 1.1.3 (2025-11-02)
15
+ - Fix detection of beacon type (MOB/SART/EPIRB)
16
+ * 1.1.2 (2025-11-01)
17
+ - Better approach at getting MOB coordinates
14
18
  * 1.1.1 (2025-09-18)
15
19
  - Notifications include position when available
16
20
  * 1.1.0 (2025-09-04)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meri-imperiumi/signalk-mob-notifier",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Create Signal K notifications for discovered AIS MOB, EPIRB, and SART beacons",
5
5
  "main": "plugin/index.js",
6
6
  "scripts": {
package/plugin/index.js CHANGED
@@ -103,18 +103,34 @@ module.exports = (app) => {
103
103
  return;
104
104
  }
105
105
  let message = 'Crew Overboard Beacon detected';
106
- if (mmsi.indexOf('970') === 0) {
106
+ if (String(mmsi).indexOf('970') === 0) {
107
107
  message = 'Search and Rescue Transponder Beacon detected';
108
108
  }
109
- if (mmsi.indexOf('974') === 0) {
109
+ if (String(mmsi).indexOf('974') === 0) {
110
110
  message = 'Emergency Position Indicating Beacon detected';
111
111
  }
112
112
  // For each MOB get direction and range
113
- const ownPosition = app.getSelfPath('navigation.position');
114
- const mobPosition = app.getPath(`vessels.urn:mrn:imo:mmsi:${mmsi}.navigation.position`);
115
- if (ownPosition && ownPosition.value && mobPosition && mobPosition.value) {
116
- const me = new Point(ownPosition.value.latitude, ownPosition.value.longitude);
117
- const they = new Point(mobPosition.value.latitude, mobPosition.value.longitude);
113
+ const getCoordinates = (v) => {
114
+ if (Number.isFinite(v.latitude)) {
115
+ return v;
116
+ }
117
+ if (v.value && Number.isFinite(v.value.latitude)) {
118
+ return v.value;
119
+ }
120
+ return {};
121
+ };
122
+ const ownPosition = getCoordinates(app.getSelfPath('navigation.position'));
123
+ const mob = app.getPath(`vessels.urn:mrn:imo:mmsi:${mmsi}`);
124
+ let mobPosition = {};
125
+ if (mob.navigation && mob.navigation.position) {
126
+ mobPosition = getCoordinates(mob.navigation.position);
127
+ }
128
+ if (ownPosition
129
+ && Number.isFinite(ownPosition.latitude)
130
+ && mobPosition
131
+ && Number.isFinite(mobPosition.latitude)) {
132
+ const me = new Point(ownPosition.latitude, ownPosition.longitude);
133
+ const they = new Point(mobPosition.latitude, mobPosition.longitude);
118
134
  const distance = me.distanceTo(they, 'K') * 1000; // In meters
119
135
  const direction = longDirection(me.directionTo(they));
120
136
  message = `${message} ${distance} meters to ${direction}`;
@@ -134,7 +150,7 @@ module.exports = (app) => {
134
150
  path: `notifications.mob.${mmsi}`,
135
151
  value: {
136
152
  message,
137
- position: mobPosition ? mobPosition.value : null,
153
+ position: mobPosition || null,
138
154
  data: {
139
155
  mmsi,
140
156
  },