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
Weird connection/disconnection behaviour #433
Comments
Hi. BTstack stores the bonding information on Linux systems in /tmp, which gets deleted on a power cycle. |
Hi, |
if you want to connect in a BTstack app running on the Raspi to the Windows PC, you need to specify the Bluetooth Address (BD_ADDR) of the PC in the hid_device_connect call. Also, please have a look at /tmp/hci_dump.pklg with Wireshark. It is often helpful to just follow the HCI Commands and check the responses. |
That is what I would have expected, but how can I get the host address? My guess would be to read it from some packet of some type during the connection procedure, save it in a file, and then try to reconnect to previously seen hosts until one responds. |
You can get it during connection from HID_SUBEVENT_CONNECTION_OPENED with hid_subevent_connection_opened_get_bd_addr. For a first test, you can write it down and hard-code it. In practice, you could store the address in BTstack's persistent store via btstack_tlv.h. |
I managed to get the server address from the connection_openened event, and it corresponds to the one found in the hci_dump. HCI dump can be found here: Any suggestions? |
BTstack is not thread-safe. You can use BTstack's timer sources, see led_counter.c, to trigger periodic action. |
I implemented it like in the led_counter example but still not working. hci dump log here: https://www.dropbox.com/s/2sdkx0hdcq2gszr/hci_dump_heartbeat.pklg?dl=0 As expected, after 10s I see the connection attempt and after another 15s it prints "Connection failed, status 0x4" |
Looks good. if you get statux 0x04, that's a page timeout. Usually, the BD_ADDR is not correct or the device is not in range. Please double check the BD_ADDR. Your code tries to connected to 08:78:A7:B6:08:78. |
OK, sorry to have bothered you! Thanks a lot for your help. |
Glad you got it working |
Perhaps one last question. Currently the heartbeat calls the connect and resets itself. Is there a way to wait until the connection attempt fails before starting the next countdown? |
well. what about setting the timer on the connection failure? |
Ah yes, event HID_SUBEVENT_CONNECTION_OPENED fires also when it fails. Thanks. |
I have a raspberry pi zero acting as HID joystick using a program running the btstack (modified HID mouse example), and a windows 10 computer that the pi has to connect to.
I start the program on the pi, btstack goes online, and the computer can find the HID device and connect to it without trouble. The pi is correctly seen as a joystick, and it sends correct HID reports to the computer.
Eventually I kill the program on the pi, but windows 10 still shows the HID device as connected. Even when pi is completely off, cut from the power supply, windows still thinks it is connected. It even appears in the list of USB joysticks, although it does not show any sign of life.
When I start the pi and the program again, it shows the message that btstack is online, but it does not connect to the computer. In order to connect it again, I have to manually disconnect the device from the windows bluetooth control panel, then search for it again, at which point it connects and works as expected.
I would have expected windows to realize the HID joystick was disconnected but paired, and automatically reconnect when the btstack program starts on the pi.
Did I miss something or did something wrong?
Thanks for your help.
The text was updated successfully, but these errors were encountered: