nimble/gap: Adding LE Clear Advertising Sets Command

This commit is contained in:
Mohamed Essayed
2019-05-10 15:07:10 +02:00
committed by Łukasz Rymanowski
parent 976bb8f84b
commit ce39050c6b
2 changed files with 48 additions and 0 deletions
+7
View File
@@ -965,6 +965,13 @@ int ble_gap_ext_adv_stop(uint8_t instance);
int ble_gap_ext_adv_set_data(uint8_t instance, struct os_mbuf *data);
int ble_gap_ext_adv_rsp_set_data(uint8_t instance, struct os_mbuf *data);
int ble_gap_ext_adv_remove(uint8_t instance);
/**
* Clear All existing extended Adv Sets.
* @return 0 on success,
* BLE_HS_EBUSY if advertising is in progress,
* other error code on failure.
*/
int ble_gap_ext_adv_clear(void);
#if MYNEWT_VAL(BLE_PERIODIC_ADV)
/* Periodic Advertising */
+41
View File
@@ -3007,6 +3007,47 @@ ble_gap_ext_adv_remove(uint8_t instance)
return 0;
}
int
ble_gap_ext_adv_clear(void)
{
int rc;
uint8_t instance;
uint16_t opcode;
ble_hs_lock();
for (instance = 0; instance < BLE_ADV_INSTANCES; instance++) {
/* If there is an active instance or periodic adv instance,
* Don't send the command
* */
if ((ble_gap_slave[instance].op == BLE_GAP_OP_S_ADV)) {
ble_hs_unlock();
return BLE_HS_EBUSY;
}
#if MYNEWT_VAL(BLE_PERIODIC_ADV)
if ((ble_gap_slave[instance].periodic_op ==
BLE_GAP_OP_S_PERIODIC_ADV)) {
ble_hs_unlock();
return BLE_HS_EBUSY;
}
#endif
}
opcode = BLE_HCI_OP(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_CLEAR_ADV_SETS);
rc = ble_hs_hci_cmd_tx_empty_ack(opcode, NULL, 0);
if (rc != 0) {
ble_hs_unlock();
return rc;
}
memset(ble_gap_slave, 0, sizeof(ble_gap_slave));
ble_hs_unlock();
return 0;
}
#if MYNEWT_VAL(BLE_PERIODIC_ADV)
static int
ble_gap_periodic_adv_params_tx(uint8_t instance,