-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connection between android-netsim and Zephyr BT Stack work arounds #220
Comments
Nice demo! |
Most of the errors I encountered where related to the controller from android not recognizing the commands. Did not check logcat though. About the command I get this error
Also I wanted to ask if its possible to make the tcp server send packets without delay. I noticed that sometimes several hci packets are packed in the same tcp payload. The Zephyr TCP client I wrote is simple and cannot decode multiple hci packets in the same payload. Update: I found the part of the spec to decode HCI packets and modified it to parse correctly if multiple hci packets are in the same tcp payload. After decoding missing hci packets due to this issue, the following commands are the only ones that have to be filtered:
|
I'll check with the netsim team if they can add support for those HCI commands. In the meantime, filtering them with the HCI bridge seems like a good workaround. |
I figured a workaround to not have to filter the hci commands. Flow control can be disabled in the zephyr BT stack by setting the KCONFIG option |
Based on more tests the LE Extended commands are needed (when using the bumble virtual controller not android-netsim). According to this comment #229 (comment) this will be fixed once this branch is merged https://github.com/google/bumble/tree/gbg/controller-extended-advertising |
As a follow upt to the issues I posted
#215
#217
I have managed to connect the Zephyr Bluetooth stack to the Android emulator with the bumble hci-bridge 👍
I open this issue to discuss the workarounds to make it work.
After some trial and error I figured out that the following commands from host to controller (zephyr tcp-client to android-netsim) should be filtered and not sent to the android-netsim.
An example of how to make it work
Make sure your Zephyr OS is updated to at least this commit
zephyrproject-rtos/zephyr@33c922a
Compile the BLE Hearbeat sensor sample from zephyr located here .
For any other zephyr project be sure to set these configurations as follows
CONFIG_BT_HCI_ACL_FLOW_CONTROL=n
CONFIG_BT_SMP_SC_PAIR_ONLY=n
Run the android emulator.
emulator -avd Pixel_7_API_34 -packet-streamer-endpoint default
Note: Only tested with API 34, other APIs <34 gave me some problems
Create the hci-bridge with bumble and the filters for hci commands I mentioned above
bumble-hci-bridge tcp-server:_:9000 android-netsim 0x03:0x0031,0x08:0x013,0x08:0x032,0x08:0x016,0x03:0x035
update: If in zephyr you set
CONFIG_BT_HCI_ACL_FLOW_CONTROL=n
you do not need to filter the hci commands. I.e., you can runbumble-hci-bridge tcp-server:_:9000 android-netsim
Run the zephyr binary
zephyr.exe --bt-dev=127.0.0.1:9000
Note: This instruction assume that zephyr binary has access to localhost. In case Android emulator and bumble are installed in Windows and using WSL to compile and execute the zephyr binary, then you need to get the proxy IP for localhost by running
cat /etc/resolv.conf
and obtaining the nameserver ip address.And here a small video of the Proof of concept. Note I have not tested every option from the BT Zephyr stack or the APIs so this is still experimental.
Upper left screen is the HCI traffice between zephyr bluetooth stack (host) and the android-netsim (Controller). Lower window is the zephyr binary running the peripheral_hr example in the Windows Subsystem for Linux. And on the right is the Android emulator running with Android API 34 and the NRF Connect App to test the GATT notification of the peripheral_hr sample.
clideo_editor_bc0051d87a63439b9a0a10a32635c453.mp4
The text was updated successfully, but these errors were encountered: