Jackson-gjh opened a new pull request, #21535:
URL: https://github.com/apache/nuttx/pull/21535
## Summary
Fix raw HCI socket receive-device selection and share the Bluetooth device
index lookup between the HCI send and receive paths.
## Problem
`sockaddr_hci.hci_dev` is stored in `bluetooth_conn_s.bc_ldev` as a
zero-based
index among Bluetooth devices. The HCI send path already uses this selector,
but `bluetooth_recvmsg()` used the address-based `bluetooth_find_device()`
lookup with `bc_laddr`.
For a raw HCI socket this can return no device, so the external Bluetooth
Host
stack cannot receive Controller events. On ESP32-C6 with Apache NimBLE this
caused the Host to reset with reason 19 before advertising started.
## Fix
- Move the existing Bluetooth-only index traversal into
`bluetooth_find_device_byindex()`.
- Use the helper from both HCI send and receive paths.
- Preserve the address-based lookup for L2CAP sockets.
## Testing
Hardware and versions:
- ESP32-C6 revision v0.2
- NuttX `43f7f34b995`
- NuttX Apps `b3d9d96bf`
- Apache NimBLE `3932e99f43041f28dcf25c42a0f06e4584774dd8`
- Espressif HAL `cf95a27f2aa263d77c7a8d7f56007abfc899fc47`
- `examples/nimble_bleprph`
A/B test with all other source and configuration kept the same:
- Without this receive-path fix: `Resetting state; reason=19`; a 12-second
active scan did not find the device.
- With this fix: advertising, connection, GATT service discovery and a
Battery
Level read all succeeded.
Client output:
```text
connected=True
service=00001811-0000-1000-8000-00805f9b34fb
service=0000180f-0000-1000-8000-00805f9b34fb
service=59462f12-9543-9999-12c8-58b459a2712d
battery_level=9
```
Device output included:
```text
connection established; status=0
mtu update event; conn_handle=0 cid=4 mtu=256
disconnect; reason=531
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]