Merge branch 'feat/ble_mesh_v1.1_feat_disable_support_v5.2' into 'release/v5.2'

feat(ble_mesh): esp ble mesh v1.1 features enable/disable supported (v5.2)

See merge request espressif/esp-idf!33778
This commit is contained in:
Island
2024-10-10 19:09:58 +08:00
27 changed files with 845 additions and 308 deletions

View File

@ -46,12 +46,20 @@ set(ble_mesh_include_dirs
"esp_ble_mesh/api/core/include" "esp_ble_mesh/api/core/include"
"esp_ble_mesh/api/models/include" "esp_ble_mesh/api/models/include"
"esp_ble_mesh/api" "esp_ble_mesh/api"
)
set(ble_mesh_v11_include_dirs
"esp_ble_mesh/lib/include" "esp_ble_mesh/lib/include"
"esp_ble_mesh/v1.1/api/core/include" "esp_ble_mesh/v1.1/api/core/include"
"esp_ble_mesh/v1.1/api/models/include" "esp_ble_mesh/v1.1/api/models/include"
"esp_ble_mesh/v1.1/btc/include" "esp_ble_mesh/v1.1/btc/include"
) )
if(CONFIG_IDF_DOC_BUILD)
list(APPEND ble_mesh_include_dirs
${ble_mesh_v11_include_dirs})
endif()
set(bluedroid_include_dirs host/bluedroid/api/include/api) set(bluedroid_include_dirs host/bluedroid/api/include/api)
if(CONFIG_BT_CONTROLLER_ENABLED OR CONFIG_IDF_DOC_BUILD) if(CONFIG_BT_CONTROLLER_ENABLED OR CONFIG_IDF_DOC_BUILD)
@ -533,7 +541,11 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/models/server/server_common.c" "esp_ble_mesh/models/server/server_common.c"
"esp_ble_mesh/models/server/state_binding.c" "esp_ble_mesh/models/server/state_binding.c"
"esp_ble_mesh/models/server/state_transition.c" "esp_ble_mesh/models/server/state_transition.c"
"esp_ble_mesh/models/server/time_scene_server.c" "esp_ble_mesh/models/server/time_scene_server.c")
if(CONFIG_BLE_MESH_V11_SUPPORT)
list(APPEND include_dirs ${ble_mesh_v11_include_dirs})
list(APPEND srcs
"esp_ble_mesh/v1.1/api/core/esp_ble_mesh_agg_model_api.c" "esp_ble_mesh/v1.1/api/core/esp_ble_mesh_agg_model_api.c"
"esp_ble_mesh/v1.1/api/core/esp_ble_mesh_brc_model_api.c" "esp_ble_mesh/v1.1/api/core/esp_ble_mesh_brc_model_api.c"
"esp_ble_mesh/v1.1/api/core/esp_ble_mesh_cm_data_api.c" "esp_ble_mesh/v1.1/api/core/esp_ble_mesh_cm_data_api.c"
@ -556,12 +568,15 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/v1.1/btc/btc_ble_mesh_sar_model.c" "esp_ble_mesh/v1.1/btc/btc_ble_mesh_sar_model.c"
"esp_ble_mesh/v1.1/btc/btc_ble_mesh_srpl_model.c" "esp_ble_mesh/v1.1/btc/btc_ble_mesh_srpl_model.c"
"esp_ble_mesh/lib/ext.c") "esp_ble_mesh/lib/ext.c")
if(CONFIG_BLE_MESH_SAR_ENHANCEMENT) if(CONFIG_BLE_MESH_SAR_ENHANCEMENT)
list(APPEND srcs "esp_ble_mesh/core/transport.enh.c") list(APPEND srcs "esp_ble_mesh/core/transport.enh.c")
else() else()
list(APPEND srcs "esp_ble_mesh/core/transport.c") list(APPEND srcs "esp_ble_mesh/core/transport.c")
endif() endif()
else()
list(APPEND srcs
"esp_ble_mesh/core/transport.c")
endif()
endif() endif()
@ -881,7 +896,7 @@ if(CONFIG_BT_ENABLED)
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
endif() endif()
if(CONFIG_BLE_MESH) if(CONFIG_BLE_MESH_V11_SUPPORT)
if(CONFIG_IDF_TARGET_ESP32) if(CONFIG_IDF_TARGET_ESP32)
add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32/libble_mesh.a") add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32/libble_mesh.a")
target_link_libraries(${COMPONENT_LIB} PRIVATE ble_mesh) target_link_libraries(${COMPONENT_LIB} PRIVATE ble_mesh)

View File

@ -69,6 +69,12 @@
#include "btc_ble_mesh_prov.h" #include "btc_ble_mesh_prov.h"
#include "btc_ble_mesh_health_model.h" #include "btc_ble_mesh_health_model.h"
#include "btc_ble_mesh_config_model.h" #include "btc_ble_mesh_config_model.h"
#include "btc_ble_mesh_generic_model.h"
#include "btc_ble_mesh_lighting_model.h"
#include "btc_ble_mesh_sensor_model.h"
#include "btc_ble_mesh_time_scene_model.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "btc_ble_mesh_mbt_model.h"
#include "btc_ble_mesh_agg_model.h" #include "btc_ble_mesh_agg_model.h"
#include "btc_ble_mesh_brc_model.h" #include "btc_ble_mesh_brc_model.h"
#include "btc_ble_mesh_df_model.h" #include "btc_ble_mesh_df_model.h"
@ -78,11 +84,7 @@
#include "btc_ble_mesh_rpr_model.h" #include "btc_ble_mesh_rpr_model.h"
#include "btc_ble_mesh_sar_model.h" #include "btc_ble_mesh_sar_model.h"
#include "btc_ble_mesh_srpl_model.h" #include "btc_ble_mesh_srpl_model.h"
#include "btc_ble_mesh_generic_model.h" #endif /* CONFIG_BLE_MESH_V11_SUPPORT */
#include "btc_ble_mesh_lighting_model.h"
#include "btc_ble_mesh_sensor_model.h"
#include "btc_ble_mesh_time_scene_model.h"
#include "btc_ble_mesh_mbt_model.h"
#endif /* #if CONFIG_BLE_MESH */ #endif /* #if CONFIG_BLE_MESH */
#define BTC_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE) #define BTC_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE)

View File

