Quantcast
Viewing all articles
Browse latest Browse all 4895

C/C++ • RPI Pico W as a bluetooth HOG keyboard can't pair with a hardcoded passkey (btstack)

Hello, I've been struggling with this for a couple days.

Using the Pico C SDK btstack (bluetooth stack), I am trying make my Pico W into a simplified virtual bluetooth keyboard for my phone (or another device) with just two buttons. At this point I can't achieve the pairing as I want it. I want to hardcode a passcode into my Pico and from my phone to enter that hardcoded passkey when requested.

I managed to achieve that type of pairing using the hog_MOUSE_demo example with:

Code:

sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_ONLY);sm_set_authentication_requirements(SM_AUTHREQ_MITM_PROTECTION | SM_AUTHREQ_BONDING);sm_use_fixed_passkey_in_display_role(MY_HARDCODED_PASSKEY);
However when I try to use the same SM-config with the hog_KEYBOARD_demo example, my phone, when I try to pair with my Pico, just flashes random 6-digits numbers on the screen and connection fails. For some reason, my phone thinks that I want the pairing mode where the passcode should be entered on my Pico, whereas I want to enter the passkey on my phone (the value that's hardcoded in my Pico).

I am also able to pair without the passcode like this:

Code:

sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);sm_set_authentication_requirements(SM_AUTHREQ_MITM_PROTECTION);
but I do want to use the passcode for more security.

I tried all values: IO_CAPABILITY_DISPLAY_ONLY, IO_CAPABILITY_DISPLAY_YES_NO, IO_CAPABILITY_KEYBOARD_ONLY, IO_CAPABILITY_NO_INPUT_NO_OUTPUT, IO_CAPABILITY_KEYBOARD_DISPLAY with no success.

I am starting to suspect that the issue is that I declare my device as keyboard and the phone (bluetooth host?) assumes that at least I should be able to enter the code from it, however it won't work in my case, because I won't have enough buttons to enter a random code displayed on the phone on my Pico given that it'll have only two buttons.

Any advice is appreciated, thanks!

Statistics: Posted by sd1074 — Fri Jan 10, 2025 12:24 am



Viewing all articles
Browse latest Browse all 4895

Trending Articles