Follow up on: github.com/.../50438
Describe the bug
There is a specific case in which the Bluetooth stack seems to become stuck in a state where it will not accept/initiate any new connections. The following warning is printed in the console:<wrn> bt_hci_core: opcode 0x2005 status 0x0c
I'm using an nRF52840 and NCS 2.1. The only way to get out of this state seems to be resetting the device. Below the steps I found which reproduces this state consistently using an example application.
To Reproduce
- Grab two nRF52840 devkits and an iPhone that has nRFConnect for mobile installed.
- Flash the "central_and_peripheral_hr" example on one devkit. Flash the "peripheral_hr" example on the other devkit.
- Turn on the central_and_peripheral_hr devkit and connect to its console.
- Get your phone and connect to "Nordic_HR". Make sure that the connection stays on for the following steps.
- Turn on the "peripheral_hr" devkit. Make sure that it connects to the "central_and_peripheral_hr" devkit.
- Once the connection has been established between the two devkits, turn off the "peripheral_hr" (important)
- Close the connection with the phone through nRF Connect.
- The Bluetooth stack is now in a state where it wont accept new connections (incoming/outgoing). Observe the console output in the section below.
Impact
This is not limited to the heartrate example. We initially discovered this bug in our own application and reproduced it using a sample so it would be easier to fix. Our users have to restart their gateways when configuring them to make sure that they still work properly. This feels like a pretty severe bug.
Logs and console output
*** Booting Zephyr OS build v3.1.99-ncs1-rc1 ***
Starting Bluetooth Central and Peripheral Heart Rate relay example
I: 8 Sectors of 4096 bytes
I: alloc wra: 1, fb8
I: data wra: 1, 164
I: SoftDevice Controller build revision:
I: b3 30 26 8d c5 f3 4a bd |.0&...J.
I: f4 21 f5 83 2d de 9c f2 |.!..-...
I: 5e da 68 ec |^.h.
I: No ID address. App must call settings_load()
Scanning started
Advertising started
W: opcode 0x200a status 0x09
Connected: 48:79:82:C7:36:F1 (random). <--- MOBILE PHONE
W: Ignoring data for unknown channel ID 0x003a
Filters matched. Address: F1:CE:C4:C1:92:BA (random) connectable: 1
Connected: F1:CE:C4:C1:92:BA (random) <--- HR PERIPHERAL
Security failed: F1:CE:C4:C1:92:BA (random) level 1 err 2
The discovery procedure succeeded
Heart Rate Sensor body location: Chest
Heart Rate Measurement notification received:
Heart Rate Measurement Value Format: 8 - bit
Sensor Contact detected: 1
Sensor Contact supported: 1
Energy Expended present: 0
RR-Intervals present: 0
Heart Rate Measurement Value: 92 bpm
Disconnected: F1:CE:C4:C1:92:BA (random) (reason 8) <--- HR PERIPHERAL
Disconnected: 48:79:82:C7:36:F1 (random) (reason 19). <--- MOBILE PHONE
Filters matched. Address: F1:CE:C4:C1:92:BA (random) connectable: 1 <--- HR PERIPHERAL
W: opcode 0x2005 status 0x0c
Connecting failed
Environment (please complete the following information):
- OS: MacOS
- Zephyr OS build v3.1.99-ncs1-rc1