@ -6,6 +6,12 @@ if BLE_MESH
help help
It is a temporary solution and needs further modifications. It is a temporary solution and needs further modifications.
config BLE_MESH_V11_SUPPORT
bool "Support ESP BLE Mesh v1.1 features (Preview)"
default y
help
Support BLE Mesh v1.1 features
config BLE_MESH_RANDOM_ADV_INTERVAL config BLE_MESH_RANDOM_ADV_INTERVAL
bool "Support using random adv interval for mesh packets" bool "Support using random adv interval for mesh packets"
select BT_BLE_HIGH_DUTY_ADV_INTERVAL if BT_BLUEDROID_ENABLED select BT_BLE_HIGH_DUTY_ADV_INTERVAL if BT_BLUEDROID_ENABLED
@ -33,6 +39,7 @@ if BLE_MESH
config BLE_MESH_ACTIVE_SCAN config BLE_MESH_ACTIVE_SCAN
bool "Support Active Scan in BLE Mesh" bool "Support Active Scan in BLE Mesh"
depends on BLE_MESH_V11_SUPPORT
help help
Enable this option to allow using BLE Active Scan for BLE Mesh. Enable this option to allow using BLE Active Scan for BLE Mesh.
@ -282,6 +289,7 @@ if BLE_MESH
config BLE_MESH_PROV_EPA config BLE_MESH_PROV_EPA
bool "BLE Mesh enhanced provisioning authentication" bool "BLE Mesh enhanced provisioning authentication"
depends on BLE_MESH_PROV depends on BLE_MESH_PROV
depends on BLE_MESH_V11_SUPPORT
default y default y
help help
Enable this option to support BLE Mesh enhanced provisioning authentication Enable this option to support BLE Mesh enhanced provisioning authentication
@ -291,6 +299,7 @@ if BLE_MESH
config BLE_MESH_CERT_BASED_PROV config BLE_MESH_CERT_BASED_PROV
bool "Support Certificate-based provisioning" bool "Support Certificate-based provisioning"
depends on BLE_MESH_PROV depends on BLE_MESH_PROV
depends on BLE_MESH_V11_SUPPORT
default n default n
help help
Enable this option to support BLE Mesh Certificate-Based Provisioning. Enable this option to support BLE Mesh Certificate-Based Provisioning.
@ -391,6 +400,7 @@ if BLE_MESH
config BLE_MESH_PROXY_SOLIC_PDU_RX config BLE_MESH_PROXY_SOLIC_PDU_RX
bool "Support receiving Proxy Solicitation PDU" bool "Support receiving Proxy Solicitation PDU"
depends on BLE_MESH_GATT_PROXY_SERVER depends on BLE_MESH_GATT_PROXY_SERVER
depends on BLE_MESH_V11_SUPPORT
help help
Enable this option to support receiving Proxy Solicitation PDU. Enable this option to support receiving Proxy Solicitation PDU.
@ -418,6 +428,7 @@ if BLE_MESH
config BLE_MESH_PROXY_SOLIC_PDU_TX config BLE_MESH_PROXY_SOLIC_PDU_TX
bool "Support sending Proxy Solicitation PDU" bool "Support sending Proxy Solicitation PDU"
depends on BLE_MESH_GATT_PROXY_CLIENT depends on BLE_MESH_GATT_PROXY_CLIENT
depends on BLE_MESH_V11_SUPPORT
help help
Enable this option to support sending Proxy Solicitation PDU. Enable this option to support sending Proxy Solicitation PDU.
@ -704,6 +715,7 @@ if BLE_MESH
to perform the IV index recovery procedure. to perform the IV index recovery procedure.
config BLE_MESH_SAR_ENHANCEMENT config BLE_MESH_SAR_ENHANCEMENT
depends on BLE_MESH_V11_SUPPORT
bool "Segmentation and reassembly enhancement" bool "Segmentation and reassembly enhancement"
default n default n
help help
@ -1103,6 +1115,8 @@ if BLE_MESH
help help
Enable support for Health Server model. Enable support for Health Server model.
if BLE_MESH_V11_SUPPORT
config BLE_MESH_BRC_CLI config BLE_MESH_BRC_CLI
bool "Bridge Configuration Client model" bool "Bridge Configuration Client model"
help help
@ -1351,6 +1365,8 @@ if BLE_MESH
endif # BLE_MESH_DF_SRV endif # BLE_MESH_DF_SRV
endif # BLE_MESH_V11_SUPPORT
endmenu #Support for BLE Mesh Foundation models endmenu #Support for BLE Mesh Foundation models
menu "Support for BLE Mesh Client/Server models" menu "Support for BLE Mesh Client/Server models"
@ -1466,6 +1482,7 @@ if BLE_MESH
config BLE_MESH_MBT_CLI config BLE_MESH_MBT_CLI
bool "BLOB Transfer Client model" bool "BLOB Transfer Client model"
depends on BLE_MESH_V11_SUPPORT
default n default n
help help
Enable support for BLOB Transfer Client model. Enable support for BLOB Transfer Client model.
@ -1484,6 +1501,7 @@ if BLE_MESH
config BLE_MESH_MBT_SRV config BLE_MESH_MBT_SRV
bool "BLOB Transfer Server model" bool "BLOB Transfer Server model"
depends on BLE_MESH_V11_SUPPORT
default n default n
help help
Enable support for BLOB Transfer Server model. Enable support for BLOB Transfer Server model.

View File

