Skip to content

Commit 313d3c0

Browse files
committed
fix: ensure we always work with lowercase UUIDs so that callbacks always work correctly
1 parent 46ab924 commit 313d3c0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/ble/index.common.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ export function bluetoothEnabled(target: Object, propertyKey: string, descriptor
5454
// BT assigned-numbers: https://www.bluetooth.com/specifications/assigned-numbers/
5555
const patternBtAssignedNumbers = /0000(.{4})-0000-1000-8000-00805f9b34fb/i;
5656
export function shortenUuidIfAssignedNumber(uuid: string) {
57-
const matcher = uuid.toLowerCase().match(patternBtAssignedNumbers);
58-
return (matcher && matcher.length > 0 ? matcher[1] : uuid);
57+
const lUUID = uuid.toLowerCase();
58+
const matcher = lUUID.match(patternBtAssignedNumbers);
59+
return matcher && matcher.length > 0 ? matcher[1] : lUUID;
5960
}
6061

6162
export function prepareArgs(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) {
@@ -70,7 +71,7 @@ export function prepareArgs(target: Object, propertyKey: string, descriptor: Typ
7071
const value = paramsToCheck[k];
7172
if (value) {
7273
if (Array.isArray(value)) {
73-
paramsToCheck[k] = paramsToCheck[k].map(v => shortenUuidIfAssignedNumber(v));
74+
paramsToCheck[k] = paramsToCheck[k].map((v) => shortenUuidIfAssignedNumber(v));
7475
} else {
7576
paramsToCheck[k] = shortenUuidIfAssignedNumber(paramsToCheck[k] ?? '');
7677
}
@@ -532,7 +533,7 @@ export interface DiscoverCharacteristicsOptions extends DiscoverOptions {
532533
}
533534

534535
// tslint:disable-next-line:no-empty-interface
535-
export interface StopNotifyingOptions extends CRUDOptions { }
536+
export interface StopNotifyingOptions extends CRUDOptions {}
536537

537538
export interface StartNotifyingOptions extends CRUDOptions {
538539
onNotify: (data: ReadResult) => void;

0 commit comments

Comments
 (0)