@meri-imperiumi/signalk-mob-notifier 1.0.0 → 1.0.2
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 +1 -1
- package/package.json +2 -2
- package/plugin/index.js +14 -6
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Signal K MOB notifier plugin
|
|
2
2
|
============================
|
|
3
3
|
|
|
4
|
-
This plugin detects if Signal K has seen an AIS MOB (MMSI starting with `972`) or SART (MMSI starting with `970`) beacon. If a beacon is detected, a [Signal K notification](https://signalk.org/specification/1.5.0/doc/notifications.html) will be raised. With the notification there are various ways to alert the crew:
|
|
4
|
+
This plugin detects if Signal K has seen an AIS MOB (MMSI starting with `972`), EPIRB (MMSI starting with `974`), or SART (MMSI starting with `970`) beacon. If a beacon is detected, a [Signal K notification](https://signalk.org/specification/1.5.0/doc/notifications.html) will be raised. With the notification there are various ways to alert the crew:
|
|
5
5
|
|
|
6
6
|
* Audio with plugins like [signalk-audio-notifications](https://github.com/meri-imperiumi/signalk-audio-notifications) and an attached speaker
|
|
7
7
|
* Meshtastic message with [signalk-meshtastic](https://github.com/meri-imperiumi/signalk-meshtastic)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meri-imperiumi/signalk-mob-notifier",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Create Signal K notifications for discovered AIS MOB and SART beacons",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Create Signal K notifications for discovered AIS MOB, EPIRB, and SART beacons",
|
|
5
5
|
"main": "plugin/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "eslint ."
|
package/plugin/index.js
CHANGED
|
@@ -38,12 +38,12 @@ module.exports = (app) => {
|
|
|
38
38
|
const notified = [];
|
|
39
39
|
plugin.id = 'signalk-mob-notifier';
|
|
40
40
|
plugin.name = 'MOB Beacon Notifier';
|
|
41
|
-
plugin.description = 'Create notifications for discovered AIS MOB and SART beacons';
|
|
41
|
+
plugin.description = 'Create notifications for discovered AIS MOB, EPIRB, and SART beacons';
|
|
42
42
|
|
|
43
43
|
plugin.start = (settings) => {
|
|
44
44
|
interval = setInterval(() => {
|
|
45
45
|
// Check context for MOBs
|
|
46
|
-
const mobs = Object.keys(app.signalk.vessels)
|
|
46
|
+
const mobs = Object.keys(app.signalk.root.vessels)
|
|
47
47
|
.filter((context) => {
|
|
48
48
|
const mmsi = context.split(':').at(-1);
|
|
49
49
|
if (mmsi.indexOf('972') === 0) {
|
|
@@ -54,6 +54,10 @@ module.exports = (app) => {
|
|
|
54
54
|
// SART beacon seen!
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
|
+
if (mmsi.indexOf('974') === 0) {
|
|
58
|
+
// EPIRB seen!
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
57
61
|
return false;
|
|
58
62
|
});
|
|
59
63
|
|
|
@@ -67,7 +71,7 @@ module.exports = (app) => {
|
|
|
67
71
|
return true;
|
|
68
72
|
})
|
|
69
73
|
.forEach((mmsi) => {
|
|
70
|
-
app.handleMessage('signalk-
|
|
74
|
+
app.handleMessage('signalk-mob-notifier', {
|
|
71
75
|
context: `vessels.${app.selfId}`,
|
|
72
76
|
updates: [
|
|
73
77
|
{
|
|
@@ -87,8 +91,9 @@ module.exports = (app) => {
|
|
|
87
91
|
notified.splice(notified.indexOf(mmsi), 1);
|
|
88
92
|
});
|
|
89
93
|
|
|
94
|
+
app.setPluginStatus(`${mobs.length} MOB or SART beacons detected`);
|
|
95
|
+
|
|
90
96
|
if (mobs.length === 0) {
|
|
91
|
-
// TODO: Clear notifications
|
|
92
97
|
return;
|
|
93
98
|
}
|
|
94
99
|
mobs.forEach((mmsi) => {
|
|
@@ -96,6 +101,9 @@ module.exports = (app) => {
|
|
|
96
101
|
if (mmsi.indexOf('970') === 0) {
|
|
97
102
|
message = 'Search and Rescue Transponder Beacon detected';
|
|
98
103
|
}
|
|
104
|
+
if (mmsi.indexOf('974') === 0) {
|
|
105
|
+
message = 'Emergency Position Indicating Beacon detected';
|
|
106
|
+
}
|
|
99
107
|
// For each MOB get direction and range
|
|
100
108
|
const ownPosition = app.getSelfPath('navigation.position');
|
|
101
109
|
const mobPosition = app.getPath(`vessels.urn:mrn:imo:mmsi:${mmsi}.navigation.position`);
|
|
@@ -108,7 +116,7 @@ module.exports = (app) => {
|
|
|
108
116
|
}
|
|
109
117
|
|
|
110
118
|
// Raise notification
|
|
111
|
-
app.handleMessage('signalk-
|
|
119
|
+
app.handleMessage('signalk-mob-notifier', {
|
|
112
120
|
context: `vessels.${app.selfId}`,
|
|
113
121
|
updates: [
|
|
114
122
|
{
|
|
@@ -148,7 +156,7 @@ module.exports = (app) => {
|
|
|
148
156
|
interval: {
|
|
149
157
|
type: 'integer',
|
|
150
158
|
default: 5,
|
|
151
|
-
title: 'How often to check for
|
|
159
|
+
title: 'How often to check for Beacons (in seconds)?',
|
|
152
160
|
},
|
|
153
161
|
},
|
|
154
162
|
};
|