@ -10,11 +10,13 @@
#include "btc_ble_mesh_prov.h" #include "btc_ble_mesh_prov.h"
#include "btc_ble_mesh_config_model.h" #include "btc_ble_mesh_config_model.h"
#include "btc_ble_mesh_health_model.h" #include "btc_ble_mesh_health_model.h"
#include "btc_ble_mesh_prb_model.h"
#include "btc_ble_mesh_generic_model.h" #include "btc_ble_mesh_generic_model.h"
#include "btc_ble_mesh_time_scene_model.h" #include "btc_ble_mesh_time_scene_model.h"
#include "btc_ble_mesh_sensor_model.h" #include "btc_ble_mesh_sensor_model.h"
#include "btc_ble_mesh_lighting_model.h" #include "btc_ble_mesh_lighting_model.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "btc_ble_mesh_prb_model.h"
#include "btc_ble_mesh_brc_model.h" #include "btc_ble_mesh_brc_model.h"
#include "btc_ble_mesh_odp_model.h" #include "btc_ble_mesh_odp_model.h"
#include "btc_ble_mesh_srpl_model.h" #include "btc_ble_mesh_srpl_model.h"
@ -24,6 +26,8 @@
#include "btc_ble_mesh_rpr_model.h" #include "btc_ble_mesh_rpr_model.h"
#include "btc_ble_mesh_df_model.h" #include "btc_ble_mesh_df_model.h"
#include "btc_ble_mesh_mbt_model.h" #include "btc_ble_mesh_mbt_model.h"
#include "mesh_v1.1/utils.h"
#endif /* CONFIG_BLE_MESH_V11_SUPPORT */
#include "adv.h" #include "adv.h"
#include "mesh/kernel.h" #include "mesh/kernel.h"
@ -65,8 +69,6 @@
#include "mesh/state_binding.h" #include "mesh/state_binding.h"
#include "local.h" #include "local.h"
#include "mesh_v1.1/utils.h"
#include "esp_ble_mesh_common_api.h" #include "esp_ble_mesh_common_api.h"
#include "esp_ble_mesh_provisioning_api.h" #include "esp_ble_mesh_provisioning_api.h"
#include "esp_ble_mesh_networking_api.h" #include "esp_ble_mesh_networking_api.h"

View File

@ -2,7 +2,7 @@
/* /*
* SPDX-FileCopyrightText: 2017 Intel Corporation * SPDX-FileCopyrightText: 2017 Intel Corporation
* SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileContributor: 2018-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -11,6 +11,7 @@
#include <errno.h> #include <errno.h>
#include "mesh.h" #include "mesh.h"
#include "tag.h"
#include "adv.h" #include "adv.h"
#include "lpn.h" #include "lpn.h"
#include "friend.h" #include "friend.h"
@ -22,7 +23,9 @@
#include "fast_prov.h" #include "fast_prov.h"
#include "pvnr_mgmt.h" #include "pvnr_mgmt.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#define BLE_MESH_SDU_MAX_LEN 384 #define BLE_MESH_SDU_MAX_LEN 384
@ -814,6 +817,135 @@ static bool ready_to_send(uint16_t dst)
return false; return false;
} }
#if !CONFIG_BLE_MESH_V11_SUPPORT
static bool use_friend_cred(uint16_t net_idx, uint16_t dst)
{
/* Currently LPN only supports using NetKey in bt_mesh.sub[0] */
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) &&
net_idx == 0 &&
bt_mesh_lpn_match(dst)) {
return true;
}
if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND) &&
bt_mesh_friend_match(net_idx, dst)) {
return true;
}
return false;
}
bool bt_mesh_valid_security_cred(struct bt_mesh_net_tx *tx)
{
/* If the message is tagged with immutable-credentials,
* then the security credentials shall not be changed
* in lower layers.
* If not, later a better security credentials could be
* chosen for the message.
*/
if (!bt_mesh_tag_immutable_cred(tx->ctx->send_tag)) {
return true;
}
if (tx->ctx->send_cred > BLE_MESH_FRIENDSHIP_CRED) {
return false;
}
if (tx->ctx->send_cred == BLE_MESH_FRIENDSHIP_CRED &&
!use_friend_cred(tx->ctx->net_idx, tx->ctx->addr)) {
return false;
}
return true;
}
void bt_mesh_choose_better_security_cred(struct bt_mesh_net_tx *tx)
{
uint8_t send_cred = 0U;
uint8_t send_tag = 0U;
uint16_t net_idx = 0U;
uint16_t addr = 0U;
send_cred = tx->ctx->send_cred;
send_tag = tx->ctx->send_tag;
net_idx = tx->ctx->net_idx;
addr = tx->ctx->addr;
/* If the message is tagged with immutable-credentials,
* then the security credentials shall not be changed.
*/
if (bt_mesh_tag_immutable_cred(send_tag)) {
return;
}
if (send_cred > BLE_MESH_FRIENDSHIP_CRED) {
BT_INFO("Use managed flooding security credentials");
tx->ctx->send_cred = BLE_MESH_FLOODING_CRED;
return;
}
if (send_cred == BLE_MESH_FRIENDSHIP_CRED) {
if (!use_friend_cred(net_idx, addr)) {
BT_INFO("Use managed flooding security credentials");
tx->ctx->send_cred = BLE_MESH_FLOODING_CRED;
tx->ctx->send_tag = send_tag | BLE_MESH_TAG_IMMUTABLE_CRED;
} else {
/* TODO:
* For LPN, do we need to change the friendship security
* credentials to managed flooding credentials?
* If changed, this could increase the possibility that
* the corresponding Friend node receives this message.
*/
}
return;
}
/* If the message is destinated to a LPN, the following could be
* introduced to send the message with the friendship credentials.
*
* For LPN, this optimization should not be introduced, since it
* may cause the message failed to received by the Friend node,
* using friendship credentials will make the message can not be
* relayed by other mesh nodes.
*/
if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND) &&
BLE_MESH_ADDR_IS_UNICAST(addr) &&
bt_mesh_friend_match(net_idx, addr)) {
BT_INFO("Use friendship security credentials");
tx->ctx->send_cred = BLE_MESH_FRIENDSHIP_CRED;
tx->ctx->send_tag = send_tag | BLE_MESH_TAG_IMMUTABLE_CRED;
return;
}
/**
* Spec 3.7.3.1
* The Low power node in friendship should use friendship security
* material.
*
* But in Spec 3.6.6.2
* Depending on the value of the Publish Friendship Credentials Flag
* (see Section 4.2.3.4), the Low Power node model publishes messages
* using either the friendship security credentials or the managed
* flooding security credentials (see Section 3.9.6.3.1).
*
* So use the BLE_MESH_TAG_IMMUTABLE_CRED to indicate that the
* credentials of the message should not be changed when the
* message is sent by model publishing, even though the spec
* didn't require this flag to be set when model publishing.
*/
#if CONFIG_BLE_MESH_LOW_POWER
if (BLE_MESH_ADDR_IS_UNICAST(addr) &&
bt_mesh.lpn.frnd == addr &&
!bt_mesh_tag_immutable_cred(send_tag)) {
tx->ctx->send_cred = BLE_MESH_FRIENDSHIP_CRED;
tx->ctx->send_tag = send_tag | BLE_MESH_TAG_IMMUTABLE_CRED;
return;
}
#endif
}
#endif /* !CONFIG_BLE_MESH_V11_SUPPORT */
static int model_send(struct bt_mesh_model *model, static int model_send(struct bt_mesh_model *model,
struct bt_mesh_net_tx *tx, bool implicit_bind, struct bt_mesh_net_tx *tx, bool implicit_bind,
struct net_buf_simple *msg, struct net_buf_simple *msg,
@ -1108,11 +1240,13 @@ size_t bt_mesh_rx_devkey_size(void)
#if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER #if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER
if (bt_mesh_is_provisioned()) { if (bt_mesh_is_provisioned()) {
size = 1; size = 1;
#if CONFIG_BLE_MESH_RPR_SRV
if (bt_mesh_dev_key_ca_valid()) { if (bt_mesh_dev_key_ca_valid()) {
size += 1; size += 1;
} }
#endif /* CONFIG_BLE_MESH_RPR_SRV */
} }
#endif #endif /* CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER */
#if !CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER #if !CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (bt_mesh_is_provisioner_en()) { if (bt_mesh_is_provisioner_en()) {
@ -1122,9 +1256,11 @@ size_t bt_mesh_rx_devkey_size(void)
#if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER #if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
size = 1; size = 1;
#if CONFIG_BLE_MESH_RPR_SRV
if (bt_mesh_dev_key_ca_valid()) { if (bt_mesh_dev_key_ca_valid()) {
size += 1; size += 1;
} }
#endif /* CONFIG_BLE_MESH_RPR_SRV */
if (bt_mesh_is_provisioner_en()) { if (bt_mesh_is_provisioner_en()) {
size += 1; size += 1;
} }
@ -1156,7 +1292,9 @@ const uint8_t *bt_mesh_rx_devkey_get(size_t index, uint16_t src)
#if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER #if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (index == 0) { if (index == 0) {
key = bt_mesh.dev_key; key = bt_mesh.dev_key;
} else if (index == 1 && bt_mesh_dev_key_ca_valid()) { } else
#if CONFIG_BLE_MESH_RPR_SRV
if (index == 1 && bt_mesh_dev_key_ca_valid()) {
/* If index == 1, there are two cases. /* If index == 1, there are two cases.
* 1. bt_mesh_dev_key_ca_valid() is true, it should be return bt_mesh.dev_key_ca. * 1. bt_mesh_dev_key_ca_valid() is true, it should be return bt_mesh.dev_key_ca.
* 2. bt_mesh_is_provisioner_en() is true, it should be return bt_mesh_provisioner_dev_key_get(src). * 2. bt_mesh_is_provisioner_en() is true, it should be return bt_mesh_provisioner_dev_key_get(src).
@ -1166,7 +1304,9 @@ const uint8_t *bt_mesh_rx_devkey_get(size_t index, uint16_t src)
* Then this round of function bt_mesh_rx_devkey_get(2, src) will return bt_mesh_provisioner_dev_key_get(src). * Then this round of function bt_mesh_rx_devkey_get(2, src) will return bt_mesh_provisioner_dev_key_get(src).
*/ */
key = bt_mesh.dev_key_ca; key = bt_mesh.dev_key_ca;
} else { } else
#endif
{
key = bt_mesh_provisioner_dev_key_get(src); key = bt_mesh_provisioner_dev_key_get(src);
} }
#endif #endif

