Simple question:
Is possible a central to evaluate RSSI before connecting to a peripheral?
The idea is to make central device connect and bond to a peripheral only if a determined RSSI is achieved.
Cheers
Fávero
Simple question:
Is possible a central to evaluate RSSI before connecting to a peripheral?
The idea is to make central device connect and bond to a peripheral only if a determined RSSI is achieved.
Cheers
Fávero
Well yes - the RSSI received is in the advertising report event structure, ble_gap_evt_adv_report_t. So you can read it before you connect. You can also put the TX power in the advertising packet as well if you like so you have a good idea how close the device actually is to you.
Thank you! Could you please point an example on how to do that?
Fávero
Don't remember seeing an example. But the structure is documented, you receive the advertising event, check the rssi, if it's high enough for you, you call the connect on the peripheral. That's it.
See the scanning section of the BLE Central Tutorial.
In most SDK examples you will have the following function handling BLE events:
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
const ble_gap_evt_t * p_gap_evt = &p_ble_evt->evt.gap_evt;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_ADV_REPORT:
{
const ble_gap_evt_adv_report_t *p_adv_report = &p_gap_evt->params.adv_report;
The p_adv_report contains all the received advertisement data. You will find the rssi at p_adv_report->rssi.
See the documentation on the type ble_gap_evt_adv_report_t
Thanks!
When does the RSSI is updated? Everytime on_ble_evt is called?