noble / bleno

A Node.js module for implementing BLE (Bluetooth Low Energy) peripherals
MIT License
2.12k stars 447 forks source link

startAdvertising and startAdvertisingIBeacon, Command Dissallowed #393

Open lastmjs opened 6 years ago

lastmjs commented 6 years ago

Hi there,

I am advertising both iBeacons and plain advertisements. I have an interval of 100 milliseconds setup, where I switch between each type of advertisement. It works very well most of the time. Every once in a while, I will get one of the following errors when I try to start advertising one of the advertisement types:

bleno.startAdvertisingIBeacon Error: Command Disallowed
    at Gap.onHciLeAdvertiseEnableSet (/home/pi/development/portal-blue/door-device/node_modules/bleno/lib/hci-socket/gap.js:201:15)
    at emitOne (events.js:115:13)
    at Hci.emit (events.js:210:7)
    at Hci.processCmdCompleteEvent (/home/pi/development/portal-blue/door-device/node_modules/bleno/lib/hci-socket/hci.js:669:10)
    at Hci.onSocketData (/home/pi/development/portal-blue/door-device/node_modules/bleno/lib/hci-socket/hci.js:540:12)
    at emitOne (events.js:115:13)
    at BluetoothHciSocket.emit (events.js:210:7)

or

bleno.startAdvertising Error: Command Disallowed
    at Gap.onHciLeAdvertiseEnableSet (/home/pi/development/portal-blue/door-device/node_modules/bleno/lib/hci-socket/gap.js:201:15)
    at emitOne (events.js:115:13)
    at Hci.emit (events.js:210:7)
    at Hci.processCmdCompleteEvent (/home/pi/development/portal-blue/door-device/node_modules/bleno/lib/hci-socket/hci.js:669:10)
    at Hci.onSocketData (/home/pi/development/portal-blue/door-device/node_modules/bleno/lib/hci-socket/hci.js:540:12)
    at emitOne (events.js:115:13)
    at BluetoothHciSocket.emit (events.js:210:7)

I understand that you cannot advertise both at the same time, which is why I always call bleno.stopAdvertising before starting to advertise the other advertisement. I start up the advertising in the callback of the bleno.stopAdvertising call, which I would think waits until the system is ready for any other type of advertisement to begin, but that doesn't seem to be the case.

Usually the errors happen once or twice and my interval then continues to work properly. At least once though, the errors get into some kind of infinite loop and don't stop occurring until I completely cycle the bluetooth interface.

icarus31 commented 2 years ago

@lastmjs , i know it's been a while, but do you remember if you figure out something?

rzr commented 1 year ago

May I suggest to try @abandonware fork and report at: Relate-to: https://github.com/abandonware/bleno/issues/17