View File

@ -2,7 +2,7 @@
/* /*
* SPDX-FileCopyrightText: 2017 Intel Corporation * SPDX-FileCopyrightText: 2017 Intel Corporation
* SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileContributor: 2018-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -25,7 +25,9 @@
#include "pvnr_mgmt.h" #include "pvnr_mgmt.h"
#include "mesh/common.h" #include "mesh/common.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#if defined(CONFIG_BLE_MESH_UNPROVISIONED_BEACON_INTERVAL) #if defined(CONFIG_BLE_MESH_UNPROVISIONED_BEACON_INTERVAL)
#define UNPROV_BEACON_INTERVAL K_SECONDS(CONFIG_BLE_MESH_UNPROVISIONED_BEACON_INTERVAL) #define UNPROV_BEACON_INTERVAL K_SECONDS(CONFIG_BLE_MESH_UNPROVISIONED_BEACON_INTERVAL)
@ -472,12 +474,13 @@ void bt_mesh_beacon_recv(struct net_buf_simple *buf, int8_t rssi)
bt_mesh_provisioner_unprov_beacon_recv(buf, rssi); bt_mesh_provisioner_unprov_beacon_recv(buf, rssi);
} }
if (IS_ENABLED(CONFIG_BLE_MESH_RPR_SRV) && #if CONFIG_BLE_MESH_RPR_SRV
bt_mesh_is_provisioned()) { if (bt_mesh_is_provisioned()) {
const bt_mesh_addr_t *addr = bt_mesh_get_unprov_dev_addr(); const bt_mesh_addr_t *addr = bt_mesh_get_unprov_dev_addr();
bt_mesh_unprov_dev_fifo_enqueue(buf->data, addr->val, bt_mesh_get_adv_type()); 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); bt_mesh_rpr_srv_unprov_beacon_recv(buf, bt_mesh_get_adv_type(), addr, rssi);
} }
#endif
break; break;
case BEACON_TYPE_SECURE: case BEACON_TYPE_SECURE:
secure_beacon_recv(buf); secure_beacon_recv(buf);

View File

@ -32,7 +32,9 @@
#include "net.h" #include "net.h"
#include "beacon.h" #include "beacon.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
struct bt_mesh_dev bt_mesh_dev; struct bt_mesh_dev bt_mesh_dev;

View File

@ -2,7 +2,7 @@
/* /*
* SPDX-FileCopyrightText: 2017 Intel Corporation * SPDX-FileCopyrightText: 2017 Intel Corporation
* SPDX-FileContributor: 2018-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileContributor: 2018-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -30,7 +30,9 @@
#include "mesh/common.h" #include "mesh/common.h"
#include "heartbeat.h" #include "heartbeat.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#define DEFAULT_TTL 7 #define DEFAULT_TTL 7
@ -38,6 +40,158 @@ static struct bt_mesh_cfg_srv *conf;
static struct label labels[CONFIG_BLE_MESH_LABEL_COUNT]; static struct label labels[CONFIG_BLE_MESH_LABEL_COUNT];
#if !CONFIG_BLE_MESH_V11_SUPPORT
const void *comp_0;
static uint8_t bt_mesh_comp_page_check(uint8_t page, bool largest)
{
/* If the page doesn't exist, TWO situations currently:
* 1. For Composition Data Get:
* With the Page field set to the largest page number of
* the Composition Data that the node supports and that is
* less than the Page field value of the received Config
* Composition Data Get message;
* 2. For Large Composition Data Get:
* The Page field shall be set to the largest page number
* of the Composition Data that the node supports.
*/
ARG_UNUSED(largest);
if (page != 0) {
BT_WARN("Composition Data Page %d not exists", page);
}
return 0;
}
static inline uint16_t get_comp_elem_size(struct bt_mesh_elem *elem)
{
return (4 + elem->model_count * 2 + elem->vnd_model_count * 4);
}
static uint16_t get_comp_data_size(const struct bt_mesh_comp *comp)
{
uint16_t size = 10; /* CID + PID + VID + CRPL + Features */
for (int i = 0; i < comp->elem_count; i++) {
size += get_comp_elem_size(&(comp->elem[i]));
}
return size;
}
static void get_comp_data(struct net_buf_simple *buf,
const struct bt_mesh_comp *comp,
bool full_element)
{
struct bt_mesh_model *model = NULL;
struct bt_mesh_elem *elem = NULL;
uint16_t feat = 0;
if (IS_ENABLED(CONFIG_BLE_MESH_RELAY)) {
feat |= BLE_MESH_FEAT_RELAY;
}
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
feat |= BLE_MESH_FEAT_PROXY;
}
if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
feat |= BLE_MESH_FEAT_FRIEND;
}
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER)) {
feat |= BLE_MESH_FEAT_LOW_POWER;
}
net_buf_simple_add_le16(buf, comp->cid);
net_buf_simple_add_le16(buf, comp->pid);
net_buf_simple_add_le16(buf, comp->vid);
net_buf_simple_add_le16(buf, CONFIG_BLE_MESH_CRPL);
net_buf_simple_add_le16(buf, feat);
for (size_t i = 0; i < comp->elem_count; i++) {
elem = &(comp->elem[i]);
/* If "full_element" is true, which means the complete list
* of models within the element needs to fit in the data,
* otherwise the element shall not be reported.
*/
if (full_element &&
net_buf_simple_tailroom(buf) < get_comp_elem_size(elem)) {
return;
}
net_buf_simple_add_le16(buf, elem->loc);
net_buf_simple_add_u8(buf, elem->model_count);
net_buf_simple_add_u8(buf, elem->vnd_model_count);
for (size_t j = 0; j < elem->model_count; j++) {
model = &(elem->models[j]);
net_buf_simple_add_le16(buf, model->id);
}
for (size_t j = 0; j < elem->vnd_model_count; j++) {
model = &(elem->vnd_models[j]);
net_buf_simple_add_le16(buf, model->vnd.company);
net_buf_simple_add_le16(buf, model->vnd.id);
}
}
}
static int fetch_comp_data(struct net_buf_simple *buf,
const struct bt_mesh_comp *comp,
uint8_t page, uint16_t offset,
bool full_element)
{
uint16_t size = get_comp_data_size(comp);
if (offset >= size) {
BT_WARN("Too large offset %d for comp data %d, size %d",
page, offset, size);
return 0;
}
if (net_buf_simple_tailroom(buf) < 10 ||
size - offset > net_buf_simple_tailroom(buf)) {
BT_ERR("Too small buffer for comp data %d, %d, expected %d",
page, buf->size, size - offset);
return -EINVAL;
}
if (offset) {
struct net_buf_simple *pdu = bt_mesh_alloc_buf(size);
if (pdu == NULL) {
BT_ERR("%s, Out of memory", __func__);
return -ENOMEM;
}
get_comp_data(pdu, comp, false);
/* Get part of Composition Data Page 0/128 */
net_buf_simple_add_mem(buf, pdu->data + offset, pdu->len - offset);
bt_mesh_free_buf(pdu);
} else {
get_comp_data(buf, comp, full_element);
}
return 0;
}
static int bt_mesh_get_comp_data(struct net_buf_simple *buf,
uint8_t page, uint16_t offset,
bool full_element)
{
if (page == 0) {
return fetch_comp_data(buf, comp_0, page, offset, full_element);
}
BT_ERR("Invalid Composition Data Page %d", page);
return -EINVAL;
}
#endif /* !CONFIG_BLE_MESH_V11_SUPPORT */
static void comp_data_get(struct bt_mesh_model *model, static void comp_data_get(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf) struct net_buf_simple *buf)
@ -2758,7 +2912,7 @@ static void node_reset(struct bt_mesh_model *model,
bt_mesh_model_msg_init(&msg, OP_NODE_RESET_STATUS); bt_mesh_model_msg_init(&msg, OP_NODE_RESET_STATUS);
/* Send the response first since we wont have any keys left to /* Send the response first since we won't have any keys left to
* send it later. * send it later.
*/ */
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {

View File

@ -22,7 +22,9 @@
#include "mesh/common.h" #include "mesh/common.h"
#include "mesh/adapter.h" #include "mesh/adapter.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#define NET_MIC_LEN(pdu) (((pdu)[1] & 0x80) ? 8 : 4) #define NET_MIC_LEN(pdu) (((pdu)[1] & 0x80) ? 8 : 4)
#define APP_MIC_LEN(aszmic) ((aszmic) ? 8 : 4) #define APP_MIC_LEN(aszmic) ((aszmic) ? 8 : 4)

View File

@ -21,7 +21,9 @@
#include "mesh/common.h" #include "mesh/common.h"
#include "pvnr_mgmt.h" #include "pvnr_mgmt.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#ifdef CONFIG_BLE_MESH_FRIEND #ifdef CONFIG_BLE_MESH_FRIEND

View File

@ -10,6 +10,7 @@
#include <errno.h> #include <errno.h>
#include "crypto.h" #include "crypto.h"
#include "tag.h"
#include "adv.h" #include "adv.h"
#include "scan.h" #include "scan.h"
#include "mesh.h" #include "mesh.h"
@ -23,7 +24,9 @@
#include "mesh/cfg_srv.h" #include "mesh/cfg_srv.h"
#include "heartbeat.h" #include "heartbeat.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#ifdef CONFIG_BLE_MESH_LOW_POWER #ifdef CONFIG_BLE_MESH_LOW_POWER

View File

@ -2,7 +2,7 @@
/* /*
* SPDX-FileCopyrightText: 2017 Intel Corporation * SPDX-FileCopyrightText: 2017 Intel Corporation
* SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileContributor: 2018-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -30,7 +30,9 @@
#include "prov_pvnr.h" #include "prov_pvnr.h"
#include "pvnr_mgmt.h" #include "pvnr_mgmt.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
static bool mesh_init = false; static bool mesh_init = false;
@ -161,9 +163,9 @@ void bt_mesh_node_reset(void)
bt_mesh_clear_seq(); bt_mesh_clear_seq();
bt_mesh_clear_dkca(); bt_mesh_clear_dkca();
bt_mesh_clear_role(); bt_mesh_clear_role();
if (IS_ENABLED(CONFIG_BLE_MESH_DF_SRV)) { #if CONFIG_BLE_MESH_DF_SRV
bt_mesh_clear_all_directed_forwarding_table_data(); bt_mesh_clear_all_directed_forwarding_table_data();
} #endif
} }
memset(bt_mesh.flags, 0, sizeof(bt_mesh.flags)); memset(bt_mesh.flags, 0, sizeof(bt_mesh.flags));
@ -405,12 +407,14 @@ int bt_mesh_init(const struct bt_mesh_prov *prov,
return -EALREADY; return -EALREADY;
} }
#if CONFIG_BLE_MESH_V11_SUPPORT
extern int bt_mesh_v11_ext_init(void); extern int bt_mesh_v11_ext_init(void);
err = bt_mesh_v11_ext_init(); err = bt_mesh_v11_ext_init();
if (err) { if (err) {
BT_ERR("Bluetooth Mesh v1.1 init failed"); BT_ERR("Bluetooth Mesh v1.1 init failed");
return err; return err;
} }
#endif
bt_mesh_mutex_init(); bt_mesh_mutex_init();

View File

@ -11,6 +11,7 @@
#define _MESH_H_ #define _MESH_H_
#include "net.h" #include "net.h"
#include "tag.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -31,7 +31,9 @@
#include "proxy_server.h" #include "proxy_server.h"
#include "pvnr_mgmt.h" #include "pvnr_mgmt.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
/* Minimum valid Mesh Network PDU length. The Network headers /* Minimum valid Mesh Network PDU length. The Network headers
* themselves take up 9 bytes. After that there is a minumum of 1 byte * themselves take up 9 bytes. After that there is a minumum of 1 byte
@ -1019,6 +1021,33 @@ int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct net_buf_simple *buf,
return bt_mesh_net_obfuscate(buf->data, BLE_MESH_NET_IVI_TX, priv); return bt_mesh_net_obfuscate(buf->data, BLE_MESH_NET_IVI_TX, priv);
} }
#if !CONFIG_BLE_MESH_V11_SUPPORT
static void bt_mesh_net_adv_xmit_update(struct bt_mesh_net_tx *tx)
{
/* When transmitting a Network PDU that is tagged as friendship,
* the Advertising Bearer Network Interface shall transmit the
* Network PDU over the advertising bearer only once.
*
* Note: Currently when transmitting a packet with the friendship
* credentials used, the message flow will not reach here. It
* will be enqueued into the friend queue in transport.c, and
* waited to be sent.
*/
if (bt_mesh_tag_friendship(tx->ctx->send_tag)) {
tx->xmit = BLE_MESH_TRANSMIT(0, BLE_MESH_TRANSMIT_INT(bt_mesh_net_transmit_get()));
return;
}
if (bt_mesh_tag_relay(tx->ctx->send_tag)) {
tx->xmit = bt_mesh_relay_retransmit_get();
} else {
tx->xmit = bt_mesh_net_transmit_get();
}
return;
}
#endif /* !CONFIG_BLE_MESH_V11_SUPPORT */
int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf, int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf,
const struct bt_mesh_send_cb *cb, void *cb_data) const struct bt_mesh_send_cb *cb, void *cb_data)
{ {
@ -1418,13 +1447,94 @@ static bool relay_to_adv(enum bt_mesh_net_if net_if)
case BLE_MESH_NET_IF_ADV: case BLE_MESH_NET_IF_ADV:
return (bt_mesh_relay_get() == BLE_MESH_RELAY_ENABLED); return (bt_mesh_relay_get() == BLE_MESH_RELAY_ENABLED);
case BLE_MESH_NET_IF_PROXY: case BLE_MESH_NET_IF_PROXY:
return (bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED || return (bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED
bt_mesh_private_gatt_proxy_state_get() == BLE_MESH_PRIVATE_GATT_PROXY_ENABLED); #if CONFIG_BLE_MESH_PRB_SRV
|| bt_mesh_private_gatt_proxy_state_get() == BLE_MESH_PRIVATE_GATT_PROXY_ENABLED
#endif
);
default: default:
return false; return false;
} }
} }
#if !CONFIG_BLE_MESH_V11_SUPPORT
static uint8_t net_retransmission_adv(struct bt_mesh_net_rx *rx,
uint8_t *cred, uint8_t *tag)
{
if (rx->ctx.recv_cred == BLE_MESH_FLOODING_CRED) {
uint8_t bearer = BLE_MESH_NONE_BEARER;
/* Inbound bearer: ADV;
* Inbound Security Material: managed flooding;
*/
/* Condition: Relay is enabled. */
if (IS_ENABLED(CONFIG_BLE_MESH_RELAY) &&
bt_mesh_relay_get() == BLE_MESH_RELAY_ENABLED) {
bearer |= BLE_MESH_ADV_BEARER;
*cred = BLE_MESH_FLOODING_CRED;
/* Additional action: Tag as relay */
*tag |= BLE_MESH_TAG_RELAY;
}
/* Condition: Proxy is enabled. */
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) &&
bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED) {
bearer |= BLE_MESH_GATT_BEARER;
*cred = BLE_MESH_FLOODING_CRED;
}
return bearer;
}
if (rx->ctx.recv_cred == BLE_MESH_FRIENDSHIP_CRED &&
IS_ENABLED(CONFIG_BLE_MESH_FRIEND) &&
bt_mesh_friend_get() == BLE_MESH_FRIEND_ENABLED) {
/* Condition: Directed friend is disabled. */
*cred = BLE_MESH_FLOODING_CRED;
return BLE_MESH_ALL_BEARERS;
}
return BLE_MESH_NONE_BEARER;
}
static uint8_t net_retransmission_gatt(struct bt_mesh_net_rx *rx,
uint8_t *cred, uint8_t *tag)
{
if (rx->ctx.recv_cred == BLE_MESH_FLOODING_CRED) {
/* Inbound bearer: GATT;
* Inbound Security Material: managed flooding;
* Condition: Proxy is enabled;
*/
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) &&
bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED) {
/* Condition: Directed proxy is disabled. */
*cred = BLE_MESH_FLOODING_CRED;
return BLE_MESH_ALL_BEARERS;
}
return BLE_MESH_NONE_BEARER;
}
return BLE_MESH_NONE_BEARER;
}
static uint8_t bt_mesh_net_retrans_match(struct bt_mesh_net_rx *rx,
uint8_t *cred, uint8_t *tag)
{
if (rx->net_if == BLE_MESH_NET_IF_ADV) {
return net_retransmission_adv(rx, cred, tag);
}
if (rx->net_if == BLE_MESH_NET_IF_PROXY) {
return net_retransmission_gatt(rx, cred, tag);
}
return BLE_MESH_NONE_BEARER;
}
#endif /* !CONFIG_BLE_MESH_V11_SUPPORT */
static void bt_mesh_net_relay(struct net_buf_simple *sbuf, static void bt_mesh_net_relay(struct net_buf_simple *sbuf,
struct bt_mesh_net_rx *rx) struct bt_mesh_net_rx *rx)
{ {
@ -1621,7 +1731,9 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf,
(bearer & BLE_MESH_GATT_BEARER) && (bearer & BLE_MESH_GATT_BEARER) &&
((bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED && ((bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED &&
cred != BLE_MESH_FRIENDSHIP_CRED) || cred != BLE_MESH_FRIENDSHIP_CRED) ||
#if CONFIG_BLE_MESH_PRB_SRV
bt_mesh_private_gatt_proxy_state_get() == BLE_MESH_PRIVATE_GATT_PROXY_ENABLED || bt_mesh_private_gatt_proxy_state_get() == BLE_MESH_PRIVATE_GATT_PROXY_ENABLED ||
#endif
rx->net_if == BLE_MESH_NET_IF_LOCAL || rx->net_if == BLE_MESH_NET_IF_LOCAL ||
rx->ctx.recv_cred == BLE_MESH_FRIENDSHIP_CRED)) { rx->ctx.recv_cred == BLE_MESH_FRIENDSHIP_CRED)) {
if (bt_mesh_proxy_server_relay(&buf->b, rx->ctx.recv_dst) && if (bt_mesh_proxy_server_relay(&buf->b, rx->ctx.recv_dst) &&
@ -1819,7 +1931,9 @@ void bt_mesh_net_recv(struct net_buf_simple *data, int8_t rssi,
bt_mesh_elem_find(rx.ctx.recv_dst)); bt_mesh_elem_find(rx.ctx.recv_dst));
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) && if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) &&
#if CONFIG_BLE_MESH_PRB_SRV
bt_mesh_private_gatt_proxy_state_get() != BLE_MESH_PRIVATE_GATT_PROXY_ENABLED && bt_mesh_private_gatt_proxy_state_get() != BLE_MESH_PRIVATE_GATT_PROXY_ENABLED &&
#endif
net_if == BLE_MESH_NET_IF_PROXY) { net_if == BLE_MESH_NET_IF_PROXY) {
bt_mesh_proxy_server_addr_add(data, rx.ctx.addr); bt_mesh_proxy_server_addr_add(data, rx.ctx.addr);

View File

@ -17,7 +17,9 @@
#include "mesh/timer.h" #include "mesh/timer.h"
#include "mesh/adapter.h" #include "mesh/adapter.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -22,7 +22,9 @@
#include "prov_common.h" #include "prov_common.h"
#include "prov_node.h" #include "prov_node.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#if CONFIG_BLE_MESH_NODE #if CONFIG_BLE_MESH_NODE

View File

@ -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 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -22,7 +22,9 @@
#include "prov_pvnr.h" #include "prov_pvnr.h"
#include "pvnr_mgmt.h" #include "pvnr_mgmt.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#if CONFIG_BLE_MESH_PROVISIONER #if CONFIG_BLE_MESH_PROVISIONER
@ -1413,7 +1415,7 @@ static int prov_auth(struct bt_mesh_prov_link *link,
return -EINVAL; return -EINVAL;
} }
/* Provisioner ouput number/string and wait for device's Provisioning Input Complete PDU */ /* Provisioner output number/string and wait for device's Provisioning Input Complete PDU */
link->expect = PROV_INPUT_COMPLETE; link->expect = PROV_INPUT_COMPLETE;
/* NOTE: The Bluetooth SIG recommends that mesh implementations enforce a randomly /* NOTE: The Bluetooth SIG recommends that mesh implementations enforce a randomly

View File

@ -21,7 +21,9 @@
#include "pvnr_mgmt.h" #include "pvnr_mgmt.h"
#include "mesh/adapter.h" #include "mesh/adapter.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \ #if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT CONFIG_BLE_MESH_GATT_PROXY_CLIENT

View File

@ -11,7 +11,9 @@
#include "mesh/adapter.h" #include "mesh/adapter.h"
#include "prov_common.h" #include "prov_common.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -22,7 +22,9 @@
#include "prov_common.h" #include "prov_common.h"
#include "prov_node.h" #include "prov_node.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \ #if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_SERVER CONFIG_BLE_MESH_GATT_PROXY_SERVER

View File

@ -22,7 +22,9 @@
#include "prov_pvnr.h" #include "prov_pvnr.h"
#include "pvnr_mgmt.h" #include "pvnr_mgmt.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#if CONFIG_BLE_MESH_PROVISIONER #if CONFIG_BLE_MESH_PROVISIONER

View File

@ -2,7 +2,7 @@
/* /*
* SPDX-FileCopyrightText: 2017 Intel Corporation * SPDX-FileCopyrightText: 2017 Intel Corporation
* SPDX-FileContributor: 2020-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileContributor: 2020-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -27,7 +27,9 @@
#include "prov_pvnr.h" #include "prov_pvnr.h"
#include "mesh/adapter.h" #include "mesh/adapter.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
/* Scan Window and Interval are equal for continuous scanning */ /* Scan Window and Interval are equal for continuous scanning */
#define SCAN_INTERVAL 0x20 #define SCAN_INTERVAL 0x20
@ -263,12 +265,13 @@ static void handle_adv_service_data(struct net_buf_simple *buf,
bt_mesh_provisioner_prov_adv_recv(buf, addr, rssi); bt_mesh_provisioner_prov_adv_recv(buf, addr, rssi);
} }
if (IS_ENABLED(CONFIG_BLE_MESH_RPR_SRV) && #if CONFIG_BLE_MESH_RPR_SRV
bt_mesh_is_provisioned()) { if (bt_mesh_is_provisioned()) {
const bt_mesh_addr_t *addr = bt_mesh_get_unprov_dev_addr(); const bt_mesh_addr_t *addr = bt_mesh_get_unprov_dev_addr();
bt_mesh_unprov_dev_fifo_enqueue(buf->data, addr->val, bt_mesh_get_adv_type()); 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); bt_mesh_rpr_srv_unprov_beacon_recv(buf, bt_mesh_get_adv_type(), addr, rssi);
} }
#endif
break; break;
#endif #endif
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT #if CONFIG_BLE_MESH_GATT_PROXY_CLIENT

