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

how to know softdevice state

I am using s120 for central device, and my central device connects to multiple BLE slaves. After connection, some slaves may lost connection due to power off of that device. The device might be powered on again after sometime.

The way I am currently doing is to send connection command sd_ble_gap_connect(). For one-peripheral case, it works ok. But for multiple peripherals, softdevice will return "NRF_ERROR_INVALID_STATE" error.

My question is can we know the softdevice state before call "sd_ble_gap_connect()"?

Is there a better way to know the slave is powered on again (it will still broadcast), when the central is in connection state?

Thanks.

Parents
  • Your Central should always send a connect request sd_ble_gap_connect only when it gets an advertising report event BLE_GAP_EVT_ADV_REPORT from that slave. From the advertisement report you can parse the information of that slave. If your central is doing active scanning then you can get more information in BLE_GAP_EVT_SCAN_REQ_REPORT event.

    When you get one of this event and your central is able to parse the information to know that it came from the slave device you want to connect, then sending connect request is safe as you know that slave was advertising at-most 150us ago.

    You can look in some of the central examples in SDK. I do not see any other way of polling non connected device states.

  • Hi YSquare,

    What is the advertisement interval from the peripheral side and what are scan interval and window size on central side?

    If central is not getting ADV report from peripheral then something is wrong, i recommend you to sniff the packets to see if peripheral packets are coming out into air and still central side is not able to get them. Also debug your central to see if it has hardfaulted or something else.

Reply
  • Hi YSquare,

    What is the advertisement interval from the peripheral side and what are scan interval and window size on central side?

    If central is not getting ADV report from peripheral then something is wrong, i recommend you to sniff the packets to see if peripheral packets are coming out into air and still central side is not able to get them. Also debug your central to see if it has hardfaulted or something else.

Children
No Data
Related