incyclist-devices 3.0.8 → 3.0.9
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/antv2/base/interface.js +3 -0
- package/lib/cjs/ble/base/interface.js +6 -1
- package/lib/cjs/direct-connect/base/interface.js +6 -3
- package/lib/cjs/serial/base/serial-interface.js +3 -0
- package/lib/esm/antv2/base/interface.js +3 -0
- package/lib/esm/ble/base/interface.js +6 -1
- package/lib/esm/direct-connect/base/interface.js +6 -3
- package/lib/esm/serial/base/serial-interface.js +3 -0
- package/lib/types/antv2/base/interface.d.ts +1 -0
- package/lib/types/ble/base/interface.d.ts +2 -1
- package/lib/types/direct-connect/base/interface.d.ts +2 -1
- package/lib/types/serial/base/serial-interface.d.ts +1 -0
- package/lib/types/types/interface.d.ts +1 -0
- package/package.json +1 -1
|
@@ -144,6 +144,9 @@ class AntInterface extends node_events_1.EventEmitter {
|
|
|
144
144
|
this.connected = false;
|
|
145
145
|
return closed;
|
|
146
146
|
}
|
|
147
|
+
async terminate() {
|
|
148
|
+
await this.disconnect();
|
|
149
|
+
}
|
|
147
150
|
onError(profile, error) {
|
|
148
151
|
this.logEvent({ message: 'ANT+ERROR:', profile, error });
|
|
149
152
|
}
|
|
@@ -115,7 +115,6 @@ class BleInterface extends node_events_1.EventEmitter {
|
|
|
115
115
|
return false;
|
|
116
116
|
}
|
|
117
117
|
if (this.isConnecting()) {
|
|
118
|
-
this.logEvent({ message: 'BLE connect - already connecting' });
|
|
119
118
|
return this.connectTask.getPromise();
|
|
120
119
|
}
|
|
121
120
|
this.logEvent({ message: 'BLE connect request' });
|
|
@@ -184,6 +183,9 @@ class BleInterface extends node_events_1.EventEmitter {
|
|
|
184
183
|
const success = await this.disconnectTask.run().catch(() => false);
|
|
185
184
|
return success;
|
|
186
185
|
}
|
|
186
|
+
async terminate() {
|
|
187
|
+
await this.disconnect();
|
|
188
|
+
}
|
|
187
189
|
isConnected() {
|
|
188
190
|
return this.confirmedBleState === 'poweredOn';
|
|
189
191
|
}
|
|
@@ -629,6 +631,9 @@ class BleInterface extends node_events_1.EventEmitter {
|
|
|
629
631
|
});
|
|
630
632
|
}
|
|
631
633
|
onError(err) {
|
|
634
|
+
if (typeof err === 'string') {
|
|
635
|
+
this.logError(new Error(err), 'BLE connect');
|
|
636
|
+
}
|
|
632
637
|
this.logError(err, 'BLE connect');
|
|
633
638
|
}
|
|
634
639
|
async onConnected() {
|
|
@@ -144,13 +144,16 @@ class DirectConnectInterface extends node_events_1.EventEmitter {
|
|
|
144
144
|
return true;
|
|
145
145
|
this.logEvent({ message: 'Disconnecting from Direct Connect' });
|
|
146
146
|
await this.stopScan();
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
async terminate() {
|
|
150
|
+
await this.disconnect();
|
|
147
151
|
this.getBinding()?.mdns?.disconnect();
|
|
148
152
|
this.internalEvents.removeAllListeners();
|
|
149
153
|
this.connected = false;
|
|
150
154
|
const disconnected = !this.isConnected();
|
|
151
155
|
if (disconnected)
|
|
152
156
|
this.emit('disconnect');
|
|
153
|
-
return disconnected;
|
|
154
157
|
}
|
|
155
158
|
isConnected() {
|
|
156
159
|
return this.connected && this.getBinding()?.mdns !== undefined && this.binding.mdns !== null;
|
|
@@ -159,7 +162,7 @@ class DirectConnectInterface extends node_events_1.EventEmitter {
|
|
|
159
162
|
this.logDisabled = false;
|
|
160
163
|
if (this.isScanning()) {
|
|
161
164
|
this.logEvent({ message: 'starting scan - already scanning' });
|
|
162
|
-
await this.scanTask
|
|
165
|
+
await this.scanTask?.getPromise();
|
|
163
166
|
}
|
|
164
167
|
this.logEvent({ message: 'starting scan ..' });
|
|
165
168
|
await this.reconnect();
|
|
@@ -177,7 +180,7 @@ class DirectConnectInterface extends node_events_1.EventEmitter {
|
|
|
177
180
|
if (!this.isScanning())
|
|
178
181
|
return true;
|
|
179
182
|
this.logEvent({ message: 'stopping scan ...', interface: 'wifi' });
|
|
180
|
-
const res = await this.scanTask
|
|
183
|
+
const res = await this.scanTask?.stop();
|
|
181
184
|
delete this.scanTask;
|
|
182
185
|
return (res === true);
|
|
183
186
|
}
|
|
@@ -118,6 +118,9 @@ class SerialInterface extends node_events_1.EventEmitter {
|
|
|
118
118
|
this.connected = false;
|
|
119
119
|
return true;
|
|
120
120
|
}
|
|
121
|
+
async terminate() {
|
|
122
|
+
await this.disconnect();
|
|
123
|
+
}
|
|
121
124
|
async openPort(path) {
|
|
122
125
|
this.logEvent({ message: 'opening port', port: path });
|
|
123
126
|
const existing = this.ports.findIndex(p => p.path === path);
|
|
@@ -139,6 +139,9 @@ export default class AntInterface extends EventEmitter {
|
|
|
139
139
|
this.connected = false;
|
|
140
140
|
return closed;
|
|
141
141
|
}
|
|
142
|
+
async terminate() {
|
|
143
|
+
await this.disconnect();
|
|
144
|
+
}
|
|
142
145
|
onError(profile, error) {
|
|
143
146
|
this.logEvent({ message: 'ANT+ERROR:', profile, error });
|
|
144
147
|
}
|
|
@@ -112,7 +112,6 @@ export class BleInterface extends EventEmitter {
|
|
|
112
112
|
return false;
|
|
113
113
|
}
|
|
114
114
|
if (this.isConnecting()) {
|
|
115
|
-
this.logEvent({ message: 'BLE connect - already connecting' });
|
|
116
115
|
return this.connectTask.getPromise();
|
|
117
116
|
}
|
|
118
117
|
this.logEvent({ message: 'BLE connect request' });
|
|
@@ -181,6 +180,9 @@ export class BleInterface extends EventEmitter {
|
|
|
181
180
|
const success = await this.disconnectTask.run().catch(() => false);
|
|
182
181
|
return success;
|
|
183
182
|
}
|
|
183
|
+
async terminate() {
|
|
184
|
+
await this.disconnect();
|
|
185
|
+
}
|
|
184
186
|
isConnected() {
|
|
185
187
|
return this.confirmedBleState === 'poweredOn';
|
|
186
188
|
}
|
|
@@ -626,6 +628,9 @@ export class BleInterface extends EventEmitter {
|
|
|
626
628
|
});
|
|
627
629
|
}
|
|
628
630
|
onError(err) {
|
|
631
|
+
if (typeof err === 'string') {
|
|
632
|
+
this.logError(new Error(err), 'BLE connect');
|
|
633
|
+
}
|
|
629
634
|
this.logError(err, 'BLE connect');
|
|
630
635
|
}
|
|
631
636
|
async onConnected() {
|
|
@@ -141,13 +141,16 @@ export default class DirectConnectInterface extends EventEmitter {
|
|
|
141
141
|
return true;
|
|
142
142
|
this.logEvent({ message: 'Disconnecting from Direct Connect' });
|
|
143
143
|
await this.stopScan();
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
async terminate() {
|
|
147
|
+
await this.disconnect();
|
|
144
148
|
this.getBinding()?.mdns?.disconnect();
|
|
145
149
|
this.internalEvents.removeAllListeners();
|
|
146
150
|
this.connected = false;
|
|
147
151
|
const disconnected = !this.isConnected();
|
|
148
152
|
if (disconnected)
|
|
149
153
|
this.emit('disconnect');
|
|
150
|
-
return disconnected;
|
|
151
154
|
}
|
|
152
155
|
isConnected() {
|
|
153
156
|
return this.connected && this.getBinding()?.mdns !== undefined && this.binding.mdns !== null;
|
|
@@ -156,7 +159,7 @@ export default class DirectConnectInterface extends EventEmitter {
|
|
|
156
159
|
this.logDisabled = false;
|
|
157
160
|
if (this.isScanning()) {
|
|
158
161
|
this.logEvent({ message: 'starting scan - already scanning' });
|
|
159
|
-
await this.scanTask
|
|
162
|
+
await this.scanTask?.getPromise();
|
|
160
163
|
}
|
|
161
164
|
this.logEvent({ message: 'starting scan ..' });
|
|
162
165
|
await this.reconnect();
|
|
@@ -174,7 +177,7 @@ export default class DirectConnectInterface extends EventEmitter {
|
|
|
174
177
|
if (!this.isScanning())
|
|
175
178
|
return true;
|
|
176
179
|
this.logEvent({ message: 'stopping scan ...', interface: 'wifi' });
|
|
177
|
-
const res = await this.scanTask
|
|
180
|
+
const res = await this.scanTask?.stop();
|
|
178
181
|
delete this.scanTask;
|
|
179
182
|
return (res === true);
|
|
180
183
|
}
|
|
@@ -113,6 +113,9 @@ export default class SerialInterface extends EventEmitter {
|
|
|
113
113
|
this.connected = false;
|
|
114
114
|
return true;
|
|
115
115
|
}
|
|
116
|
+
async terminate() {
|
|
117
|
+
await this.disconnect();
|
|
118
|
+
}
|
|
116
119
|
async openPort(path) {
|
|
117
120
|
this.logEvent({ message: 'opening port', port: path });
|
|
118
121
|
const existing = this.ports.findIndex(p => p.path === path);
|
|
@@ -39,6 +39,7 @@ export default class AntInterface extends EventEmitter implements IncyclistInter
|
|
|
39
39
|
isConnected(): boolean;
|
|
40
40
|
connect(): Promise<boolean>;
|
|
41
41
|
disconnect(): Promise<boolean>;
|
|
42
|
+
terminate(): Promise<void>;
|
|
42
43
|
onError(profile: any, error: any): void;
|
|
43
44
|
onData(profile: any, id: any, data: any, tag: any): void;
|
|
44
45
|
getReconnectPause(): number;
|
|
@@ -54,6 +54,7 @@ export declare class BleInterface extends EventEmitter implements IBleInterface<
|
|
|
54
54
|
connect(reconnect?: boolean): Promise<boolean>;
|
|
55
55
|
connectInternal(reconnect?: boolean): Promise<boolean>;
|
|
56
56
|
disconnect(connectionLost?: boolean): Promise<boolean>;
|
|
57
|
+
terminate(): Promise<void>;
|
|
57
58
|
isConnected(): boolean;
|
|
58
59
|
registerConnected(peripheral: IBlePeripheral, id: string): void;
|
|
59
60
|
unregisterConnected(id: string): void;
|
|
@@ -101,7 +102,7 @@ export declare class BleInterface extends EventEmitter implements IBleInterface<
|
|
|
101
102
|
addKnownDevice(_settings: BleDeviceSettings): void;
|
|
102
103
|
protected connectBle(): Promise<boolean>;
|
|
103
104
|
protected waitForBleConnected(): Promise<boolean>;
|
|
104
|
-
protected onError(err: Error): void;
|
|
105
|
+
protected onError(err: Error | string): void;
|
|
105
106
|
protected onConnected(): Promise<void>;
|
|
106
107
|
protected onDisconnected(): Promise<void>;
|
|
107
108
|
protected onBleStateChange(state: BleInterfaceState): Promise<void>;
|
|
@@ -24,7 +24,7 @@ export default class DirectConnectInterface extends EventEmitter implements IBle
|
|
|
24
24
|
protected logDisabled: boolean;
|
|
25
25
|
protected internalEvents: EventEmitter;
|
|
26
26
|
protected services: Announcement[];
|
|
27
|
-
protected scanTask: InteruptableTask<TaskState, DeviceSettings[]
|
|
27
|
+
protected scanTask: InteruptableTask<TaskState, DeviceSettings[]> | undefined;
|
|
28
28
|
protected matching?: Array<string>;
|
|
29
29
|
protected instance: number;
|
|
30
30
|
protected connected: boolean;
|
|
@@ -43,6 +43,7 @@ export default class DirectConnectInterface extends EventEmitter implements IBle
|
|
|
43
43
|
autoConnect(): void;
|
|
44
44
|
connect(reconnect?: boolean): Promise<boolean>;
|
|
45
45
|
disconnect(): Promise<boolean>;
|
|
46
|
+
terminate(): Promise<void>;
|
|
46
47
|
isConnected(): boolean;
|
|
47
48
|
scan(props: DirectConnectScanProps): Promise<DeviceSettings[]>;
|
|
48
49
|
stopScan(): Promise<boolean>;
|
|
@@ -26,6 +26,7 @@ export default class SerialInterface extends EventEmitter implements IncyclistIn
|
|
|
26
26
|
releaseInUse(path: string): void;
|
|
27
27
|
connect(): Promise<boolean>;
|
|
28
28
|
disconnect(): Promise<boolean>;
|
|
29
|
+
terminate(): Promise<void>;
|
|
29
30
|
openPort(path: string): Promise<SerialPortStream | null>;
|
|
30
31
|
closePort(path: string): Promise<boolean>;
|
|
31
32
|
scan(props: SerialScannerProps): Promise<SerialDeviceSettings[]>;
|
|
@@ -12,6 +12,7 @@ export interface IncyclistInterface extends EventEmitter {
|
|
|
12
12
|
setBinding(binding: any): void;
|
|
13
13
|
connect(): Promise<boolean>;
|
|
14
14
|
disconnect(): Promise<boolean>;
|
|
15
|
+
terminate(): Promise<void>;
|
|
15
16
|
isConnected(): boolean;
|
|
16
17
|
scan(props: IncyclistScanProps): Promise<DeviceSettings[]>;
|
|
17
18
|
stopScan(): Promise<boolean>;
|