View File

@ -22,7 +22,9 @@
#include "pvnr_mgmt.h" #include "pvnr_mgmt.h"
#include "prov_pvnr.h" #include "prov_pvnr.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
/* BLE Mesh NVS Key and corresponding data struct. /* BLE Mesh NVS Key and corresponding data struct.
* Note: The length of nvs key must be <= 15. * Note: The length of nvs key must be <= 15.

View File

@ -0,0 +1,53 @@
/*
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BLE_MESH_v11_TAG_H_
#define _BLE_MESH_v11_TAG_H_
#include <stdint.h>
#include <stdbool.h>
#include "mesh.h"
#ifdef __cplusplus
extern "C" {
#endif
#if !CONFIG_BLE_MESH_V11_SUPPORT
/* TAG - additional metadata */
#define BLE_MESH_TAG_SEND_SEGMENTED BIT(0)
#define BLE_MESH_TAG_IMMUTABLE_CRED BIT(1)
#define BLE_MESH_TAG_RELAY BIT(3)
#define BLE_MESH_TAG_FRIENDSHIP BIT(4)
static inline bool bt_mesh_tag_send_segmented(uint8_t tag)
{
return (tag & BLE_MESH_TAG_SEND_SEGMENTED);
}
static inline bool bt_mesh_tag_immutable_cred(uint8_t tag)
{
return (tag & BLE_MESH_TAG_IMMUTABLE_CRED);
}
static inline bool bt_mesh_tag_relay(uint8_t tag)
{
return (tag & BLE_MESH_TAG_RELAY);
}
static inline bool bt_mesh_tag_friendship(uint8_t tag)
{
return (tag & BLE_MESH_TAG_FRIENDSHIP);
}
#endif /* !CONFIG_BLE_MESH_V11_SUPPORT */
#ifdef __cplusplus
}
#endif
#endif /* _BLE_MESH_v11_TAG_H_ */

