diff --git a/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c b/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c index 2a1ffbd3f3..904790dbcc 100644 --- a/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c +++ b/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c @@ -1959,17 +1959,20 @@ int bt_mesh_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], } #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) -int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info) +int bt_mesh_update_exceptional_list(uint8_t sub_code, uint32_t type, void *info) { BD_ADDR value = {0}; - if ((sub_code > BLE_MESH_EXCEP_LIST_CLEAN) || - (type > BLE_MESH_EXCEP_INFO_MESH_PROXY_ADV)) { + if ((sub_code > BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN) || + (sub_code < BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN && + type > BLE_MESH_EXCEP_LIST_TYPE_MESH_PROXY_ADV) || + (sub_code == BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN && + !(type & BLE_MESH_EXCEP_LIST_CLEAN_ALL_LIST))) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } - if (type == BLE_MESH_EXCEP_INFO_MESH_LINK_ID) { + if (type == BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID) { if (!info) { BT_ERR("Invalid Provisioning Link ID"); return -EINVAL; @@ -1977,7 +1980,7 @@ int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info) sys_memcpy_swap(value, info, sizeof(uint32_t)); } - BT_DBG("%s exceptional list, type 0x%02x", sub_code ? "Remove" : "Add", type); + BT_DBG("%s exceptional list, type 0x%08x", sub_code ? "Remove" : "Add", type); /* The parameter "device_info" can't be NULL in the API */ BLE_MESH_BTM_CHECK_STATUS(BTM_UpdateBleDuplicateExceptionalList(sub_code, type, value, NULL)); diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h index 0174c32741..7bd95c78e0 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h @@ -776,29 +776,28 @@ int bt_mesh_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], uint8_t enc_data[16]); enum { - BLE_MESH_EXCEP_LIST_ADD = 0, - BLE_MESH_EXCEP_LIST_REMOVE, - BLE_MESH_EXCEP_LIST_CLEAN, + BLE_MESH_EXCEP_LIST_SUB_CODE_ADD = 0, + BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE, + BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN, }; enum { - BLE_MESH_EXCEP_INFO_ADV_ADDR = 0, - BLE_MESH_EXCEP_INFO_MESH_LINK_ID, - BLE_MESH_EXCEP_INFO_MESH_BEACON, - BLE_MESH_EXCEP_INFO_MESH_PROV_ADV, - BLE_MESH_EXCEP_INFO_MESH_PROXY_ADV, + BLE_MESH_EXCEP_LIST_TYPE_ADV_ADDR = 0, + BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID, + BLE_MESH_EXCEP_LIST_TYPE_MESH_BEACON, + BLE_MESH_EXCEP_LIST_TYPE_MESH_PROV_ADV, + BLE_MESH_EXCEP_LIST_TYPE_MESH_PROXY_ADV, }; -enum { - BLE_MESH_EXCEP_CLEAN_ADDR_LIST = BIT(0), - BLE_MESH_EXCEP_CLEAN_MESH_LINK_ID_LIST = BIT(1), - BLE_MESH_EXCEP_CLEAN_MESH_BEACON_LIST = BIT(2), - BLE_MESH_EXCEP_CLEAN_MESH_PROV_ADV_LIST = BIT(3), - BLE_MESH_EXCEP_CLEAN_MESH_PROXY_ADV_LIST = BIT(4), - BLE_MESH_EXCEP_CLEAN_ALL_LIST = 0xFFFF, -}; +#define BLE_MESH_EXCEP_LIST_CLEAN_ADDR_LIST BIT(0) +#define BLE_MESH_EXCEP_LIST_CLEAN_MESH_LINK_ID_LIST BIT(1) +#define BLE_MESH_EXCEP_LIST_CLEAN_MESH_BEACON_LIST BIT(2) +#define BLE_MESH_EXCEP_LIST_CLEAN_MESH_PROV_ADV_LIST BIT(3) +#define BLE_MESH_EXCEP_LIST_CLEAN_MESH_PROXY_ADV_LIST BIT(4) +#define BLE_MESH_EXCEP_LIST_CLEAN_ALL_LIST (BIT(0) | BIT(1) | \ + BIT(2) | BIT(3) | BIT(4)) -int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info); +int bt_mesh_update_exceptional_list(uint8_t sub_code, uint32_t type, void *info); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_core/main.c b/components/bt/esp_ble_mesh/mesh_core/main.c index 01bebb04be..a0a1b83813 100644 --- a/components/bt/esp_ble_mesh/mesh_core/main.c +++ b/components/bt/esp_ble_mesh/mesh_core/main.c @@ -613,14 +613,14 @@ int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers) #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) if (IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) && (bearers & BLE_MESH_PROV_ADV)) { - bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, - BLE_MESH_EXCEP_INFO_MESH_BEACON, NULL); + bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD, + BLE_MESH_EXCEP_LIST_TYPE_MESH_BEACON, NULL); } if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && (bearers & BLE_MESH_PROV_GATT)) { - bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, - BLE_MESH_EXCEP_INFO_MESH_PROV_ADV, NULL); + bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD, + BLE_MESH_EXCEP_LIST_TYPE_MESH_PROV_ADV, NULL); } #endif @@ -668,8 +668,8 @@ int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers) (bearers & BLE_MESH_PROV_GATT)) { bt_mesh_proxy_client_prov_disable(); #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) - bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE, - BLE_MESH_EXCEP_INFO_MESH_PROV_ADV, NULL); + bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE, + BLE_MESH_EXCEP_LIST_TYPE_MESH_PROV_ADV, NULL); #endif } @@ -680,8 +680,8 @@ int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers) #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) if (IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) && (enable & BLE_MESH_PROV_ADV)) { - bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE, - BLE_MESH_EXCEP_INFO_MESH_BEACON, NULL); + bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE, + BLE_MESH_EXCEP_LIST_TYPE_MESH_BEACON, NULL); } #endif diff --git a/components/bt/esp_ble_mesh/mesh_core/net.c b/components/bt/esp_ble_mesh/mesh_core/net.c index 26adf5ce3f..d202b6db2f 100644 --- a/components/bt/esp_ble_mesh/mesh_core/net.c +++ b/components/bt/esp_ble_mesh/mesh_core/net.c @@ -1550,8 +1550,8 @@ void bt_mesh_net_start(void) #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) /* Add Mesh beacon type (Secure Network Beacon) to the exceptional list */ - bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, - BLE_MESH_EXCEP_INFO_MESH_BEACON, NULL); + bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD, + BLE_MESH_EXCEP_LIST_TYPE_MESH_BEACON, NULL); #endif if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER)) { diff --git a/components/bt/esp_ble_mesh/mesh_core/prov.c b/components/bt/esp_ble_mesh/mesh_core/prov.c index c18c6949cf..29c3973152 100644 --- a/components/bt/esp_ble_mesh/mesh_core/prov.c +++ b/components/bt/esp_ble_mesh/mesh_core/prov.c @@ -311,8 +311,8 @@ static void reset_adv_link(void) #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) /* Remove the link id from exceptional list */ - bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE, - BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id); + bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE, + BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID, &link.id); #endif reset_state(); @@ -1380,8 +1380,8 @@ static void link_open(struct prov_rx *rx, struct net_buf_simple *buf) #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) /* Add the link id into exceptional list */ - bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, - BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id); + bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD, + BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID, &link.id); #endif bearer_ctl_send(LINK_ACK, NULL, 0); @@ -1837,8 +1837,8 @@ int bt_mesh_prov_deinit(void) k_delayed_work_free(&link.tx.retransmit); #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) /* Remove the link id from exceptional list */ - bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE, - BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id); + bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE, + BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID, &link.id); #endif /* CONFIG_BLE_MESH_USE_DUPLICATE_SCAN */ #endif /* CONFIG_BLE_MESH_PB_ADV */ diff --git a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c index 60ac6c2f03..9f039132d0 100644 --- a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c +++ b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c @@ -1318,8 +1318,8 @@ static void reset_link(const uint8_t idx, uint8_t reason) #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) /* Remove the link id from exceptional list */ - bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE, - BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link[idx].link_id); + bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE, + BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID, &link[idx].link_id); #endif /* Clear everything except the retransmit delayed work config */ @@ -1478,8 +1478,8 @@ static void send_link_open(const uint8_t idx) #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) /* Add the link id into exceptional list */ - bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, - BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link[idx].link_id); + bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD, + BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID, &link[idx].link_id); #endif bearer_ctl_send(idx, LINK_OPEN, link[idx].uuid, 16); @@ -3338,8 +3338,8 @@ int bt_mesh_provisioner_prov_reset(bool erase) #if CONFIG_BLE_MESH_PB_ADV prov_clear_tx(i); #if CONFIG_BLE_MESH_USE_DUPLICATE_SCAN - bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE, - BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link[i].link_id); + bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE, + BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID, &link[i].link_id); #endif memset(&link[i], 0, offsetof(struct prov_link, tx.retransmit)); link[i].pending_ack = XACT_NVAL; diff --git a/components/bt/esp_ble_mesh/mesh_core/proxy_client.c b/components/bt/esp_ble_mesh/mesh_core/proxy_client.c index 588ba74ab0..8241c0c902 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_client.c +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_client.c @@ -983,8 +983,8 @@ int bt_mesh_proxy_client_init(void) bt_mesh_gattc_conn_cb_register(&conn_callbacks); #if CONFIG_BLE_MESH_USE_DUPLICATE_SCAN && CONFIG_BLE_MESH_GATT_PROXY_CLIENT - bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, - BLE_MESH_EXCEP_INFO_MESH_PROXY_ADV, NULL); + bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD, + BLE_MESH_EXCEP_LIST_TYPE_MESH_PROXY_ADV, NULL); #endif return 0; diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_register_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_register_cmd.c index 5abde9e8fc..a59bc51fcc 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_register_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_register_cmd.c @@ -696,7 +696,7 @@ int ble_mesh_node_enable_bearer(int argc, char **argv) int ble_mesh_exceptional_list_test(int argc, char **argv) { esp_err_t err = ESP_FAIL; - uint32_t type = BLE_MESH_EXCEP_INFO_MESH_BEACON; + uint32_t type = BLE_MESH_EXCEP_LIST_TYPE_MESH_BEACON; uint8_t *info = NULL; int nerrors = arg_parse(argc, argv, (void **) &exceptional_list_test); @@ -718,11 +718,11 @@ int ble_mesh_exceptional_list_test(int argc, char **argv) } if (strcmp(exceptional_list_test.action_type->sval[0], "add") == 0) { - err = bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, type, info); + err = bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD, type, info); } else if (strcmp(exceptional_list_test.action_type->sval[0], "remove") == 0) { - err = bt_mesh_update_exceptional_list( BLE_MESH_EXCEP_LIST_REMOVE, type, info); + err = bt_mesh_update_exceptional_list( BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE, type, info); } else if (strcmp(exceptional_list_test.action_type->sval[0], "clean") == 0) { - err = bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_CLEAN, type, NULL); + err = bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN, type, NULL); } if (err == ESP_OK) {