@noforeignland/signalk-to-noforeignland 1.1.0 → 1.2.0-beta.1
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 +22 -3
- package/package.json +38 -6
- package/.github/workflows/publish.yml +0 -40
- package/CHANGELOG.md +0 -122
- package/PROJECT_STRUCTURE.md +0 -357
- package/doc/beta_install_cerbo.md +0 -127
- package/doc/beta_install_rpi.md +0 -64
- package/index.js +0 -295
- package/lib/ConfigManager.js +0 -216
- package/lib/DataPathEmitter.js +0 -93
- package/lib/DirectoryUtils.js +0 -38
- package/lib/HealthMonitor.js +0 -91
- package/lib/PluginCleanup.js +0 -259
- package/lib/TrackLogger.js +0 -306
- package/lib/TrackMigration.js +0 -110
- package/lib/TrackSender.js +0 -219
package/README.md
CHANGED
|
@@ -6,8 +6,9 @@ Effortlessly log your boat's movement to **noforeignland.com**
|
|
|
6
6
|
* Send detailed tracks to log your entire trip and not just your final position
|
|
7
7
|
* Can be used in near real time or cache and upload when stopped and data-connection is available
|
|
8
8
|
* Sends 24h keepalive
|
|
9
|
+
* **Velocity-based GPS outlier filtering** - catches anomalous GPS jumps (new in v1.2.0)
|
|
9
10
|
* Option to archive your track on the local disk
|
|
10
|
-
* Detailed plugin information in the SK dashboard
|
|
11
|
+
* Detailed plugin information in the SK dashboard
|
|
11
12
|
* SK data paths about the plugin status for your own dashboard or Node Red coding
|
|
12
13
|
|
|
13
14
|
## Issues
|
|
@@ -28,7 +29,10 @@ Effortlessly log your boat's movement to **noforeignland.com**
|
|
|
28
29
|
## Configuration
|
|
29
30
|
1. Add your boat's API Key into the Server > Plugin Config > Signal K to Noforeignland > Boat API Key
|
|
30
31
|
2. Hit "Submit"
|
|
31
|
-
3. Restart the Signal K server
|
|
32
|
+
3. Restart the Signal K server
|
|
33
|
+
|
|
34
|
+
### Expert Settings
|
|
35
|
+
* **Maximum velocity (m/s)** - Rejects positions implying movement faster than this threshold. Catches GPS outliers that jump to impossible locations. Default: 50 m/s (~97 knots). Adjust higher for aircraft tracking.
|
|
32
36
|
|
|
33
37
|
## Data paths created by this plugin
|
|
34
38
|
```
|
|
@@ -42,7 +46,22 @@ noforeignland.source - string - string - data source of
|
|
|
42
46
|
notifications.noforeignland.status_boolean - json object - auto created
|
|
43
47
|
```
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
## Development
|
|
50
|
+
|
|
51
|
+
This plugin is written in TypeScript with strict type checking.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install # Install dependencies
|
|
55
|
+
npm run build # Compile TypeScript
|
|
56
|
+
npm run dev # Watch mode compilation
|
|
57
|
+
npm run test # Run tests
|
|
58
|
+
npm run test:coverage # Run tests with coverage
|
|
59
|
+
npm run lint # Run ESLint
|
|
60
|
+
npm run format # Run Prettier
|
|
61
|
+
npm run validate # Run all checks (typecheck + lint + test:coverage)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
# Victron Cerbo GX Users
|
|
46
65
|
|
|
47
66
|
## Limited storage
|
|
48
67
|
Signal K can quickly exhaust the small onboard storage of the device, especially when a lot of logging is enabled and not properly configured. Even concider to not enable "Keep track files on disk" if you are moving a lot.
|
package/package.json
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
"signalk": {
|
|
4
4
|
"id": "@noforeignland/signalk-to-noforeignland"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.2.0-beta.1",
|
|
7
7
|
"description": "SignalK track logger to noforeignland.com",
|
|
8
|
-
"main": "index.js",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
9
13
|
"keywords": [
|
|
10
14
|
"signalk-node-server-plugin",
|
|
11
15
|
"signalk-category-utility"
|
|
@@ -24,11 +28,39 @@
|
|
|
24
28
|
"node": ">=18.0.0"
|
|
25
29
|
},
|
|
26
30
|
"scripts": {
|
|
27
|
-
"
|
|
31
|
+
"build": "tsc",
|
|
32
|
+
"dev": "tsc --watch",
|
|
33
|
+
"test": "jest",
|
|
34
|
+
"test:watch": "jest --watch",
|
|
35
|
+
"test:coverage": "jest --coverage",
|
|
36
|
+
"lint": "eslint src test",
|
|
37
|
+
"lint:fix": "eslint src test --fix",
|
|
38
|
+
"format": "eslint src test --fix && prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
39
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"validate": "npm run typecheck && npm run lint && npm run test:coverage",
|
|
42
|
+
"prepublishOnly": "npm run validate && npm run build"
|
|
28
43
|
},
|
|
29
44
|
"dependencies": {
|
|
30
|
-
"cron": "^2.1
|
|
31
|
-
"fs-extra": "^
|
|
32
|
-
"node-fetch": "^2.
|
|
45
|
+
"cron": "^3.2.1",
|
|
46
|
+
"fs-extra": "^11.2.0",
|
|
47
|
+
"node-fetch": "^2.7.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@eslint/js": "^9.18.0",
|
|
51
|
+
"@signalk/server-api": "^2.10.0",
|
|
52
|
+
"@tsconfig/node20": "^20.1.4",
|
|
53
|
+
"@types/fs-extra": "^11.0.4",
|
|
54
|
+
"@types/jest": "^29.5.14",
|
|
55
|
+
"@types/node": "^20.17.14",
|
|
56
|
+
"@types/node-fetch": "^2.6.12",
|
|
57
|
+
"eslint": "^9.18.0",
|
|
58
|
+
"eslint-config-prettier": "^10.0.1",
|
|
59
|
+
"jest": "^29.7.0",
|
|
60
|
+
"mock-fs": "^5.4.1",
|
|
61
|
+
"prettier": "^3.4.2",
|
|
62
|
+
"ts-jest": "^29.2.5",
|
|
63
|
+
"typescript": "^5.7.3",
|
|
64
|
+
"typescript-eslint": "^8.21.0"
|
|
33
65
|
}
|
|
34
66
|
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
name: Publish Package
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
tags:
|
|
6
|
-
- 'v*'
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
id-token: write
|
|
10
|
-
contents: read
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
publish:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
|
|
16
|
-
steps:
|
|
17
|
-
- uses: actions/checkout@v4
|
|
18
|
-
|
|
19
|
-
- name: Clean workspace
|
|
20
|
-
run: git clean -xfd
|
|
21
|
-
|
|
22
|
-
- uses: actions/setup-node@v4
|
|
23
|
-
with:
|
|
24
|
-
node-version: '20'
|
|
25
|
-
registry-url: 'https://registry.npmjs.org'
|
|
26
|
-
|
|
27
|
-
# Ensure npm 11.5.1 or later is installed
|
|
28
|
-
- name: Update npm
|
|
29
|
-
run: npm install -g npm@latest
|
|
30
|
-
- run: npm install
|
|
31
|
-
|
|
32
|
-
- run: npm test
|
|
33
|
-
|
|
34
|
-
- name: Publish
|
|
35
|
-
run: |
|
|
36
|
-
if [[ "${{ github.ref }}" == refs/tags/*-beta.* ]] || [[ "${{ github.ref }}" == refs/tags/*-rc.* ]]; then
|
|
37
|
-
npm publish --provenance --access public --tag beta
|
|
38
|
-
else
|
|
39
|
-
npm publish --provenance --access public
|
|
40
|
-
fi
|
package/CHANGELOG.md
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
1.1.0
|
|
2
|
-
* CHANGE: Removed postinstall script - SignalK server will use --ignore-scripts (issue #2181). Runtime PluginCleanup handles all migration.
|
|
3
|
-
* CHANGE: Refactored Project structure, see PROJECT_STRUCTURE.md
|
|
4
|
-
* CHANGE: Use phrase GNSS instead of GPS - Thanks Piotr
|
|
5
|
-
* BUGFIX: Removed unreliable DNS-based internet connectivity test (beta.11) - API retry logic is sufficient
|
|
6
|
-
* BUGFIX: Reverted to beta.3 working configuration (beta.10) - undoing all failed schema experiments from beta.4-9
|
|
7
|
-
* CHANGE: Improved cleanup error handling - only shows error after all retry attempts fail
|
|
8
|
-
* CHANGE: Added installed plugins logging for better debugging
|
|
9
|
-
* CHANGE: Platform-specific cleanup instructions (Cerbo GX vs standard)
|
|
10
|
-
|
|
11
|
-
1.0.1
|
|
12
|
-
* CHANGE: Cleanup previous installs and migrate plugin config, removes depricated old plugins.
|
|
13
|
-
|
|
14
|
-
1.0.0
|
|
15
|
-
* 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.
|
|
16
|
-
Users of the old (depricated) 0.1.x versions need to install this new package once manually using the Signal K Appstore. The Plugin Configuration will be kept from the 0.1.x install.
|
|
17
|
-
|
|
18
|
-
0.2.x
|
|
19
|
-
* CHANGE: Deployment via OIDC authentication
|
|
20
|
-
npmjs.org is revoking all deployment keys Nov 19th. The future deployment shall be via trusted publishers, so the workflow changes from publishing local -> npmjs to local -> github -> npmjs.
|
|
21
|
-
To fullfil this we had to deprecate the old package and deploy it under the scope of the org noforeignland in npmjs. This is the reason, why you don't see the old package anymore in the Appstore.
|
|
22
|
-
|
|
23
|
-
The "new" one has to be installed once manually, after that everything is back to normal and you are fine.
|
|
24
|
-
|
|
25
|
-
0.1.3x
|
|
26
|
-
* CHANGE: Working on Deployment via OIDC authentication
|
|
27
|
-
|
|
28
|
-
0.1.29
|
|
29
|
-
* CHANGE: Removed unused dependency "is-reachable" in package.json
|
|
30
|
-
|
|
31
|
-
0.1.29-beta.2
|
|
32
|
-
* NEW: setPluginError and error in data path if Internet Connection is not working.
|
|
33
|
-
|
|
34
|
-
0.1.29-beta.1
|
|
35
|
-
* CHANGE: After talking to Treppo from Sugnal K core team we should use the data path "noforeignland.*", code and docs changed.
|
|
36
|
-
* CHANGE: README.md info added and format optimized
|
|
37
|
-
* CHANGE: GNSS source at the end for setPluginStatus - Cerbo has a long source name and truncates it.
|
|
38
|
-
* CHANGE: Use "npm install instead" of "npm ci" to push from Github to npmjs using OIDC authentication
|
|
39
|
-
* CHANGE: Moved navigation.position source from path noforeignland.status to noforeignland.source
|
|
40
|
-
|
|
41
|
-
0.1.28
|
|
42
|
-
* BUGFIX: No GNSS data found - introduced in 0.1.27 - Thanks Piotr
|
|
43
|
-
|
|
44
|
-
0.1.28-beta.2
|
|
45
|
-
* EXPERIMENTAL: Signal K data path to visualize the plugin behaviour or error in Node Red, KIP, etc. Using plugin.signalk-to-noforeignland.* for now. See README.md for details.
|
|
46
|
-
* CHANGE: Using app.getDataDirPath() to store transient data, thanks Jeremy, they are now in "plugin-config-data/signalk-to-noforeignland/nfl-track" and renamed to pending.json1 and sent.json1
|
|
47
|
-
* CHANGE: Optimize GNSS detection if multiple navigation.position from different sources exist.
|
|
48
|
-
* CHANGE: PluginStatus optimized for limited space available.
|
|
49
|
-
* CHANGE: doc/beta_install.md changed for new file structure.
|
|
50
|
-
|
|
51
|
-
0.1.28-beta.1
|
|
52
|
-
* CHANGE: By design SK deletes the track folder upon Pluging update via the Appstore, so we have to save the long term track in a different location, default folder: signalk-to-noforeignland-data
|
|
53
|
-
|
|
54
|
-
0.1.27
|
|
55
|
-
* Final version after successful testing SV MOIN and SV KIAPA NUI
|
|
56
|
-
|
|
57
|
-
0.1.27-beta.1
|
|
58
|
-
* NEW: NPMJS requires new method for publishing. The old tokens will expire Nov 19th, 2025, so moving to OIDC authentication.
|
|
59
|
-
* NEW: Check the GNSS status in navigation.position, else retry and throw PluginError on Dashboard
|
|
60
|
-
* CHANGE: Keep track data on disk rewritten and migrate old files to new structure, so nfl-track-sent.jsonl becomes a continuous archive of all sent track data over time, when enabled. New Logic:
|
|
61
|
-
* New points accumulate in nfl-track-pending.jsonl
|
|
62
|
-
* Send succeeds → API confirms receipt
|
|
63
|
-
* If keepFiles=true: The content of pending file is appended to nfl-track-sent.jsonl (line 588)
|
|
64
|
-
* Pending file is deleted
|
|
65
|
-
* Next GNSS points → create a new pending file
|
|
66
|
-
* Next successful send → appends again to the same nfl-track-sent.jsonl
|
|
67
|
-
|
|
68
|
-
0.1.26
|
|
69
|
-
* Same as 0.1.26-beta.1
|
|
70
|
-
|
|
71
|
-
0.1.26-beta.1
|
|
72
|
-
* CHANGE: PluginStatus last track sent "Not transfered since plugin start" gets truncated by the dashboard. Changed to "None since start"
|
|
73
|
-
|
|
74
|
-
0.1.25
|
|
75
|
-
* CHANGE: Minimum boat move default increased from 50m to 80m
|
|
76
|
-
* CHANGE: Updated the README.md
|
|
77
|
-
* CHANGE: Use public ipv4 DNS instead of local with cache for testInternet()
|
|
78
|
-
* Final version after successful testing SV MOIN and SV KIAPA NUI
|
|
79
|
-
|
|
80
|
-
0.1.25-beta.3
|
|
81
|
-
* NEW: Check if boat key is set on startup, else report error to dashboard
|
|
82
|
-
* CHANGE: Changing the order and label of the Plugin Settings to make it more clear for unexpierienced users and grouped to Mandatory, Advanced and Expert.
|
|
83
|
-
* CHANGE: Migration of < 0.1.25 Plugin settings to new structure.
|
|
84
|
-
* CHANGE: PluginStatus last track sent "Never" changed to "Not transfered since plugin start" to avoid confusions.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
0.1.25-beta.2
|
|
88
|
-
* CHANGE: Typo in pluginName fixed
|
|
89
|
-
* CHANGE: Dates for SetPlugin now ISO8601 formated (https://github.com/noforeignland/nfl-signalk/issues/9)
|
|
90
|
-
|
|
91
|
-
0.1.25-beta.1
|
|
92
|
-
* CHANGE: User mattzilla470 reported timout Issues on VE Cerbo with a small CPU and using 4G (https://github.com/noforeignland/nfl-signalk/issues/7). So added a timout option in the plugin config and a tripple retry while increasing the timeout for the API call.
|
|
93
|
-
|
|
94
|
-
0.1.24
|
|
95
|
-
* CHANGE: testInternet() only uses ipv4 now, some users don't have ipv6 configured properly and where unable to reach the API, when testInternet returned false
|
|
96
|
-
* NEW: PluginStatus on SK dashboard now shows last savePoint and last API transfer, so a user has more feedback what the app is doing without enabling the debug log and crawling though it.
|
|
97
|
-
* CHANGE: Renamed CHANGELOG to CHANGELOG.md
|
|
98
|
-
* CHANGE: CHANGELOG ORDER - newest on top.
|
|
99
|
-
* Final version after successful testing SV MOIN and SV KIAPA NUI
|
|
100
|
-
|
|
101
|
-
0.1.23
|
|
102
|
-
* Final version after successful testing SV MOIN and SV KIAPA NUI
|
|
103
|
-
|
|
104
|
-
0.1.23-beta.1
|
|
105
|
-
* Renamed branch to follow the release versions.
|
|
106
|
-
* CLEANUP - More debug info for the SK dashboard using this.app.setPluginError
|
|
107
|
-
* CLEANUP - Removed CreateGPX, was only used for removed Email transmission of the track
|
|
108
|
-
|
|
109
|
-
0.1.22-beta.2
|
|
110
|
-
|
|
111
|
-
* CLEANUP and move to Object Oriented Javascript
|
|
112
|
-
|
|
113
|
-
0.1.22-beta.1
|
|
114
|
-
|
|
115
|
-
* CONFIG: Attempt sending location while moving - Default changed from false to true
|
|
116
|
-
* CONFIG: Ping added for 24h ping if boat is not moved. - Default: true
|
|
117
|
-
* Package.json - Nodemailer dependency removed
|
|
118
|
-
* Marked for removal - Depricated "sendEmailData" function.
|
|
119
|
-
* REMOVED - sendEmail.js
|
|
120
|
-
* CLEANUP - Renamed emaiCron to apiCron
|
|
121
|
-
* NEW: 24h api ping, when enabled, even if boat didn't move.
|
|
122
|
-
|
package/PROJECT_STRUCTURE.md
DELETED
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
# Project Structure
|
|
2
|
-
|
|
3
|
-
This document describes the architecture and organization of the SignalK to Noforeignland plugin.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
This plugin follows a modular architecture where each responsibility is encapsulated in a dedicated module. The main orchestrator ([index.js](index.js)) coordinates all modules through a class-based approach.
|
|
8
|
-
|
|
9
|
-
## Directory Layout
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
nfl-signalk/
|
|
13
|
-
index.js # Main plugin entry point & orchestrator
|
|
14
|
-
cleanup-old-plugin.js # Postinstall script for removing old versions
|
|
15
|
-
package.json # NPM package configuration
|
|
16
|
-
lib/ # Core modules directory
|
|
17
|
-
ConfigManager.js # Configuration handling & migration
|
|
18
|
-
TrackLogger.js # Position subscription & logging
|
|
19
|
-
TrackSender.js # API communication & track sending
|
|
20
|
-
HealthMonitor.js # Position data health checks
|
|
21
|
-
PluginCleanup.js # Runtime cleanup of old plugins
|
|
22
|
-
TrackMigration.js # Track file migration utilities
|
|
23
|
-
DataPathEmitter.js # SignalK delta emission
|
|
24
|
-
DirectoryUtils.js # File system utilities
|
|
25
|
-
README.md # User documentation
|
|
26
|
-
CHANGELOG.md # Version history
|
|
27
|
-
PROJECT_STRUCTURE.md # This file
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Module Responsibilities
|
|
31
|
-
|
|
32
|
-
### Core Orchestrator
|
|
33
|
-
|
|
34
|
-
#### [index.js](index.js)
|
|
35
|
-
**Purpose**: Main plugin class that orchestrates all modules and implements SignalK plugin lifecycle.
|
|
36
|
-
|
|
37
|
-
**Key Responsibilities**:
|
|
38
|
-
- Exports SignalK plugin object with `start()` and `stop()` methods
|
|
39
|
-
- Initializes all module instances in correct order
|
|
40
|
-
- Manages plugin state (options, upSince, cron, lastSuccessfulTransfer)
|
|
41
|
-
- Coordinates between modules during startup sequence
|
|
42
|
-
- Handles plugin status and error reporting to SignalK UI
|
|
43
|
-
- Implements CRON-based interval for data sending
|
|
44
|
-
|
|
45
|
-
**Key Methods**:
|
|
46
|
-
- `start(options, restartPlugin)`: 13-step startup sequence
|
|
47
|
-
- `stop()`: Cleanup and shutdown
|
|
48
|
-
- `interval()`: CRON job handler for sending tracks
|
|
49
|
-
- `handleSavePoint(lastPosition)`: Callback when track point is saved
|
|
50
|
-
- `handleHealthy()`: Callback when health check passes
|
|
51
|
-
- `setPluginStatus(status)`: Update UI status
|
|
52
|
-
- `setPluginError(error)`: Report error to UI
|
|
53
|
-
|
|
54
|
-
### Configuration & Migration
|
|
55
|
-
|
|
56
|
-
#### [lib/ConfigManager.js](lib/ConfigManager.js)
|
|
57
|
-
**Purpose**: Handles plugin configuration, schema definition, and config migration.
|
|
58
|
-
|
|
59
|
-
**Key Responsibilities**:
|
|
60
|
-
- Defines plugin schema (mandatory/advanced/expert settings groups)
|
|
61
|
-
- Migrates old flat config structure to new nested structure
|
|
62
|
-
- Flattens nested config back to internal format with defaults
|
|
63
|
-
- Validates boat API key
|
|
64
|
-
- Resolves track directory paths (absolute vs relative)
|
|
65
|
-
- Randomizes CRON schedule to avoid server load spikes
|
|
66
|
-
|
|
67
|
-
**Config Structure**:
|
|
68
|
-
```javascript
|
|
69
|
-
{
|
|
70
|
-
mandatory: { boatApiKey: string },
|
|
71
|
-
advanced: { minMove, minSpeed, sendWhileMoving, ping_api_every_24h },
|
|
72
|
-
expert: { filterSource, trackDir, keepFiles, trackFrequency, apiCron,
|
|
73
|
-
internetTestTimeout, apiTimeout }
|
|
74
|
-
}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Position Tracking
|
|
78
|
-
|
|
79
|
-
#### [lib/TrackLogger.js](lib/TrackLogger.js)
|
|
80
|
-
**Purpose**: Subscribes to position updates and logs them to disk.
|
|
81
|
-
|
|
82
|
-
**Key Responsibilities**:
|
|
83
|
-
- Subscribes to `navigation.position` and optionally `navigation.speedOverGround`
|
|
84
|
-
- Implements GNSS source auto-selection (stick to one source unless stale)
|
|
85
|
-
- Supports manual source filtering via `filterSource` config
|
|
86
|
-
- Validates positions (rejects coordinates near 0,0)
|
|
87
|
-
- Applies movement filters (minSpeed, minMove, trackFrequency)
|
|
88
|
-
- Implements 24-hour keepalive ping
|
|
89
|
-
- Saves track points to JSONL file (`pending.jsonl`)
|
|
90
|
-
- Calculates distances using equirectangular approximation
|
|
91
|
-
|
|
92
|
-
**GNSS Source Logic**:
|
|
93
|
-
- If `filterSource` is set: only accept that specific source
|
|
94
|
-
- If not set: auto-select first source, switch only if stale (>5 min)
|
|
95
|
-
- Prevents position jumps when multiple GNSS devices are present
|
|
96
|
-
|
|
97
|
-
**Track Point Format**:
|
|
98
|
-
```json
|
|
99
|
-
{"lat": 37.8136, "lon": -122.4784, "t": "2025-01-15T10:30:00.000Z"}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
#### [lib/TrackSender.js](lib/TrackSender.js)
|
|
103
|
-
**Purpose**: Sends accumulated track data to the Noforeignland API.
|
|
104
|
-
|
|
105
|
-
**Key Responsibilities**:
|
|
106
|
-
- Reads track points from `pending.jsonl`
|
|
107
|
-
- Tests internet connectivity via DNS lookups (8.8.8.8, 1.1.1.1)
|
|
108
|
-
- Checks if boat is moving (based on last position timestamp)
|
|
109
|
-
- Sends track data to NFL API with retry logic (3 attempts)
|
|
110
|
-
- Handles successful sends (archive to `sent.jsonl` or delete)
|
|
111
|
-
- Validates position coordinates before sending
|
|
112
|
-
|
|
113
|
-
**API Request Format**:
|
|
114
|
-
```javascript
|
|
115
|
-
POST https://www.noforeignland.com/home/api/v1/boat/tracking/track
|
|
116
|
-
Headers: { 'X-NFL-API-Key': pluginApiKey }
|
|
117
|
-
Body: {
|
|
118
|
-
timestamp: ms,
|
|
119
|
-
track: [[ms, lat, lon], [ms, lat, lon], ...],
|
|
120
|
-
boatApiKey: userBoatApiKey
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
**Retry Logic**:
|
|
125
|
-
- Attempt 1: base timeout (default 30s)
|
|
126
|
-
- Attempt 2: 2x timeout + 2s delay
|
|
127
|
-
- Attempt 3: 3x timeout + 4s delay
|
|
128
|
-
|
|
129
|
-
### Health & Monitoring
|
|
130
|
-
|
|
131
|
-
#### [lib/HealthMonitor.js](lib/HealthMonitor.js)
|
|
132
|
-
**Purpose**: Monitors GNSS position data freshness and reports issues.
|
|
133
|
-
|
|
134
|
-
**Key Responsibilities**:
|
|
135
|
-
- Initial check: 2 minutes after startup
|
|
136
|
-
- Periodic checks: every 5 minutes
|
|
137
|
-
- Detects stale position data (>5 minutes old)
|
|
138
|
-
- Detects missing position data
|
|
139
|
-
- Provides context-aware error messages (filtered vs auto-selected source)
|
|
140
|
-
- Calls error/healthy callbacks to update plugin status
|
|
141
|
-
|
|
142
|
-
**Health States**:
|
|
143
|
-
- Healthy: Position received within last 5 minutes
|
|
144
|
-
- Warning: No position for >5 minutes
|
|
145
|
-
- Error: No position ever received (or 2+ min after startup)
|
|
146
|
-
|
|
147
|
-
### Cleanup & Migration
|
|
148
|
-
|
|
149
|
-
#### [lib/PluginCleanup.js](lib/PluginCleanup.js)
|
|
150
|
-
**Purpose**: Runtime cleanup of old plugin versions.
|
|
151
|
-
|
|
152
|
-
**Key Responsibilities**:
|
|
153
|
-
- Detects Victron Cerbo vs standard SignalK paths
|
|
154
|
-
- Migrates config from old `signalk-to-noforeignland` to new scoped name
|
|
155
|
-
- Removes old plugin directories (`signalk-to-noforeignland`, `signalk-to-nfl`)
|
|
156
|
-
- Multiple retry attempts (immediate, 5s, 15s, 30s delays)
|
|
157
|
-
- Falls back to manual instructions if removal fails
|
|
158
|
-
- Returns promise resolving to 'all_removed' or 'partial_removal'
|
|
159
|
-
|
|
160
|
-
**Old Plugins Removed**:
|
|
161
|
-
- `signalk-to-noforeignland` (unscoped predecessor)
|
|
162
|
-
- `signalk-to-nfl` (deprecated alias)
|
|
163
|
-
|
|
164
|
-
#### [cleanup-old-plugin.js](cleanup-old-plugin.js)
|
|
165
|
-
**Purpose**: Postinstall script for immediate cleanup during npm install.
|
|
166
|
-
|
|
167
|
-
**Key Responsibilities**:
|
|
168
|
-
- Runs via `npm postinstall` hook
|
|
169
|
-
- Uses direct `fs.rmSync()` instead of npm uninstall (safer during install)
|
|
170
|
-
- 2-second delay to allow npm to complete current operation
|
|
171
|
-
- Detects Victron Cerbo vs standard SignalK paths
|
|
172
|
-
- Migrates config files
|
|
173
|
-
- Provides fallback manual instructions
|
|
174
|
-
|
|
175
|
-
**Why Two Cleanup Mechanisms?**
|
|
176
|
-
1. **Postinstall**: Runs during installation, removes old plugins immediately
|
|
177
|
-
2. **Runtime**: Handles cases where postinstall failed (permissions, timing)
|
|
178
|
-
|
|
179
|
-
#### [lib/TrackMigration.js](lib/TrackMigration.js)
|
|
180
|
-
**Purpose**: Migrates track files from old naming/location schemes.
|
|
181
|
-
|
|
182
|
-
**Key Responsibilities**:
|
|
183
|
-
- Migrates old file names to new naming scheme:
|
|
184
|
-
- `nfl-track.jsonl` -> `pending.jsonl`
|
|
185
|
-
- `nfl-track-pending.jsonl` -> `pending.jsonl`
|
|
186
|
-
- `nfl-track-sent.jsonl` -> `sent.jsonl`
|
|
187
|
-
- Migrates track files from old plugin directory to new data directory
|
|
188
|
-
- Removes old track directory if empty
|
|
189
|
-
- Non-destructive: only migrates if target doesn't exist
|
|
190
|
-
|
|
191
|
-
### SignalK Integration
|
|
192
|
-
|
|
193
|
-
#### [lib/DataPathEmitter.js](lib/DataPathEmitter.js)
|
|
194
|
-
**Purpose**: Creates and updates SignalK data paths for external integrations.
|
|
195
|
-
|
|
196
|
-
**Key Responsibilities**:
|
|
197
|
-
- Emits SignalK deltas to create data paths
|
|
198
|
-
- Updates status paths on state changes
|
|
199
|
-
- Manages error state independently
|
|
200
|
-
- Provides both ISO8601 and locale-formatted timestamps
|
|
201
|
-
|
|
202
|
-
**Data Paths Created**:
|
|
203
|
-
```
|
|
204
|
-
noforeignland.savepoint # ISO8601 timestamp of last save
|
|
205
|
-
noforeignland.savepoint_local # Locale string of last save
|
|
206
|
-
noforeignland.sent_to_api # ISO8601 timestamp of last API transfer
|
|
207
|
-
noforeignland.sent_to_api_local # Locale string of last API transfer
|
|
208
|
-
noforeignland.status # Status string (save/transfer/source info)
|
|
209
|
-
noforeignland.status_boolean # 0 = OK, 1 = error
|
|
210
|
-
noforeignland.source # Active GNSS source name
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
**Usage**: These paths can be consumed by Node-RED, KIP dashboards, or other SignalK consumers.
|
|
214
|
-
|
|
215
|
-
#### [lib/DirectoryUtils.js](lib/DirectoryUtils.js)
|
|
216
|
-
**Purpose**: File system utilities with proper error handling.
|
|
217
|
-
|
|
218
|
-
**Key Responsibilities**:
|
|
219
|
-
- Creates directories recursively
|
|
220
|
-
- Checks read/write permissions
|
|
221
|
-
- Provides context-specific error messages
|
|
222
|
-
- Handles common error codes (EACCES, EPERM, ETIMEDOUT)
|
|
223
|
-
|
|
224
|
-
## Data Flow
|
|
225
|
-
|
|
226
|
-
### Startup Sequence
|
|
227
|
-
```
|
|
228
|
-
1. ConfigManager: Migrate old config -> flatten -> validate
|
|
229
|
-
2. DirectoryUtils: Create track directory
|
|
230
|
-
3. PluginCleanup: Remove old plugins (async, non-blocking)
|
|
231
|
-
4. TrackMigration: Migrate old track files
|
|
232
|
-
5. Initialize: TrackLogger, TrackSender, HealthMonitor
|
|
233
|
-
6. ConfigManager: Randomize CRON schedule
|
|
234
|
-
7. TrackLogger: Start position subscription
|
|
235
|
-
8. CRON: Start interval job
|
|
236
|
-
9. HealthMonitor: Start health checks
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### Position Logging Flow
|
|
240
|
-
```
|
|
241
|
-
navigation.position delta
|
|
242
|
-
-> TrackLogger.doOnValue()
|
|
243
|
-
-> handleSourceSelection() [filter/auto-select]
|
|
244
|
-
-> isValidPosition() [validate lat/lon]
|
|
245
|
-
-> shouldLogPosition() [check distance/frequency]
|
|
246
|
-
-> savePoint() [append to pending.jsonl]
|
|
247
|
-
-> callback to index.handleSavePoint()
|
|
248
|
-
-> DataPathEmitter.emitSavepoint()
|
|
249
|
-
-> setPluginStatus()
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
### Track Sending Flow (CRON Interval)
|
|
253
|
-
```
|
|
254
|
-
CRON trigger
|
|
255
|
-
-> index.interval()
|
|
256
|
-
-> TrackSender.isBoatMoving() [check last position age]
|
|
257
|
-
-> TrackSender.hasTrackData() [check pending.jsonl exists]
|
|
258
|
-
-> TrackSender.testInternet() [DNS lookup test]
|
|
259
|
-
-> TrackSender.sendTrack()
|
|
260
|
-
-> createTrackFromFile() [read pending.jsonl]
|
|
261
|
-
-> sendWithRetry() [POST to API, 3 attempts]
|
|
262
|
-
-> handleSuccessfulSend() [archive or delete]
|
|
263
|
-
-> DataPathEmitter.emitApiTransfer()
|
|
264
|
-
-> setPluginStatus()
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
### Health Monitoring Flow
|
|
268
|
-
```
|
|
269
|
-
HealthMonitor timer (every 5 min)
|
|
270
|
-
-> performHealthCheck()
|
|
271
|
-
-> check lastPositionReceived timestamp
|
|
272
|
-
-> if stale/missing: call onError callback
|
|
273
|
-
-> index.setPluginError()
|
|
274
|
-
-> DataPathEmitter.setError()
|
|
275
|
-
-> app.setPluginError()
|
|
276
|
-
-> if healthy: call onHealthy callback
|
|
277
|
-
-> index.handleHealthy()
|
|
278
|
-
-> setPluginStatus() [clear error if needed]
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
## File Locations
|
|
282
|
-
|
|
283
|
-
### Victron Cerbo GX
|
|
284
|
-
- SignalK directory: `/data/conf/signalk`
|
|
285
|
-
- Plugin installed at: `/data/conf/signalk/node_modules/@noforeignland/signalk-to-noforeignland`
|
|
286
|
-
- Config: `/data/conf/signalk/plugin-config-data/@noforeignland-signalk-to-noforeignland.json`
|
|
287
|
-
- Track files: `/data/conf/signalk/plugin-config-data/@noforeignland-signalk-to-noforeignland/nfl-track/`
|
|
288
|
-
|
|
289
|
-
### Standard SignalK
|
|
290
|
-
- SignalK directory: `~/.signalk`
|
|
291
|
-
- Plugin installed at: `~/.signalk/node_modules/@noforeignland/signalk-to-noforeignland`
|
|
292
|
-
- Config: `~/.signalk/plugin-config-data/@noforeignland-signalk-to-noforeignland.json`
|
|
293
|
-
- Track files: `~/.signalk/plugin-config-data/@noforeignland-signalk-to-noforeignland/nfl-track/`
|
|
294
|
-
|
|
295
|
-
## Development Notes
|
|
296
|
-
|
|
297
|
-
### Adding New Features
|
|
298
|
-
1. Create module in `lib/` if it's a distinct responsibility
|
|
299
|
-
2. Instantiate in [index.js](index.js) constructor
|
|
300
|
-
3. Initialize in `start()` method at appropriate step
|
|
301
|
-
4. Clean up in `stop()` method
|
|
302
|
-
5. Update this document
|
|
303
|
-
|
|
304
|
-
### Configuration Changes
|
|
305
|
-
1. Update schema in [ConfigManager.js](lib/ConfigManager.js) `getSchema()`
|
|
306
|
-
2. Add migration logic in `migrateOldConfig()` if breaking change
|
|
307
|
-
3. Update `flattenConfig()` to include new fields with defaults
|
|
308
|
-
4. Test both old and new config formats
|
|
309
|
-
|
|
310
|
-
### Track File Format Changes
|
|
311
|
-
1. Update `TrackLogger.savePoint()` for writing
|
|
312
|
-
2. Update `TrackSender.createTrackFromFile()` for reading
|
|
313
|
-
3. Add migration logic in [TrackMigration.js](lib/TrackMigration.js) if needed
|
|
314
|
-
|
|
315
|
-
### Testing Checklist
|
|
316
|
-
- [ ] Test on Victron Cerbo GX (path detection, limited storage)
|
|
317
|
-
- [ ] Test on standard SignalK installation
|
|
318
|
-
- [ ] Test config migration from old versions
|
|
319
|
-
- [ ] Test with multiple GNSS sources (auto-selection)
|
|
320
|
-
- [ ] Test with filtered source
|
|
321
|
-
- [ ] Test with no internet connection
|
|
322
|
-
- [ ] Test with slow internet (timeout scenarios)
|
|
323
|
-
- [ ] Test cleanup of old plugins
|
|
324
|
-
- [ ] Test track file migration
|
|
325
|
-
|
|
326
|
-
## Dependencies
|
|
327
|
-
|
|
328
|
-
```json
|
|
329
|
-
{
|
|
330
|
-
"cron": "^2.1.0", // CRON job scheduling
|
|
331
|
-
"fs-extra": "^10.1.0", // Enhanced file system operations
|
|
332
|
-
"node-fetch": "^2.6.7" // HTTP requests to API
|
|
333
|
-
}
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
## Version History Notes
|
|
337
|
-
|
|
338
|
-
- **1.1.0**: Refactored to modular structure
|
|
339
|
-
- **1.0.x**: Scoped package name, cleanup mechanism
|
|
340
|
-
- **0.1.x**: Original flat structure (deprecated)
|
|
341
|
-
|
|
342
|
-
## Known Technical Debt
|
|
343
|
-
|
|
344
|
-
1. **Empty process.exit()**: [cleanup-old-plugin.js](cleanup-old-plugin.js) setTimeout may not complete
|
|
345
|
-
2. **Error timing**: [PluginCleanup.js](lib/PluginCleanup.js) shows error before retries complete
|
|
346
|
-
3. **No test suite**: Manual testing only, no automated tests
|
|
347
|
-
|
|
348
|
-
## SignalK Plugin Conventions
|
|
349
|
-
|
|
350
|
-
This plugin follows SignalK plugin conventions:
|
|
351
|
-
- Exports function returning `{id, name, schema, start, stop}`
|
|
352
|
-
- Uses `app.debug()` for logging
|
|
353
|
-
- Uses `app.setPluginStatus()` and `app.setPluginError()` for UI feedback
|
|
354
|
-
- Subscribes via `app.subscriptionmanager.subscribe()`
|
|
355
|
-
- Emits deltas via `app.handleMessage(pluginId, delta)`
|
|
356
|
-
- Config stored in `plugin-config-data/` directory
|
|
357
|
-
- Data stored in plugin's data directory
|