Merge branch 'fix/ble_mesh_micellaneous_update_v5.2' into 'release/v5.2'

Fix/ble mesh micellaneous update v5.2

See merge request espressif/esp-idf!39462
This commit is contained in:
Island
2025-05-28 10:37:35 +08:00
18 changed files with 372 additions and 80 deletions

View File

@ -212,7 +212,7 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
[BTC_PID_RPR_CLIENT] = {btc_ble_mesh_rpr_client_call_handler, btc_ble_mesh_rpr_client_cb_handler },
#endif /* CONFIG_BLE_MESH_RPR_CLI */
#if CONFIG_BLE_MESH_RPR_SRV
[BTC_PID_RPR_SERVER] = {NULL, btc_ble_mesh_rpr_server_cb_handler },
[BTC_PID_RPR_SERVER] = {btc_ble_mesh_rpr_server_call_handler, btc_ble_mesh_rpr_server_cb_handler },
#endif /* CONFIG_BLE_MESH_RPR_SRV */
#if CONFIG_BLE_MESH_SAR_CLI
[BTC_PID_SAR_CLIENT] = {btc_ble_mesh_sar_client_call_handler, btc_ble_mesh_sar_client_cb_handler },

View File

@ -409,7 +409,7 @@ if BLE_MESH
int "Maximum capacity of solicitation replay protection list"
depends on BLE_MESH_PROXY_SOLIC_PDU_RX
default 2
range 1 255
range 1 65536
help
This option specifies the maximum capacity of the solicitation replay
protection list. The solicitation replay protection list is used to

View File

@ -44,6 +44,7 @@ enum bt_mesh_adv_type {
BLE_MESH_ADV_URI,
BLE_MESH_ADV_BLE,
BLE_MESH_ADV_PROXY_SOLIC,
BLE_MESH_ADV_TYPES_NUM,
};
struct bt_mesh_adv {

View File

@ -441,7 +441,9 @@ int bt_mesh_init(const struct bt_mesh_prov *prov,
if ((IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) &&
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) ||
IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) {
IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT) ||
(IS_ENABLED(CONFIG_BLE_MESH_RPR_SRV) &&
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT))) {
bt_mesh_proxy_client_init();
}
@ -591,7 +593,9 @@ int bt_mesh_deinit(struct bt_mesh_deinit_param *param)
if ((IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) &&
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) ||
IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) {
IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT) ||
(IS_ENABLED(CONFIG_BLE_MESH_RPR_SRV) &&
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT))) {
bt_mesh_proxy_client_deinit();
}

View File

