You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ha...@apache.org on 2022/01/13 12:48:57 UTC
[mynewt-nimble] branch master updated: host/gap: improve API for legacy adv for EXT_ADV:=1
This is an automated email from the ASF dual-hosted git repository.
hauke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new 0741f19 host/gap: improve API for legacy adv for EXT_ADV:=1
0741f19 is described below
commit 0741f19599f87e1818dd00182caae3c2c9343875
Author: Hauke Petersen <ha...@fu-berlin.de>
AuthorDate: Tue Dec 14 11:19:53 2021 +0100
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().
---
nimble/host/include/host/ble_gap.h | 14 +++++++++++++-
nimble/host/src/ble_gap.c | 19 ++++++++++++++++---
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/nimble/host/include/host/ble_gap.h b/nimble/host/include/host/ble_gap.h
index af9c978..63ae900 100644
--- a/nimble/host/include/host/ble_gap.h
+++ b/nimble/host/include/host/ble_gap.h
@@ -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 */
diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index 8f7e5ca..3d8f303 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -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) {