mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-08-20 17:00:01 +00:00
host/gap: add function that returns free advertising instance
ble_gap_adv_get_free_instance browses through list of advertising instances and returns first that is not yet configured. Previously, user had to track which instance is used by themselves, and could only check if advertising is active, via ble_gap_ext_adv_active
This commit is contained in:
committed by
Krzysztof Kopyściński
parent
a621805349
commit
ca7aeaad9e
@@ -1692,6 +1692,14 @@ int ble_gap_ext_adv_clear(void);
|
||||
*
|
||||
*/
|
||||
int ble_gap_ext_adv_active(uint8_t instance);
|
||||
|
||||
/**
|
||||
* Returns first not configured advertising instance.
|
||||
*
|
||||
* @return advertising instance if one was found, negative error code otherwise
|
||||
*
|
||||
*/
|
||||
int ble_gap_adv_get_free_instance(void);
|
||||
#endif
|
||||
|
||||
/* Periodic Advertising */
|
||||
|
||||
@@ -1390,6 +1390,20 @@ int ble_gap_ext_adv_active(uint8_t instance)
|
||||
}
|
||||
return ble_gap_adv_active_instance(instance);
|
||||
}
|
||||
|
||||
int
|
||||
ble_gap_adv_get_free_instance(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BLE_ADV_INSTANCES; i++) {
|
||||
if (!ble_gap_slave[i].configured) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -BLE_HS_ENOENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user