incyclist-devices 2.3.0-beta.16 → 2.3.0-beta.18
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.
|
@@ -35,6 +35,7 @@ export declare class BleInterface extends EventEmitter implements IBleInterface<
|
|
|
35
35
|
protected connectAttemptCnt: number;
|
|
36
36
|
static getInstance(props?: InterfaceProps): BleInterface;
|
|
37
37
|
protected constructor(props: InterfaceProps);
|
|
38
|
+
setProps(props: InterfaceProps): void;
|
|
38
39
|
getLogger(): EventLogger;
|
|
39
40
|
setLogger(logger: EventLogger): void;
|
|
40
41
|
getName(): string;
|
|
@@ -28,6 +28,7 @@ class BleInterface extends events_1.default {
|
|
|
28
28
|
if (BleInterface._instance === undefined)
|
|
29
29
|
BleInterface._instance = new BleInterface(props);
|
|
30
30
|
else {
|
|
31
|
+
BleInterface._instance.setProps(props);
|
|
31
32
|
if (props.binding) {
|
|
32
33
|
BleInterface._instance.setBinding(props.binding);
|
|
33
34
|
}
|
|
@@ -60,9 +61,13 @@ class BleInterface extends events_1.default {
|
|
|
60
61
|
}
|
|
61
62
|
this.internalEvents = new events_1.default();
|
|
62
63
|
this.onDiscovered = this.onPeripheralFound.bind(this);
|
|
63
|
-
|
|
64
|
+
const { enabled = true } = props;
|
|
65
|
+
if (this.binding && enabled)
|
|
64
66
|
this.autoConnect();
|
|
65
67
|
}
|
|
68
|
+
setProps(props) {
|
|
69
|
+
this.props = props;
|
|
70
|
+
}
|
|
66
71
|
getLogger() {
|
|
67
72
|
return this.logger;
|
|
68
73
|
}
|
|
@@ -73,8 +78,9 @@ class BleInterface extends events_1.default {
|
|
|
73
78
|
return BleInterface.INTERFACE_NAME;
|
|
74
79
|
}
|
|
75
80
|
setBinding(binding) {
|
|
81
|
+
const prev = this.binding;
|
|
76
82
|
this.binding = binding;
|
|
77
|
-
if (!this.isConnected()) {
|
|
83
|
+
if (!prev && !this.isConnected() && this.props.enabled) {
|
|
78
84
|
this.autoConnect();
|
|
79
85
|
}
|
|
80
86
|
}
|
|
@@ -189,8 +195,10 @@ class BleInterface extends events_1.default {
|
|
|
189
195
|
pauseLogging() {
|
|
190
196
|
this.logEvent({ message: 'pausing logging' });
|
|
191
197
|
this.logDisabled = true;
|
|
198
|
+
this.getBinding().pauseLogging();
|
|
192
199
|
}
|
|
193
200
|
resumeLogging() {
|
|
201
|
+
this.getBinding().resumeLogging();
|
|
194
202
|
this.logDisabled = false;
|
|
195
203
|
this.logEvent({ message: 'resuming logging' });
|
|
196
204
|
}
|
|
@@ -232,7 +240,7 @@ class BleInterface extends events_1.default {
|
|
|
232
240
|
const { peripheral } = service;
|
|
233
241
|
if (peripheral.address === undefined || peripheral.address === '')
|
|
234
242
|
peripheral.address = peripheral.id || peripheral.name;
|
|
235
|
-
const protocol = this.getAdapterFactory().getProtocol(service.
|
|
243
|
+
const protocol = this.getAdapterFactory().getProtocol(service.serviceUUIDs);
|
|
236
244
|
const { id, name, address } = (0, utils_1.getPeripheralInfo)(peripheral);
|
|
237
245
|
return { interface: BleInterface.INTERFACE_NAME, protocol, id, name, address };
|
|
238
246
|
}
|
|
@@ -29,6 +29,7 @@ export default class DirectConnectInterface extends EventEmitter implements IBle
|
|
|
29
29
|
protected connected: boolean;
|
|
30
30
|
static getInstance(props?: InterfaceProps): DirectConnectInterface;
|
|
31
31
|
constructor(props: InterfaceProps);
|
|
32
|
+
setProps(props: InterfaceProps): void;
|
|
32
33
|
createPeripheral(announcement: MulticastDnsAnnouncement): IBlePeripheral;
|
|
33
34
|
createDeviceSetting(service: MulticastDnsAnnouncement): BleDeviceSettings;
|
|
34
35
|
createPeripheralFromSettings(settings: DeviceSettings): IBlePeripheral;
|
|
@@ -27,6 +27,7 @@ class DirectConnectInterface extends events_1.default {
|
|
|
27
27
|
if (DirectConnectInterface._instance === undefined)
|
|
28
28
|
DirectConnectInterface._instance = new DirectConnectInterface(props);
|
|
29
29
|
else {
|
|
30
|
+
DirectConnectInterface._instance.setProps(props);
|
|
30
31
|
if (props.binding) {
|
|
31
32
|
DirectConnectInterface._instance.setBinding(props.binding);
|
|
32
33
|
}
|
|
@@ -54,9 +55,13 @@ class DirectConnectInterface extends events_1.default {
|
|
|
54
55
|
}
|
|
55
56
|
this.internalEvents = new events_1.default();
|
|
56
57
|
this.instance = ++instanceId;
|
|
57
|
-
|
|
58
|
+
const { enabled } = props;
|
|
59
|
+
if (this.binding && (enabled !== null && enabled !== void 0 ? enabled : false))
|
|
58
60
|
this.autoConnect();
|
|
59
61
|
}
|
|
62
|
+
setProps(props) {
|
|
63
|
+
this.props = props;
|
|
64
|
+
}
|
|
60
65
|
createPeripheral(announcement) {
|
|
61
66
|
return peripheral_1.DirectConnectPeripheral.create(announcement);
|
|
62
67
|
}
|
|
@@ -83,7 +88,7 @@ class DirectConnectInterface extends events_1.default {
|
|
|
83
88
|
setBinding(binding) {
|
|
84
89
|
const prev = this.binding;
|
|
85
90
|
this.binding = binding;
|
|
86
|
-
if (!prev)
|
|
91
|
+
if (!prev && this.props.enabled)
|
|
87
92
|
this.autoConnect();
|
|
88
93
|
}
|
|
89
94
|
getBinding() {
|
package/lib/types/interface.d.ts
CHANGED