incyclist-services 1.0.9 → 1.0.11

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.
@@ -18,7 +18,7 @@ export declare class DeviceAccessService extends EventEmitter {
18
18
  protected logEvent(event: any): void;
19
19
  setDefaultInterfaceProperties(props: InterfaceAccessProps): void;
20
20
  enableInterface(ifaceName: string, binding?: any, props?: InterfaceAccessProps): void;
21
- disableInterface(ifaceName: string): void;
21
+ disableInterface(ifaceName: string, avalailable?: boolean): void;
22
22
  setInterfaceProperties(ifaceName: string, props: InterfaceAccessProps): void;
23
23
  getInterfaceInfo(ifaceName: string): InterfaceInfo;
24
24
  protected getInterface(ifaceName: string): IncyclistInterface;
@@ -69,7 +69,7 @@ class DeviceAccessService extends events_1.default {
69
69
  this.emit('interface-changed', ifaceName, this.interfaces[ifaceName]);
70
70
  }
71
71
  }
72
- disableInterface(ifaceName) {
72
+ disableInterface(ifaceName, avalailable = true) {
73
73
  const existing = this.interfaces[ifaceName];
74
74
  if (!existing)
75
75
  return;
@@ -84,6 +84,12 @@ class DeviceAccessService extends events_1.default {
84
84
  return;
85
85
  }
86
86
  existing.enabled = false;
87
+ if (!avalailable) {
88
+ existing.state = 'unavailable';
89
+ existing.unavailable = true;
90
+ this.emit('interface-changed', ifaceName, { name: ifaceName, state: 'unavailable', isScanning: false });
91
+ return;
92
+ }
87
93
  this.emit('interface-changed', ifaceName, this.interfaces[ifaceName]);
88
94
  }
89
95
  setInterfaceProperties(ifaceName, props) {
@@ -175,21 +181,17 @@ class DeviceAccessService extends events_1.default {
175
181
  interfaces.forEach((i) => {
176
182
  i.on('device', (deviceSettings) => __awaiter(this, void 0, void 0, function* () {
177
183
  var _a, _b;
178
- console.log('~~~ detected device:', deviceSettings);
179
184
  if (adapters.find(a => a.isEqual(deviceSettings))) {
180
- console.log('~~~ device already detected');
181
185
  return;
182
186
  }
183
187
  if (filter.profile && deviceSettings.profile !== filter.profile) {
184
- console.log('~~~ device does not match profile', filter.profile);
185
188
  return;
186
189
  }
187
190
  if (filter.protocol && deviceSettings.protocol !== filter.protocol) {
188
- console.log('~~~ device does not match protocol', filter.protocol);
189
191
  return;
190
192
  }
191
193
  if (filter.protocols && !filter.protocols.includes(deviceSettings.protocol)) {
192
- console.log('~~~ device does not match protocols', filter.protocol);
194
+ return;
193
195
  }
194
196
  const adapter = incyclist_devices_1.AdapterFactory.create(deviceSettings);
195
197
  if (filter.capabilities) {
@@ -198,7 +200,6 @@ class DeviceAccessService extends events_1.default {
198
200
  found = found || adapter.getCapabilities().includes(capability);
199
201
  });
200
202
  if (!found) {
201
- console.log('~~~ device does not match capabilties', filter.capabilities);
202
203
  return;
203
204
  }
204
205
  }
@@ -219,11 +220,11 @@ class DeviceAccessService extends events_1.default {
219
220
  yield adapter.stop();
220
221
  }
221
222
  catch (err) {
222
- console.log(err);
223
+ this.logEvent({ message: 'could not start device', device: adapter === null || adapter === void 0 ? void 0 : adapter.getUniqueName(), reason: err.message });
223
224
  }
224
225
  }
225
226
  catch (err) {
226
- console.log('~~~ start error', err);
227
+ this.logEvent({ message: 'error', fn: 'scan#adapte', error: err.message, stack: err.stack });
227
228
  }
228
229
  }
229
230
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-services",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "peerDependencies": {
5
5
  "gd-eventlog": "^0.1.22"
6
6
  },
@@ -36,7 +36,7 @@
36
36
  "lib": "./src"
37
37
  },
38
38
  "dependencies": {
39
- "incyclist-devices": "^2.0.8",
39
+ "incyclist-devices": "^2.0.11",
40
40
  "uuid": "^9.0.0"
41
41
  }
42
42
  }