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

Softdevice, pairing and connecting to bonded device

Hello,

While I was testing the codes, I just got a few errors and I am confused as to why it's happening. The questions are:

1) Sometimes, I get pm_conn_secure error code 17 and I found out it's NRF_ERROR_BUSY. Is there some way to avoid it. I am calling it only after I receive the connected event so the devices are not disconnected.

2) Pairing happens very fast but connected to those paired devices takes time. Is there any reason why it is that way?

3) Suppose I am calling any softdevice function or any of the SDK libraries without any error code. Where are those error codes stored or are they destroyed. This isn't as much a doubt, more like curiosity on how things work in the GCC compiler.

Thanks and Regards

  • Hi

    1. An NRF_ERROR_BUSY from pm_conn_secure() will return if a security procedure is already in progress on the link, or if the link is disconnecting /disconnected. So if the devices aren't disconnected it's likely due to the devices being in a security procedure already, so you could add a check to make sure that the devices are "ready" or add a delay before calling pm_conn_secure().

    2. I'm not sure I understand what you mean with this question. The devices will pair after they have connected, not the other way around. Also, are you using two nRF52832 devices in this connection, or are you using a phone for one of the roles for instance?

    3. If you don't get an error code, that should mean you "passed" the function, and it won't be called at all. So it shouldn't be stored or "destroyed" at all if that's what you mean. If you're wondering where the error codes are described, this is usually in the comments on header files. Like for pm_conn_secure(), you can find the various error messages described in \SDK_FOLDER\nRF5_SDK_17.0.2_d674dde\components\ble\peer_manager\peer_manager.h

    Best regards,

    Simon

  • so you could add a check to make sure that the devices are "ready

    Thats cool. I can try that.

    I'm not sure I understand what you mean with this question.

    Ok, i will try to explain it even further. I am trying to connect two nrf52832 chips and pair them. First, i scan without whitelist and the two devices connect and pair in like 500 ms.

    Then, I disconnect the device and start advertising in the peripheral and scanning in central, both using whitelist (which contains the information of previously bonded device). The pairing of this takes around 5sec. Why is it that this is slower than the first one is my question?

    In other words once I call sd_ble_gap_connect(), it takes more time while connecting to a device with whitelist enabled than a device without whitelist enabled.

    So it shouldn't be stored or "destroyed" at all if that's what you mean.

    Ok, basically consider two scenarios

    Scenario 1 : ret_code_t ret = sd_ble_gap_advertising_start();

    In this case, if my parameters are correct I get ret as success which is zero.

    Suppose I call only call

    s_ble_gap_advertising_start();

    Where does the error code which returns from the softdevice go?

  • 2. Okay, I didn't realize this was about the re-connection taking too long. Thank you for explaining. Can you confirm whether it is the time from the DISCONNECTED to CONNNECTED events or from the CONNECTED event until the devices are paired again that takes ~5 seconds by debugging? How do you handle the  BLE_GAP_EVT_DISCONNECTED event for instance?

    3. Well, if you don't ask for a return code (ret_code) then you won't get any, the error will still occur, but won't be printed for you to see, which will make it hard for you to see what (or if something) is wrong.

    Best regards,

    Simon

  • Can you confirm whether it is the time from the DISCONNECTED to CONNNECTED events or from the CONNECTED event until the devices are paired again that takes ~5 seconds by debugging?

    Time taken is from the time I get BLE_adv_report and if the UUID match request does match to the time I get connection secured event. Basically if UUIDs match I call connect request, from that time till I get connection secured event. I call pm_conn_secure once I receive the BLE_GAP_connected event.

    How do you handle the  BLE_GAP_EVT_DISCONNECTED event for instance?

    Central : start scanning with whitelist.

    Peripheral : directed advertising and then fast advertising with whitelist.

    Thank you for your Help

  • Okay, this seems to take a bit too long then, do you have a debug log with timestamps or maybe you can take a sniffer trace so we can get some details as to what exactly is taking time in this process? If you have an nRF52 DK you can use it as a sniffer with the nRF Sniffer firmware and Wireshark for example.

    Best regards,

    Simon

Related