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.

  • @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.

  • Thank you for the responce! the ble_app_template it's really nice project for my application. However it doesn't work with windows 8.1. I have just compiled it as is and downloaded to the chip.:( I plan to add USART functionality to it to make some debug and investigate the issue.

  • @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.

  • I add BP to case:

    case BLE_GAP_EVT_AUTH_STATUS:
        m_auth_status = p_ble_evt->evt.gap_evt.params.auth_status;
    					break;
    

    and I caught:

    m_auth_status: 
     auth_status 0x88
     error_src 0x01
     bonded 0x00
    

    The same result I've got previously before asking the question.

    Following your advice, I tried to set BP to assert handler, is it app_error_handler(DEAD_BEEF, line_num, p_file_name); for this project? I couldn't set the breakpoint ot this line, debugger shows icon on this line like (!) and it seems that this code does not execute. Could you please point me in to more details how to debug with assert handler.

  • @Valer_l: It's pretty strange to see auth_status 0x88 which mean BLE_GAP_SEC_STATUS_UNSPECIFIED.

    Could you track and send me a sniffer trace ? It would help a lot. Do you have the same issue when testing with other examples that use the device manager ?

    You should set the break point in the content of the app_error_handler() function, It's defined in the app_error.c file. You should add "DEBUG" in the compiler flag so that it won't reset when there is an assert.

Related