1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

pkg/nimble/netif: make advertisement instance configurable

This commit is contained in:
Francisco Molina 2021-11-24 14:50:58 +01:00
parent 3702087084
commit 81cd99980e

View File

@ -55,7 +55,9 @@
#define NIMBLE_NETIF_PRIO GNRC_NETIF_PRIO
#endif
#define EXT_ADV_INST 0
#ifndef CONFIG_NIMBLE_NETIF_ADV_INSTANCE
#define CONFIG_NIMBLE_NETIF_ADV_INSTANCE 0
#endif
/* thread flag used for signaling transmit readiness */
#define FLAG_TX_UNSTALLED (1u << 13)
@ -763,7 +765,7 @@ static int _accept(const uint8_t *ad, size_t ad_len, const ble_addr_t *addr,
p.secondary_phy = (uint8_t)phy_sec;
p.tx_power = params->tx_power;
res = ble_gap_ext_adv_configure(EXT_ADV_INST, &p, NULL,
res = ble_gap_ext_adv_configure(CONFIG_NIMBLE_NETIF_ADV_INSTANCE, &p, NULL,
_on_gap_slave_evt, (void *)handle);
if (res != 0) {
nimble_netif_conn_free(handle, NULL);
@ -782,10 +784,10 @@ static int _accept(const uint8_t *ad, size_t ad_len, const ble_addr_t *addr,
nimble_netif_conn_free(handle, NULL);
return -ENOMEM;
}
res = ble_gap_ext_adv_set_data(EXT_ADV_INST, data);
res = ble_gap_ext_adv_set_data(CONFIG_NIMBLE_NETIF_ADV_INSTANCE, data);
assert(res == 0);
}
res = ble_gap_ext_adv_start(EXT_ADV_INST, params->timeout_ms / 10, 0);
res = ble_gap_ext_adv_start(CONFIG_NIMBLE_NETIF_ADV_INSTANCE, params->timeout_ms / 10, 0);
#else
uint8_t mode = (addr != NULL) ? BLE_GAP_CONN_MODE_DIR
: BLE_GAP_CONN_MODE_UND;
@ -847,7 +849,7 @@ int nimble_netif_accept_stop(void)
int res;
#if MYNEWT_VAL_BLE_EXT_ADV
res = ble_gap_ext_adv_stop(EXT_ADV_INST);
res = ble_gap_ext_adv_stop(CONFIG_NIMBLE_NETIF_ADV_INSTANCE);
#else
res = ble_gap_adv_stop();
#endif