summaryrefslogtreecommitdiff
path: root/lib/bt/esp_ble_mesh/api
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2025-07-25 13:33:07 +1000
committerjacqueline <me@jacqueline.id.au>2025-07-25 13:33:07 +1000
commitc8e79a926620e48830778714cfe4b2ea2453fcaf (patch)
tree8c756e08e01b8e147cf72bec128026f46bd854c5 /lib/bt/esp_ble_mesh/api
parent237136f3e93cb6b5be24670d7520adb17cc0fa36 (diff)
downloadtangara-fw-c8e79a926620e48830778714cfe4b2ea2453fcaf.tar.gz
Update forked idf components
Diffstat (limited to 'lib/bt/esp_ble_mesh/api')
-rw-r--r--lib/bt/esp_ble_mesh/api/core/esp_ble_mesh_ble_api.c26
-rw-r--r--lib/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c2
-rw-r--r--lib/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_ble_api.h88
-rw-r--r--lib/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h25
4 files changed, 126 insertions, 15 deletions
diff --git a/lib/bt/esp_ble_mesh/api/core/esp_ble_mesh_ble_api.c b/lib/bt/esp_ble_mesh/api/core/esp_ble_mesh_ble_api.c
index 559528e8..fcba1f4b 100644
--- a/lib/bt/esp_ble_mesh/api/core/esp_ble_mesh_ble_api.c
+++ b/lib/bt/esp_ble_mesh/api/core/esp_ble_mesh_ble_api.c
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -12,14 +12,14 @@
#include "btc_ble_mesh_ble.h"
#include "esp_ble_mesh_ble_api.h"
-#if CONFIG_BLE_MESH_BLE_COEX_SUPPORT
+#if (CONFIG_BLE_MESH_BLE_COEX_SUPPORT || CONFIG_BLE_MESH_USE_BLE_50)
esp_err_t esp_ble_mesh_register_ble_callback(esp_ble_mesh_ble_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_BLE_MESH_BLE_COEX, callback) == 0 ? ESP_OK : ESP_FAIL);
}
-#endif /* CONFIG_BLE_MESH_BLE_COEX_SUPPORT */
+#endif /* (CONFIG_BLE_MESH_BLE_COEX_SUPPORT || CONFIG_BLE_MESH_USE_BLE_50) */
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
esp_err_t esp_ble_mesh_start_ble_advertising(const esp_ble_mesh_ble_adv_param_t *param,
@@ -100,3 +100,23 @@ esp_err_t esp_ble_mesh_stop_ble_scanning(void)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
+
+esp_err_t esp_ble_mesh_scan_params_update(esp_ble_mesh_scan_param_t *scan_param)
+{
+ btc_ble_mesh_ble_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (!scan_param) {
+ return ESP_FAIL;
+ }
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
+ msg.act = BTC_BLE_MESH_ACT_UPDATE_SCAN_PARAMS;
+
+ arg.scan_params.scan_interval = scan_param->scan_interval;
+ arg.scan_params.uncoded_scan_window = scan_param->uncoded_scan_window;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_ble_args_t), NULL, NULL)
+ == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
diff --git a/lib/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c b/lib/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c
index 82128786..eaa18681 100644
--- a/lib/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c
+++ b/lib/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
diff --git a/lib/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_ble_api.h b/lib/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_ble_api.h
index 6818ba18..83d7e627 100644
--- a/lib/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_ble_api.h
+++ b/lib/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_ble_api.h
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -9,6 +9,10 @@
#include "esp_ble_mesh_defs.h"
+#if CONFIG_BLE_MESH_USE_BLE_50 && CONFIG_BT_NIMBLE_ENABLED
+#include "host/ble_gap.h"
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -20,9 +24,38 @@ typedef enum {
ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT, /*!< Start BLE scanning completion event */
ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT, /*!< Stop BLE scanning completion event */
ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT, /*!< Scanning BLE advertising packets event */
+ ESP_BLE_MESH_SCAN_PARAMS_UPDATE_COMP_EVT, /*!< Scan parameters update completion event */
+#if CONFIG_BLE_MESH_USE_BLE_50 && CONFIG_BT_NIMBLE_ENABLED
+ ESP_BLE_MESH_NIMBLE_GAP_EVENT_EVT, /*!< NIMBLE GAP event */
+#endif /* CONFIG_BLE_MESH_USE_BLE_50 && CONFIG_BT_NIMBLE_ENABLED */
ESP_BLE_MESH_BLE_EVT_MAX,
} esp_ble_mesh_ble_cb_event_t;
+/** Context of BLE advertising report. */
+typedef struct {
+ uint8_t addr[6]; /*!< Device address */
+ uint8_t addr_type; /*!< Device address type */
+#if CONFIG_BLE_MESH_USE_BLE_50
+ uint8_t adv_type __attribute__((deprecated("`event_type` should be used to determine the advertising type"))); /*!< advertising type */
+#else
+ uint8_t adv_type; /*!< Advertising type */
+#endif
+ uint8_t *data; /*!< Advertising data */
+ uint16_t length; /*!< Advertising data length */
+ int8_t rssi; /*!< RSSI of the advertising packet */
+#if CONFIG_BLE_MESH_USE_BLE_50
+ uint8_t event_type; /*!< Extended advertising event type */
+ uint8_t primary_phy; /*!< Extended advertising primary PHY */
+ uint8_t secondary_phy; /*!< Extended advertising secondary PHY */
+ uint8_t sid; /*!< Extended advertising set ID */
+ uint8_t tx_power; /*!< Extended advertising TX power */
+ uint8_t dir_addr_type; /*!< Direct address type */
+ uint8_t dir_addr[6]; /*!< Direct address */
+ uint8_t data_status; /*!< Data type */
+ uint16_t per_adv_interval; /*!< Periodic advertising interval */
+#endif /* CONFIG_BLE_MESH_USE_BLE_50 */
+} esp_ble_mesh_ble_adv_rpt_t;
+
/** BLE operation callback parameters */
typedef union {
/**
@@ -52,16 +85,24 @@ typedef union {
int err_code; /*!< Indicate the result of stopping BLE scanning */
} stop_ble_scan_comp; /*!< Event parameters of ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT */
/**
- * @brief ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT
+ * @brief Event parameters of ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT
*/
- struct {
- uint8_t addr[6]; /*!< Device address */
- uint8_t addr_type; /*!< Device address type */
- uint8_t adv_type; /*!< Advertising data type */
- uint8_t *data; /*!< Advertising data */
- uint16_t length; /*!< Advertising data length */
- int8_t rssi; /*!< RSSI of the advertising packet */
- } scan_ble_adv_pkt; /*!< Event parameters of ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT */
+ esp_ble_mesh_ble_adv_rpt_t scan_ble_adv_pkt;
+ /**
+ * @brief Event parameter of ESP_BLE_MESH_SCAN_PARAMS_UPDATE_COMP_EVT
+ */
+ struct ble_mesh_scan_params_update_comp_param {
+ int err_code; /*!< Indicates the result of updating scan parameters */
+ } scan_params_update_comp; /*!< Event parameter of ESP_BLE_MESH_SCAN_PARAMS_UPDATE_COMP_EVT */
+#if CONFIG_BLE_MESH_USE_BLE_50 && CONFIG_BT_NIMBLE_ENABLED
+ /**
+ * @brief Event parameters of ESP_BLE_MESH_NIMBLE_GAP_EVENT_EVT
+ */
+ struct ble_mesh_nimble_gap_event_evt_param {
+ struct ble_gap_event event; /*!< GAP event parameters for NimBLE Host */
+ void *arg; /*!< User parameters */
+ } nimble_gap_evt; /*!< Event parameters of ESP_BLE_MESH_NIMBLE_GAP_EVENT_EVT */
+#endif /* CONFIG_BLE_MESH_USE_BLE_50 && CONFIG_BT_NIMBLE_ENABLED */
} esp_ble_mesh_ble_cb_param_t;
/**
@@ -175,6 +216,33 @@ esp_err_t esp_ble_mesh_start_ble_scanning(esp_ble_mesh_ble_scan_param_t *param);
*/
esp_err_t esp_ble_mesh_stop_ble_scanning(void);
+/**
+ * @brief Update BLE Mesh scan parameters.
+ *
+ * @note
+ * 1. This function shall be used after ESP BLE Mesh is initialized!
+ * Parameters `scan_interval` and `uncoded_scan_window` must both
+ * be multiples of 8.
+ *
+ * 2. If the config BLE_MESH_USE_BLE_50 is enabled, within the scan_interval:
+ * - If uncoded_scan_window is not zero, the scan_interval is divided into
+ * two parts:
+ * - uncoded_scan_window: Used for performing uncoded scanning.
+ * - (scan_interval - uncoded_scan_window): The remaining time is
+ * used for coded scanning (coded_scan).
+ * - If uncoded_scan_window is set to 0, it means the entire scan_interval
+ * is used for coded scanning.
+ * - If uncoded_scan_window is equal to scan_interval, it means the entire
+ * scan_interval is used for uncoded scanning.
+ *
+ * @param[in] scan_param: Scan parameters
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_FAIL: Invalid parameters or unable transfer this command to the stack
+*/
+esp_err_t esp_ble_mesh_scan_params_update(esp_ble_mesh_scan_param_t *scan_param);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h b/lib/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h
index efbf2df5..188d6db2 100644
--- a/lib/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h
+++ b/lib/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -415,6 +415,29 @@ typedef struct {
bool erase_flash; /*!< Indicate if erasing flash when deinit mesh stack */
} esp_ble_mesh_deinit_param_t;
+/** Scan parameters */
+typedef struct {
+ /**
+ * Scan interval.
+ *
+ * Range: 0x0004 to 0x4000.
+ *
+ * Time = N * 0.625 ms. Time Range: 2.5 ms to 10.24 s
+ */
+ uint16_t scan_interval;
+
+ /**
+ * Uncoded Scan window.
+ *
+ * Time scanned on uncoded PHY within a scan interval.
+ *
+ * Range: 0x0004 to 0x4000.
+ *
+ * Time = N * 0.625 ms. Time Range: 2.5 ms to 10.24 s
+ */
+ uint16_t uncoded_scan_window;
+} esp_ble_mesh_scan_param_t;
+
/** Format of Unicast Address Range */
typedef struct {
uint16_t len_present:1, /*!< Indicate the presence or absence of the RangeLength field */