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

Windows 8.1 bonding/pairing error

Hello all, before I decided to write my own question I read the forum thoroughly. How ever no aid found to solve my problem. At first I want to make "just work" bonding(pairing) to encrypt further communication. I saw many nordic examples for this using DeviceManager+pstorage. However my RAM budget could not allow usage of this lib. I try to do this manually without saving keys in flash( at present revision). When initiate pairing from windows 8.1 the flow are next (in debug):

BLE_GAP_EVT_CONNECTED
BLE_GAP_ROLE_PERIPH (ID 3)
BLE_GAP_EVT_SEC_PARAMS_REQUEST
   Sec params from host: 
   Bond: 1
   Io_caps: 4
   kdist_central: 124
   kdist_periph: 219
   max_key_size: 16
   min_key_size: 0
   mitm: 1
   oob: 0

My peripheral answers:

 uint32_t res=sd_ble_gap_sec_params_reply(ble_evt->evt.gap_evt.conn_handle,BLE_GAP_SEC_STATUS_SUCCESS,&m_sec_params,NULL);

where m_sec_params are:

        #define SEC_PARAM_BOND                       1
        #define SEC_PARAM_MITM                        0 
        #define SEC_PARAM_IO_CAPABILITIES       BLE_GAP_IO_CAPS_NONE 
        #define SEC_PARAM_OOB                         0
        #define SEC_PARAM_MIN_KEY_SIZE           7 
        #define SEC_PARAM_MAX_KEY_SIZE          16  

 



 BLE_GAP_EVT_AUTH_STATUS
      Auth status: 0x88 , Src: Remote  
      //BLE_GAP_SEC_STATUS_UNSPECIFIED            0x88  /**< Unspecified reason. */
    Disconnect from host, reason 19 
      //BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION           0x13  
      /**< Remote User Terminated Connection. */

When initiate pairing from Android the flow are next:

BLE_GAP_EVT_CONNECTED
BLE_GAP_ROLE_PERIPH (ID: 3)
BLE_GAP_EVT_SEC_PARAMS_REQUEST
Sec params from host: 
  Bond: 1
  Io_caps: 4
  kdist_central: 231
  kdist_periph: 119
  max_key_size: 16
  min_key_size: 0
  mitm: 1
  oob: 0
BLE_GAP_EVT_CONN_SEC_UPDATE
BLE_GAP_EVT_AUTH_STATUS
Auth status: 00, Src: Local 

//Success.

Than I have a look on examples: and found that windows 8.1 paired correctly when at BLE_GAP_EVT_SEC_PARAMS_REQUEST peripheral answers:

uint32_t res=sd_ble_gap_sec_params_reply(ble_evt->evt.gap_evt.conn_handle,BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP,NULL,NULL);

Then central (windows) disconnects and reconnects. Now it is possible to work with device. The problem is that Android do not support such trick. i.e. BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP and show the pairing failure. Please help to make device bondable/pairable on both win and android devices. Or may be it would beter to show key pieces of code from DM where it made properly.

best regards.

Parents
  • @Valer_I : If you have SDK v8.x you can have a look at the ble_app_template. In that template we don't use device manager and the distributed keys can be retreived with m_keys when the bonding is finished (BLE_GAP_EVT_AUTH_STATUS event). In the ble_app_template, we don't store the key to flash, (erased when restart) but you can implement that.

    I don't think you would have any issue with Android testing with this example.

  • @Valer_I: Could you let me know what didn't work when testing with Windows 8.1 ? For debugging, you can either add a breakpoint in the assert handler to track back which error code, line number, file name cause the assertion. Or you can use UART debug, as you mentioned. You can either use simple uart library or use app_uart.

    You can have a look at ble_app_uart on how to use it.

Reply
  • @Valer_I: Could you let me know what didn't work when testing with Windows 8.1 ? For debugging, you can either add a breakpoint in the assert handler to track back which error code, line number, file name cause the assertion. Or you can use UART debug, as you mentioned. You can either use simple uart library or use app_uart.

    You can have a look at ble_app_uart on how to use it.

Children
No Data
Related