This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

bounding with pc-ble-driver

I'm using pc-ble-driver on Windows7 (from master as I'm using a s130v2 programmed dongle) to connect a BLE device (developer.nordicsemi.com/.../a00053.html).

This device supports bounding and I could find no example explaining how this should be handled using the pc-ble-driver API.

When I connect the "Nordic_Mouse" device, I receive BLE_GAP_EVT_CONNECTED event and BLE_GAP_EVT_DISCONNECTED right after it (with reason set to 0x3E, BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED).

How should I bound the device? What pc-ble-driver function should I use to bound the device as I do in the "Master Control Panel" when I click "Bound"?


Edit: With metch and Hung Bui help, I started trying to call sd_ble_gap_authenticate, like this:

ble_gap_sec_params_t params;
params.bond = (pairing != BTLE::Bound); // 1 to bond, 0 to pair?
params.mitm = 0;
params.lesc = 0;
params.keypress = 0;
params.io_caps = 1;
params.oob = 0;
params.min_key_size = 8;
params.max_key_size = 15;
params.kdist_own.enc = 1;
params.kdist_own.id = 1;
params.kdist_own.link = 1;
params.kdist_own.sign = 1;
params.kdist_peer.enc = 1;
params.kdist_peer.id = 1;
params.kdist_peer.link = 1;
params.kdist_peer.sign = 1;

uint32_t err_code = sd_ble_gap_authenticate(adapter, connectionHandle, &params );

However, this fails with code 6. Is there no working C-based example able to connect Dev kit programmed with "Nordic Mouse " example?

  • @metch: See edited question, I'm having a hard time finding the appropriate parameters for sd_ble_gap_authenticate (and it will likely be the same later when I'll have to call sd_ble_gap_sec_params_reply). Could you and/or link me to a working example? I'm surprised there is no example establishing connection with "Nordic Mouse" as there is one for "Nordic HRM".

  • @HungBui: See edited question, I'm having a hard time finding the appropriate parameters for sd_ble_gap_authenticate (and it will likely be the same later when I'll have to call sd_ble_gap_sec_params_reply). Could you and/or link me to a working example? I'm surprised there is no example establishing connection with "Nordic Mouse" as there is one for "Nordic HRM".

  • @jpo: Unfortunately we don't have an example. We do have example for central device which handle bonding but it uses devicemanager/peermanager. You may need to look into those example to figure out. In addition, I just checked with the developer, if you are using the pc-ble-driver v0.5 downloaded from our website. Bonding may not work. We had some issue with that.

    You may need to use the one on our github. You have two option, either you compile this to get the dll, or you use this and get the dll precompiled by callling "pip install pc-ble-driver-py"

    I would suggest you test and make sure things work by directly use S130/S132 as the central(without the driver, you write code on the nRF5 chip) so you know how bonding is handled, after that you can move to the driver.

  • @HangBui: Thanks for the answer. It would be really great if you could consider adding an example for the coming release. This bonding process does not seem to be very obvious and it would really help to have a working example to adapt. I'm already using the driver from github (as I use s130v2). I'll probably try to move to the latest version and try again. Could you provide me a link to the example doing bonding as the central (firmware team members are on vacation....I'm alone to try to work this out ;-)

  • @HangBui: By the way the example should also cover many other questions I'll have next (How to make keys persistent between two sessions? How to know if a device is already bonded upon search process? How to clear all bonding keys on the driver side?...)

Related