noble / bleno

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

It stopped advertising shortly after startAdvertising(). #382

Closed vicary closed 6 years ago

vicary commented 6 years ago

I am testing Bleno with Noble in a Raspberry Pi.

After I called bleno.startAdvertising(...); I can scan the device with an iPhone and an Android, but when I refresh the device list after initial discovery the Pi never appeared again until I reboot.

I would really like to narrow down the case, where shall I start?

sandeepmistry commented 6 years ago

@vicary I suggest you look and the debug logssudo DEBUG=* node <file>.js and hcidump/btmon captures ...

vicary commented 6 years ago

@sandeepmistry Thanks for the reply.

I added the DEBUG=* env var, could use some help in making sense out of it.

At the very least, assuming the default advertisement interval is 100ms, shall I be seeing logs starting with the following lines every 100ms?

hci set advertise enable - writing: 010a200100 +6ms
hci set advertisement parameters - writing: 0106200fa000a0000000000000000000000700 +5ms

If that's the case, the log is not generating at that interval. It only happened 4 times in 5 mins.

EDIT: Further narrowing it down, when using NOBLE_MULTI_ROLE both noble and bleno will emit an addressChange event with an identical MAC address at about 1 minute mark. There it follows some onSocketData things, and that's where it stops advertising.

vicary commented 6 years ago

This gist shows a full log along with my test script, at line 189-190 is where it stops advertising.

In the test script I tried tapping into the internal bindings' bleno._bindings.on("addressChange", ...) event, but, interestingly, it generated exactly one more tick of advertisement in response just to fail again.

There is a roughly 60s interval between each addressChange event.

I am testing with a Pi Zero, Raspbian Lite.

vicary commented 6 years ago

I don't have driver knowledges to further narrow down anything, could really use some help here.