incyclist-devices 3.0.29 → 3.0.30

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.
@@ -169,12 +169,12 @@ class BlePeripheral {
169
169
  return res;
170
170
  }
171
171
  checkAnnouncedServices(discovered) {
172
- const announced = this.getAnnouncedServices().map(x => (0, utils_js_2.beautifyUUID)(x));
172
+ const announced = this.getAnnouncedServices();
173
173
  const toBeChecked = discovered.map(x => (0, utils_js_2.beautifyUUID)(x));
174
174
  const cntAnnounced = announced.length;
175
175
  let cntVerified = 0;
176
176
  for (const s of announced) {
177
- if (toBeChecked.includes(s))
177
+ if (toBeChecked.some(d => (0, utils_js_2.isSameServiceFamily)(s, d)))
178
178
  cntVerified++;
179
179
  }
180
180
  return cntAnnounced === cntVerified;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bit = exports.propertyFromVal = exports.propertyVal = exports.fullUUID = exports.beautifyUUID = exports.parseUUID = void 0;
3
+ exports.bit = exports.propertyFromVal = exports.propertyVal = exports.fullUUID = exports.isSameServiceFamily = exports.beautifyUUID = exports.parseUUID = void 0;
4
4
  exports.mapLegacyProfile = mapLegacyProfile;
5
5
  exports.uuid = uuid;
6
6
  exports.matches = matches;
@@ -106,6 +106,17 @@ const beautifyUUID = (str, withX = false) => {
106
106
  return parts.join('-');
107
107
  };
108
108
  exports.beautifyUUID = beautifyUUID;
109
+ const isSameServiceFamily = (uuid1, uuid2) => {
110
+ const a = (0, exports.beautifyUUID)(uuid1);
111
+ const b = (0, exports.beautifyUUID)(uuid2);
112
+ if (a === b)
113
+ return true;
114
+ const isCustom128 = (u) => u.length === 36;
115
+ if (isCustom128(a) && isCustom128(b))
116
+ return a.substring(9) === b.substring(9);
117
+ return false;
118
+ };
119
+ exports.isSameServiceFamily = isSameServiceFamily;
109
120
  const fullUUID = (str) => {
110
121
  if (!str)
111
122
  return str;
@@ -1,5 +1,5 @@
1
1
  import { sleep } from "../../utils/utils.js";
2
- import { beautifyUUID, fullUUID, matches } from "../utils.js";
2
+ import { beautifyUUID, fullUUID, isSameServiceFamily, matches } from "../utils.js";
3
3
  import { BleInterface } from "./interface.js";
4
4
  export class BlePeripheral {
5
5
  announcement;
@@ -166,12 +166,12 @@ export class BlePeripheral {
166
166
  return res;
167
167
  }
168
168
  checkAnnouncedServices(discovered) {
169
- const announced = this.getAnnouncedServices().map(x => beautifyUUID(x));
169
+ const announced = this.getAnnouncedServices();
170
170
  const toBeChecked = discovered.map(x => beautifyUUID(x));
171
171
  const cntAnnounced = announced.length;
172
172
  let cntVerified = 0;
173
173
  for (const s of announced) {
174
- if (toBeChecked.includes(s))
174
+ if (toBeChecked.some(d => isSameServiceFamily(s, d)))
175
175
  cntVerified++;
176
176
  }
177
177
  return cntAnnounced === cntVerified;
@@ -96,6 +96,16 @@ export const beautifyUUID = (str, withX = false) => {
96
96
  }
97
97
  return parts.join('-');
98
98
  };
99
+ export const isSameServiceFamily = (uuid1, uuid2) => {
100
+ const a = beautifyUUID(uuid1);
101
+ const b = beautifyUUID(uuid2);
102
+ if (a === b)
103
+ return true;
104
+ const isCustom128 = (u) => u.length === 36;
105
+ if (isCustom128(a) && isCustom128(b))
106
+ return a.substring(9) === b.substring(9);
107
+ return false;
108
+ };
99
109
  export const fullUUID = (str) => {
100
110
  if (!str)
101
111
  return str;
@@ -16,6 +16,7 @@ export declare function getPeripheralInfo(p: BleRawPeripheral): {
16
16
  export declare function getCharachteristicsInfo(c: BleCharacteristic): string;
17
17
  export declare const parseUUID: (str: string) => string;
18
18
  export declare const beautifyUUID: (str: string, withX?: boolean) => string;
19
+ export declare const isSameServiceFamily: (uuid1: string, uuid2: string) => boolean;
19
20
  export declare const fullUUID: (str: string) => string;
20
21
  export declare const propertyVal: (properties: BleProperty[]) => number;
21
22
  export declare const propertyFromVal: (val: number) => BleProperty[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "3.0.29",
3
+ "version": "3.0.30",
4
4
  "scripts": {
5
5
  "lint": "eslint . --ext .ts",
6
6
  "build": "npm run build:esm && npm run build:cjs",