incyclist-devices 2.1.5 → 2.1.7
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/antv2/base/adapter.js +6 -4
- package/lib/antv2/fe/adapter.d.ts +1 -0
- package/lib/antv2/fe/adapter.js +9 -2
- package/lib/ble/base/comms.js +3 -3
- package/lib/ble/fm/comms.d.ts +1 -1
- package/lib/ble/fm/comms.js +2 -1
- package/lib/ble/tacx/comms.js +1 -2
- package/lib/serial/daum/classic/comms.d.ts +1 -0
- package/lib/serial/daum/classic/comms.js +5 -2
- package/lib/serial/daum/premium/comms.js +1 -1
- package/package.json +1 -1
|
@@ -120,8 +120,8 @@ class AntAdapter extends adpater_1.default {
|
|
|
120
120
|
this.emit('device-info', this.getSettings(), { manufacturer: (0, utils_2.getBrand)(deviceData.ManId) });
|
|
121
121
|
}
|
|
122
122
|
const logData = this.getLogData(deviceData, ['PairedDevices', 'RawData']);
|
|
123
|
-
this.logEvent({ message: 'onDeviceData', data: logData, paused: this.paused });
|
|
124
|
-
if (
|
|
123
|
+
this.logEvent({ message: 'onDeviceData', data: logData, paused: this.paused, started: this.started, canEmit: this.canEmitData() });
|
|
124
|
+
if (this.isStopped() || !this.canEmitData())
|
|
125
125
|
return;
|
|
126
126
|
if (this.isControllable()) {
|
|
127
127
|
let incyclistData = this.mapData(deviceData);
|
|
@@ -333,9 +333,12 @@ class AntAdapter extends adpater_1.default {
|
|
|
333
333
|
try {
|
|
334
334
|
this.sensorConnected = yield this.startSensor();
|
|
335
335
|
if (this.sensorConnected) {
|
|
336
|
-
this.logEvent({ message: 'sensor started', props });
|
|
336
|
+
this.logEvent({ message: 'sensor started', device: this.getName(), props });
|
|
337
337
|
this.startStatus.sensorStarted = true;
|
|
338
338
|
}
|
|
339
|
+
else {
|
|
340
|
+
this.logEvent({ message: 'start sensor failed', device: this.getName(), reason: 'unknown', props });
|
|
341
|
+
}
|
|
339
342
|
}
|
|
340
343
|
catch (err) {
|
|
341
344
|
this.logEvent({ message: 'start sensor failed', device: this.getName(), reason: err.message, props });
|
|
@@ -402,7 +405,6 @@ class AntAdapter extends adpater_1.default {
|
|
|
402
405
|
this.promiseWaitForData = null;
|
|
403
406
|
if (this.startStatus) {
|
|
404
407
|
this.startStatus.interrupted = true;
|
|
405
|
-
console.log('~~~ still starting');
|
|
406
408
|
yield (0, utils_1.sleep)(20);
|
|
407
409
|
}
|
|
408
410
|
try {
|
|
@@ -15,6 +15,7 @@ export default class AntFEAdapter extends AntAdapter<FitnessEquipmentSensorState
|
|
|
15
15
|
protected distanceInternal?: number;
|
|
16
16
|
protected startProps: AntDeviceProperties;
|
|
17
17
|
protected promiseReconnect: Promise<boolean>;
|
|
18
|
+
protected promiseSendUpdate: Promise<boolean>;
|
|
18
19
|
constructor(settings: AntDeviceSettings, props?: AntDeviceProperties);
|
|
19
20
|
getDisplayName(): string;
|
|
20
21
|
isReconnecting(): boolean;
|
package/lib/antv2/fe/adapter.js
CHANGED
|
@@ -40,19 +40,26 @@ class AntFEAdapter extends adapter_1.default {
|
|
|
40
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
41
|
if ((this.paused || this.isReconnecting()) && !forced)
|
|
42
42
|
return;
|
|
43
|
+
if (this.promiseSendUpdate) {
|
|
44
|
+
this.logEvent({ message: 'send bike update skipped', device: this.getName(), request, reason: 'busy' });
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
43
47
|
let isReset = request.reset && Object.keys(request).length === 1;
|
|
44
48
|
const update = isReset ? this.getCyclingMode().getBikeInitRequest() : this.getCyclingMode().sendBikeUpdate(request);
|
|
45
49
|
this.logEvent({ message: 'send bike update requested', device: this.getName(), update, request });
|
|
46
50
|
try {
|
|
47
51
|
const fe = this.sensor;
|
|
48
52
|
if (update.slope !== undefined) {
|
|
49
|
-
|
|
53
|
+
this.promiseSendUpdate = fe.sendTrackResistance(update.slope);
|
|
50
54
|
}
|
|
51
55
|
if (update.targetPower !== undefined) {
|
|
52
|
-
|
|
56
|
+
this.promiseSendUpdate = fe.sendTargetPower(update.targetPower);
|
|
53
57
|
}
|
|
58
|
+
yield this.promiseSendUpdate;
|
|
59
|
+
delete this.promiseSendUpdate;
|
|
54
60
|
}
|
|
55
61
|
catch (err) {
|
|
62
|
+
delete this.promiseSendUpdate;
|
|
56
63
|
if (err.message && err.message.toLowerCase() === 'timeout') {
|
|
57
64
|
this.emit('timeout');
|
|
58
65
|
if (this.startProps.automaticReconnect) {
|
package/lib/ble/base/comms.js
CHANGED
|
@@ -176,9 +176,9 @@ class BleComms extends events_1.default {
|
|
|
176
176
|
}
|
|
177
177
|
initDevice() {
|
|
178
178
|
this.logEvent({ message: 'get device info' });
|
|
179
|
-
return this.getDeviceInfo().then(() => {
|
|
180
|
-
this.emit('deviceInfo',
|
|
181
|
-
this.logEvent(Object.assign({ message: 'device init done' },
|
|
179
|
+
return this.getDeviceInfo().then((info) => {
|
|
180
|
+
this.emit('deviceInfo', info);
|
|
181
|
+
this.logEvent(Object.assign({ message: 'device init done' }, info));
|
|
182
182
|
this.isInitialized = true;
|
|
183
183
|
return true;
|
|
184
184
|
});
|
package/lib/ble/fm/comms.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export default class BleFitnessMachineDevice extends BleComms {
|
|
|
35
35
|
getWindSpeed(): number;
|
|
36
36
|
parseIndoorBikeData(_data: Uint8Array): IndoorBikeData;
|
|
37
37
|
parseFitnessMachineStatus(_data: Uint8Array): IndoorBikeData;
|
|
38
|
-
getFitnessMachineFeatures(): Promise<IndoorBikeFeatures>;
|
|
38
|
+
getFitnessMachineFeatures(): Promise<IndoorBikeFeatures | undefined>;
|
|
39
39
|
onData(characteristic: string, data: Buffer): boolean;
|
|
40
40
|
writeFtmsMessage(requestedOpCode: any, data: any, props?: BleWriteProps): Promise<number>;
|
|
41
41
|
requestControl(): Promise<boolean>;
|
package/lib/ble/fm/comms.js
CHANGED
|
@@ -76,7 +76,7 @@ class BleFitnessMachineDevice extends comms_1.BleComms {
|
|
|
76
76
|
this.cw = 0.6;
|
|
77
77
|
this.windSpeed = 0;
|
|
78
78
|
this.wheelSize = 2100;
|
|
79
|
-
this.
|
|
79
|
+
this.reset();
|
|
80
80
|
this.services = BleFitnessMachineDevice.services;
|
|
81
81
|
}
|
|
82
82
|
static isMatching(characteristics) {
|
|
@@ -310,6 +310,7 @@ class BleFitnessMachineDevice extends comms_1.BleComms {
|
|
|
310
310
|
}
|
|
311
311
|
catch (err) {
|
|
312
312
|
this.logEvent({ message: 'could not read FitnessMachineFeatures', error: err.message, stack: err.stack });
|
|
313
|
+
return undefined;
|
|
313
314
|
}
|
|
314
315
|
});
|
|
315
316
|
}
|
package/lib/ble/tacx/comms.js
CHANGED
|
@@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const _1 = require(".");
|
|
16
15
|
const consts_1 = require("../consts");
|
|
17
16
|
const comms_1 = __importDefault(require("../fm/comms"));
|
|
18
17
|
const utils_1 = require("../utils");
|
|
@@ -88,7 +87,7 @@ class TacxAdvancedFitnessMachineDevice extends comms_1.default {
|
|
|
88
87
|
return 'Smart Trainer';
|
|
89
88
|
}
|
|
90
89
|
getProtocol() {
|
|
91
|
-
return
|
|
90
|
+
return TacxAdvancedFitnessMachineDevice.protocol;
|
|
92
91
|
}
|
|
93
92
|
getServiceUUids() {
|
|
94
93
|
return TacxAdvancedFitnessMachineDevice.services;
|
|
@@ -5,6 +5,7 @@ import { SerialCommProps } from '../../types';
|
|
|
5
5
|
import { DeviceType, IncyclistBikeData, User } from '../../../types';
|
|
6
6
|
export default class Daum8008 extends SerialPortComms<DaumClassicCommsState, DaumClassicRequest, DaumClassicResponse> implements DaumSerialComms {
|
|
7
7
|
protected bikeNo: number;
|
|
8
|
+
protected prevFailedPayload: any;
|
|
8
9
|
constructor(props: SerialCommProps);
|
|
9
10
|
validatePath(path: string): string;
|
|
10
11
|
getDefaultLoggerName(): string;
|
|
@@ -17,7 +17,7 @@ const comms_1 = __importDefault(require("../../base/comms"));
|
|
|
17
17
|
const utils_2 = require("./utils");
|
|
18
18
|
const types_1 = require("../types");
|
|
19
19
|
const ByteLength = require('@serialport/parser-byte-length');
|
|
20
|
-
const TIMEOUT_SEND =
|
|
20
|
+
const TIMEOUT_SEND = 5000;
|
|
21
21
|
class Daum8008 extends comms_1.default {
|
|
22
22
|
constructor(props) {
|
|
23
23
|
super(props);
|
|
@@ -65,11 +65,12 @@ class Daum8008 extends comms_1.default {
|
|
|
65
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
66
|
this.initForResponse(expected);
|
|
67
67
|
yield this.write(Buffer.from(payload));
|
|
68
|
-
|
|
68
|
+
let response = yield this.waitForResponse();
|
|
69
69
|
if (response.type === 'Error')
|
|
70
70
|
throw response.error;
|
|
71
71
|
if (response.data[0] !== payload[0]) {
|
|
72
72
|
this.portFlush();
|
|
73
|
+
this.logEvent({ message: "sendCommand:received:", port: this.path, hex: Buffer.from(response.data).toString('hex') });
|
|
73
74
|
throw new Error('illegal response');
|
|
74
75
|
}
|
|
75
76
|
return response;
|
|
@@ -91,11 +92,13 @@ class Daum8008 extends comms_1.default {
|
|
|
91
92
|
const res = yield this.doSend(expected, payload);
|
|
92
93
|
this.logEvent(Object.assign(Object.assign({ message: "sendCommand:received:" }, logPayload), { hex: Buffer.from(res.data).toString('hex') }));
|
|
93
94
|
this.sendCmdPromise = null;
|
|
95
|
+
this.prevFailedPayload = null;
|
|
94
96
|
resolve(res);
|
|
95
97
|
}
|
|
96
98
|
catch (err) {
|
|
97
99
|
this.logEvent(Object.assign(Object.assign({ message: "sendCommand:error:" }, logPayload), { error: err.message }));
|
|
98
100
|
this.sendCmdPromise = null;
|
|
101
|
+
this.prevFailedPayload = payload;
|
|
99
102
|
reject(err);
|
|
100
103
|
}
|
|
101
104
|
}));
|
|
@@ -569,7 +569,7 @@ class Daum8i extends comms_1.default {
|
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
571
|
catch (err) {
|
|
572
|
-
this.logEvent({ message: '
|
|
572
|
+
this.logEvent({ message: 'programUpload failed', reason: err.message });
|
|
573
573
|
return false;
|
|
574
574
|
}
|
|
575
575
|
});
|