robotastic / ble-ancs

A NodeJS library for Apple Notification Center Service over BLE
MIT License
80 stars 15 forks source link

Encrypt change called before Accept #12

Open PaulBGD opened 7 years ago

PaulBGD commented 7 years ago

Here's what it looks like in console:

~/Documents/Coding/ble-ancs master 
❯ sudo node examples/test.js 
on -> stateChange: poweredOn
on -> advertisingStart: success
able encryptChange!!!
/home/paul/Documents/Coding/ble-ancs/index.js:45
  this._peripheral.findServiceAndCharacteristics(SERVICE_UUID, [], function(error, services, characteristics) {
                  ^

TypeError: Cannot read property 'findServiceAndCharacteristics' of undefined
    at BleAncs.discoverServicesAndCharacteristics (/home/paul/Documents/Coding/ble-ancs/index.js:45:19)
    at BleAncs.onEncryptChange (/home/paul/Documents/Coding/ble-ancs/index.js:233:12)
    at emitNone (events.js:86:13)
    at Able.emit (events.js:185:7)
    at Able.onEncryptChange (/home/paul/Documents/Coding/ble-ancs/lib/able.js:90:10)
    at emitNone (events.js:86:13)
    at AbleBindings.emit (events.js:185:7)
    at AbleBindings.onEncryptChange (/home/paul/Documents/Coding/ble-ancs/lib/hci-socket/bindings.js:370:10)
    at emitTwo (events.js:106:13)
    at Hci.emit (events.js:191:7)

this._peripheral isn't set because the accept event hasn't been called yet.

jake-b commented 7 years ago

+1 I'm experiencing this issue as well. I've been poking around the code but I have yet to figure it out.

Side note, I'm using a Raspberry Pi Zero, which isn't listed as a supported device for noble so that might be my issue.

PaulBGD commented 7 years ago

Same issue on Ubuntu 17.04 with a supported adapter, so it looks like a common issue.