@rhizomatics/signalk-einklabel-plugin 1.3.0-beta1 → 1.3.0-beta2
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/dist/config.js +12 -12
- package/dist/devices/bleBackend.d.ts +1 -2
- package/dist/devices/bleBackend.js +13 -3
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -309,6 +309,18 @@ function configSchema(app, discovered = []) {
|
|
|
309
309
|
return {
|
|
310
310
|
type: "object",
|
|
311
311
|
properties: {
|
|
312
|
+
...(app.bleApi
|
|
313
|
+
? {
|
|
314
|
+
useBleApi: {
|
|
315
|
+
type: "boolean",
|
|
316
|
+
title: "Use the SignalK BLE Manager API",
|
|
317
|
+
description: "Route Bluetooth access through SignalK server's BLE Manager API (server >= 2.32.0) instead of connecting to " +
|
|
318
|
+
"BlueZ directly, so this plugin shares the adapter with other BLE plugins instead of contending for it. Requires " +
|
|
319
|
+
"the server to have a local Bluetooth adapter or BLE gateway available (Server → Settings → Bluetooth).",
|
|
320
|
+
default: defaults.useBleApi,
|
|
321
|
+
},
|
|
322
|
+
}
|
|
323
|
+
: {}),
|
|
312
324
|
templatesDir: {
|
|
313
325
|
type: "string",
|
|
314
326
|
title: "Templates directory",
|
|
@@ -331,18 +343,6 @@ function configSchema(app, discovered = []) {
|
|
|
331
343
|
minimum: 1,
|
|
332
344
|
default: defaults.scanDurationSeconds,
|
|
333
345
|
},
|
|
334
|
-
...(app.bleApi
|
|
335
|
-
? {
|
|
336
|
-
useBleApi: {
|
|
337
|
-
type: "boolean",
|
|
338
|
-
title: "Use the SignalK BLE Manager API",
|
|
339
|
-
description: "Route Bluetooth access through SignalK server's BLE Manager API (server >= 2.32.0) instead of connecting to " +
|
|
340
|
-
"BlueZ directly, so this plugin shares the adapter with other BLE plugins instead of contending for it. Requires " +
|
|
341
|
-
"the server to have a local Bluetooth adapter or BLE gateway available (Server → Settings → Bluetooth).",
|
|
342
|
-
default: defaults.useBleApi,
|
|
343
|
-
},
|
|
344
|
-
}
|
|
345
|
-
: {}),
|
|
346
346
|
paintConnectTimeoutSeconds: {
|
|
347
347
|
type: "number",
|
|
348
348
|
title: "Paint connect timeout (seconds)",
|
|
@@ -15,7 +15,6 @@ export interface BleBackend {
|
|
|
15
15
|
export declare function nodeBleBackend(): BleBackend;
|
|
16
16
|
/**
|
|
17
17
|
* `bleApi.connectGATT()` has no timeout of its own, same story as node-ble's `Device#connect()` (see
|
|
18
|
-
* `connectWithTimeout` in `bleDiscovery.ts`) - races it against `timeoutMs
|
|
19
|
-
* background if it eventually resolves after the caller has already given up.
|
|
18
|
+
* `connectWithTimeout` in `bleDiscovery.ts`) - races it against `timeoutMs`.
|
|
20
19
|
*/
|
|
21
20
|
export declare function bleApiBackend(bleApi: BLEApi, pluginId: string): BleBackend;
|
|
@@ -50,8 +50,7 @@ function nodeBleBackend() {
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* `bleApi.connectGATT()` has no timeout of its own, same story as node-ble's `Device#connect()` (see
|
|
53
|
-
* `connectWithTimeout` in `bleDiscovery.ts`) - races it against `timeoutMs
|
|
54
|
-
* background if it eventually resolves after the caller has already given up.
|
|
53
|
+
* `connectWithTimeout` in `bleDiscovery.ts`) - races it against `timeoutMs`.
|
|
55
54
|
*/
|
|
56
55
|
function bleApiBackend(bleApi, pluginId) {
|
|
57
56
|
return {
|
|
@@ -65,7 +64,18 @@ function bleApiBackend(bleApi, pluginId) {
|
|
|
65
64
|
let timedOut = false;
|
|
66
65
|
const conn = await Promise.race([connecting, (0, bleDiscovery_1.sleep)(timeoutMs).then(() => void (timedOut = true))]);
|
|
67
66
|
if (timedOut || !conn) {
|
|
68
|
-
|
|
67
|
+
// The server registers the claim as soon as `connectGATT()` is called, not once it succeeds -
|
|
68
|
+
// giving up here without releasing it would leave the claim (and, once/if the connect attempt
|
|
69
|
+
// does eventually land server-side, a live connection) orphaned indefinitely, since this
|
|
70
|
+
// plugin never gets a handle back to disconnect it itself. `releaseGATTDevice` tears down
|
|
71
|
+
// whatever the claim currently is, connected or still connecting, regardless of how the
|
|
72
|
+
// original `connectGATT()` promise eventually settles - disconnecting it too if it does still
|
|
73
|
+
// resolve afterwards, harmlessly, since a connection the server already released is a no-op to
|
|
74
|
+
// disconnect again.
|
|
75
|
+
void bleApi
|
|
76
|
+
.releaseGATTDevice(address, pluginId)
|
|
77
|
+
.catch(() => { })
|
|
78
|
+
.then(() => connecting.then((c) => c.disconnect()).catch(() => { }));
|
|
69
79
|
throw new Error(`connecting to device timed out after ${timeoutMs}ms`);
|
|
70
80
|
}
|
|
71
81
|
return conn;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhizomatics/signalk-einklabel-plugin",
|
|
3
|
-
"version": "1.3.0-
|
|
3
|
+
"version": "1.3.0-beta2",
|
|
4
4
|
"description": "Display SignalK data on eInk Electronic Shelf Labels, includes working examples for tide clock and watch schedule.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ble",
|