incyclist-devices 3.0.18 → 3.0.19
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/lib/cjs/ble/base/adapter.js +1 -1
- package/lib/cjs/ble/base/sensor.js +7 -6
- package/lib/cjs/ble/fm/sensor.js +5 -0
- package/lib/esm/ble/base/adapter.js +1 -1
- package/lib/esm/ble/base/sensor.js +7 -6
- package/lib/esm/ble/fm/sensor.js +5 -0
- package/lib/types/ble/base/sensor.d.ts +2 -2
- package/lib/types/ble/fm/sensor.d.ts +1 -0
- package/package.json +1 -1
|
@@ -359,7 +359,7 @@ class BleAdapter extends adpater_js_1.default {
|
|
|
359
359
|
sensor.off('data', this.onDeviceDataHandler);
|
|
360
360
|
let connected = false;
|
|
361
361
|
if (sensor.isReconnectBusy()) {
|
|
362
|
-
connected = await sensor.reconnectSensor();
|
|
362
|
+
connected = await sensor.reconnectSensor(false);
|
|
363
363
|
}
|
|
364
364
|
if (connected) {
|
|
365
365
|
sensor.on('data', this.onDeviceDataHandler);
|
|
@@ -112,18 +112,19 @@ class TBleSensor extends node_events_1.EventEmitter {
|
|
|
112
112
|
isReconnectBusy() {
|
|
113
113
|
return (this.reconnectPromise !== undefined);
|
|
114
114
|
}
|
|
115
|
-
async reconnectSensor() {
|
|
115
|
+
async reconnectSensor(connectionLost = true) {
|
|
116
116
|
if (this.reconnectPromise !== undefined) {
|
|
117
117
|
return await this.reconnectPromise;
|
|
118
118
|
}
|
|
119
|
-
this.reconnectPromise = this.doReconnectSensor();
|
|
119
|
+
this.reconnectPromise = this.doReconnectSensor(connectionLost);
|
|
120
120
|
const res = await this.reconnectPromise;
|
|
121
121
|
delete this.reconnectPromise;
|
|
122
122
|
return res;
|
|
123
123
|
}
|
|
124
|
-
async doReconnectSensor() {
|
|
124
|
+
async doReconnectSensor(connectionLost = true) {
|
|
125
125
|
this.onDisconnect();
|
|
126
|
-
this.
|
|
126
|
+
const { name, address } = this.peripheral?.getInfo() ?? {};
|
|
127
|
+
this.logEvent({ message: 'reconnect sensor', name, address, connectionLost });
|
|
127
128
|
let connected = false;
|
|
128
129
|
let subscribed = false;
|
|
129
130
|
let success = false;
|
|
@@ -143,8 +144,8 @@ class TBleSensor extends node_events_1.EventEmitter {
|
|
|
143
144
|
if (!success) {
|
|
144
145
|
await (0, utils_js_1.sleep)(1000);
|
|
145
146
|
}
|
|
146
|
-
if (!this.stopRequested)
|
|
147
|
-
this.logEvent({ message: 'reconnect sensor retry' });
|
|
147
|
+
if (!this.stopRequested && !success)
|
|
148
|
+
this.logEvent({ message: 'reconnect sensor retry', name, address });
|
|
148
149
|
} while (!success || this.stopRequested);
|
|
149
150
|
this.logEvent({ message: 'reconnect sensor completed', success, stopRequested: this.stopRequested });
|
|
150
151
|
return success;
|
package/lib/cjs/ble/fm/sensor.js
CHANGED
|
@@ -22,6 +22,7 @@ class BleFitnessMachineDevice extends sensor_js_1.TBleSensor {
|
|
|
22
22
|
windSpeed = 0;
|
|
23
23
|
wheelSize = 2100;
|
|
24
24
|
ftmsServiceData;
|
|
25
|
+
ftmsServiceDataAttempts = 0;
|
|
25
26
|
rowerDataTS;
|
|
26
27
|
rowerMaxPower;
|
|
27
28
|
constructor(peripheral, props) {
|
|
@@ -102,6 +103,7 @@ class BleFitnessMachineDevice extends sensor_js_1.TBleSensor {
|
|
|
102
103
|
}
|
|
103
104
|
onDisconnect() {
|
|
104
105
|
this.hasControl = false;
|
|
106
|
+
this.ftmsServiceDataAttempts = 0;
|
|
105
107
|
}
|
|
106
108
|
async requestControl() {
|
|
107
109
|
if (this.hasControl) {
|
|
@@ -472,11 +474,14 @@ class BleFitnessMachineDevice extends sensor_js_1.TBleSensor {
|
|
|
472
474
|
parseServiceData() {
|
|
473
475
|
if (this.ftmsServiceData)
|
|
474
476
|
return this.ftmsServiceData;
|
|
477
|
+
if (this.ftmsServiceDataAttempts > 3)
|
|
478
|
+
return this.ftmsServiceData;
|
|
475
479
|
try {
|
|
476
480
|
const peripheral = this.peripheral;
|
|
477
481
|
if (peripheral?.getServiceData === undefined)
|
|
478
482
|
return;
|
|
479
483
|
const bitSet = (value, bitNo) => (value & (0, utils_js_1.bit)(bitNo)) > 0;
|
|
484
|
+
this.ftmsServiceDataAttempts++;
|
|
480
485
|
const data = peripheral.getServiceData(consts_js_1.FTMS);
|
|
481
486
|
const dataLength = data?.length ?? 0;
|
|
482
487
|
if (dataLength >= 2) {
|
|
@@ -354,7 +354,7 @@ export default class BleAdapter extends IncyclistDevice {
|
|
|
354
354
|
sensor.off('data', this.onDeviceDataHandler);
|
|
355
355
|
let connected = false;
|
|
356
356
|
if (sensor.isReconnectBusy()) {
|
|
357
|
-
connected = await sensor.reconnectSensor();
|
|
357
|
+
connected = await sensor.reconnectSensor(false);
|
|
358
358
|
}
|
|
359
359
|
if (connected) {
|
|
360
360
|
sensor.on('data', this.onDeviceDataHandler);
|
|
@@ -109,18 +109,19 @@ export class TBleSensor extends EventEmitter {
|
|
|
109
109
|
isReconnectBusy() {
|
|
110
110
|
return (this.reconnectPromise !== undefined);
|
|
111
111
|
}
|
|
112
|
-
async reconnectSensor() {
|
|
112
|
+
async reconnectSensor(connectionLost = true) {
|
|
113
113
|
if (this.reconnectPromise !== undefined) {
|
|
114
114
|
return await this.reconnectPromise;
|
|
115
115
|
}
|
|
116
|
-
this.reconnectPromise = this.doReconnectSensor();
|
|
116
|
+
this.reconnectPromise = this.doReconnectSensor(connectionLost);
|
|
117
117
|
const res = await this.reconnectPromise;
|
|
118
118
|
delete this.reconnectPromise;
|
|
119
119
|
return res;
|
|
120
120
|
}
|
|
121
|
-
async doReconnectSensor() {
|
|
121
|
+
async doReconnectSensor(connectionLost = true) {
|
|
122
122
|
this.onDisconnect();
|
|
123
|
-
this.
|
|
123
|
+
const { name, address } = this.peripheral?.getInfo() ?? {};
|
|
124
|
+
this.logEvent({ message: 'reconnect sensor', name, address, connectionLost });
|
|
124
125
|
let connected = false;
|
|
125
126
|
let subscribed = false;
|
|
126
127
|
let success = false;
|
|
@@ -140,8 +141,8 @@ export class TBleSensor extends EventEmitter {
|
|
|
140
141
|
if (!success) {
|
|
141
142
|
await sleep(1000);
|
|
142
143
|
}
|
|
143
|
-
if (!this.stopRequested)
|
|
144
|
-
this.logEvent({ message: 'reconnect sensor retry' });
|
|
144
|
+
if (!this.stopRequested && !success)
|
|
145
|
+
this.logEvent({ message: 'reconnect sensor retry', name, address });
|
|
145
146
|
} while (!success || this.stopRequested);
|
|
146
147
|
this.logEvent({ message: 'reconnect sensor completed', success, stopRequested: this.stopRequested });
|
|
147
148
|
return success;
|
package/lib/esm/ble/fm/sensor.js
CHANGED
|
@@ -20,6 +20,7 @@ export default class BleFitnessMachineDevice extends TBleSensor {
|
|
|
20
20
|
windSpeed = 0;
|
|
21
21
|
wheelSize = 2100;
|
|
22
22
|
ftmsServiceData;
|
|
23
|
+
ftmsServiceDataAttempts = 0;
|
|
23
24
|
rowerDataTS;
|
|
24
25
|
rowerMaxPower;
|
|
25
26
|
constructor(peripheral, props) {
|
|
@@ -100,6 +101,7 @@ export default class BleFitnessMachineDevice extends TBleSensor {
|
|
|
100
101
|
}
|
|
101
102
|
onDisconnect() {
|
|
102
103
|
this.hasControl = false;
|
|
104
|
+
this.ftmsServiceDataAttempts = 0;
|
|
103
105
|
}
|
|
104
106
|
async requestControl() {
|
|
105
107
|
if (this.hasControl) {
|
|
@@ -470,11 +472,14 @@ export default class BleFitnessMachineDevice extends TBleSensor {
|
|
|
470
472
|
parseServiceData() {
|
|
471
473
|
if (this.ftmsServiceData)
|
|
472
474
|
return this.ftmsServiceData;
|
|
475
|
+
if (this.ftmsServiceDataAttempts > 3)
|
|
476
|
+
return this.ftmsServiceData;
|
|
473
477
|
try {
|
|
474
478
|
const peripheral = this.peripheral;
|
|
475
479
|
if (peripheral?.getServiceData === undefined)
|
|
476
480
|
return;
|
|
477
481
|
const bitSet = (value, bitNo) => (value & bit(bitNo)) > 0;
|
|
482
|
+
this.ftmsServiceDataAttempts++;
|
|
478
483
|
const data = peripheral.getServiceData(FTMS);
|
|
479
484
|
const dataLength = data?.length ?? 0;
|
|
480
485
|
if (dataLength >= 2) {
|
|
@@ -28,8 +28,8 @@ export declare class TBleSensor extends EventEmitter implements IBleSensor {
|
|
|
28
28
|
subscribe(): Promise<boolean>;
|
|
29
29
|
stopSensor(): Promise<boolean>;
|
|
30
30
|
isReconnectBusy(): boolean;
|
|
31
|
-
reconnectSensor(): Promise<boolean>;
|
|
32
|
-
doReconnectSensor(): Promise<boolean>;
|
|
31
|
+
reconnectSensor(connectionLost?: boolean): Promise<boolean>;
|
|
32
|
+
doReconnectSensor(connectionLost?: boolean): Promise<boolean>;
|
|
33
33
|
reset(): void;
|
|
34
34
|
isConnected(): boolean;
|
|
35
35
|
isSubscribed(): boolean;
|
|
@@ -19,6 +19,7 @@ export default class BleFitnessMachineDevice extends TBleSensor {
|
|
|
19
19
|
protected windSpeed: number;
|
|
20
20
|
protected wheelSize: number;
|
|
21
21
|
protected ftmsServiceData: FtmsServiceData;
|
|
22
|
+
protected ftmsServiceDataAttempts: number;
|
|
22
23
|
protected rowerDataTS: number | undefined;
|
|
23
24
|
protected rowerMaxPower: number | undefined;
|
|
24
25
|
constructor(peripheral: IBlePeripheral, props?: any);
|