mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-21 00:17:22 +00:00
host/gap: improve API for legacy adv for EXT_ADV:=1
The possible combination of options when setting legacy_pdu:=1 in `struct ble_gap_ext_adv_params` was not obvious to API users. This commit improves the API by i) adding accoring documentation and ii) adding a validity check into ble_gap_ext_adv_params_tx().
This commit is contained in:
committed by
Hauke Petersen
parent
52d47ada52
commit
0741f19599
@@ -1160,7 +1160,19 @@ struct ble_gap_ext_adv_params {
|
||||
/** If perform high-duty directed advertising */
|
||||
unsigned int high_duty_directed:1;
|
||||
|
||||
/** If use legacy PDUs for advertising */
|
||||
/** If use legacy PDUs for advertising.
|
||||
*
|
||||
* Valid combinations of the connectable, scannable, directed,
|
||||
* high_duty_directed options with the legcy_pdu flag are:
|
||||
* - IND -> legacy_pdu + connectable + scannable
|
||||
* - LD_DIR -> legacy_pdu + connectable + directed
|
||||
* - HD_DIR -> legacy_pdu + connectable + directed + high_duty_directed
|
||||
* - SCAN -> legacy_pdu + scannable
|
||||
* - NONCONN -> legacy_pdu
|
||||
*
|
||||
* Any other combination of these options combined with the legacy_pdu flag
|
||||
* are invalid.
|
||||
*/
|
||||
unsigned int legacy_pdu:1;
|
||||
|
||||
/** If perform anonymous advertising */
|
||||
|
||||
@@ -2692,15 +2692,28 @@ ble_gap_ext_adv_params_tx(uint8_t instance,
|
||||
if (params->high_duty_directed) {
|
||||
cmd.props |= BLE_HCI_LE_SET_EXT_ADV_PROP_HD_DIRECTED;
|
||||
}
|
||||
if (params->legacy_pdu) {
|
||||
cmd.props |= BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY;
|
||||
}
|
||||
if (params->anonymous) {
|
||||
cmd.props |= BLE_HCI_LE_SET_EXT_ADV_PROP_ANON_ADV;
|
||||
}
|
||||
if (params->include_tx_power) {
|
||||
cmd.props |= BLE_HCI_LE_SET_EXT_ADV_PROP_INC_TX_PWR;
|
||||
}
|
||||
if (params->legacy_pdu) {
|
||||
cmd.props |= BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY;
|
||||
|
||||
/* check right away if the applied configuration is valid before handing
|
||||
* the command to the controller to improve error reporting */
|
||||
switch (cmd.props) {
|
||||
case BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_IND:
|
||||
case BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_LD_DIR:
|
||||
case BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_HD_DIR:
|
||||
case BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_SCAN:
|
||||
case BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_NONCONN:
|
||||
break;
|
||||
default:
|
||||
return BLE_HS_EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fill optional fields if application did not specify them. */
|
||||
if (params->itvl_min == 0 && params->itvl_max == 0) {
|
||||
|
||||
Reference in New Issue
Block a user