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

s130v2 ble_app_hrs does not bond second time onwards

Hi, I am using s130v2 and running the example code from: nRF5_SDK_12.3.0_d7731ad\examples\ble_peripheral\ble_app_hrs\pca10028\s130\arm4

This is the only modification I have made: bool erase_bonds=true; (under main) I have attached the main.c also herewith. I have used Samsung Galaxy S6 phone Android version: 5.1.1 To reproduce the scenario, please follow the following sequence:

  1. Erase the chip using nRF Go Studio.

  2. Flash s130v2 .hex file via nRF Go Studio.

  3. Run the example code under nRF5_SDK_12.3.0_d7731ad\examples\ble_peripheral\ble_app_hrs\pca10028\s130\arm4 (with the attached main.c).

  4. Use nRFConnect app to scan and connect to the device - Then click bond in the nRFConnect app. The device would bond successfully. In the app, click "Delete Bond" - the app would disconnect with the device successfully.

  5. Power cycle the board. Repeat step 4. This time, when "Bond" is clicked in the nRFConnect app, the device would disconnect automatically.

    main.c

Update: The reason for disconnection is under BLE_GAP_EVT_AUTH_STATUS (in security_dispatcher.c), auth_status_process has p_gap_evt->params.auth_status.auth_status to be 0x85. Hence, auth_status_failure_process(p_gap_evt); is called. Not sure how to solve this..

Parents
  • Found the issue. Eventhough I was sending erase_bonds=true in the main, that was changed to zero by buttons_leds_init in main.c. So, the code works now with this as main():

    int main(void)

    {

    uint32_t err_code;
    bool     erase_bonds=true;
    
    // Initialize.
    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);
    
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    	erase_bonds=true;
    peer_manager_init(erase_bonds);
    if (erase_bonds == true)
    {
        NRF_LOG_INFO("Bonds erased!\r\n");
    }
    gap_params_init();
    advertising_init();
    gatt_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();
    
    // Start execution.
    NRF_LOG_INFO("Heart Rate Sensor Start!\r\n");
    application_timers_start();
    advertising_start();
    
    // Enter main loop.
    for (;;)
    {
        if (NRF_LOG_PROCESS() == false)
        {
            power_manage();
        }
    }
    

    }

Reply
  • Found the issue. Eventhough I was sending erase_bonds=true in the main, that was changed to zero by buttons_leds_init in main.c. So, the code works now with this as main():

    int main(void)

    {

    uint32_t err_code;
    bool     erase_bonds=true;
    
    // Initialize.
    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);
    
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    	erase_bonds=true;
    peer_manager_init(erase_bonds);
    if (erase_bonds == true)
    {
        NRF_LOG_INFO("Bonds erased!\r\n");
    }
    gap_params_init();
    advertising_init();
    gatt_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();
    
    // Start execution.
    NRF_LOG_INFO("Heart Rate Sensor Start!\r\n");
    application_timers_start();
    advertising_start();
    
    // Enter main loop.
    for (;;)
    {
        if (NRF_LOG_PROCESS() == false)
        {
            power_manage();
        }
    }
    

    }

Children
No Data
Related