chrvadala / node-ble

Bluetooth Low Energy (BLE) library written with pure Node.js (no bindings) - baked by Bluez via DBus
https://www.npmjs.com/package/node-ble
MIT License
315 stars 46 forks source link

Event leaking. Any active notifications not removed prior to device disconnect leak. #12

Open steves2j opened 4 years ago

steves2j commented 4 years ago

When subscribing to a notify attribute on a BLE device with startNotifications() the created listener is not removed when a device.disconnect() is called. This will cause the subsequent connect and subscription to have corrupt data in the valuedchanged event.

e.g. ` const readNotify = await service.getCharacteristic('aUUid');

await readNotify .startNotifications();

readNotify.on('valuechanged',buffer=>{ buffer has some data});

await device.disconnect();

await device.connect();

await readNotify .startNotifications();

readNotify.on('valuechanged',buffer=>{ buffer has previous data and some new data});

`