Merge pull request #158 from cafjs/master

Fix for #157 (and possibly #131)
This commit is contained in:
Nathan Kellenicki 2024-04-25 17:05:54 -07:00 committed by GitHub
commit 505bbdc648
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -130,9 +130,9 @@ export class PoweredUP extends EventEmitter {
private _determineLPF2HubType (device: IBLEAbstraction): Promise<Consts.HubType> {
return new Promise((resolve) => {
return new Promise(async (resolve) => {
let buf: Buffer = Buffer.alloc(0);
device.subscribeToCharacteristic(Consts.BLECharacteristic.LPF2_ALL, (data: Buffer) => {
await device.subscribeToCharacteristic(Consts.BLECharacteristic.LPF2_ALL, (data: Buffer) => {
buf = Buffer.concat([buf, data]);
while (buf[0] <= buf.length) {
const len = buf[0];

View File

@ -85,7 +85,7 @@ export class WebBLEDevice extends EventEmitter implements IBLEAbstraction {
}
public subscribeToCharacteristic (uuid: string, callback: (data: Buffer) => void) {
public subscribeToCharacteristic (uuid: string, callback: (data: Buffer) => void): Promise<any> {
if (this._listeners[uuid]) {
this._characteristics[uuid].removeEventListener("characteristicvaluechanged", this._listeners[uuid]);
}
@ -108,7 +108,7 @@ export class WebBLEDevice extends EventEmitter implements IBLEAbstraction {
callback(data);
}
this._characteristics[uuid].startNotifications();
return this._characteristics[uuid].startNotifications();
}