@ -147,7 +147,8 @@ void bt_mesh_hci_init(void)
static struct ble_gap_disc_params scan_param;
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
static struct gattc_prov_info {
/* Service to be found depends on the type of adv pkt received */
struct bt_mesh_conn conn;
@ -396,13 +397,16 @@ static int svc_disced(uint16_t conn_handle, const struct ble_gatt_error *error,
return rc;
}
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_CLIENT */
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT ||
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT) */
static int disc_cb(struct ble_gap_event *event, void *arg)
{
struct ble_gap_disc_desc *desc;
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
int rc, i;
uint8_t notif_data[100];
uint16_t notif_len;
@ -425,7 +429,8 @@ static int disc_cb(struct ble_gap_event *event, void *arg)
break;
}
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
case BLE_GAP_EVENT_CONNECT:
if (event->connect.status == 0) {
/* Connection successfully established. */
@ -1357,7 +1362,8 @@ int bt_mesh_gatts_set_local_device_name(const char *name)
#endif /* CONFIG_BLE_MESH_NODE */
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
void bt_mesh_gattc_conn_cb_register(struct bt_mesh_prov_conn_cb *cb)
{
bt_mesh_gattc_conn_cb = cb;
@ -1598,7 +1604,10 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn)
* Mesh Proxy Data In: 0x2ADD
* Mesh PROXY Data Out: 0x2ADE
*/
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_CLIENT */
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) ||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT ||
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)*/
struct bt_mesh_conn *bt_mesh_conn_ref(struct bt_mesh_conn *conn)
{
@ -1743,7 +1752,8 @@ void bt_mesh_gatt_init(void)
#endif /* CONFIG_BLE_MESH_NODE */
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
for (int i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
bt_mesh_gattc_info[i].conn.handle = 0xFFFF;
bt_mesh_gattc_info[i].mtu = BLE_ATT_MTU_DFLT;
@ -1761,7 +1771,8 @@ void bt_mesh_gatt_deinit(void)
#endif
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
for (int i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
bt_mesh_gattc_info[i].conn.handle = 0xFFFF;
memset(&bt_mesh_gattc_info[i].addr, 0, sizeof(bt_mesh_addr_t));

View File

@ -2,7 +2,7 @@
/*
* SPDX-FileCopyrightText: 2017 Intel Corporation
* SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -82,12 +82,12 @@ static void reset_state(void)
}
#endif /* CONFIG_BLE_MESH_PB_GATT */
#if CONFIG_BLE_MESH_PB_ADV
/* Clear everything except the retransmit and protocol timer
* delayed work objects.
*/
(void)memset(&prov_link, 0, offsetof(struct bt_mesh_prov_link, tx.retransmit));
#if CONFIG_BLE_MESH_PB_ADV
prov_link.pending_ack = PROV_XACT_NVAL;
prov_link.rx.prev_id = PROV_XACT_NVAL;
@ -154,7 +154,7 @@ static int prov_send_gatt(struct bt_mesh_prov_link *link, struct net_buf_simple
/* Changed by Espressif, add provisioning timeout timer operations.
* When sending a provisioning PDU successfully, restart the 60s timer.
*/
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT && CONFIG_BLE_MESH_RPR_SRV
#if CONFIG_BLE_MESH_RPR_SRV
if (bt_mesh_atomic_test_bit(link->flags, PB_REMOTE)) {
err = bt_mesh_proxy_client_send(link->conn, BLE_MESH_PROXY_PROV, msg);
@ -1075,10 +1075,19 @@ static void link_ack(struct prov_rx *rx, struct net_buf_simple *buf)
bt_mesh_prov_clear_tx(&prov_link, true);
bt_mesh_rpr_srv_recv_link_ack(prov_link.pb_remote_uuid, true);
} else {
BT_INFO("Link ACK for PB-Remote already received");
BT_DBG("Link ACK for PB-Remote already received");
return;
}
}
#endif /* CONFIG_BLE_MESH_RPR_SRV */
if (!k_delayed_work_remaining_get(&prov_link.prot_timer)) {
/**
* When the link is opened, the provisioner and the unprovisioned device
* shall start the link timer with the timeout value set to 60 seconds.
*/
k_delayed_work_submit(&prov_link.prot_timer, PROTOCOL_TIMEOUT);
}
}
static void link_close(struct prov_rx *rx, struct net_buf_simple *buf)
@ -1434,6 +1443,11 @@ int bt_mesh_pb_gatt_open(struct bt_mesh_conn *conn)
{
BT_DBG("conn %p", conn);
/**
* It's necessary to determine if it is PB_REMOTE because when the
* node acts as an RPR server, LINK_ACTIVE has already been set upon
* receiving the link open from the RPR client.
*/
if (!bt_mesh_atomic_test_bit(prov_link.flags, PB_REMOTE) &&
bt_mesh_atomic_test_and_set_bit(prov_link.flags, LINK_ACTIVE)) {
BT_ERR("Link is busy");
@ -1451,6 +1465,14 @@ int bt_mesh_pb_gatt_open(struct bt_mesh_conn *conn)
prov_link.expect = PROV_INVITE;
}
/**
* Just like ADV Link, start provision timeout timer after
* establishing the link to prevent the RPR server from
* being unable to recover to a configurable network state
* during remote provisioning.
*/
k_delayed_work_submit(&prov_link.prot_timer, PROTOCOL_TIMEOUT);
if (bt_mesh_prov_get()->link_open) {
bt_mesh_prov_get()->link_open(BLE_MESH_PROV_GATT);
}
@ -1496,7 +1518,7 @@ static void protocol_timeout(struct k_work *work)
#if CONFIG_BLE_MESH_PB_GATT
if (prov_link.conn) {
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT && CONFIG_BLE_MESH_RPR_SRV
#if CONFIG_BLE_MESH_RPR_SRV
if (bt_mesh_atomic_test_bit(prov_link.flags, PB_REMOTE)) {
prov_link.pb_remote_reset = true;
bt_mesh_gattc_disconnect(prov_link.conn);

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -47,6 +47,10 @@ _Static_assert(BLE_MESH_MAX_CONN >= CONFIG_BLE_MESH_PBG_SAME_TIME,
*/
static struct bt_mesh_prov_link prov_links[BLE_MESH_PROV_SAME_TIME];
#if CONFIG_BLE_MESH_RPR_CLI
extern struct bt_mesh_prov_link rpr_links[CONFIG_BLE_MESH_RPR_CLI_PROV_SAME_TIME];
#endif
struct bt_mesh_prov_ctx {
/* Primary element address of Provisioner */
uint16_t primary_addr;
@ -244,7 +248,7 @@ void bt_mesh_provisioner_restore_prov_info(uint16_t primary_addr, uint16_t alloc
}
#endif /* CONFIG_BLE_MESH_SETTINGS */
static bool is_unprov_dev_being_provision(const uint8_t uuid[16])
bool bt_mesh_is_unprov_dev_being_prov(const uint8_t uuid[16])
{
int i;
@ -261,6 +265,15 @@ static bool is_unprov_dev_being_provision(const uint8_t uuid[16])
}
#endif /* CONFIG_BLE_MESH_FAST_PROV */
#if CONFIG_BLE_MESH_RPR_CLI
for (i = 0; i < CONFIG_BLE_MESH_RPR_CLI_PROV_SAME_TIME;i++) {
if (!memcmp(rpr_links[i].pb_remote_uuid, uuid, 16)) {
BT_WARN("Device is being provisioning by Remote Provisioning");
return true;
}
}
#endif
for (i = 0; i < BLE_MESH_PROV_SAME_TIME; i++) {
if (bt_mesh_atomic_test_bit(prov_links[i].flags, LINK_ACTIVE)
#if CONFIG_BLE_MESH_PB_GATT
@ -311,7 +324,7 @@ static int provisioner_check_unprov_dev_info(const uint8_t uuid[16], bt_mesh_pro
* receive the connectable prov adv pkt from this device.
* Here we check both PB-GATT and PB-ADV link status.
*/
if (is_unprov_dev_being_provision(uuid)) {
if (bt_mesh_is_unprov_dev_being_prov(uuid)) {
return -EALREADY;
}
@ -366,7 +379,7 @@ static int provisioner_start_prov_pb_adv(const uint8_t uuid[16], const bt_mesh_a
return -EIO;
}
if (is_unprov_dev_being_provision(uuid)) {
if (bt_mesh_is_unprov_dev_being_prov(uuid)) {
bt_mesh_pb_adv_unlock();
return 0;
}
@ -428,7 +441,7 @@ static int provisioner_start_prov_pb_gatt(const uint8_t uuid[16], const bt_mesh_
return -EIO;
}
if (is_unprov_dev_being_provision(uuid)) {
if (bt_mesh_is_unprov_dev_being_prov(uuid)) {
bt_mesh_pb_gatt_unlock();
return 0;
}
@ -1959,6 +1972,7 @@ static void send_prov_data(struct bt_mesh_prov_link *link)
uint8_t session_key[16] = {0};
uint8_t nonce[13] = {0};
uint8_t pdu[25] = {0};
uint8_t *dev_uuid = NULL;
PROV_BUF(buf, 34);
int err = 0;
@ -2014,7 +2028,13 @@ static void send_prov_data(struct bt_mesh_prov_link *link)
*/
/* Check if this device is a re-provisioned device */
node = bt_mesh_provisioner_get_node_with_uuid(link->uuid);
if (bt_mesh_atomic_test_bit(link->flags, PB_REMOTE)) {
dev_uuid = link->pb_remote_uuid;
} else {
dev_uuid = link->uuid;
}
node = bt_mesh_provisioner_get_node_with_uuid(dev_uuid);
if (node) {
if (link->element_num <= node->element_num &&
link->pb_remote_nppi != NPPI_NODE_ADDR_REFRESH) {
@ -2029,7 +2049,7 @@ static void send_prov_data(struct bt_mesh_prov_link *link)
*/
if (!bt_mesh_atomic_test_bit(link->flags, PB_REMOTE) ||
link->pb_remote_nppi == NPPI_UNKNOWN) {
bt_mesh_provisioner_remove_node(link->uuid);
bt_mesh_provisioner_remove_node(dev_uuid);
}
}
@ -2213,6 +2233,7 @@ static void prov_complete(struct bt_mesh_prov_link *link,
uint16_t net_idx = 0U;
uint16_t index = 0U;
bool nppi = false;
uint8_t *dev_uuid = NULL;
int err = 0;
int i;
@ -2229,12 +2250,16 @@ static void prov_complete(struct bt_mesh_prov_link *link,
net_idx = prov_ctx.net_idx;
}
if (bt_mesh_atomic_test_bit(link->flags, PB_REMOTE) &&
link->pb_remote_nppi != NPPI_UNKNOWN) {
nppi = true;
if (bt_mesh_atomic_test_bit(link->flags, PB_REMOTE)) {
if (link->pb_remote_nppi != NPPI_UNKNOWN) {
nppi = true;
}
dev_uuid = link->pb_remote_uuid;
} else {
dev_uuid = link->uuid;
}
err = bt_mesh_provisioner_provision(&link->addr, link->uuid, link->oob_info,
err = bt_mesh_provisioner_provision(&link->addr, dev_uuid, link->oob_info,
link->unicast_addr, link->element_num,
net_idx, link->kri_flags, bt_mesh.iv_index,
device_key, &index, nppi);
@ -2266,13 +2291,13 @@ static void prov_complete(struct bt_mesh_prov_link *link,
#endif /* CONFIG_BLE_MESH_RPR_CLI */
if (bt_mesh_prov_get()->prov_complete) {
bt_mesh_prov_get()->prov_complete(index, link->uuid, link->unicast_addr,
bt_mesh_prov_get()->prov_complete(index, dev_uuid, link->unicast_addr,
link->element_num, net_idx);
}
/* Find if the device is in the device queue */
for (i = 0; i < ARRAY_SIZE(unprov_dev); i++) {
if (!memcmp(unprov_dev[i].uuid, link->uuid, 16) &&
if (!memcmp(unprov_dev[i].uuid, dev_uuid, 16) &&
(unprov_dev[i].flags & RM_AFTER_PROV)) {
memset(&unprov_dev[i], 0, sizeof(struct unprov_dev_queue));
break;

View File

@ -379,6 +379,8 @@ uint16_t bt_mesh_provisioner_get_fast_prov_net_idx(void);
*/
uint8_t bt_mesh_set_fast_prov_unicast_addr_range(uint16_t min, uint16_t max);
bool bt_mesh_is_unprov_dev_being_prov(const uint8_t uuid[16]);
int bt_mesh_rpr_cli_pdu_recv(struct bt_mesh_prov_link *link, uint8_t type,
struct net_buf_simple *buf);

View File

@ -26,7 +26,8 @@
#endif
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
static struct bt_mesh_proxy_server {
struct bt_mesh_conn *conn;
@ -85,6 +86,22 @@ static void proxy_sar_timeout(struct k_work *work)
bt_mesh_gattc_disconnect(server->conn);
}
#if (CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
int bt_mesh_rpr_srv_set_waiting_prov_link(struct bt_mesh_prov_link *link,
bt_mesh_addr_t *addr)
{
for (size_t i = 0; i < ARRAY_SIZE(waiting_conn_link);i++) {
if (waiting_conn_link[i].link == NULL) {
waiting_conn_link[i].link = link;
memcpy(&waiting_conn_link[i].addr, addr, sizeof(bt_mesh_addr_t));
return 0;
}
}
return -ENOBUFS;
}
#endif /* CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT */
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT
/**
* The following callbacks are used to notify proper information
@ -115,22 +132,6 @@ void bt_mesh_proxy_client_set_filter_status_cb(proxy_client_recv_filter_status_c
proxy_client_filter_status_recv_cb = cb;
}
#if (CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
int bt_mesh_rpr_srv_set_waiting_prov_link(struct bt_mesh_prov_link *link,
bt_mesh_addr_t *addr)
{
for (size_t i = 0; i < ARRAY_SIZE(waiting_conn_link);i++) {
if (waiting_conn_link[i].link == NULL) {
waiting_conn_link[i].link = link;
memcpy(&waiting_conn_link[i].addr, addr, sizeof(bt_mesh_addr_t));
return 0;
}
}
return -ENOBUFS;
}
#endif /* CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT */
static void filter_status(struct bt_mesh_proxy_server *server,
struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf)
@ -266,7 +267,9 @@ static void proxy_complete_pdu(struct bt_mesh_proxy_server *server)
} else
#endif
{
#if CONFIG_BLE_MESH_PROVISIONER
bt_mesh_provisioner_pb_gatt_recv(server->conn, &server->buf);
#endif
}
break;
#endif
@ -494,6 +497,7 @@ static void proxy_disconnected(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn,
if (bt_mesh_prov_node_get_link()->conn == conn) {
for (size_t i = 0; i < ARRAY_SIZE(waiting_conn_link); i++) {
if (waiting_conn_link[i].link->conn == conn) {
waiting_conn_link[i].link = NULL;
memset(&waiting_conn_link[i].addr, 0, sizeof(bt_mesh_addr_t));
break;
}
@ -503,7 +507,9 @@ static void proxy_disconnected(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn,
} else
#endif /* CONFIG_BLE_MESH_RPR_SRV */
{
#if CONFIG_BLE_MESH_PROVISIONER
bt_mesh_provisioner_pb_gatt_close(conn, reason);
#endif /* CONFIG_BLE_MESH_PROVISIONER */
}
}
#endif /* CONFIG_BLE_MESH_PB_GATT && (CONFIG_BLE_MESH_PROVISIONER || CONFIG_BLE_MESH_RPR_SRV) */
@ -550,7 +556,9 @@ static ssize_t prov_write_ccc(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn)
}
#endif
#if CONFIG_BLE_MESH_PROVISIONER
return bt_mesh_provisioner_pb_gatt_open(conn, addr->val);
#endif
}
return -ENOMEM;
@ -694,10 +702,12 @@ int bt_mesh_proxy_client_gatt_disable(void)
static struct bt_mesh_prov_conn_cb conn_callbacks = {
.connected = proxy_connected,
.disconnected = proxy_disconnected,
#if CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT
#if (CONFIG_BLE_MESH_PROVISIONER || CONFIG_BLE_MESH_RPR_SRV) && \
CONFIG_BLE_MESH_PB_GATT
.prov_write_descr = prov_write_ccc,
.prov_notify = prov_recv_ntf,
#endif /* CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT */
#endif /* (CONFIG_BLE_MESH_PROVISIONER || CONFIG_BLE_MESH_RPR_SRV) && \
CONFIG_BLE_MESH_PB_GATT */
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT
.proxy_write_descr = proxy_write_ccc,
.proxy_notify = proxy_recv_ntf,
@ -1125,4 +1135,5 @@ int bt_mesh_proxy_client_deinit(void)
#endif /* CONFIG_BLE_MESH_DEINIT */
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT */
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT) */

View File

@ -2,7 +2,7 @@
/*
* SPDX-FileCopyrightText: 2017 Intel Corporation
* SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -828,6 +828,12 @@ static void proxy_connected(struct bt_mesh_conn *conn, uint8_t err)
BT_DBG("conn %p err 0x%02x", conn, err);
if (gatt_svc == MESH_GATT_PROV && conn_count == 1) {
BT_WARN("Only one prov connection could exists");
bt_mesh_gatts_disconnect(conn, 0x13);
return;
}
conn_count++;
/* Since we use ADV_OPT_ONE_TIME */

View File

@ -119,7 +119,6 @@ int bt_mesh_unprov_dev_info_query(uint8_t uuid[16], uint8_t addr[6],
}
if (cnt == unprov_dev_info_fifo.pair_num) {
BT_WARN("Didn't find info for %d", query_type);
return -1;
}
@ -136,6 +135,11 @@ int bt_mesh_unprov_dev_fifo_enqueue(uint8_t uuid[16], const uint8_t addr[6], uin
return -EINVAL;
}
if (!bt_mesh_unprov_dev_info_query(uuid, NULL, NULL, BLE_MESH_STORE_UNPROV_INFO_QUERY_TYPE_ADDR |
BLE_MESH_STORE_UNPROV_INFO_QUERY_TYPE_EXISTS)) {
return 0;
}
if (unprov_dev_info_fifo.pair_num == BLE_MESH_STORE_UNPROV_INFO_MAX_NUM) {
bt_mesh_unprov_dev_fifo_dequeue(NULL, NULL);
}
@ -166,7 +170,8 @@ uint8_t bt_mesh_get_adv_type(void)
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
CONFIG_BLE_MESH_PROXY_SOLIC_PDU_RX
CONFIG_BLE_MESH_PROXY_SOLIC_PDU_RX || \
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
static bool adv_flags_valid(struct net_buf_simple *buf)
{
uint8_t flags = 0U;
@ -253,8 +258,10 @@ static void handle_adv_service_data(struct net_buf_simple *buf,
}
switch (type) {
#if CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT
#if (CONFIG_BLE_MESH_PROVISIONER || CONFIG_BLE_MESH_RPR_SRV) && \
CONFIG_BLE_MESH_PB_GATT
case BLE_MESH_UUID_MESH_PROV_VAL:
#if CONFIG_BLE_MESH_PROVISIONER
if (bt_mesh_is_provisioner_en()) {
if (buf->len != PROV_SVC_DATA_LEN) {
BT_WARN("Invalid Mesh Prov Service Data length %d", buf->len);
@ -264,6 +271,7 @@ static void handle_adv_service_data(struct net_buf_simple *buf,
BT_DBG("Start to handle Mesh Prov Service Data");
bt_mesh_provisioner_prov_adv_recv(buf, addr, rssi);
}
#endif /* CONFIG_BLE_MESH_PROVISIONER */
#if CONFIG_BLE_MESH_RPR_SRV
if (bt_mesh_is_provisioned()) {
@ -271,9 +279,11 @@ static void handle_adv_service_data(struct net_buf_simple *buf,
bt_mesh_unprov_dev_fifo_enqueue(buf->data, addr->val, bt_mesh_get_adv_type());
bt_mesh_rpr_srv_unprov_beacon_recv(buf, bt_mesh_get_adv_type(), addr, rssi);
}
#endif
#endif /* CONFIG_BLE_MESH_RPR_SRV */
#endif /* (CONFIG_BLE_MESH_PROVISIONER || CONFIG_BLE_MESH_RPR_SRV) &&
CONFIG_BLE_MESH_PB_GATT */
break;
#endif
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT
case BLE_MESH_UUID_MESH_PROXY_VAL:
if (buf->len != PROXY_SVC_DATA_LEN_NET_ID &&
@ -306,8 +316,9 @@ static void handle_adv_service_data(struct net_buf_simple *buf,
}
}
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
CONFIG_BLE_MESH_PROXY_SOLIC_PDU_RX */
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
CONFIG_BLE_MESH_PROXY_SOLIC_PDU_RX || \
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT) */
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
static bool ble_scan_en;
@ -370,8 +381,9 @@ static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr,
uint8_t scan_rsp_len)
{
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
CONFIG_BLE_MESH_PROXY_SOLIC_PDU_RX
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
CONFIG_BLE_MESH_PROXY_SOLIC_PDU_RX || \
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
uint16_t uuid = 0U;
#endif
#if (CONFIG_BLE_MESH_RPR_SRV || CONFIG_BLE_MESH_SUPPORT_BLE_SCAN)
@ -445,7 +457,8 @@ static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr,
break;
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT || \
CONFIG_BLE_MESH_PROXY_SOLIC_PDU_RX
CONFIG_BLE_MESH_PROXY_SOLIC_PDU_RX || \
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
case BLE_MESH_DATA_FLAGS:
if (!adv_flags_valid(buf)) {
BT_DBG("Adv Flags mismatch, ignore this adv pkt");

View File

@ -1561,7 +1561,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx,
* eventually be freed up and we'll be able to process
* this one.
*/
BT_WARN("No free slots for new incoming segmented messages");
BT_WARN("No free slots for new incoming segmented messages, src: %04x", net_rx->ctx.addr);
return -ENOMEM;
}

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -81,6 +81,25 @@
#define RPL(a) ((struct bt_mesh_rpl *)(a))
#define VOID(a) ((void *)(a))
/* Declare Lib Variables */
uint8_t __meshlib_var_BLE_MESH_ADV_PROV = BLE_MESH_ADV_PROV;
uint8_t __meshlib_var_BLE_MESH_ADV_DATA = BLE_MESH_ADV_DATA;
#if CONFIG_BLE_MESH_FRIEND
uint8_t __meshlib_var_BLE_MESH_ADV_FRIEND = BLE_MESH_ADV_DATA;
#endif
#if CONFIG_BLE_MESH_RELAY_ADV_BUF
uint8_t __meshlib_var_BLE_MESH_ADV_RELAY_DATA = BLE_MESH_ADV_DATA;
#endif
uint8_t __meshlib_var_BLE_MESH_ADV_BEACON = BLE_MESH_ADV_BEACON;
uint8_t __meshlib_var_BLE_MESH_ADV_URI = BLE_MESH_ADV_URI;
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
uint8_t __meshlib_var_BLE_MESH_ADV_BLE = BLE_MESH_ADV_BLE;
#endif
#if CONFIG_BLE_MESH_PROXY_SOLIC_PDU_TX
uint8_t __meshlib_var_BLE_MESH_ADV_PROXY_SOLIC = BLE_MESH_ADV_PROXY_SOLIC;
#endif
uint8_t __meshlib_var_BLE_MESH_ADV_TYPES_NUM = BLE_MESH_ADV_TYPES_NUM;
/* Sys utilities */
void bt_mesh_ext_put_be16(uint16_t val, uint8_t dst[2])
{
@ -1159,17 +1178,17 @@ uint8_t *bt_mesh_ext_net_get_dev_key_ca(void)
return bt_mesh.dev_key_ca;
}
uint8_t bt_mesh_ext_net_get_rpl_count(void)
uint16_t bt_mesh_ext_net_get_rpl_count(void)
{
return ARRAY_SIZE(bt_mesh.rpl);
}
uint16_t bt_mesh_ext_net_get_rpl_src(uint8_t index)
uint16_t bt_mesh_ext_net_get_rpl_src(uint16_t index)
{
return bt_mesh.rpl[index].src;
}
void bt_mesh_ext_net_reset_rpl(uint8_t index)
void bt_mesh_ext_net_reset_rpl(uint16_t index)
{
memset(&bt_mesh.rpl[index], 0, sizeof(bt_mesh.rpl[index]));
}
@ -1506,6 +1525,11 @@ void bt_mesh_ext_prov_link_set_expect(void *link, uint8_t val)
LINK(link)->expect = val;
}
uint8_t bt_mesh_ext_prov_link_get_expect(void *link)
{
return LINK(link)->expect;
}
uint8_t bt_mesh_ext_prov_link_get_pub_key_type(void *link)
{
return LINK(link)->public_key;
@ -1633,6 +1657,16 @@ uint8_t *bt_mesh_ext_prov_link_get_pb_remote_uuid(void *link)
return LINK(link)->pb_remote_uuid;
}
void *bt_mesh_ext_prov_link_get_prot_timer(void *link)
{
return &(LINK(link)->prot_timer);
}
void *bt_mesh_ext_prov_link_get_with_work(void *work)
{
return CONTAINER_OF(work, struct bt_mesh_prov_link, prot_timer.work);
}
uint8_t bt_mesh_ext_prov_link_get_pb_remote_timeout(void *link)
{
return LINK(link)->pb_remote_timeout;
@ -2049,9 +2083,19 @@ int bt_mesh_ext_rpr_cli_pdu_recv(void *link, uint8_t type, struct net_buf_simple
}
#if CONFIG_BLE_MESH_RPR_CLI
static struct bt_mesh_prov_link rpr_links[CONFIG_BLE_MESH_RPR_CLI_PROV_SAME_TIME];
struct bt_mesh_prov_link rpr_links[CONFIG_BLE_MESH_RPR_CLI_PROV_SAME_TIME];
#endif /* CONFIG_BLE_MESH_RPR_CLI */
bool bt_mesh_ext_bt_mesh_is_unprov_dev_being_prov(void *uuid)
{
#if CONFIG_BLE_MESH_RPR_CLI
return bt_mesh_is_unprov_dev_being_prov(uuid);
#else
assert(0);
return 0;
#endif
}
void *bt_mesh_ext_rpr_cli_get_rpr_link(uint8_t index)
{
#if CONFIG_BLE_MESH_RPR_CLI
@ -2083,16 +2127,12 @@ int bt_mesh_ext_rpr_srv_nppi_pdu_recv(uint8_t type, const uint8_t *data)
int bt_mesh_ext_rpr_srv_set_waiting_prov_link(void* link, bt_mesh_addr_t *addr)
{
#if (CONFIG_BLE_MESH_GATT_PROXY_CLIENT && \
CONFIG_BLE_MESH_PB_GATT && \
CONFIG_BLE_MESH_RPR_SRV)
#if (CONFIG_BLE_MESH_PB_GATT && CONFIG_BLE_MESH_RPR_SRV)
return bt_mesh_rpr_srv_set_waiting_prov_link(link, addr);
#else
assert(0);
return 0;
#endif /* (CONFIG_BLE_MESH_GATT_PROXY_CLIENT && \
CONFIG_BLE_MESH_PB_GATT && \
CONFIG_BLE_MESH_RPR_SRV) */
#endif /* CONFIG_BLE_MESH_PB_GATT && CONFIG_BLE_MESH_RPR_SRV) */
}
/* Friend */
@ -3776,7 +3816,7 @@ void *bt_mesh_ext_brc_srv_get_bridge_table_entry(void *srv, uint8_t index)
#endif /* CONFIG_BLE_MESH_BRC_SRV */
}
void *bt_mesh_ext_brc_srv_get_bridge_rpl(uint8_t index)
void *bt_mesh_ext_brc_srv_get_bridge_rpl(uint16_t index)
{
#if CONFIG_BLE_MESH_BRC_SRV
return &bridge_rpl[index];
@ -3968,6 +4008,7 @@ void bt_mesh_ext_mbt_server_cb_evt_to_btc(uint8_t event, void *model, void *ctx)
typedef struct {
uint64_t config_ble_mesh_stack_trace_level : 3;
uint64_t config_ble_mesh_use_ble_50: 1;
uint64_t config_ble_mesh_use_duplicate_scan : 1;
uint64_t config_ble_mesh_pb_adv : 1;
uint64_t config_ble_mesh_pb_gatt : 1;
@ -4011,6 +4052,7 @@ typedef struct {
uint64_t config_ble_mesh_srpl_cli : 1;
uint64_t config_ble_mesh_srpl_srv : 1;
uint32_t config_ble_mesh_prov_protocol_timeout;
uint16_t config_ble_mesh_record_frag_max_size;
uint16_t config_ble_mesh_crpl;
uint16_t config_ble_mesh_proxy_solic_rx_crpl;
@ -4132,6 +4174,7 @@ typedef struct {
static const bt_mesh_ext_config_t bt_mesh_ext_cfg = {
.config_ble_mesh_stack_trace_level = BLE_MESH_LOG_LEVEL,
.config_ble_mesh_use_ble_50 = IS_ENABLED(CONFIG_BLE_MESH_USE_BLE_50),
.config_ble_mesh_use_duplicate_scan = IS_ENABLED(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN),
.config_ble_mesh_pb_adv = IS_ENABLED(CONFIG_BLE_MESH_PB_ADV),
.config_ble_mesh_pb_gatt = IS_ENABLED(CONFIG_BLE_MESH_PB_GATT),
@ -4176,6 +4219,7 @@ static const bt_mesh_ext_config_t bt_mesh_ext_cfg = {
.config_ble_mesh_sar_srv = IS_ENABLED(CONFIG_BLE_MESH_SAR_SRV),
.config_ble_mesh_srpl_cli = IS_ENABLED(CONFIG_BLE_MESH_SRPL_CLI),
.config_ble_mesh_srpl_srv = IS_ENABLED(CONFIG_BLE_MESH_SRPL_SRV),
.config_ble_mesh_prov_protocol_timeout = PROTOCOL_TIMEOUT,
#if CONFIG_BLE_MESH_CERT_BASED_PROV
.config_ble_mesh_record_frag_max_size = CONFIG_BLE_MESH_RECORD_FRAG_MAX_SIZE,
@ -4511,6 +4555,7 @@ typedef struct {
int (*_bt_mesh_ext_rpr_cli_pdu_send)(void *link, uint8_t type);
int (*_bt_mesh_ext_rpr_cli_recv_pub_key_outbound_report)(void *link);
int (*_bt_mesh_ext_rpr_cli_pdu_recv)(void *link, uint8_t type, struct net_buf_simple *buf);
bool (*_bt_mesh_ext_bt_mesh_is_unprov_dev_being_prov)(void *uuid);
void *(*_bt_mesh_ext_rpr_cli_get_rpr_link)(uint8_t index);
/* CONFIG_BLE_MESH_RPR_CLI */
@ -4542,7 +4587,7 @@ typedef struct {
uint16_t (*_bt_mesh_ext_sub_get_sbr_net_idx)(void *sub);
void (*_bt_mesh_ext_sub_set_sbr_net_idx)(void *sub, uint16_t sbr_net_idx);
void *(*_bt_mesh_ext_brc_srv_get_bridge_table_entry)(void *srv, uint8_t index);
void *(*_bt_mesh_ext_brc_srv_get_bridge_rpl)(uint8_t index);
void *(*_bt_mesh_ext_brc_srv_get_bridge_rpl)(uint16_t index);
/* CONFIG_BLE_MESH_BRC_SRV */
/* CONFIG_BLE_MESH_AGG_CLI */
@ -4832,6 +4877,7 @@ static const bt_mesh_ext_funcs_t bt_mesh_ext_func = {
._bt_mesh_ext_rpr_cli_pdu_send = bt_mesh_ext_rpr_cli_pdu_send,
._bt_mesh_ext_rpr_cli_recv_pub_key_outbound_report = bt_mesh_ext_rpr_cli_recv_pub_key_outbound_report,
._bt_mesh_ext_rpr_cli_pdu_recv = bt_mesh_ext_rpr_cli_pdu_recv,
._bt_mesh_ext_bt_mesh_is_unprov_dev_being_prov = bt_mesh_ext_bt_mesh_is_unprov_dev_being_prov,
._bt_mesh_ext_rpr_cli_get_rpr_link = bt_mesh_ext_rpr_cli_get_rpr_link,
/* CONFIG_BLE_MESH_RPR_CLI */

View File

@ -1,10 +1,11 @@
/*
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <string.h>
#include "btc/btc_manage.h"
@ -91,4 +92,34 @@ esp_err_t esp_ble_mesh_register_rpr_server_callback(esp_ble_mesh_rpr_server_cb_t
return (btc_profile_cb_set(BTC_PID_RPR_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_rpr_server_set_uuid_match(const uint8_t *match_val, uint8_t match_len, uint8_t offset)
{
btc_ble_mesh_rpr_server_args_t arg = {0};
btc_msg_t msg = {0};
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_RPR_SERVER;
msg.act = BTC_BLE_MESH_ACT_RPR_SRV_SET_UUID_MATCH;
if (!match_len || match_len > 16 ||
!match_val || offset >= 16 ||
offset + match_len > 16) {
return ESP_ERR_INVALID_ARG;
}
arg.set_uuid_match.match_val = bt_mesh_calloc(match_len);
if (!arg.set_uuid_match.match_val) {
BT_ERR("%s:Out of memory", __func__);
return ESP_ERR_NO_MEM;
}
memcpy(arg.set_uuid_match.match_val, match_val, match_len);
arg.set_uuid_match.match_len = match_len;
arg.set_uuid_match.offset = offset;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_rpr_server_args_t),
btc_ble_mesh_rpr_server_arg_deep_copy,
btc_ble_mesh_rpr_server_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_RPR_SRV */

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -396,6 +396,13 @@ typedef union {
uint16_t net_idx; /*!< NetKey Index used by Remote Provisioning Client */
uint16_t rpr_cli_addr; /*!< Unicast address of Remote Provisioning Client */
} prov_comp;
/**
* @brief ESP_BLE_MESH_RPR_SERVER_SET_UUID_MATCH_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of setting Device UUID match value by the Remote Provisioning Server */
} set_uuid_match_comp;
} esp_ble_mesh_rpr_server_cb_param_t;
/** This enum value is the event of Remote Provisioning Server model */
@ -407,6 +414,7 @@ typedef enum {
ESP_BLE_MESH_RPR_SERVER_LINK_OPEN_EVT,
ESP_BLE_MESH_RPR_SERVER_LINK_CLOSE_EVT,
ESP_BLE_MESH_RPR_SERVER_PROV_COMP_EVT,
ESP_BLE_MESH_RPR_SERVER_SET_UUID_MATCH_COMP_EVT,
ESP_BLE_MESH_RPR_SERVER_EVT_MAX,
} esp_ble_mesh_rpr_server_cb_event_t;
@ -474,6 +482,18 @@ typedef void (* esp_ble_mesh_rpr_server_cb_t)(esp_ble_mesh_rpr_server_cb_event_t
*/
esp_err_t esp_ble_mesh_register_rpr_server_callback(esp_ble_mesh_rpr_server_cb_t callback);
/**
* @brief This function is called by Remote Provisioning Server to set the part of
* the device UUID to be compared before starting to remote provision.
*
* @param[in] match_val: Value to be compared with the part of the device UUID.
* @param[in] match_len: Length of the compared match value.
* @param[in] offset: Offset of the device UUID to be compared (based on zero).
*
* @return ESP_OK on success or error code otherwise.
*/
esp_err_t esp_ble_mesh_rpr_server_set_uuid_match(const uint8_t *match_val, uint8_t match_len, uint8_t offset);
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -451,6 +451,61 @@ void btc_ble_mesh_rpr_client_cb_handler(btc_msg_t *msg)
#if CONFIG_BLE_MESH_RPR_SRV
/* Remote Provisioning Server model related functions */
extern int bt_mesh_rpr_srv_scan_set_dev_uuid_match(uint8_t offset, uint8_t length,const uint8_t *match);
void btc_ble_mesh_rpr_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{
btc_ble_mesh_rpr_server_args_t *dst = p_dest;
btc_ble_mesh_rpr_server_args_t *src = p_src;
if (!msg || !dst || !src) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch(msg->act) {
case BTC_BLE_MESH_ACT_RPR_SRV_SET_UUID_MATCH:
dst->set_uuid_match.match_val = bt_mesh_calloc(src->set_uuid_match.match_len);
if (dst->set_uuid_match.match_val) {
memcpy(dst->set_uuid_match.match_val, src->set_uuid_match.match_val, src->set_uuid_match.match_len);
dst->set_uuid_match.match_len = src->set_uuid_match.match_len;
dst->set_uuid_match.offset = src->set_uuid_match.offset;
} else {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
bt_mesh_free(src->set_uuid_match.match_val);
break;
default:
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
return;
}
void btc_ble_mesh_rpr_server_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_rpr_server_args_t *arg = NULL;
if (!msg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_rpr_server_args_t *)msg->arg;
switch(msg->act) {
case BTC_BLE_MESH_ACT_RPR_SRV_SET_UUID_MATCH:
if (arg->set_uuid_match.match_val) {
bt_mesh_free(arg->set_uuid_match.match_val);
}
break;
default:
break;
}
return;
}
static inline void btc_ble_mesh_rpr_server_cb_to_app(esp_ble_mesh_rpr_server_cb_event_t event,
esp_ble_mesh_rpr_server_cb_param_t *param)
@ -522,6 +577,33 @@ void bt_mesh_rpr_server_cb_evt_to_btc(uint8_t event, const void *val, size_t len
btc_ble_mesh_rpr_server_cb(&cb_params, act);
}
void btc_ble_mesh_rpr_server_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_rpr_server_cb_param_t cb = {0};
btc_ble_mesh_rpr_server_args_t *arg = NULL;
if (!msg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_rpr_server_args_t *)msg->arg;
switch (msg->act) {
case BTC_BLE_MESH_ACT_RPR_SRV_SET_UUID_MATCH:
cb.set_uuid_match_comp.err_code = bt_mesh_rpr_srv_scan_set_dev_uuid_match(arg->set_uuid_match.offset,
arg->set_uuid_match.match_len,
arg->set_uuid_match.match_val);
btc_ble_mesh_rpr_server_cb(&cb, ESP_BLE_MESH_RPR_SERVER_SET_UUID_MATCH_COMP_EVT);
break;
default:
break;
}
btc_ble_mesh_rpr_server_arg_deep_free(msg);
}
void btc_ble_mesh_rpr_server_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_rpr_server_cb_param_t *arg = NULL;

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -64,6 +64,11 @@ void bt_mesh_rpr_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
struct bt_mesh_msg_ctx *ctx,
const void *val, size_t len);
typedef enum {
BTC_BLE_MESH_ACT_RPR_SRV_SET_UUID_MATCH,
BTC_BLE_MESH_ACT_RPR_SRV_MAX,
} btc_ble_mesh_rpr_server_act_t;
typedef enum {
BTC_BLE_MESH_EVT_RPR_SERVER_SCAN_START,
BTC_BLE_MESH_EVT_RPR_SERVER_SCAN_STOP,
@ -72,9 +77,22 @@ typedef enum {
BTC_BLE_MESH_EVT_RPR_SERVER_LINK_OPEN,
BTC_BLE_MESH_EVT_RPR_SERVER_LINK_CLOSE,
BTC_BLE_MESH_EVT_RPR_SERVER_PROV_COMP,
BTC_BLE_MESH_EVT_RPR_SERVER_SET_UUID_MATCH_COMP,
BTC_BLE_MESH_EVT_RPR_SERVER_MAX,
} btc_ble_mesh_rpr_server_evt_t;
typedef union {
struct {
uint8_t *match_val;
uint8_t match_len;
uint8_t offset;
} set_uuid_match;
} btc_ble_mesh_rpr_server_args_t;
void btc_ble_mesh_rpr_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_rpr_server_arg_deep_free(btc_msg_t *msg);
void btc_ble_mesh_rpr_server_call_handler(btc_msg_t *msg);
void btc_ble_mesh_rpr_server_cb_handler(btc_msg_t *msg);
void bt_mesh_rpr_server_cb_evt_to_btc(uint8_t event, const void *val, size_t len);