View File

@ -11,6 +11,7 @@
#include <errno.h> #include <errno.h>
#include "crypto.h" #include "crypto.h"
#include "tag.h"
#include "adv.h" #include "adv.h"
#include "mesh.h" #include "mesh.h"
#include "lpn.h" #include "lpn.h"
@ -26,7 +27,9 @@
#include "mesh/cfg_srv.h" #include "mesh/cfg_srv.h"
#include "heartbeat.h" #include "heartbeat.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
/* The transport layer needs at least three buffers for itself to avoid /* The transport layer needs at least three buffers for itself to avoid
* deadlocks. Ensure that there are a sufficient number of advertising * deadlocks. Ensure that there are a sufficient number of advertising
@ -1039,7 +1042,7 @@ static int ctl_recv(struct bt_mesh_net_rx *rx, uint8_t hdr,
return 0; return 0;
} }
if (IS_ENABLED(CONFIG_BLE_MESH_DF_SRV)) { #if CONFIG_BLE_MESH_DF_SRV
switch (ctl_op) { switch (ctl_op) {
case TRANS_CTL_OP_PATH_REQ: case TRANS_CTL_OP_PATH_REQ:
case TRANS_CTL_OP_PATH_REPLY: case TRANS_CTL_OP_PATH_REPLY:
@ -1050,7 +1053,7 @@ static int ctl_recv(struct bt_mesh_net_rx *rx, uint8_t hdr,
case TRANS_CTL_OP_PATH_REQ_SOLIC: case TRANS_CTL_OP_PATH_REQ_SOLIC:
return bt_mesh_directed_forwarding_ctl_recv(ctl_op, rx, buf); return bt_mesh_directed_forwarding_ctl_recv(ctl_op, rx, buf);
} }
} #endif
if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND) && !bt_mesh_lpn_established()) { if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND) && !bt_mesh_lpn_established()) {
switch (ctl_op) { switch (ctl_op) {
@ -1759,8 +1762,6 @@ void bt_mesh_trans_init(void)
{ {
int i; int i;
bt_mesh_sar_init();
for (i = 0; i < ARRAY_SIZE(seg_tx); i++) { for (i = 0; i < ARRAY_SIZE(seg_tx); i++) {
k_delayed_work_init(&seg_tx[i].rtx_timer, seg_retransmit); k_delayed_work_init(&seg_tx[i].rtx_timer, seg_retransmit);
} }

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@ -14,7 +14,9 @@
#include "mesh/client_common.h" #include "mesh/client_common.h"
#include "mesh/common.h" #include "mesh/common.h"
#if CONFIG_BLE_MESH_V11_SUPPORT
#include "mesh_v1.1/utils.h" #include "mesh_v1.1/utils.h"
#endif
#define HCI_TIME_FOR_START_ADV K_MSEC(5) /* Three adv related hci commands may take 4 ~ 5ms */ #define HCI_TIME_FOR_START_ADV K_MSEC(5) /* Three adv related hci commands may take 4 ~ 5ms */