incyclist-devices 2.3.0-beta.3 → 2.3.0-beta.4

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.
@@ -88,7 +88,7 @@ class DirectConnectPeripheral {
88
88
  response = yield this.send(seqNo, request);
89
89
  const res = message.parseResponse(response);
90
90
  const uuids = res.body.serviceDefinitions.map(s => (0, utils_1.beautifyUUID)(s.serviceUUID));
91
- this.logEvent({ message: 'DiscoverServices response', path: this.getPath(), uuids, raw: request.toString('hex') });
91
+ this.logEvent({ message: 'DiscoverServices response', path: this.getPath(), uuids, raw: response.toString('hex') });
92
92
  return res.body.serviceDefinitions.map(s => s.serviceUUID);
93
93
  }
94
94
  catch (err) {
@@ -109,7 +109,7 @@ class DirectConnectPeripheral {
109
109
  const res = message.parseResponse(response);
110
110
  const service = (0, utils_1.beautifyUUID)(res.body.serviceUUID);
111
111
  const characteristics = res.body.characteristicDefinitions.map(cd => `${(0, utils_1.beautifyUUID)(cd.characteristicUUID)}:${cd.properties.join('/')}`);
112
- this.logEvent({ message: 'DiscoverCharacteritics response', path: this.getPath(), service, characteristics, raw: request.toString('hex') });
112
+ this.logEvent({ message: 'DiscoverCharacteritics response', path: this.getPath(), service, characteristics, raw: response.toString('hex') });
113
113
  return res.body.characteristicDefinitions.map(c => ({ uuid: c.characteristicUUID, properties: c.properties }));
114
114
  }
115
115
  catch (err) {
@@ -128,7 +128,7 @@ class DirectConnectPeripheral {
128
128
  try {
129
129
  response = yield this.send(seqNo, request);
130
130
  const res = message.parseResponse(response);
131
- this.logEvent({ message: 'EnableCharacteristicNotifications response', path: this.getPath(), characteristic: (0, utils_1.beautifyUUID)(res.body.characteristicUUID), raw: request.toString('hex') });
131
+ this.logEvent({ message: 'EnableCharacteristicNotifications response', path: this.getPath(), characteristic: (0, utils_1.beautifyUUID)(res.body.characteristicUUID), raw: response.toString('hex') });
132
132
  const confirmed = res.body.characteristicUUID;
133
133
  if ((0, utils_1.parseUUID)(confirmed) === (0, utils_1.parseUUID)(characteristicUUID)) {
134
134
  this.subscribed.push(characteristicUUID);
@@ -156,7 +156,7 @@ class DirectConnectPeripheral {
156
156
  this.logEvent({ message: 'EnableCharacteristicNotifications request', path: this.getPath(), characteristic: (0, utils_1.beautifyUUID)(characteristicUUID), enabled: false, raw: request.toString('hex') });
157
157
  response = yield this.send(seqNo, request);
158
158
  const res = message.parseResponse(response);
159
- this.logEvent({ message: 'EnableCharacteristicNotifications response', path: this.getPath(), characteristic: (0, utils_1.beautifyUUID)(res.body.characteristicUUID), raw: request.toString('hex') });
159
+ this.logEvent({ message: 'EnableCharacteristicNotifications response', path: this.getPath(), characteristic: (0, utils_1.beautifyUUID)(res.body.characteristicUUID), raw: response.toString('hex') });
160
160
  const confirmed = res.body.characteristicUUID;
161
161
  if ((0, utils_1.parseUUID)(confirmed) === (0, utils_1.parseUUID)(characteristicUUID)) {
162
162
  this.subscribed.splice(this.subscribed.indexOf(characteristicUUID), 1);
@@ -214,7 +214,27 @@ class DirectConnectPeripheral {
214
214
  }
215
215
  subscribeSelected(characteristics, callback) {
216
216
  return __awaiter(this, void 0, void 0, function* () {
217
+ let services = [];
218
+ let supported = [];
219
+ try {
220
+ services = yield this.discoverServices();
221
+ }
222
+ catch (err) {
223
+ this.logEvent({ message: 'could not discover services', reason: err.message });
224
+ }
225
+ for (const element of services) {
226
+ const service = element;
227
+ try {
228
+ const c = yield this.discoverCharacteristics(service);
229
+ supported = supported.concat(c);
230
+ }
231
+ catch (err) {
232
+ this.logEvent({ message: 'could not discover characteristics', service, reason: err.message });
233
+ return false;
234
+ }
235
+ }
217
236
  const retry = [];
237
+ this.logEvent({ message: 'characteristics supported', requested: characteristics.map(c => (0, utils_1.beautifyUUID)(c)), supported: supported.map(c => (0, utils_1.beautifyUUID)(c)) });
218
238
  for (const element of characteristics) {
219
239
  const uuid = element;
220
240
  const success = yield this.subscribe(uuid, callback);
@@ -250,7 +270,7 @@ class DirectConnectPeripheral {
250
270
  const res = message.parseResponse(response);
251
271
  this.logEvent({ message: 'ReadCharacteristic response', path: this.getPath(), characteristic: (0, utils_1.beautifyUUID)(res.body.characteristicUUID),
252
272
  data: Buffer.from(res.body.characteristicData).toString('hex'),
253
- raw: request.toString('hex') });
273
+ raw: response.toString('hex') });
254
274
  return Buffer.from(res.body.characteristicData);
255
275
  }
256
276
  catch (err) {
@@ -281,7 +301,7 @@ class DirectConnectPeripheral {
281
301
  const res = message.parseResponse(response);
282
302
  characteristic = (0, utils_1.beautifyUUID)(res.body.characteristicUUID);
283
303
  this.logEvent({ message: 'WriteCharacteristic response', path: this.getPath(), characteristic,
284
- raw: request.toString('hex') });
304
+ raw: response.toString('hex') });
285
305
  if (options === null || options === void 0 ? void 0 : options.withoutResponse) {
286
306
  resolve(Buffer.from([]));
287
307
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.3.0-beta.3",
3
+ "version": "2.3.0-beta.4",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",