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

When do encryption keys exchange?

I have a problem with bonding with a static passkey. I have some sensors, which have a static passkey hardcoded in them. If I want to bond with them, I have to provide this passkey from my custom central app, which uses s120 and SDK 8.1.0. For the past few days I wasn't able to make a successfull bond, because I keep getting BLE_GAP_SEC_STATUS_AUTH_REQ from the sensor. I can't find much information on what to do in this case. I can bond with MCP just fine.

I compared log file from MCP and sniffer trace from my central bonding attempt and they are different in one very impotant aspect. MCP exchanges keys and encrypts the connection before trying to authenticate the link. Default behavioral of the device manage in SDK 8.1.0 is not the same. If I call dm_security_setup_req it only forces authentication without previous key exchange. This is why authentication fails. If I go into debug mode, I can see that keys are always 0. Does anyone have any suggestions about this matter? Are there any examples that mimic MCP behavioral?

Edit: added trace logs for windows phone, s120 and MCP log file, all done with the same sensor (which uses TI stack).

Windows phone pairing attempt: windows_pairing_with_adv.pcapng

S120 pairing attempt: s120_central_pairing.pcapng

MCP log file: log.txt

Android bonding attempt: android_bonding.pcapng

Parents
  • Because my question is somewhat identical to this one, I'm replying in both questions. I think I solved this problem by changing the default address type to BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE. First I initialize the SD and immediately set the address by calling this sequence after sd_initialize function:

    ble_gap_addr_t local_address; local_address.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE;

    err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_AUTO, &local_address); APP_ERROR_CHECK(err_code);

    Now I get the right responses when bonding and encrypting the link

Reply
  • Because my question is somewhat identical to this one, I'm replying in both questions. I think I solved this problem by changing the default address type to BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE. First I initialize the SD and immediately set the address by calling this sequence after sd_initialize function:

    ble_gap_addr_t local_address; local_address.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE;

    err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_AUTO, &local_address); APP_ERROR_CHECK(err_code);

    Now I get the right responses when bonding and encrypting the link

Children
Related