@noforeignland/signalk-to-noforeignland 1.0.1-beta.5 → 1.0.1-beta.8
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/CHANGELOG.md +1 -1
- package/cleanup-old-plugin.js +58 -14
- package/doc/beta_install_cerbo.md +106 -0
- package/doc/beta_install_rpi.md +64 -0
- package/doc/dev +4 -0
- package/index.js +118 -91
- package/package.json +3 -2
- package/doc/beta_install.md +0 -60
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
1.0.1
|
|
2
|
-
* CHANGE: Cleanup previous installs and migrate plugin config.
|
|
2
|
+
* CHANGE: Cleanup previous installs and migrate plugin config, removes depricated old plugins.
|
|
3
3
|
|
|
4
4
|
1.0.0
|
|
5
5
|
* CHANGE: Package now released unter npmjs org noforeignland in version 1.0.0 due to deployment changes in npmjs and the need of trustworthy sources. All npmjs keys will be revoked Nov 19th, 2025.
|
package/cleanup-old-plugin.js
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cleanup script for old plugin versions
|
|
5
|
+
* This runs as a standalone script during npm postinstall
|
|
6
|
+
* NOT a class - just a simple executable script
|
|
7
|
+
*/
|
|
8
|
+
|
|
2
9
|
const fs = require('fs');
|
|
3
10
|
const path = require('path');
|
|
4
11
|
|
|
5
|
-
//
|
|
12
|
+
// Detect SignalK directory (standard ~/.signalk or Victron Cerbo /data/conf/signalk)
|
|
13
|
+
function getSignalKDir() {
|
|
14
|
+
const victronPath = '/data/conf/signalk';
|
|
15
|
+
const homePath = path.join(process.env.HOME || '', '.signalk');
|
|
16
|
+
|
|
17
|
+
// Check Victron path first
|
|
18
|
+
if (fs.existsSync(victronPath)) {
|
|
19
|
+
return victronPath;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return homePath;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const signalkDir = getSignalKDir();
|
|
26
|
+
console.log(`Using SignalK directory: ${signalkDir}`);
|
|
27
|
+
|
|
28
|
+
// 1. Migration (only for signalk-to-noforeignland config)
|
|
6
29
|
try {
|
|
7
|
-
const
|
|
8
|
-
const configPath = path.join(configDir, 'plugin-config-data');
|
|
30
|
+
const configPath = path.join(signalkDir, 'plugin-config-data');
|
|
9
31
|
const oldConfig = path.join(configPath, 'signalk-to-noforeignland.json');
|
|
10
32
|
const newConfig = path.join(configPath, '@noforeignland-signalk-to-noforeignland.json');
|
|
11
33
|
|
|
@@ -18,19 +40,41 @@ try {
|
|
|
18
40
|
console.warn('Could not migrate config:', e.message);
|
|
19
41
|
}
|
|
20
42
|
|
|
21
|
-
// 2. Uninstall (
|
|
43
|
+
// 2. Uninstall old plugins (with delay so npm can finish)
|
|
22
44
|
setTimeout(() => {
|
|
23
45
|
try {
|
|
24
|
-
const
|
|
25
|
-
|
|
46
|
+
const oldPlugins = [
|
|
47
|
+
{ dir: path.join(signalkDir, 'node_modules', 'signalk-to-noforeignland'), name: 'signalk-to-noforeignland' },
|
|
48
|
+
{ dir: path.join(signalkDir, 'node_modules', 'signalk-to-nfl'), name: 'signalk-to-nfl' }
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
let removedAny = false;
|
|
52
|
+
const failedPlugins = [];
|
|
53
|
+
|
|
54
|
+
for (const plugin of oldPlugins) {
|
|
55
|
+
if (fs.existsSync(plugin.dir)) {
|
|
56
|
+
try {
|
|
57
|
+
console.log(`Removing old plugin "${plugin.name}"...`);
|
|
58
|
+
// Direct deletion is safer than npm uninstall during installation
|
|
59
|
+
fs.rmSync(plugin.dir, { recursive: true, force: true });
|
|
60
|
+
console.log(`✓ Old plugin "${plugin.name}" removed`);
|
|
61
|
+
removedAny = true;
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.warn(`Could not remove "${plugin.name}":`, e.message);
|
|
64
|
+
failedPlugins.push(plugin.name);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (failedPlugins.length > 0) {
|
|
70
|
+
const uninstallCmd = failedPlugins.join(' ');
|
|
71
|
+
console.warn(`Please run manually: npm uninstall ${uninstallCmd}`);
|
|
72
|
+
}
|
|
26
73
|
|
|
27
|
-
if (
|
|
28
|
-
console.log('
|
|
29
|
-
// Direktes Löschen ist sicherer als npm uninstall während Installation
|
|
30
|
-
fs.rmSync(oldPluginDir, { recursive: true, force: true });
|
|
31
|
-
console.log('✓ Old plugin removed');
|
|
74
|
+
if (!removedAny && failedPlugins.length === 0) {
|
|
75
|
+
console.log('No old plugins found - already clean!');
|
|
32
76
|
}
|
|
33
77
|
} catch (e) {
|
|
34
|
-
console.warn('
|
|
78
|
+
console.warn('Error during cleanup:', e.message);
|
|
35
79
|
}
|
|
36
|
-
}, 2000); // 2
|
|
80
|
+
}, 2000); // Wait 2 seconds for npm to finish
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
How-to install the latest beta or dev tree (unstable) on your device?
|
|
2
|
+
|
|
3
|
+
This guide assumes you have a default install with default folders.
|
|
4
|
+
This is written for a Victron Cerbo GX jump to the section you need want to go to.
|
|
5
|
+
It is recommended to enable the Debug Log for this plugin in Server -> Plugin Config before updating.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Pre-requirements
|
|
9
|
+
On the Cerbo GUI enable SSH access and set a afmin password
|
|
10
|
+
Windows User: Download putty (for ssh) and Winscp (for secure fie copy)
|
|
11
|
+
|
|
12
|
+
## On GUI v1:
|
|
13
|
+
1. Click "Menu" (bottom right)
|
|
14
|
+
2. Settings > General
|
|
15
|
+
3. Set root password
|
|
16
|
+
4. Enable "SSH on LAN"
|
|
17
|
+
|
|
18
|
+
## On GUI v2:
|
|
19
|
+
1. Settings -> General
|
|
20
|
+
2. Set root password
|
|
21
|
+
3. Enable "SSH on LAN"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Backup old data
|
|
25
|
+
|
|
26
|
+
## BEST + SLOW: Full signalk copy to local computer
|
|
27
|
+
1. Connect your Cerbo with WinSCP
|
|
28
|
+
2. Copy the folder "/data/conf/signalk" to your local PC
|
|
29
|
+
|
|
30
|
+
## Alternative Cerbo has a SD Card connected:
|
|
31
|
+
1. ssh to the Cerbo
|
|
32
|
+
```
|
|
33
|
+
df -h
|
|
34
|
+
# showns for me that /dev/mmcblk0p1 has 29GB free and is mounted to /run/media/mmcblk0p1
|
|
35
|
+
# This is a SD card that is manually inserted.
|
|
36
|
+
|
|
37
|
+
mount
|
|
38
|
+
# confirms this for me with output:
|
|
39
|
+
# /dev/mmcblk0p1 on /run/media/mmcblk0p1 type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
|
|
40
|
+
|
|
41
|
+
cp -r /data/conf/signalk /run/media/mmcblk0p1/signalk-backup
|
|
42
|
+
# copies the files for you, it will take some time, as the CPU and IO are not the fastest
|
|
43
|
+
|
|
44
|
+
ls –la /run/media/mmcblk0p1/signalk-backup
|
|
45
|
+
# Verify that folder and files exist.
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# npmjs beta on Cerbo
|
|
50
|
+
|
|
51
|
+
## Install latest beta
|
|
52
|
+
1. SSH to the Cerbo:
|
|
53
|
+
```
|
|
54
|
+
cd /data/conf/signalk
|
|
55
|
+
|
|
56
|
+
npm i @noforeignland/signalk-to-noforeignland@beta
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
2. Restart Server & Check logs
|
|
61
|
+
```
|
|
62
|
+
Restart Server vom Webgui and check logs in Webgui
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## Install specific beta version f.e. 1.0.1-beta.5
|
|
67
|
+
1. SSH to the Cerbo:
|
|
68
|
+
```
|
|
69
|
+
cd /data/conf/signalk
|
|
70
|
+
|
|
71
|
+
# Here use the beta version you want to install
|
|
72
|
+
npm i @noforeignland/signalk-to-noforeignland@1.0.1-beta.5
|
|
73
|
+
```
|
|
74
|
+
2. Restart Server & Check logs
|
|
75
|
+
```
|
|
76
|
+
Restart Server vom Webgui and check logs in Webgui
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
----------------------------------------
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# dev tree (unstable) install - NOT RECOMMENDED
|
|
84
|
+
|
|
85
|
+
1. Backup as above
|
|
86
|
+
|
|
87
|
+
2. Get new files from repo (main for latest)
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
cd ~
|
|
91
|
+
mkdir dev
|
|
92
|
+
cd dev
|
|
93
|
+
wget https://github.com/noforeignland/nfl-signalk/archive/refs/heads/main.zip
|
|
94
|
+
unzip main.zip
|
|
95
|
+
cd nfl-signalk-main/
|
|
96
|
+
npm pack
|
|
97
|
+
|
|
98
|
+
cd /data/conf/signalk
|
|
99
|
+
npm install ~/dev/nfl-signalk-main/<your_npm_pack.tgz>
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
3. Restart Server & Check logs
|
|
104
|
+
```
|
|
105
|
+
Restart Server vom Webgui and check logs in Webgui
|
|
106
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
How-to install the latest beta or dev tree (unstable) on your device?
|
|
2
|
+
|
|
3
|
+
This guide assumes you have a default install with default folders.
|
|
4
|
+
This is written for a RPI, jump to the section you need want to go to.
|
|
5
|
+
It is recommended to enable the Debug Log for this plugin in Server -> Plugin Config before updating.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Backup old data
|
|
9
|
+
```
|
|
10
|
+
cp -a ~/.signalk ~/signalk-backup
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
# npmjs beta on RPI
|
|
14
|
+
|
|
15
|
+
## Install latest beta
|
|
16
|
+
```
|
|
17
|
+
cd ~.signalk
|
|
18
|
+
|
|
19
|
+
npm i @noforeignland/signalk-to-noforeignland@beta
|
|
20
|
+
|
|
21
|
+
sudo systemctl restart signalk.service && sudo journalctl -u signalk.service -f
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Install a specific beta
|
|
25
|
+
```
|
|
26
|
+
cd ~.signalk
|
|
27
|
+
|
|
28
|
+
# Here use the beta version you want to install
|
|
29
|
+
npm i @noforeignland/signalk-to-noforeignland@1.0.1-beta.5
|
|
30
|
+
|
|
31
|
+
sudo systemctl restart signalk.service && sudo journalctl -u signalk.service -f
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
--------------------------
|
|
35
|
+
|
|
36
|
+
# dev tree (unstable) - NOT RECOMMENDED
|
|
37
|
+
1. Backup old data
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
cd ~
|
|
41
|
+
cp -a .signalk/ signalk-backup
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
2. Get new files from repo (main for latest)
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
cd ~
|
|
48
|
+
mkdir dev
|
|
49
|
+
cd dev
|
|
50
|
+
wget https://github.com/noforeignland/nfl-signalk/archive/refs/heads/main.zip
|
|
51
|
+
unzip main.zip
|
|
52
|
+
cd nfl-signalk-main/
|
|
53
|
+
npm pack
|
|
54
|
+
|
|
55
|
+
cd ~/.signalk
|
|
56
|
+
npm install ~/dev/nfl-signalk-main/<your_npm_pack.tgz>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
3. Restart Server & Check logs
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
sudo systemctl restart signalk.service && sudo journalctl -u signalk.service -f
|
|
63
|
+
```
|
|
64
|
+
|
package/doc/dev
CHANGED
package/index.js
CHANGED
|
@@ -279,8 +279,10 @@ class SignalkToNoforeignland {
|
|
|
279
279
|
return;
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
//
|
|
283
|
-
|
|
282
|
+
// Cleanup old plugin (fire and forget, non-blocking)
|
|
283
|
+
this.cleanupOldPlugin().catch(err => {
|
|
284
|
+
this.app.debug('Error in cleanupOldPlugin:', err.message);
|
|
285
|
+
});
|
|
284
286
|
|
|
285
287
|
// Migrate old track files
|
|
286
288
|
await this.migrateOldTrackFile();
|
|
@@ -310,52 +312,77 @@ class SignalkToNoforeignland {
|
|
|
310
312
|
this.startPositionHealthCheck();
|
|
311
313
|
}
|
|
312
314
|
|
|
313
|
-
async cleanupOldPlugin() {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
const oldConfigFile = path.join(configPath, 'signalk-to-noforeignland.json');
|
|
320
|
-
const newConfigFile = path.join(configPath, '@noforeignland-signalk-to-noforeignland.json');
|
|
321
|
-
|
|
322
|
-
if (fs.existsSync(oldConfigFile) && !fs.existsSync(newConfigFile)) {
|
|
323
|
-
this.app.debug('Migrating configuration from old plugin...');
|
|
324
|
-
fs.copyFileSync(oldConfigFile, newConfigFile);
|
|
325
|
-
fs.copyFileSync(oldConfigFile, `${oldConfigFile}.backup`);
|
|
326
|
-
this.app.debug('✓ Configuration migrated successfully');
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// 2. Check if old plugin still exists
|
|
330
|
-
const oldPluginDir = path.join(configDir, 'node_modules', 'signalk-to-noforeignland');
|
|
331
|
-
|
|
332
|
-
if (fs.existsSync(oldPluginDir)) {
|
|
333
|
-
this.app.debug('Old plugin "signalk-to-noforeignland" detected');
|
|
334
|
-
this.app.setPluginError(
|
|
335
|
-
'Old plugin "signalk-to-noforeignland" is still installed. ' +
|
|
336
|
-
'Please uninstall it manually: cd ~/.signalk && npm uninstall signalk-to-noforeignland'
|
|
337
|
-
);
|
|
315
|
+
async cleanupOldPlugin() {
|
|
316
|
+
try {
|
|
317
|
+
// Detect SignalK directory (standard or Victron Cerbo)
|
|
318
|
+
const victronPath = '/data/conf/signalk';
|
|
319
|
+
const standardPath = process.env.SIGNALK_NODE_CONFIG_DIR ||
|
|
320
|
+
path.join(process.env.HOME || process.env.USERPROFILE, '.signalk');
|
|
338
321
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
322
|
+
const configDir = fs.existsSync(victronPath) ? victronPath : standardPath;
|
|
323
|
+
this.app.debug(`Using SignalK directory: ${configDir}`);
|
|
324
|
+
|
|
325
|
+
const configPath = path.join(configDir, 'plugin-config-data');
|
|
326
|
+
|
|
327
|
+
// 1. Config Migration - only from signalk-to-noforeignland
|
|
328
|
+
const oldConfigFile = path.join(configPath, 'signalk-to-noforeignland.json');
|
|
329
|
+
const newConfigFile = path.join(configPath, '@noforeignland-signalk-to-noforeignland.json');
|
|
330
|
+
|
|
331
|
+
if (fs.existsSync(oldConfigFile) && !fs.existsSync(newConfigFile)) {
|
|
332
|
+
this.app.debug('Migrating configuration from old plugin "signalk-to-noforeignland"...');
|
|
333
|
+
fs.copyFileSync(oldConfigFile, newConfigFile);
|
|
334
|
+
fs.copyFileSync(oldConfigFile, `${oldConfigFile}.backup`);
|
|
335
|
+
this.app.debug('✓ Configuration migrated successfully');
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// 2. Check if old plugins still exist (including very old signalk-to-nfl)
|
|
339
|
+
const oldPlugins = [
|
|
340
|
+
{ dir: path.join(configDir, 'node_modules', 'signalk-to-noforeignland'), name: 'signalk-to-noforeignland' },
|
|
341
|
+
{ dir: path.join(configDir, 'node_modules', 'signalk-to-nfl'), name: 'signalk-to-nfl' }
|
|
342
|
+
];
|
|
343
|
+
|
|
344
|
+
const foundOldPlugins = oldPlugins.filter(plugin => fs.existsSync(plugin.dir));
|
|
345
|
+
|
|
346
|
+
if (foundOldPlugins.length > 0) {
|
|
347
|
+
const pluginNames = foundOldPlugins.map(p => `"${p.name}"`).join(' and ');
|
|
348
|
+
const uninstallCmd = foundOldPlugins.map(p => p.name).join(' ');
|
|
349
|
+
|
|
350
|
+
this.app.debug(`Old plugin(s) detected: ${pluginNames}`);
|
|
351
|
+
this.app.setPluginError(
|
|
352
|
+
`Old plugin(s) ${pluginNames} still installed. ` +
|
|
353
|
+
`Please uninstall manually: cd ${configDir} && npm uninstall ${uninstallCmd}`
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
// Try to remove them after a delay (non-blocking)
|
|
357
|
+
setTimeout(async () => {
|
|
358
|
+
let anyRemoved = false;
|
|
359
|
+
let anyFailed = false;
|
|
360
|
+
|
|
361
|
+
for (const plugin of foundOldPlugins) {
|
|
362
|
+
try {
|
|
363
|
+
this.app.debug(`Attempting to remove old plugin directory: ${plugin.name}...`);
|
|
364
|
+
await fs.remove(plugin.dir);
|
|
365
|
+
this.app.debug(`✓ Old plugin "${plugin.name}" directory removed`);
|
|
366
|
+
anyRemoved = true;
|
|
367
|
+
} catch (err) {
|
|
368
|
+
this.app.debug(`Could not automatically remove old plugin "${plugin.name}":`, err.message);
|
|
369
|
+
anyFailed = true;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (anyRemoved && !anyFailed) {
|
|
374
|
+
this.setPluginStatus('Started (old plugins cleaned up)');
|
|
375
|
+
} else if (anyFailed) {
|
|
376
|
+
const remainingPlugins = foundOldPlugins.map(p => p.name).join(' ');
|
|
377
|
+
this.app.debug(`Please manually run: cd ${configDir} && npm uninstall ${remainingPlugins}`);
|
|
378
|
+
}
|
|
379
|
+
}, 5000); // 5 seconds wait for SignalK to fully start
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
} catch (err) {
|
|
383
|
+
this.app.debug('Error during old plugin cleanup:', err.message);
|
|
352
384
|
}
|
|
353
|
-
|
|
354
|
-
} catch (err) {
|
|
355
|
-
this.app.debug('Error during old plugin cleanup:', err.message);
|
|
356
385
|
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
386
|
|
|
360
387
|
async migrateOldTrackFile() {
|
|
361
388
|
const oldTrackFile = path.join(this.options.trackDir, 'nfl-track.jsonl');
|
|
@@ -674,54 +701,54 @@ async cleanupOldPlugin() {
|
|
|
674
701
|
return res;
|
|
675
702
|
}
|
|
676
703
|
|
|
677
|
-
startPositionHealthCheck() {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
const activeSource = this.options.filterSource || this.autoSelectedSource || 'any';
|
|
685
|
-
const filterMsg = activeSource !== 'any' ? ` from source '${activeSource}'` : '';
|
|
686
|
-
|
|
687
|
-
if (!this.lastPositionReceived) {
|
|
688
|
-
const errorMsg = this.options.filterSource
|
|
689
|
-
? `No GPS position data received from filtered source '${this.options.filterSource}'. Check Expert Settings > Position source device, or leave empty to use any GPS source.`
|
|
690
|
-
: 'No GPS position data received. Check that your GPS is connected and SignalK is receiving navigation.position data.';
|
|
691
|
-
this.setPluginError(errorMsg);
|
|
692
|
-
this.app.debug('Position health check: No position data ever received' + filterMsg);
|
|
693
|
-
} else if (timeSinceLastPosition > 300) {
|
|
694
|
-
const errorMsg = this.options.filterSource
|
|
695
|
-
? `No GPS position data${filterMsg} for ${Math.floor(timeSinceLastPosition / 60)} minutes. Check that source '${this.options.filterSource}' is active, or change/clear Position source device in Expert Settings.`
|
|
696
|
-
: `No GPS position data${filterMsg} for ${Math.floor(timeSinceLastPosition / 60)} minutes. Check your GPS connection.`;
|
|
697
|
-
this.setPluginError(errorMsg);
|
|
698
|
-
this.app.debug(`Position health check: No position for ${timeSinceLastPosition.toFixed(0)} seconds` + filterMsg);
|
|
699
|
-
} else {
|
|
700
|
-
this.app.debug(`Position health check: OK (last position ${timeSinceLastPosition.toFixed(0)} seconds ago${filterMsg})`);
|
|
704
|
+
startPositionHealthCheck() {
|
|
705
|
+
this.positionCheckInterval = setInterval(() => {
|
|
706
|
+
const now = new Date().getTime();
|
|
707
|
+
const timeSinceLastPosition = this.lastPositionReceived
|
|
708
|
+
? (now - this.lastPositionReceived) / 1000
|
|
709
|
+
: null;
|
|
701
710
|
|
|
702
|
-
// Clear any previous errors when position health is OK
|
|
703
|
-
if (this.currentError) {
|
|
704
|
-
const activeSource = this.options.filterSource || this.autoSelectedSource || '';
|
|
705
|
-
const sourcePrefix = activeSource ? `${activeSource} | ` : '';
|
|
706
|
-
const saveTime = this.lastPosition ? new Date(this.lastPosition.currentTime).toISOString() : 'None since start';
|
|
707
|
-
const transferTime = this.lastSuccessfulTransfer ? this.lastSuccessfulTransfer.toISOString() : 'None since start';
|
|
708
|
-
this.setPluginStatus(`Save: ${saveTime} | Transfer: ${transferTime} | ${sourcePrefix}`);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
}, 5 * 60 * 1000);
|
|
712
|
-
|
|
713
|
-
// Initial check after 2 minutes of startup
|
|
714
|
-
setTimeout(() => {
|
|
715
|
-
if (!this.lastPositionReceived) {
|
|
716
711
|
const activeSource = this.options.filterSource || this.autoSelectedSource || 'any';
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
712
|
+
const filterMsg = activeSource !== 'any' ? ` from source '${activeSource}'` : '';
|
|
713
|
+
|
|
714
|
+
if (!this.lastPositionReceived) {
|
|
715
|
+
const errorMsg = this.options.filterSource
|
|
716
|
+
? `No GPS position data received from filtered source '${this.options.filterSource}'. Check Expert Settings > Position source device, or leave empty to use any GPS source.`
|
|
717
|
+
: 'No GPS position data received. Check that your GPS is connected and SignalK is receiving navigation.position data.';
|
|
718
|
+
this.setPluginError(errorMsg);
|
|
719
|
+
this.app.debug('Position health check: No position data ever received' + filterMsg);
|
|
720
|
+
} else if (timeSinceLastPosition > 300) {
|
|
721
|
+
const errorMsg = this.options.filterSource
|
|
722
|
+
? `No GPS position data${filterMsg} for ${Math.floor(timeSinceLastPosition / 60)} minutes. Check that source '${this.options.filterSource}' is active, or change/clear Position source device in Expert Settings.`
|
|
723
|
+
: `No GPS position data${filterMsg} for ${Math.floor(timeSinceLastPosition / 60)} minutes. Check your GPS connection.`;
|
|
724
|
+
this.setPluginError(errorMsg);
|
|
725
|
+
this.app.debug(`Position health check: No position for ${timeSinceLastPosition.toFixed(0)} seconds` + filterMsg);
|
|
726
|
+
} else {
|
|
727
|
+
this.app.debug(`Position health check: OK (last position ${timeSinceLastPosition.toFixed(0)} seconds ago${filterMsg})`);
|
|
728
|
+
|
|
729
|
+
// Clear any previous errors when position health is OK
|
|
730
|
+
if (this.currentError) {
|
|
731
|
+
const activeSource = this.options.filterSource || this.autoSelectedSource || '';
|
|
732
|
+
const sourcePrefix = activeSource ? `${activeSource} | ` : '';
|
|
733
|
+
const saveTime = this.lastPosition ? new Date(this.lastPosition.currentTime).toISOString() : 'None since start';
|
|
734
|
+
const transferTime = this.lastSuccessfulTransfer ? this.lastSuccessfulTransfer.toISOString() : 'None since start';
|
|
735
|
+
this.setPluginStatus(`Save: ${saveTime} | Transfer: ${transferTime} | ${sourcePrefix}`);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
}, 5 * 60 * 1000);
|
|
739
|
+
|
|
740
|
+
// Initial check after 2 minutes of startup
|
|
741
|
+
setTimeout(() => {
|
|
742
|
+
if (!this.lastPositionReceived) {
|
|
743
|
+
const activeSource = this.options.filterSource || this.autoSelectedSource || 'any';
|
|
744
|
+
const errorMsg = this.options.filterSource
|
|
745
|
+
? `No GPS position data received after 2 minutes from filtered source '${this.options.filterSource}'. Check Expert Settings > Position source device. You may need to leave it empty to use any available GPS source.`
|
|
746
|
+
: 'No GPS position data received after 2 minutes. Check that your GPS is connected and SignalK is receiving navigation.position data.';
|
|
747
|
+
this.setPluginError(errorMsg);
|
|
748
|
+
this.app.debug('Initial position check: No position data received' + (activeSource !== 'any' ? ` from source '${activeSource}'` : ''));
|
|
749
|
+
}
|
|
750
|
+
}, 2 * 60 * 1000);
|
|
751
|
+
}
|
|
725
752
|
|
|
726
753
|
async interval() {
|
|
727
754
|
const boatMoving = this.checkBoatMoving();
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"signalk": {
|
|
4
4
|
"id": "@noforeignland/signalk-to-noforeignland"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.0.1-beta.
|
|
6
|
+
"version": "1.0.1-beta.8",
|
|
7
7
|
"description": "SignalK track logger to noforeignland.com",
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"keywords": [
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"node": ">=18.0.0"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"test": "echo \"No tests specified\" && exit 0"
|
|
27
|
+
"test": "echo \"No tests specified\" && exit 0",
|
|
28
|
+
"postinstall": "node cleanup-old-plugin.js"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"cron": "^2.1.0",
|
package/doc/beta_install.md
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
How-to install the latest beta on your device?
|
|
2
|
-
|
|
3
|
-
This guide assumes you have a default install with default folders.
|
|
4
|
-
This is written for a Cerbo GX or a RPI, jump to the section you need want to go to.
|
|
5
|
-
It is recommended to enable the Debug Log for this plugin in Server -> Plugin Config before updating.
|
|
6
|
-
|
|
7
|
-
**For Raspberry PI:**
|
|
8
|
-
|
|
9
|
-
1. Backup old data
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
cd ~
|
|
13
|
-
mkdir nfl-backup
|
|
14
|
-
cp -a .signalk/node_modules/signalk-to-noforeignland/* nfl-backup/
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
2. Get new files from repo (main for latest)
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
cd ~/.signalk/node_modules/signalk-to-noforeignland/
|
|
21
|
-
rm -rf *
|
|
22
|
-
wget https://github.com/noforeignland/nfl-signalk/archive/refs/heads/main.zip
|
|
23
|
-
unzip main.zip
|
|
24
|
-
cp -r nfl-signalk-main/* .
|
|
25
|
-
rm main.zip
|
|
26
|
-
rm -rf nfl-signalk-main/
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
3. Restart Server & Check logs
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
sudo systemctl restart signalk.service && sudo journalctl -u signalk.service -f
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
**For Cerbo GX with Image Large:**
|
|
37
|
-
1. Backup old data
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
cd ~
|
|
41
|
-
mkdir nfl-backup
|
|
42
|
-
cp -a /data/conf/signalk/node_modules/signalk-to-noforeignland/* nfl-backup
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
2. Get new files from repo (main for latest)
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
cd /data/conf/signalk/node_modules/signalk-to-noforeignland/
|
|
49
|
-
rm -rf *
|
|
50
|
-
wget https://github.com/noforeignland/nfl-signalk/archive/refs/heads/main.zip
|
|
51
|
-
unzip main.zip
|
|
52
|
-
cp -r nfl-signalk-main/* .
|
|
53
|
-
rm main.zip
|
|
54
|
-
rm -rf nfl-signalk-main/
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
3. Restart Server & Check logs
|
|
58
|
-
```
|
|
59
|
-
Restart Server vom Webgui and check logs in Webgui
|
|
60
|
-
```
|