I am trying to connect a windows pc to the BT121 using the "host_example" program given with BGTool-0.9.1-44 and I am having issues.
Something along the line of:
It seems most pc and cellphone don't like pairing without any passkey, so I'm trying to add the management of the passkey to the program.
This does not need to be pretty, it just need to work as it is to be used for a bandwidth test.
Currently this is what I added at the end of main.c
case dumo_evt_sm_passkey_display_id: printf("passkey display %d, %d ", pck->evt_sm_passkey_display.connection, pck->evt_sm_passkey_display.passkey); break; case dumo_evt_sm_passkey_request_id: printf("passkey request %d ", pck->evt_sm_passkey_request.connection); dumo_cmd_sm_enter_passkey(pck->evt_sm_passkey_request.connection, 0); break; case dumo_evt_sm_confirm_passkey_id: printf("passkey confirm %d, %d ", pck->evt_sm_confirm_passkey.connection, pck->evt_sm_confirm_passkey.passkey); dumo_cmd_sm_passkey_confirm(pck->evt_sm_passkey_request.connection, 1); break;
I can see the passkey request event being generated, I try to answer with an hardcoded passkey for now.
Note: windows ask me the passkey before the passkey request even is called.
What I'm I doing wrong?
Also, is there a specific way to connect on windows that I'm not aware of?
Thank you for your help.
First, realize that you cannot use a hardcoded passkey. It will not work under any circumstances. Different passkey entry/confirmation/response protocols are needed based on which MITM and I/O capabilities you configure on the module side. Have you added any MITM-enabled sm_configure command in your code?
If Windows gives you a text entry box to type in a key, then you have to catch the sm_passkey_display event on the module side and type in the same key on the Windows side.
If Windows shows you a passkey itself, then you have to catch either the sm_passkey_request event or the sm_confirm_passkey event (not both), and response accordingly with the correct entered key (sm_enter_passkey) or with confirming (sm_passkey_confirm).
Note that you will not need to handle more than one of these cases. Which one you do need to handle depends on how you have configured the I/O capabilities setting on the module.
I know that in real life scenario I cannot use an hardcoded passkey. Yet I'm trying to make the example bundled with bgtool work when a windows computer try to connect to the BT121. I think that it was a reasonable goal.
Summary of the behavior of the demo out of the box:
Without any modification, the code start the spp server on the dongle, windows(7) see the device, can pair with it but then ask for a passkey each time the com port is open, and then the connection fails. I have tried 0000 or 1234 as passkey, just in case it would work, without success. I haven't found a way to connect without entering passkey.
Then I added the 3 other case in the big switch case in the demo as described in the previous message.
The pairing can be accomplish , but there is still a request for a passkey when opening the com port on windows side. I used to enter 0000 or 000000. Afterwards, the dumo_evt_sm_passkey_request_id event is generated, to witch I answer with a 0 passkey. Then the connection fails.
As I understand it, the format for the passkey is just an integer containing the decimal number and nothing more so that if the following call is made,it would represent the passkey "1234"
I have not changed anything related to the MITM yet as I didn't know what to do. That will be the next ting ill look into tomorrow.
*Does the demo should work with a windows pc out of the box? (with a Just-Work connection? )
*Is the passkey representation for the function call described above right?
*Depending on the configuration, the device OR windows should present/generate a passkey while the other should offer a prompt to enter it?
*What happen if you handle the two events? May I keep some printf without affecting the behavior? (I don't even understand how adding a case to a switch case could change the behavior, but you seems to have pretty wild #define)
I am having the same problem. Can't bond to Windows machine using API demo.
I have tried the following command with different settings, however its not clear from documentation how this works.
Does the out of the box device come with firmware to support this or do it need to be built for this functionality?
When will we get serious feedback on this?
I am facing the same problem. During searching for a solution i came across:
The problem is the Microsoft BT stack wich does not work correctly without a passkey. I have switched to a BT dongle which uses the Widcomm BT stack and then a connection to the DKBT development board running the spp_server example without passkey was possible. Of course this is not very satisfying. It should work with Windows out of the box.
Because the above link also states that it should work as long as a passkey is used i tried to set a fixed passkey in the spp_server example. This is also not working as already explained by jrowberg.
But how to preceed now? Even if Microsoft does not comply with BT specs we need a way to use the module with out-of-the-box Windows.