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
310 stars 45 forks source link

How to get descriptors of characteristic #59

Closed lesleyxyz closed 1 year ago

lesleyxyz commented 1 year ago

I'm transitioning from @abandonware/noble to node-ble. I have the following code in noble to enable notifications:

let descriptors = characteristic.discoverDescriptorsAsync()
let descriptor = descriptors[0]

descriptor.once('valueWrite', this.sendConnectSequence.bind(this));
characteristic.on('data', this.onReceive.bind(this))
await descriptor.writeValueAsync(Buffer.from([0x01, 0x00]))

How do I achieve this with node-ble? I currently have the characteristic and tried this:

await this.mepResponseChar.on('valuechanged', this.onMepResponse.bind(this))
await this.mepResponseChar.startNotifications()

but this isn't triggering any of the callbacks. I'm assuming this because I need access to the descriptors?

lesleyxyz commented 1 year ago

Nevermind, was an issue with specifically my code base