Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #157 (and possibly #131) #158

Merged
merged 3 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/poweredup-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions src/webbleabstraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand All @@ -108,7 +108,7 @@ export class WebBLEDevice extends EventEmitter implements IBLEAbstraction {
callback(data);
}

this._characteristics[uuid].startNotifications();
return this._characteristics[uuid].startNotifications();
}


Expand Down