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

Keyboard example got reset after disconnect

Hi there,

When i disconnect the keyboard, the nrf51822 will restart advertising in directed mode.

And then on_adv_evt() will receive BLE_ADV_EVT_PEER_ADDR_REQUEST event to getting a peer's device address.

But dm_peer_addr_get() return an error cause nrf51822 reset.

Could you help me fix it?

Here is my test environment:

HW: nRF51-Dongle

SW: nRF51_SDK_8.0.0

Connect device: Nexus 5, iPhone 6

Thanks.

Parents
  • In the unaltered keyboard example, a failed attempt to fetch the peer address is followed by a APP_ERROR_CHECK(err_code); This will assert on any error. Have you tried changing it so that a failed attempt to retrieve the peer address will just ignore the reply instead of asserting?

                err_code = dm_peer_addr_get(&m_bonded_peer_handle, &peer_address);
                if(err_code == NRF_SUCCESS)
                {
                    err_code = ble_advertising_peer_addr_reply(&peer_address);
                    APP_ERROR_CHECK(err_code);
                }
    
Reply
  • In the unaltered keyboard example, a failed attempt to fetch the peer address is followed by a APP_ERROR_CHECK(err_code); This will assert on any error. Have you tried changing it so that a failed attempt to retrieve the peer address will just ignore the reply instead of asserting?

                err_code = dm_peer_addr_get(&m_bonded_peer_handle, &peer_address);
                if(err_code == NRF_SUCCESS)
                {
                    err_code = ble_advertising_peer_addr_reply(&peer_address);
                    APP_ERROR_CHECK(err_code);
                }
    
Children
Related