I get the same for active:true and active:false (except for RSSI, of course)
The usual fix for this would be a long timeout, but it seems you're already doing that. My guess would be that the device is advertising its name in a scan response packet (only available with active:true rather than in the main packet).
According to the sensor documentation the local device name is included in the regular advertising packet, but the manufacturer-specific data is included in the scan response (active scan).
The device is designed to live for many months on battery, so I suspect it sleeps a lot and minimizes transmissions. nRF Connect says the advertising time is 7ms, but I can see 5 to 10s between packets from the device. So I am not surprised that Espruino misses the device occasionally ... it's not a problem, I can just re-scan.
I guess what might be happening is: the BLE device you connect to advertises very rarely (1 sec or less) and only speeds up when it gets asked to provide a scan response in an active scan.
Sounds plausible.
That's really strange. The 2v04 firmware is really very reliable with Bluetooth and I can't remember the last time I crashed it while connecting to anything. You mentioned a Serial connection earlier - if this happens again please can you try while connected on Serial and see if any errors get reported.
Could the cause of the closed connection also be on the Mac OS side (e.g. the Mac Espruino IDE or the Mac OS Bluetooth support)? I will try and capture a reproducible situation for this disconnect and let you know.
Am I right in thinking you're in Germany? If this continues to be an issue is it possible that you could lend me one of those devices to try out?
Yes. I only have one loaner device from the company, but it may be possible to get another one for testing.
Great, thanks. I will try that out tomorrow, I hope.
It still doesn't explain the crashes you were seeing though as mine just failed with ERROR Connection Timeout each time.
I tried many different permutations over the last few days so I am not sure about the exact circumstances under which this happened. Will try and reproduce.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi Gordon,
Thanks for the reply. Some answers to your questions:
This is what I get when I print(device) right after NRF.requestDevice():
I get the same for active:true and active:false (except for RSSI, of course)
According to the sensor documentation the local device name is included in the regular advertising packet, but the manufacturer-specific data is included in the scan response (active scan).
The device is designed to live for many months on battery, so I suspect it sleeps a lot and minimizes transmissions. nRF Connect says the advertising time is 7ms, but I can see 5 to 10s between packets from the device. So I am not surprised that Espruino misses the device occasionally ... it's not a problem, I can just re-scan.
Sounds plausible.
Could the cause of the closed connection also be on the Mac OS side (e.g. the Mac Espruino IDE or the Mac OS Bluetooth support)? I will try and capture a reproducible situation for this disconnect and let you know.
Yes. I only have one loaner device from the company, but it may be possible to get another one for testing.
Great, thanks. I will try that out tomorrow, I hope.
I tried many different permutations over the last few days so I am not sure about the exact circumstances under which this happened. Will try and reproduce.
Thanks again,
-- Terrence