mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'mesh_v1.1_idf' into 'master'
feat(ble_mesh): Support Bluetooth Mesh Protocol v1.1 (Preview) See merge request espressif/esp-idf!25605
This commit is contained in:
commit
2bc1f2f574
@ -372,25 +372,29 @@ if(CONFIG_BT_ENABLED)
|
||||
list(APPEND srcs "common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c")
|
||||
|
||||
if(CONFIG_BLE_MESH)
|
||||
list(APPEND srcs "esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c")
|
||||
list(APPEND srcs "esp_ble_mesh/core/bluedroid_host/adapter.c")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLE_MESH)
|
||||
list(APPEND include_dirs
|
||||
"esp_ble_mesh/mesh_common/include"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/include"
|
||||
"esp_ble_mesh/mesh_core"
|
||||
"esp_ble_mesh/mesh_core/include"
|
||||
"esp_ble_mesh/mesh_core/storage"
|
||||
"esp_ble_mesh/common/include"
|
||||
"esp_ble_mesh/common/tinycrypt/include"
|
||||
"esp_ble_mesh/core"
|
||||
"esp_ble_mesh/core/include"
|
||||
"esp_ble_mesh/core/storage"
|
||||
"esp_ble_mesh/btc/include"
|
||||
"esp_ble_mesh/mesh_models/common/include"
|
||||
"esp_ble_mesh/mesh_models/client/include"
|
||||
"esp_ble_mesh/mesh_models/server/include"
|
||||
"esp_ble_mesh/models/common/include"
|
||||
"esp_ble_mesh/models/client/include"
|
||||
"esp_ble_mesh/models/server/include"
|
||||
"esp_ble_mesh/api/core/include"
|
||||
"esp_ble_mesh/api/models/include"
|
||||
"esp_ble_mesh/api")
|
||||
"esp_ble_mesh/api"
|
||||
"esp_ble_mesh/v1.1/api/core/include"
|
||||
"esp_ble_mesh/v1.1/api/models/include"
|
||||
"esp_ble_mesh/v1.1/btc/include"
|
||||
"esp_ble_mesh/v1.1/include")
|
||||
|
||||
list(APPEND srcs "esp_ble_mesh/api/core/esp_ble_mesh_ble_api.c"
|
||||
"esp_ble_mesh/api/core/esp_ble_mesh_common_api.c"
|
||||
@ -413,66 +417,91 @@ if(CONFIG_BT_ENABLED)
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_prov.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/aes_decrypt.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/aes_encrypt.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/cbc_mode.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ccm_mode.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/cmac_mode.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ctr_mode.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ctr_prng.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dh.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dsa.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_platform_specific.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/hmac_prng.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/hmac.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/sha256.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/utils.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_atomic.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_buf.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_common.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_kernel.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_mutex.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_timer.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_util.c"
|
||||
"esp_ble_mesh/mesh_core/storage/settings_nvs.c"
|
||||
"esp_ble_mesh/mesh_core/access.c"
|
||||
"esp_ble_mesh/mesh_core/adv.c"
|
||||
"esp_ble_mesh/mesh_core/beacon.c"
|
||||
"esp_ble_mesh/mesh_core/cfg_cli.c"
|
||||
"esp_ble_mesh/mesh_core/cfg_srv.c"
|
||||
"esp_ble_mesh/mesh_core/crypto.c"
|
||||
"esp_ble_mesh/mesh_core/fast_prov.c"
|
||||
"esp_ble_mesh/mesh_core/friend.c"
|
||||
"esp_ble_mesh/mesh_core/health_cli.c"
|
||||
"esp_ble_mesh/mesh_core/health_srv.c"
|
||||
"esp_ble_mesh/mesh_core/local_operation.c"
|
||||
"esp_ble_mesh/mesh_core/lpn.c"
|
||||
"esp_ble_mesh/mesh_core/main.c"
|
||||
"esp_ble_mesh/mesh_core/net.c"
|
||||
"esp_ble_mesh/mesh_core/prov.c"
|
||||
"esp_ble_mesh/mesh_core/provisioner_main.c"
|
||||
"esp_ble_mesh/mesh_core/provisioner_prov.c"
|
||||
"esp_ble_mesh/mesh_core/proxy_client.c"
|
||||
"esp_ble_mesh/mesh_core/proxy_server.c"
|
||||
"esp_ble_mesh/mesh_core/settings_uid.c"
|
||||
"esp_ble_mesh/mesh_core/settings.c"
|
||||
"esp_ble_mesh/mesh_core/scan.c"
|
||||
"esp_ble_mesh/mesh_core/test.c"
|
||||
"esp_ble_mesh/mesh_core/transport.c"
|
||||
"esp_ble_mesh/mesh_models/common/device_property.c"
|
||||
"esp_ble_mesh/mesh_models/client/client_common.c"
|
||||
"esp_ble_mesh/mesh_models/client/generic_client.c"
|
||||
"esp_ble_mesh/mesh_models/client/lighting_client.c"
|
||||
"esp_ble_mesh/mesh_models/client/sensor_client.c"
|
||||
"esp_ble_mesh/mesh_models/client/time_scene_client.c"
|
||||
"esp_ble_mesh/mesh_models/server/generic_server.c"
|
||||
"esp_ble_mesh/mesh_models/server/lighting_server.c"
|
||||
"esp_ble_mesh/mesh_models/server/sensor_server.c"
|
||||
"esp_ble_mesh/mesh_models/server/server_common.c"
|
||||
"esp_ble_mesh/mesh_models/server/state_binding.c"
|
||||
"esp_ble_mesh/mesh_models/server/state_transition.c"
|
||||
"esp_ble_mesh/mesh_models/server/time_scene_server.c")
|
||||
"esp_ble_mesh/common/tinycrypt/src/aes_decrypt.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/aes_encrypt.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/cbc_mode.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/ccm_mode.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/cmac_mode.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/ctr_mode.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/ctr_prng.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/ecc_dh.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/ecc_dsa.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/ecc_platform_specific.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/ecc.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/hmac_prng.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/hmac.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/sha256.c"
|
||||
"esp_ble_mesh/common/tinycrypt/src/utils.c"
|
||||
"esp_ble_mesh/common/atomic.c"
|
||||
"esp_ble_mesh/common/buf.c"
|
||||
"esp_ble_mesh/common/common.c"
|
||||
"esp_ble_mesh/common/kernel.c"
|
||||
"esp_ble_mesh/common/mutex.c"
|
||||
"esp_ble_mesh/common/timer.c"
|
||||
"esp_ble_mesh/common/utils.c"
|
||||
"esp_ble_mesh/core/storage/settings_nvs.c"
|
||||
"esp_ble_mesh/core/storage/settings_uid.c"
|
||||
"esp_ble_mesh/core/storage/settings.c"
|
||||
"esp_ble_mesh/core/access.c"
|
||||
"esp_ble_mesh/core/adv.c"
|
||||
"esp_ble_mesh/core/beacon.c"
|
||||
"esp_ble_mesh/core/cfg_cli.c"
|
||||
"esp_ble_mesh/core/cfg_srv.c"
|
||||
"esp_ble_mesh/core/crypto.c"
|
||||
"esp_ble_mesh/core/fast_prov.c"
|
||||
"esp_ble_mesh/core/friend.c"
|
||||
"esp_ble_mesh/core/health_cli.c"
|
||||
"esp_ble_mesh/core/health_srv.c"
|
||||
"esp_ble_mesh/core/local.c"
|
||||
"esp_ble_mesh/core/lpn.c"
|
||||
"esp_ble_mesh/core/main.c"
|
||||
"esp_ble_mesh/core/net.c"
|
||||
"esp_ble_mesh/core/prov_common.c"
|
||||
"esp_ble_mesh/core/prov_node.c"
|
||||
"esp_ble_mesh/core/prov_pvnr.c"
|
||||
"esp_ble_mesh/core/proxy_client.c"
|
||||
"esp_ble_mesh/core/proxy_server.c"
|
||||
"esp_ble_mesh/core/pvnr_mgmt.c"
|
||||
"esp_ble_mesh/core/rpl.c"
|
||||
"esp_ble_mesh/core/scan.c"
|
||||
"esp_ble_mesh/core/test.c"
|
||||
"esp_ble_mesh/core/transport.c"
|
||||
"esp_ble_mesh/models/common/device_property.c"
|
||||
"esp_ble_mesh/models/common/model_common.c"
|
||||
"esp_ble_mesh/models/client/client_common.c"
|
||||
"esp_ble_mesh/models/client/generic_client.c"
|
||||
"esp_ble_mesh/models/client/lighting_client.c"
|
||||
"esp_ble_mesh/models/client/sensor_client.c"
|
||||
"esp_ble_mesh/models/client/time_scene_client.c"
|
||||
"esp_ble_mesh/models/server/generic_server.c"
|
||||
"esp_ble_mesh/models/server/lighting_server.c"
|
||||
"esp_ble_mesh/models/server/sensor_server.c"
|
||||
"esp_ble_mesh/models/server/server_common.c"
|
||||
"esp_ble_mesh/models/server/state_binding.c"
|
||||
"esp_ble_mesh/models/server/state_transition.c"
|
||||
"esp_ble_mesh/models/server/time_scene_server.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_cm_data_api.c"
|
||||
"esp_ble_mesh/v1.1/api/core/esp_ble_mesh_df_model_api.c"
|
||||
"esp_ble_mesh/v1.1/api/core/esp_ble_mesh_lcd_model_api.c"
|
||||
"esp_ble_mesh/v1.1/api/core/esp_ble_mesh_odp_model_api.c"
|
||||
"esp_ble_mesh/v1.1/api/core/esp_ble_mesh_prb_model_api.c"
|
||||
"esp_ble_mesh/v1.1/api/core/esp_ble_mesh_rpr_model_api.c"
|
||||
"esp_ble_mesh/v1.1/api/core/esp_ble_mesh_sar_model_api.c"
|
||||
"esp_ble_mesh/v1.1/api/core/esp_ble_mesh_srpl_model_api.c"
|
||||
"esp_ble_mesh/v1.1/api/models/esp_ble_mesh_mbt_model_api.c"
|
||||
"esp_ble_mesh/v1.1/btc/btc_ble_mesh_agg_model.c"
|
||||
"esp_ble_mesh/v1.1/btc/btc_ble_mesh_brc_model.c"
|
||||
"esp_ble_mesh/v1.1/btc/btc_ble_mesh_df_model.c"
|
||||
"esp_ble_mesh/v1.1/btc/btc_ble_mesh_lcd_model.c"
|
||||
"esp_ble_mesh/v1.1/btc/btc_ble_mesh_mbt_model.c"
|
||||
"esp_ble_mesh/v1.1/btc/btc_ble_mesh_odp_model.c"
|
||||
"esp_ble_mesh/v1.1/btc/btc_ble_mesh_prb_model.c"
|
||||
"esp_ble_mesh/v1.1/btc/btc_ble_mesh_rpr_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/ext.c")
|
||||
endif()
|
||||
|
||||
|
||||
@ -645,7 +674,7 @@ if(CONFIG_BT_ENABLED)
|
||||
"common/btc/profile/esp/blufi/nimble_host/esp_blufi.c")
|
||||
|
||||
if(CONFIG_BLE_MESH)
|
||||
list(APPEND srcs "esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c")
|
||||
list(APPEND srcs "esp_ble_mesh/core/nimble_host/adapter.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_BT_NIMBLE_MESH)
|
||||
@ -741,6 +770,25 @@ if(CONFIG_BT_ENABLED)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLE_MESH)
|
||||
if(CONFIG_IDF_TARGET_ESP32)
|
||||
add_prebuilt_library(mesh_v11 "esp_ble_mesh/v1.1/lib/esp32/libmesh_v1.1.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE mesh_v11)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32S3)
|
||||
add_prebuilt_library(mesh_v11 "esp_ble_mesh/v1.1/lib/esp32s3/libmesh_v1.1.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE mesh_v11)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C3)
|
||||
add_prebuilt_library(mesh_v11 "esp_ble_mesh/v1.1/lib/esp32c3/libmesh_v1.1.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE mesh_v11)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C6)
|
||||
add_prebuilt_library(mesh_v11 "esp_ble_mesh/v1.1/lib/esp32c6/libmesh_v1.1.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE mesh_v11)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H2)
|
||||
add_prebuilt_library(mesh_v11 "esp_ble_mesh/v1.1/lib/esp32h2/libmesh_v1.1.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE mesh_v11)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_BT_NIMBLE_MESH)
|
||||
set_source_files_properties("host/nimble/nimble/nimble/host/mesh/src/net.c"
|
||||
PROPERTIES COMPILE_FLAGS -Wno-type-limits)
|
||||
|
@ -69,10 +69,20 @@
|
||||
#include "btc_ble_mesh_prov.h"
|
||||
#include "btc_ble_mesh_health_model.h"
|
||||
#include "btc_ble_mesh_config_model.h"
|
||||
#include "btc_ble_mesh_agg_model.h"
|
||||
#include "btc_ble_mesh_brc_model.h"
|
||||
#include "btc_ble_mesh_df_model.h"
|
||||
#include "btc_ble_mesh_lcd_model.h"
|
||||
#include "btc_ble_mesh_odp_model.h"
|
||||
#include "btc_ble_mesh_prb_model.h"
|
||||
#include "btc_ble_mesh_rpr_model.h"
|
||||
#include "btc_ble_mesh_sar_model.h"
|
||||
#include "btc_ble_mesh_srpl_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"
|
||||
#include "btc_ble_mesh_mbt_model.h"
|
||||
#endif /* #if CONFIG_BLE_MESH */
|
||||
|
||||
#define BTC_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE)
|
||||
@ -158,6 +168,60 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
|
||||
[BTC_PID_CONFIG_CLIENT] = {btc_ble_mesh_config_client_call_handler, btc_ble_mesh_config_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_CFG_CLI */
|
||||
[BTC_PID_CONFIG_SERVER] = {NULL, btc_ble_mesh_config_server_cb_handler },
|
||||
#if CONFIG_BLE_MESH_AGG_CLI
|
||||
[BTC_PID_AGG_CLIENT] = {btc_ble_mesh_agg_client_call_handler, btc_ble_mesh_agg_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_AGG_CLI */
|
||||
#if CONFIG_BLE_MESH_AGG_SRV
|
||||
[BTC_PID_AGG_SERVER] = {NULL, btc_ble_mesh_agg_server_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_AGG_SRV */
|
||||
#if CONFIG_BLE_MESH_BRC_CLI
|
||||
[BTC_PID_BRC_CLIENT] = {btc_ble_mesh_brc_client_call_handler, btc_ble_mesh_brc_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_BRC_CLI */
|
||||
#if CONFIG_BLE_MESH_BRC_SRV
|
||||
[BTC_PID_BRC_SERVER] = {NULL, btc_ble_mesh_brc_server_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_BRC_SRV */
|
||||
#if CONFIG_BLE_MESH_DF_CLI
|
||||
[BTC_PID_DF_CLIENT] = {btc_ble_mesh_df_client_call_handler, btc_ble_mesh_df_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_DF_CLI */
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
[BTC_PID_DF_SERVER] = {NULL, btc_ble_mesh_df_server_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_DF_SRV */
|
||||
#if CONFIG_BLE_MESH_LCD_CLI
|
||||
[BTC_PID_LCD_CLIENT] = {btc_ble_mesh_lcd_client_call_handler, btc_ble_mesh_lcd_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_LCD_CLI */
|
||||
#if CONFIG_BLE_MESH_LCD_SRV
|
||||
[BTC_PID_LCD_SERVER] = {NULL, btc_ble_mesh_lcd_server_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_LCD_SRV */
|
||||
#if CONFIG_BLE_MESH_ODP_CLI
|
||||
[BTC_PID_ODP_CLIENT] = {btc_ble_mesh_odp_client_call_handler, btc_ble_mesh_odp_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_ODP_CLI */
|
||||
#if CONFIG_BLE_MESH_ODP_SRV
|
||||
[BTC_PID_ODP_SERVER] = {NULL, btc_ble_mesh_odp_server_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_ODP_SRV */
|
||||
#if CONFIG_BLE_MESH_PRB_CLI
|
||||
[BTC_PID_PRB_CLIENT] = {btc_ble_mesh_prb_client_call_handler, btc_ble_mesh_prb_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_PRB_CLI */
|
||||
#if CONFIG_BLE_MESH_PRB_SRV
|
||||
[BTC_PID_PRB_SERVER] = {NULL, btc_ble_mesh_prb_server_cb_handler },
|
||||
#endif /*CONFIG_BLE_MESH_PRB_SRV*/
|
||||
#if CONFIG_BLE_MESH_RPR_CLI
|
||||
[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 },
|
||||
#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 },
|
||||
#endif /* CONFIG_BLE_MESH_SAR_CLI */
|
||||
#if CONFIG_BLE_MESH_SAR_SRV
|
||||
[BTC_PID_SAR_SERVER] = {NULL, btc_ble_mesh_sar_server_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_SAR_SRV */
|
||||
#if CONFIG_BLE_MESH_SRPL_CLI
|
||||
[BTC_PID_SRPL_CLIENT] = {btc_ble_mesh_srpl_client_call_handler, btc_ble_mesh_srpl_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_SRPL_CLI */
|
||||
#if CONFIG_BLE_MESH_SRPL_SRV
|
||||
[BTC_PID_SRPL_SERVER] = {NULL, btc_ble_mesh_srpl_server_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_SRPL_SRV */
|
||||
#if CONFIG_BLE_MESH_GENERIC_CLIENT
|
||||
[BTC_PID_GENERIC_CLIENT] = {btc_ble_mesh_generic_client_call_handler, btc_ble_mesh_generic_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
|
||||
@ -182,6 +246,12 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
|
||||
#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
|
||||
[BTC_PID_TIME_SCENE_SERVER] = {NULL, btc_ble_mesh_time_scene_server_cb_handler},
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
|
||||
#if CONFIG_BLE_MESH_MBT_CLI
|
||||
[BTC_PID_MBT_CLIENT] = {btc_ble_mesh_mbt_client_call_handler, btc_ble_mesh_mbt_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_MBT_CLI */
|
||||
#if CONFIG_BLE_MESH_MBT_SRV
|
||||
[BTC_PID_MBT_SERVER] = {btc_ble_mesh_mbt_server_call_handler, btc_ble_mesh_mbt_server_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_MBT_SRV */
|
||||
#if CONFIG_BLE_MESH_BLE_COEX_SUPPORT
|
||||
[BTC_PID_BLE_MESH_BLE_COEX] = {btc_ble_mesh_ble_call_handler, btc_ble_mesh_ble_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_BLE_COEX_SUPPORT */
|
||||
|
@ -75,6 +75,24 @@ typedef enum {
|
||||
BTC_PID_HEALTH_SERVER,
|
||||
BTC_PID_CONFIG_CLIENT,
|
||||
BTC_PID_CONFIG_SERVER,
|
||||
BTC_PID_AGG_CLIENT,
|
||||
BTC_PID_AGG_SERVER,
|
||||
BTC_PID_BRC_CLIENT,
|
||||
BTC_PID_BRC_SERVER,
|
||||
BTC_PID_DF_CLIENT,
|
||||
BTC_PID_DF_SERVER,
|
||||
BTC_PID_LCD_CLIENT,
|
||||
BTC_PID_LCD_SERVER,
|
||||
BTC_PID_ODP_CLIENT,
|
||||
BTC_PID_ODP_SERVER,
|
||||
BTC_PID_PRB_CLIENT,
|
||||
BTC_PID_PRB_SERVER,
|
||||
BTC_PID_RPR_CLIENT,
|
||||
BTC_PID_RPR_SERVER,
|
||||
BTC_PID_SAR_CLIENT,
|
||||
BTC_PID_SAR_SERVER,
|
||||
BTC_PID_SRPL_CLIENT,
|
||||
BTC_PID_SRPL_SERVER,
|
||||
BTC_PID_GENERIC_CLIENT,
|
||||
BTC_PID_LIGHTING_CLIENT,
|
||||
BTC_PID_SENSOR_CLIENT,
|
||||
@ -83,6 +101,8 @@ typedef enum {
|
||||
BTC_PID_LIGHTING_SERVER,
|
||||
BTC_PID_SENSOR_SERVER,
|
||||
BTC_PID_TIME_SCENE_SERVER,
|
||||
BTC_PID_MBT_CLIENT,
|
||||
BTC_PID_MBT_SERVER,
|
||||
BTC_PID_BLE_MESH_BLE_COEX,
|
||||
#endif /* CONFIG_BLE_MESH */
|
||||
BTC_PID_NUM,
|
||||
|
@ -21,6 +21,11 @@ if BLE_MESH
|
||||
option in the Bluetooth Controller section in menuconfig, which is
|
||||
"Scan Duplicate By Device Address and Advertising Data".
|
||||
|
||||
config BLE_MESH_ACTIVE_SCAN
|
||||
bool "Support Active Scan in BLE Mesh"
|
||||
help
|
||||
Enable this option to allow using BLE Active Scan for BLE Mesh.
|
||||
|
||||
choice BLE_MESH_MEM_ALLOC_MODE
|
||||
prompt "Memory allocation strategy"
|
||||
default BLE_MESH_MEM_ALLOC_MODE_INTERNAL
|
||||
@ -264,6 +269,31 @@ if BLE_MESH
|
||||
Enable this option to support BLE Mesh Provisioning functionality. For
|
||||
BLE Mesh, this option should be always enabled.
|
||||
|
||||
config BLE_MESH_PROV_EPA
|
||||
bool "BLE Mesh enhanced provisioning authentication"
|
||||
depends on BLE_MESH_PROV
|
||||
default y
|
||||
help
|
||||
Enable this option to support BLE Mesh enhanced provisioning authentication
|
||||
functionality. This option can increase the security level of provisioning.
|
||||
It is recommended to enable this option.
|
||||
|
||||
config BLE_MESH_CERT_BASED_PROV
|
||||
bool "Support Certificate-based provisioning"
|
||||
depends on BLE_MESH_PROV
|
||||
default n
|
||||
help
|
||||
Enable this option to support BLE Mesh Certificate-Based Provisioning.
|
||||
|
||||
config BLE_MESH_RECORD_FRAG_MAX_SIZE
|
||||
int "Maximum size of the provisioning record fragment that Provisioner can receive"
|
||||
depends on BLE_MESH_CERT_BASED_PROV
|
||||
default 56
|
||||
range 1 57
|
||||
help
|
||||
This option sets the maximum size of the provisioning record fragment that the
|
||||
Provisioner can receive. The range depends on provisioning bearer.
|
||||
|
||||
config BLE_MESH_PB_ADV
|
||||
bool "Provisioning support using the advertising bearer (PB-ADV)"
|
||||
select BLE_MESH_PROV
|
||||
@ -338,6 +368,34 @@ if BLE_MESH
|
||||
list of addresses which can be used to decide which messages will be forwarded
|
||||
to the Proxy Client by the Proxy Server.
|
||||
|
||||
config BLE_MESH_PROXY_PRIVACY
|
||||
bool "Support Proxy Privacy"
|
||||
depends on BLE_MESH_PRB_SRV && BLE_MESH_GATT_PROXY_SERVER
|
||||
default y
|
||||
help
|
||||
The Proxy Privacy parameter controls the privacy of the Proxy Server
|
||||
over the connection. The value of the Proxy Privacy parameter is
|
||||
controlled by the type of proxy connection, which is dependent on the
|
||||
bearer used by the proxy connection.
|
||||
|
||||
config BLE_MESH_PROXY_SOLIC_PDU_RX
|
||||
bool "Support receiving Proxy Solicitation PDU"
|
||||
depends on BLE_MESH_GATT_PROXY_SERVER
|
||||
help
|
||||
Enable this option to support receiving Proxy Solicitation PDU.
|
||||
|
||||
config BLE_MESH_PROXY_SOLIC_RX_CRPL
|
||||
int "Maximum capacity of solicitation replay protection list"
|
||||
depends on BLE_MESH_PROXY_SOLIC_PDU_RX
|
||||
default 2
|
||||
range 1 255
|
||||
help
|
||||
This option specifies the maximum capacity of the solicitation replay
|
||||
protection list. The solicitation replay protection list is used to
|
||||
reject Solicitation PDUs that were already processed by a node, which
|
||||
will store the solicitation src and solicitation sequence number of
|
||||
the received Solicitation PDU message.
|
||||
|
||||
config BLE_MESH_GATT_PROXY_CLIENT
|
||||
bool "BLE Mesh GATT Proxy Client"
|
||||
select BLE_MESH_PROXY
|
||||
@ -347,6 +405,25 @@ if BLE_MESH
|
||||
can use the GATT bearer to send mesh messages to a node that supports the
|
||||
advertising bearer.
|
||||
|
||||
config BLE_MESH_PROXY_SOLIC_PDU_TX
|
||||
bool "Support sending Proxy Solicitation PDU"
|
||||
depends on BLE_MESH_GATT_PROXY_CLIENT
|
||||
help
|
||||
Enable this option to support sending Proxy Solicitation PDU.
|
||||
|
||||
config BLE_MESH_PROXY_SOLIC_TX_SRC_COUNT
|
||||
int "Maximum number of SSRC that can be used by Proxy Client"
|
||||
depends on BLE_MESH_PROXY_SOLIC_PDU_TX
|
||||
default 2
|
||||
range 1 16
|
||||
help
|
||||
This option specifies the maximum number of Solicitation Source (SSRC)
|
||||
that can be used by Proxy Client for sending a Solicitation PDU.
|
||||
A Proxy Client may use the primary address or any of the secondary
|
||||
addresses as the SSRC for a Solicitation PDU.
|
||||
So for a Proxy Client, it's better to choose the value based on its
|
||||
own element count.
|
||||
|
||||
config BLE_MESH_NET_BUF_POOL_USAGE
|
||||
bool
|
||||
default y
|
||||
@ -994,6 +1071,244 @@ if BLE_MESH
|
||||
help
|
||||
Enable support for Health Server model.
|
||||
|
||||
config BLE_MESH_BRC_CLI
|
||||
bool "Bridge Configuration Client model"
|
||||
help
|
||||
Enable support for Bridge Configuration Client model.
|
||||
|
||||
config BLE_MESH_BRC_SRV
|
||||
bool "Bridge Configuration Server model"
|
||||
default n
|
||||
help
|
||||
Enable support for Bridge Configuration Server model.
|
||||
|
||||
if BLE_MESH_BRC_SRV
|
||||
|
||||
config BLE_MESH_MAX_BRIDGING_TABLE_ENTRY_COUNT
|
||||
int "Maximum number of Bridging Table entries"
|
||||
range 16 65535
|
||||
default 16
|
||||
help
|
||||
Maximum number of Bridging Table entries that the Bridge Configuration Server can support.
|
||||
|
||||
endif #BLE_MESH_BRC_SRV
|
||||
|
||||
config BLE_MESH_PRB_CLI
|
||||
bool "Mesh Private Beacon Client model"
|
||||
help
|
||||
Enable support for Mesh Private Beacon Client model.
|
||||
|
||||
config BLE_MESH_PRB_SRV
|
||||
bool "Mesh Private Beacon Server model"
|
||||
help
|
||||
Enable support for Mesh Private Beacon Server model.
|
||||
|
||||
config BLE_MESH_ODP_CLI
|
||||
bool "On-Demand Private Proxy Client model"
|
||||
help
|
||||
Enable support for On-Demand Private Proxy Client model.
|
||||
|
||||
config BLE_MESH_ODP_SRV
|
||||
bool "On-Demand Private Proxy Server model"
|
||||
depends on BLE_MESH_PROXY_SOLIC_PDU_RX
|
||||
select BLE_MESH_SRPL_SRV
|
||||
help
|
||||
Enable support for On-Demand Private Proxy Server model.
|
||||
|
||||
config BLE_MESH_SRPL_CLI
|
||||
bool "Solicitation PDU RPL Configuration Client model"
|
||||
help
|
||||
Enable support for Solicitation PDU RPL Configuration Client model.
|
||||
|
||||
config BLE_MESH_SRPL_SRV
|
||||
bool "Solicitation PDU RPL Configuration Server model"
|
||||
depends on BLE_MESH_PROXY_SOLIC_PDU_RX
|
||||
help
|
||||
Enable support for Solicitation PDU RPL Configuration Server model.
|
||||
Note:
|
||||
This option depends on the functionality of receiving Solicitation
|
||||
PDU. If the device doesn't support receiving Solicitation PDU, then
|
||||
there is no need to enable this server model.
|
||||
|
||||
config BLE_MESH_AGG_CLI
|
||||
bool "Opcodes Aggregator Client model"
|
||||
help
|
||||
Enable support for Opcodes Aggregator Client model.
|
||||
|
||||
config BLE_MESH_AGG_SRV
|
||||
bool "Opcodes Aggregator Server model"
|
||||
help
|
||||
Enable support for Opcodes Aggregator Server model.
|
||||
|
||||
config BLE_MESH_SAR_CLI
|
||||
bool "SAR Configuration Client model"
|
||||
help
|
||||
Enable support for SAR Configuration Client model.
|
||||
|
||||
config BLE_MESH_SAR_SRV
|
||||
bool "SAR Configuration Server model"
|
||||
help
|
||||
Enable support for SAR Configuration Server model.
|
||||
|
||||
config BLE_MESH_COMP_DATA_1
|
||||
bool "Support Composition Data Page 1"
|
||||
help
|
||||
Composition Data Page 1 contains information about the relationships
|
||||
among models.
|
||||
Each model either can be a root model or can extend other models.
|
||||
|
||||
config BLE_MESH_COMP_DATA_128
|
||||
bool "Support Composition Data Page 128"
|
||||
help
|
||||
Composition Data Page 128 is used to indicate the structure of
|
||||
elements, features, and models of a node after the successful
|
||||
execution of the Node Address Refresh procedure or the Node
|
||||
Composition Refresh procedure, or after the execution of the
|
||||
Node Removal procedure followed by the provisioning process.
|
||||
Composition Data Page 128 shall be present if the node supports
|
||||
the Remote Provisioning Server model; otherwise it is optional.
|
||||
|
||||
config BLE_MESH_MODELS_METADATA_0
|
||||
bool "Support Models Metadata Page 0"
|
||||
help
|
||||
The Models Metadata state contains metadata of a node’s models.
|
||||
The Models Metadata state is composed of a number of pages of
|
||||
information.
|
||||
Models Metadata Page 0 shall be present if the node supports
|
||||
the Large Composition Data Server model.
|
||||
|
||||
config BLE_MESH_MODELS_METADATA_128
|
||||
bool "Support Models Metadata Page 128"
|
||||
depends on BLE_MESH_MODELS_METADATA_0
|
||||
help
|
||||
The Models Metadata state contains metadata of a node’s models.
|
||||
The Models Metadata state is composed of a number of pages of
|
||||
information.
|
||||
Models Metadata Page 128 contains metadata for the node’s models
|
||||
after the successful execution of the Node Address Refresh
|
||||
procedure or the Node Composition Refresh procedure, or after
|
||||
the execution of the Node Removal procedure followed by the
|
||||
provisioning process.
|
||||
Models Metadata Page 128 shall be present if the node supports
|
||||
the Remote Provisioning Server model and the node supports the
|
||||
Large Composition Data Server model.
|
||||
|
||||
config BLE_MESH_LCD_CLI
|
||||
bool "Large Composition Data Client model"
|
||||
help
|
||||
Enable support for Large Composition Data Client model.
|
||||
|
||||
config BLE_MESH_LCD_SRV
|
||||
bool "Large Composition Data Server model"
|
||||
select BLE_MESH_MODELS_METADATA_0
|
||||
help
|
||||
Enable support for Large Composition Data Server model.
|
||||
|
||||
config BLE_MESH_RPR_CLI
|
||||
bool "Remote Provisioning Client model"
|
||||
depends on BLE_MESH_PROVISIONER
|
||||
select BLE_MESH_PROV
|
||||
help
|
||||
Enable support for Remote Provisioning Client model
|
||||
|
||||
if BLE_MESH_RPR_CLI
|
||||
|
||||
config BLE_MESH_RPR_CLI_PROV_SAME_TIME
|
||||
int "Maximum number of PB-Remote running at the same time by Provisioner"
|
||||
range 1 5
|
||||
default 2
|
||||
help
|
||||
This option specifies how many devices can be provisioned at the same time
|
||||
using PB-REMOTE. For example, if the value is 2, it means a Provisioner can
|
||||
provision two unprovisioned devices with PB-REMOTE at the same time.
|
||||
|
||||
endif # BLE_MESH_RPR_CLI
|
||||
|
||||
config BLE_MESH_RPR_SRV
|
||||
bool "Remote Provisioning Server model"
|
||||
depends on BLE_MESH_NODE
|
||||
select BLE_MESH_PB_ADV
|
||||
help
|
||||
Enable support for Remote Provisioning Server model
|
||||
|
||||
if BLE_MESH_RPR_SRV
|
||||
|
||||
config BLE_MESH_RPR_SRV_MAX_SCANNED_ITEMS
|
||||
int "Maximum number of device information can be scanned"
|
||||
range 4 255
|
||||
default 10
|
||||
help
|
||||
This option specifies how many device information can a Remote
|
||||
Provisioning Server store each time while scanning.
|
||||
|
||||
config BLE_MESH_RPR_SRV_ACTIVE_SCAN
|
||||
bool "Support Active Scan for remote provisioning"
|
||||
select BLE_MESH_ACTIVE_SCAN
|
||||
help
|
||||
Enable this option to support Active Scan for remote provisioning.
|
||||
|
||||
config BLE_MESH_RPR_SRV_MAX_EXT_SCAN
|
||||
int "Maximum number of extended scan procedures"
|
||||
range 1 10
|
||||
default 1
|
||||
help
|
||||
This option specifies how many extended scan procedures can be
|
||||
started by the Remote Provisioning Server.
|
||||
|
||||
endif # BLE_MESH_RPR_SRV
|
||||
|
||||
config BLE_MESH_DF_CLI
|
||||
bool "Directed Forwarding Configuration Client model"
|
||||
help
|
||||
Enable support for Directed Forwarding Configuration Client model.
|
||||
|
||||
config BLE_MESH_DF_SRV
|
||||
bool "Directed Forwarding Configuration Server model"
|
||||
help
|
||||
Enable support for Directed Forwarding Configuration Server model.
|
||||
|
||||
if BLE_MESH_DF_SRV
|
||||
|
||||
config BLE_MESH_MAX_DISC_TABLE_ENTRY_COUNT
|
||||
int "Maximum number of discovery table entries in a given subnet"
|
||||
range 2 255
|
||||
default 2
|
||||
help
|
||||
Maximum number of Discovery Table entries supported by the node in a given subnet.
|
||||
|
||||
config BLE_MESH_MAX_FORWARD_TABLE_ENTRY_COUNT
|
||||
int "Maximum number of forward table entries in a given subnet"
|
||||
range 2 64
|
||||
default 2
|
||||
help
|
||||
Maximum number of Forward Table entries supported by the node in a given subnet.
|
||||
|
||||
config BLE_MESH_MAX_DEPS_NODES_PER_PATH
|
||||
int "Maximum number of dependent nodes per path"
|
||||
range 2 64
|
||||
default 2
|
||||
help
|
||||
Maximum size of dependent nodes list supported by each forward table entry.
|
||||
|
||||
config BLE_MESH_PATH_MONITOR_TEST
|
||||
bool "Enable Path Monitoring test mode"
|
||||
default n
|
||||
help
|
||||
The option only removes the Path Use timer; all other behavior of the
|
||||
device is not changed.
|
||||
If Path Monitoring test mode is going to be used, this option should
|
||||
be enabled.
|
||||
|
||||
if BLE_MESH_GATT_PROXY_SERVER
|
||||
config BLE_MESH_SUPPORT_DIRECTED_PROXY
|
||||
bool "Enable Directed Proxy functionality"
|
||||
default y
|
||||
help
|
||||
Support Directed Proxy functionality.
|
||||
endif
|
||||
|
||||
endif # BLE_MESH_DF_SRV
|
||||
|
||||
endmenu #Support for BLE Mesh Foundation models
|
||||
|
||||
menu "Support for BLE Mesh Client/Server models"
|
||||
@ -1107,6 +1422,30 @@ if BLE_MESH
|
||||
help
|
||||
Enable support for Lighting server models.
|
||||
|
||||
config BLE_MESH_MBT_CLI
|
||||
bool "BLOB Transfer Client model"
|
||||
default y
|
||||
help
|
||||
Enable support for BLOB Transfer Client model.
|
||||
|
||||
if BLE_MESH_MBT_CLI
|
||||
|
||||
config BLE_MESH_MAX_BLOB_RECEIVERS
|
||||
int "Maximum number of simultaneous blob receivers"
|
||||
default 2
|
||||
range 1 255
|
||||
help
|
||||
Maximum number of BLOB Transfer Server models that can participating
|
||||
in the BLOB transfer with a BLOB Transfer Client model.
|
||||
|
||||
endif # BLE_MESH_MBT_CLI
|
||||
|
||||
config BLE_MESH_MBT_SRV
|
||||
bool "BLOB Transfer Server model"
|
||||
default y
|
||||
help
|
||||
Enable support for BLOB Transfer Server model.
|
||||
|
||||
endmenu #Support for BLE Mesh Client/Server models
|
||||
|
||||
config BLE_MESH_IV_UPDATE_TEST
|
||||
|
@ -17,6 +17,7 @@ int32_t esp_ble_mesh_get_model_publish_period(esp_ble_mesh_model_t *model)
|
||||
if (model == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return btc_ble_mesh_model_pub_period_get(model);
|
||||
}
|
||||
|
||||
@ -31,6 +32,7 @@ uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
|
||||
if (model == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return btc_ble_mesh_model_find_group(model, group_addr);
|
||||
}
|
||||
|
||||
@ -39,6 +41,7 @@ esp_ble_mesh_elem_t *esp_ble_mesh_find_element(uint16_t element_addr)
|
||||
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(element_addr)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return btc_ble_mesh_elem_find(element_addr);
|
||||
}
|
||||
|
||||
@ -53,6 +56,7 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *
|
||||
if (element == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return btc_ble_mesh_model_find_vnd(element, company_id, model_id);
|
||||
}
|
||||
|
||||
@ -62,6 +66,7 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *ele
|
||||
if (element == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return btc_ble_mesh_model_find(element, model_id);
|
||||
}
|
||||
|
||||
@ -122,6 +127,15 @@ esp_err_t esp_ble_mesh_model_unsubscribe_group_addr(uint16_t element_addr, uint1
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
esp_err_t esp_ble_mesh_enable_directed_forwarding(uint16_t net_idx, bool directed_forwarding,
|
||||
bool directed_forwarding_relay)
|
||||
{
|
||||
return btc_ble_mesh_enable_directed_forwarding(net_idx, directed_forwarding,
|
||||
directed_forwarding_relay);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DF_SRV */
|
||||
|
||||
#if CONFIG_BLE_MESH_NODE
|
||||
|
||||
const uint8_t *esp_ble_mesh_node_get_local_net_key(uint16_t net_idx)
|
||||
|
@ -35,11 +35,6 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (device_role > ROLE_FAST_PROV) {
|
||||
BT_ERR("Invalid device role 0x%02x", device_role);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* When data is NULL, it is mandatory to set length to 0 to prevent users from misinterpreting parameters. */
|
||||
if (data == NULL) {
|
||||
length = 0;
|
||||
@ -61,9 +56,18 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
}
|
||||
|
||||
if (act == BTC_BLE_MESH_ACT_MODEL_PUBLISH) {
|
||||
mic_len = ESP_BLE_MESH_MIC_SHORT;
|
||||
/* When "send_rel" is true and "send_szmic" is 1, 8-octets TransMIC will
|
||||
* be used, otherwise 4-octets TransMIC will be used.
|
||||
*/
|
||||
mic_len = (model->pub->send_rel && model->pub->send_szmic) ?
|
||||
ESP_BLE_MESH_MIC_LONG : ESP_BLE_MESH_MIC_SHORT;
|
||||
} else {
|
||||
mic_len = ctx->send_rel ? ESP_BLE_MESH_MIC_LONG : ESP_BLE_MESH_MIC_SHORT;
|
||||
/* When the message is tagged with the send-segmented tag and "send_szmic"
|
||||
* is 1, 8-octets TransMIC will be used, otherwise 4-octets TransMIC will
|
||||
* be used.
|
||||
*/
|
||||
mic_len = ((ctx->send_tag & ESP_BLE_MESH_TAG_SEND_SEGMENTED) && ctx->send_szmic) ?
|
||||
ESP_BLE_MESH_MIC_LONG : ESP_BLE_MESH_MIC_SHORT;
|
||||
}
|
||||
|
||||
if (op_len + length + mic_len > MIN(ESP_BLE_MESH_SDU_MAX_LEN, ESP_BLE_MESH_TX_SDU_MAX)) {
|
||||
@ -89,7 +93,6 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
|
||||
if (act == BTC_BLE_MESH_ACT_MODEL_PUBLISH) {
|
||||
arg.model_publish.model = model;
|
||||
arg.model_publish.device_role = device_role;
|
||||
} else {
|
||||
arg.model_send.model = model;
|
||||
arg.model_send.ctx = ctx;
|
||||
@ -97,7 +100,6 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
arg.model_send.opcode = opcode;
|
||||
arg.model_send.length = op_len + length;
|
||||
arg.model_send.data = msg_data;
|
||||
arg.model_send.device_role = device_role;
|
||||
arg.model_send.msg_timeout = msg_timeout;
|
||||
}
|
||||
|
||||
@ -254,8 +256,7 @@ esp_err_t esp_ble_mesh_node_local_reset(void)
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER)
|
||||
|
||||
#if CONFIG_BLE_MESH_PROVISIONER
|
||||
esp_err_t esp_ble_mesh_provisioner_set_node_name(uint16_t index, const char *name)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
@ -312,6 +313,7 @@ esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
|
||||
arg.store_node_comp_data.unicast_addr = unicast_addr;
|
||||
arg.store_node_comp_data.length = length;
|
||||
arg.store_node_comp_data.data = data;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), btc_ble_mesh_prov_arg_deep_copy,
|
||||
btc_ble_mesh_prov_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -414,6 +416,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
|
||||
} else {
|
||||
bzero(arg.add_local_app_key.app_key, 16);
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -437,6 +440,7 @@ esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16
|
||||
memcpy(arg.update_local_app_key.app_key, app_key, 16);
|
||||
arg.update_local_app_key.net_idx = net_idx;
|
||||
arg.update_local_app_key.app_idx = app_idx;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -466,6 +470,7 @@ esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_
|
||||
arg.local_mod_app_bind.app_idx = app_idx;
|
||||
arg.local_mod_app_bind.model_id = model_id;
|
||||
arg.local_mod_app_bind.cid = company_id;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -491,6 +496,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16],
|
||||
} else {
|
||||
bzero(arg.add_local_net_key.net_key, 16);
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -512,13 +518,14 @@ esp_err_t esp_ble_mesh_provisioner_update_local_net_key(const uint8_t net_key[16
|
||||
|
||||
memcpy(arg.update_local_net_key.net_key, net_key, 16);
|
||||
arg.update_local_net_key.net_idx = net_idx;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx)
|
||||
{
|
||||
return bt_mesh_provisioner_local_net_key_get(net_idx);
|
||||
return bt_mesh_provisioner_net_key_get(net_idx);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_PROVISIONER_RECV_HB
|
||||
@ -760,9 +767,85 @@ uint8_t esp_ble_mesh_provisioner_get_free_settings_count(void)
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_USE_MULTIPLE_NAMESPACE */
|
||||
|
||||
#if CONFIG_BLE_MESH_CERT_BASED_PROV
|
||||
esp_err_t esp_ble_mesh_provisioner_send_prov_records_get(uint16_t link_idx)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SEND_PROV_RECORDS_GET;
|
||||
|
||||
arg.send_prov_records_get.link_idx = link_idx;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_send_prov_record_req(uint16_t link_idx, uint16_t record_id,
|
||||
uint16_t frag_offset, uint16_t max_size)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (record_id >= ESP_BLE_MESH_PROV_RECORD_MAX_ID) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SEND_PROV_RECORD_REQUEST;
|
||||
|
||||
arg.send_prov_record_req.link_idx = link_idx;
|
||||
arg.send_prov_record_req.record_id = record_id;
|
||||
arg.send_prov_record_req.frag_offset = frag_offset;
|
||||
arg.send_prov_record_req.max_size = max_size;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_send_prov_invite(uint16_t link_idx)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SEND_PROV_INVITE;
|
||||
|
||||
arg.send_prov_invite.link_idx = link_idx;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_send_link_close(uint16_t link_idx)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SEND_LINK_CLOSE;
|
||||
|
||||
arg.send_link_close.link_idx = link_idx;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_CERT_BASED_PROV */
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
||||
|
||||
#if (CONFIG_BLE_MESH_FAST_PROV)
|
||||
#if CONFIG_BLE_MESH_FAST_PROV
|
||||
const uint8_t *esp_ble_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx)
|
||||
{
|
||||
return bt_mesh_get_fast_prov_app_key(net_idx, app_idx);
|
||||
|
@ -31,13 +31,14 @@ static bool prov_bearers_valid(esp_ble_mesh_prov_bearer_t bearers)
|
||||
{
|
||||
if ((!(bearers & (ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT))) ||
|
||||
(IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
|
||||
!IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
|
||||
!(bearers & ESP_BLE_MESH_PROV_ADV)) ||
|
||||
!IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
|
||||
!(bearers & ESP_BLE_MESH_PROV_ADV)) ||
|
||||
(!IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
|
||||
!(bearers & ESP_BLE_MESH_PROV_GATT))) {
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
|
||||
!(bearers & ESP_BLE_MESH_PROV_GATT))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -141,7 +142,7 @@ esp_err_t esp_ble_mesh_node_input_string(const char *string)
|
||||
msg.act = BTC_BLE_MESH_ACT_INPUT_STRING;
|
||||
memset(arg.input_string.string, 0, sizeof(arg.input_string.string));
|
||||
strncpy(arg.input_string.string, string,
|
||||
MIN(strlen(string), sizeof(arg.input_string.string)));
|
||||
MIN(strlen(string), sizeof(arg.input_string.string)));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
@ -169,7 +170,7 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER)
|
||||
#if CONFIG_BLE_MESH_PROVISIONER
|
||||
esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32],
|
||||
uint8_t pub_key_y[32])
|
||||
{
|
||||
@ -212,7 +213,7 @@ esp_err_t esp_ble_mesh_provisioner_input_string(const char *string, uint8_t link
|
||||
|
||||
memset(arg.provisioner_input_str.string, 0, sizeof(arg.provisioner_input_str.string));
|
||||
strncpy(arg.provisioner_input_str.string, string,
|
||||
MIN(strlen(string), sizeof(arg.provisioner_input_str.string)));
|
||||
MIN(strlen(string), sizeof(arg.provisioner_input_str.string)));
|
||||
arg.provisioner_input_str.link_idx = link_idx;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
@ -305,6 +306,7 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
|
||||
memcpy(arg.provisioner_dev_add.add_dev.addr, add_dev->addr, sizeof(esp_ble_mesh_bd_addr_t));
|
||||
memcpy(arg.provisioner_dev_add.add_dev.uuid, add_dev->uuid, 16);
|
||||
arg.provisioner_dev_add.flags = flags;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -339,6 +341,7 @@ esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16],
|
||||
arg.provisioner_prov_dev_with_addr.bearer = bearer;
|
||||
arg.provisioner_prov_dev_with_addr.oob_info = oob_info;
|
||||
arg.provisioner_prov_dev_with_addr.unicast_addr = unicast_addr;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -366,6 +369,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
|
||||
} else if (del_dev->flag & DEL_DEV_UUID_FLAG) {
|
||||
memcpy(arg.provisioner_dev_del.del_dev.uuid, del_dev->uuid, 16);
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -392,6 +396,7 @@ esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val,
|
||||
arg.set_dev_uuid_match.match_len = match_len;
|
||||
arg.set_dev_uuid_match.offset = offset;
|
||||
arg.set_dev_uuid_match.prov_after_match = prov_after_match;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -420,6 +425,7 @@ esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_inf
|
||||
} else if (prov_data_info->flag & PROV_DATA_IV_INDEX_FLAG) {
|
||||
arg.set_prov_data_info.prov_data.iv_index = prov_data_info->iv_index;
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -441,6 +447,7 @@ esp_err_t esp_ble_mesh_provisioner_set_static_oob_value(const uint8_t *value, ui
|
||||
|
||||
arg.set_static_oob_val.length = length;
|
||||
memcpy(arg.set_static_oob_val.value, value, length);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -461,23 +468,22 @@ esp_err_t esp_ble_mesh_provisioner_set_primary_elem_addr(uint16_t addr)
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SET_PRIMARY_ELEM_ADDR;
|
||||
|
||||
arg.set_primary_elem_addr.addr = addr;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
||||
|
||||
/* The following APIs are for fast provisioning */
|
||||
|
||||
#if (CONFIG_BLE_MESH_FAST_PROV)
|
||||
|
||||
#if CONFIG_BLE_MESH_FAST_PROV
|
||||
esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_prov_info)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (fast_prov_info == NULL || (fast_prov_info->offset +
|
||||
fast_prov_info->match_len > ESP_BLE_MESH_OCTET16_LEN)) {
|
||||
fast_prov_info->match_len > ESP_BLE_MESH_OCTET16_LEN)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
@ -497,6 +503,7 @@ esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_pr
|
||||
if (fast_prov_info->match_len) {
|
||||
memcpy(arg.set_fast_prov_info.match_val, fast_prov_info->match_val, fast_prov_info->match_len);
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -517,8 +524,8 @@ esp_err_t esp_ble_mesh_set_fast_prov_action(esp_ble_mesh_fast_prov_action_t acti
|
||||
msg.act = BTC_BLE_MESH_ACT_SET_FAST_PROV_ACTION;
|
||||
|
||||
arg.set_fast_prov_action.action = action;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_FAST_PROV */
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include "btc_ble_mesh_prov.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
#include "esp_ble_mesh_local_data_operation_api.h"
|
||||
#include "esp_ble_mesh_proxy_api.h"
|
||||
|
||||
esp_err_t esp_ble_mesh_proxy_identity_enable(void)
|
||||
{
|
||||
@ -166,3 +168,54 @@ esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), btc_ble_mesh_prov_arg_deep_copy,
|
||||
btc_ble_mesh_prov_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_CLI
|
||||
esp_err_t esp_ble_mesh_proxy_client_directed_proxy_set(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint8_t use_directed)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (use_directed > ESP_BLE_MESH_PROXY_CLI_DIRECTED_FORWARDING_ENABLE) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROXY_CLIENT_DIRECTED_PROXY_SET;
|
||||
|
||||
arg.proxy_client_directed_proxy_set.conn_handle = conn_handle;
|
||||
arg.proxy_client_directed_proxy_set.net_idx = net_idx;
|
||||
arg.proxy_client_directed_proxy_set.use_directed = use_directed;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), btc_ble_mesh_prov_arg_deep_copy, btc_ble_mesh_prov_arg_deep_free)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DF_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_PROXY_SOLIC_PDU_TX
|
||||
esp_err_t esp_ble_mesh_proxy_client_send_solic_pdu(uint8_t net_idx, uint16_t ssrc, uint16_t dst)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (esp_ble_mesh_find_element(ssrc) == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROXY_CLIENT_SEND_SOLIC_PDU;
|
||||
|
||||
arg.proxy_client_send_solic_pdu.net_idx = net_idx;
|
||||
arg.proxy_client_send_solic_pdu.ssrc = ssrc;
|
||||
arg.proxy_client_send_solic_pdu.dst = dst;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_PROXY_SOLIC_PDU_TX */
|
||||
|
@ -76,7 +76,7 @@ typedef void (* esp_ble_mesh_ble_cb_t)(esp_ble_mesh_ble_cb_event_t event,
|
||||
/**
|
||||
* @brief Register BLE scanning callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the BLE scaning callback function.
|
||||
* @param[in] callback: Pointer to the BLE scanning callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
|
@ -200,6 +200,24 @@ esp_err_t esp_ble_mesh_node_add_local_app_key(const uint8_t app_key[16], uint16_
|
||||
esp_err_t esp_ble_mesh_node_bind_app_key_to_local_model(uint16_t element_addr, uint16_t company_id,
|
||||
uint16_t model_id, uint16_t app_idx);
|
||||
|
||||
/**
|
||||
* @brief This function used to enable directed forwarding and directed forwarding relay on self.
|
||||
*
|
||||
* @param[in] net_idx: NetKey Index.
|
||||
* @param[in] directed_forwarding: Enable or Disable directed forwarding.
|
||||
* @param[in] directed_forwarding_relay: Enable or Disable directed forwarding relay.
|
||||
*
|
||||
* @note If the directed forwarding was set to disable, the directed forwarding relay
|
||||
* must also be set to disable.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
esp_err_t esp_ble_mesh_enable_directed_forwarding(uint16_t net_idx, bool directed_forwarding,
|
||||
bool directed_forwarding_relay);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -60,7 +60,7 @@ esp_err_t esp_ble_mesh_model_msg_opcode_init(uint8_t *data, uint32_t opcode);
|
||||
/**
|
||||
* @brief Initialize the user-defined client model. All user-defined client models
|
||||
* shall call this function to initialize the client model internal data.
|
||||
* Node: Before calling this API, the op_pair_size and op_pair variabled within
|
||||
* Node: Before calling this API, the op_pair_size and op_pair variables within
|
||||
* the user_data(defined using esp_ble_mesh_client_t_) of the client model
|
||||
* need to be initialized.
|
||||
*
|
||||
@ -168,7 +168,7 @@ esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
|
||||
* @brief Reset the provisioning procedure of the local BLE Mesh node.
|
||||
*
|
||||
* @note All provisioning information in this node will be deleted and the node
|
||||
* needs to be reprovisioned. The API function esp_ble_mesh_node_prov_enable()
|
||||
* needs to be re-provisioned. The API function esp_ble_mesh_node_prov_enable()
|
||||
* needs to be called to start a new provisioning procedure.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
@ -641,6 +641,55 @@ uint8_t esp_ble_mesh_provisioner_get_free_settings_count(void);
|
||||
*/
|
||||
const uint8_t *esp_ble_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
#if CONFIG_BLE_MESH_CERT_BASED_PROV
|
||||
/**
|
||||
* @brief This function is called by provisioner to send provisioning records
|
||||
* get message.
|
||||
*
|
||||
* @param[in] link_idx: The provisioning link index.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_send_prov_records_get(uint16_t link_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by provisioner to send provisioning record
|
||||
* request message.
|
||||
*
|
||||
* @param[in] link_idx: The provisioning link index.
|
||||
* @param[in] record_id: The record identity.
|
||||
* @param[in] frag_offset: The starting offset of the fragment.
|
||||
* @param[in] max_size: The max record fragment size.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_send_prov_record_req(uint16_t link_idx, uint16_t record_id,
|
||||
uint16_t frag_offset, uint16_t max_size);
|
||||
|
||||
/**
|
||||
* @brief This function is called by provisioner to send provisioning invite
|
||||
* message.
|
||||
*
|
||||
* @param[in] link_idx: The provisioning link index.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_send_prov_invite(uint16_t link_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by provisioner to send link close
|
||||
*
|
||||
* @param[in] link_idx: The provisioning link index.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_send_link_close(uint16_t link_idx);
|
||||
#endif /* #if CONFIG_BLE_MESH_CERT_BASED_PROV */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -13,6 +13,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BLE_MESH_PROXY_CLI_DIRECTED_FORWARDING_ENABLE 0x01
|
||||
#define ESP_BLE_MESH_PROXY_CLI_DIRECTED_FORWARDING_DISABLE 0x00
|
||||
|
||||
/**
|
||||
* @brief Enable advertising with Node Identity.
|
||||
*
|
||||
@ -111,6 +114,31 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_
|
||||
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client sets whether or not the Directed Proxy Server uses directed forwarding
|
||||
* for Directed Proxy Client messages.
|
||||
*
|
||||
* @param[in] conn_handle: Proxy connection handle.
|
||||
* @param[in] net_idx: Corresponding NetKey Index.
|
||||
* @param[in] use_directed: Whether or not to send message by directed forwarding.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_directed_proxy_set(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint8_t use_directed);
|
||||
/**
|
||||
* @brief Proxy Client sends Solicitation PDU.
|
||||
*
|
||||
* @param[in] net_idx: Corresponding NetKey Index.
|
||||
* @param[in] ssrc: Solicitation SRC, shall be one of its element address.
|
||||
* @param[in] dst: Solicitation DST (TBD).
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_send_solic_pdu(uint8_t net_idx, uint16_t ssrc, uint16_t dst);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -9,35 +9,38 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "mesh_config.h"
|
||||
#include "mesh_common.h"
|
||||
#include "mesh/config.h"
|
||||
#include "mesh/common.h"
|
||||
#include "proxy_server.h"
|
||||
#include "provisioner_main.h"
|
||||
#include "pvnr_mgmt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!< The maximum length of a BLE Mesh message, including Opcode, Payload and TransMIC */
|
||||
#define ESP_BLE_MESH_SDU_MAX_LEN 384
|
||||
#define ESP_BLE_MESH_SDU_MAX_LEN 384
|
||||
|
||||
/*!< Length of a short Mesh MIC. */
|
||||
#define ESP_BLE_MESH_MIC_SHORT 4
|
||||
#define ESP_BLE_MESH_MIC_SHORT 4
|
||||
|
||||
/*!< Length of a long Mesh MIC. */
|
||||
#define ESP_BLE_MESH_MIC_LONG 8
|
||||
#define ESP_BLE_MESH_MIC_LONG 8
|
||||
|
||||
/*!< The maximum length of a BLE Mesh provisioned node name */
|
||||
#define ESP_BLE_MESH_NODE_NAME_MAX_LEN 31
|
||||
#define ESP_BLE_MESH_NODE_NAME_MAX_LEN 31
|
||||
|
||||
/*!< The maximum length of a BLE Mesh unprovisioned device name */
|
||||
#define ESP_BLE_MESH_DEVICE_NAME_MAX_LEN DEVICE_NAME_SIZE
|
||||
#define ESP_BLE_MESH_DEVICE_NAME_MAX_LEN DEVICE_NAME_SIZE
|
||||
|
||||
/*!< The maximum length of settings user id */
|
||||
#define ESP_BLE_MESH_SETTINGS_UID_SIZE 20
|
||||
#define ESP_BLE_MESH_SETTINGS_UID_SIZE 20
|
||||
|
||||
/*!< The default value of Random Update Interval Steps */
|
||||
#define ESP_BLE_MESH_RAND_UPDATE_INTERVAL_DEFAULT 0x3C
|
||||
|
||||
/*!< Invalid settings index */
|
||||
#define ESP_BLE_MESH_INVALID_SETTINGS_IDX 0xFF
|
||||
#define ESP_BLE_MESH_INVALID_SETTINGS_IDX 0xFF
|
||||
|
||||
/*!< Define the BLE Mesh octet 16 bytes size */
|
||||
#define ESP_BLE_MESH_OCTET16_LEN 16
|
||||
@ -48,69 +51,86 @@ typedef uint8_t esp_ble_mesh_octet16_t[ESP_BLE_MESH_OCTET16_LEN];
|
||||
typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN];
|
||||
|
||||
/*!< Invalid Company ID */
|
||||
#define ESP_BLE_MESH_CID_NVAL 0xFFFF
|
||||
#define ESP_BLE_MESH_CID_NVAL 0xFFFF
|
||||
|
||||
/*!< Special TTL value to request using configured default TTL */
|
||||
#define ESP_BLE_MESH_TTL_DEFAULT 0xFF
|
||||
#define ESP_BLE_MESH_TTL_DEFAULT 0xFF
|
||||
|
||||
/*!< Maximum allowed TTL value */
|
||||
#define ESP_BLE_MESH_TTL_MAX 0x7F
|
||||
#define ESP_BLE_MESH_TTL_MAX 0x7F
|
||||
|
||||
#define ESP_BLE_MESH_ADDR_UNASSIGNED 0x0000
|
||||
#define ESP_BLE_MESH_ADDR_ALL_NODES 0xFFFF
|
||||
#define ESP_BLE_MESH_ADDR_PROXIES 0xFFFC
|
||||
#define ESP_BLE_MESH_ADDR_FRIENDS 0xFFFD
|
||||
#define ESP_BLE_MESH_ADDR_RELAYS 0xFFFE
|
||||
#define ESP_BLE_MESH_ADDR_UNASSIGNED 0x0000
|
||||
#define ESP_BLE_MESH_ADDR_ALL_NODES 0xFFFF
|
||||
#define ESP_BLE_MESH_ADDR_PROXIES 0xFFFC
|
||||
#define ESP_BLE_MESH_ADDR_FRIENDS 0xFFFD
|
||||
#define ESP_BLE_MESH_ADDR_RELAYS 0xFFFE
|
||||
|
||||
#define ESP_BLE_MESH_KEY_UNUSED 0xFFFF
|
||||
#define ESP_BLE_MESH_KEY_DEV 0xFFFE
|
||||
#define ESP_BLE_MESH_KEY_UNUSED 0xFFFF
|
||||
#define ESP_BLE_MESH_KEY_DEV 0xFFFE
|
||||
|
||||
#define ESP_BLE_MESH_KEY_PRIMARY 0x0000
|
||||
#define ESP_BLE_MESH_KEY_ANY 0xFFFF
|
||||
#define ESP_BLE_MESH_KEY_PRIMARY 0x0000
|
||||
#define ESP_BLE_MESH_KEY_ANY 0xFFFF
|
||||
|
||||
/*!< Primary Network Key index */
|
||||
#define ESP_BLE_MESH_NET_PRIMARY 0x000
|
||||
#define ESP_BLE_MESH_NET_PRIMARY 0x000
|
||||
|
||||
/*!< Relay state value */
|
||||
#define ESP_BLE_MESH_RELAY_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_RELAY_ENABLED 0x01
|
||||
#define ESP_BLE_MESH_RELAY_NOT_SUPPORTED 0x02
|
||||
#define ESP_BLE_MESH_RELAY_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_RELAY_ENABLED 0x01
|
||||
#define ESP_BLE_MESH_RELAY_NOT_SUPPORTED 0x02
|
||||
|
||||
/*!< Beacon state value */
|
||||
#define ESP_BLE_MESH_BEACON_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_BEACON_ENABLED 0x01
|
||||
#define ESP_BLE_MESH_BEACON_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_BEACON_ENABLED 0x01
|
||||
|
||||
#define ESP_BLE_MESH_PRIVATE_BEACON_DISABLE 0x00
|
||||
#define ESP_BLE_MESH_PRIVATE_BEACON_ENABLE 0x01
|
||||
|
||||
/*!< GATT Proxy state value */
|
||||
#define ESP_BLE_MESH_GATT_PROXY_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_GATT_PROXY_ENABLED 0x01
|
||||
#define ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED 0x02
|
||||
#define ESP_BLE_MESH_GATT_PROXY_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_GATT_PROXY_ENABLED 0x01
|
||||
#define ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED 0x02
|
||||
|
||||
#define ESP_BLE_MESH_PRIVATE_GATT_PROXY_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_PRIVATE_GATT_PROXY_ENABLED 0x01
|
||||
#define ESP_BLE_MESH_PRIVATE_GATT_PROXY_NOT_SUPPORTED 0x02
|
||||
|
||||
#define ESP_BLE_MESH_PRIVATE_NODE_IDENTITY_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_PRIVATE_NODE_IDENTITY_ENABLED 0x01
|
||||
#define ESP_BLE_MESH_PRIVATE_NODE_IDENTITY_NOT_SUPPORTED 0x02
|
||||
|
||||
/*!< Friend state value */
|
||||
#define ESP_BLE_MESH_FRIEND_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_FRIEND_ENABLED 0x01
|
||||
#define ESP_BLE_MESH_FRIEND_NOT_SUPPORTED 0x02
|
||||
#define ESP_BLE_MESH_FRIEND_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_FRIEND_ENABLED 0x01
|
||||
#define ESP_BLE_MESH_FRIEND_NOT_SUPPORTED 0x02
|
||||
|
||||
/*!< Node identity state value */
|
||||
#define ESP_BLE_MESH_NODE_IDENTITY_STOPPED 0x00
|
||||
#define ESP_BLE_MESH_NODE_IDENTITY_RUNNING 0x01
|
||||
#define ESP_BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED 0x02
|
||||
#define ESP_BLE_MESH_NODE_IDENTITY_STOPPED 0x00
|
||||
#define ESP_BLE_MESH_NODE_IDENTITY_RUNNING 0x01
|
||||
#define ESP_BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED 0x02
|
||||
|
||||
/*!< Subnet Bridge state value */
|
||||
#define ESP_BLE_MESH_SUBNET_BRIDGE_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_SUBNET_BRIDGE_ENABLED 0x01
|
||||
|
||||
/*!< Supported features */
|
||||
#define ESP_BLE_MESH_FEATURE_RELAY BIT(0)
|
||||
#define ESP_BLE_MESH_FEATURE_PROXY BIT(1)
|
||||
#define ESP_BLE_MESH_FEATURE_FRIEND BIT(2)
|
||||
#define ESP_BLE_MESH_FEATURE_LOW_POWER BIT(3)
|
||||
#define ESP_BLE_MESH_FEATURE_ALL_SUPPORTED (ESP_BLE_MESH_FEATURE_RELAY | \
|
||||
ESP_BLE_MESH_FEATURE_PROXY | \
|
||||
ESP_BLE_MESH_FEATURE_FRIEND | \
|
||||
ESP_BLE_MESH_FEATURE_LOW_POWER)
|
||||
#define ESP_BLE_MESH_FEATURE_RELAY BIT(0)
|
||||
#define ESP_BLE_MESH_FEATURE_PROXY BIT(1)
|
||||
#define ESP_BLE_MESH_FEATURE_FRIEND BIT(2)
|
||||
#define ESP_BLE_MESH_FEATURE_LOW_POWER BIT(3)
|
||||
#define ESP_BLE_MESH_FEATURE_ALL_SUPPORTED (ESP_BLE_MESH_FEATURE_RELAY | \
|
||||
ESP_BLE_MESH_FEATURE_PROXY | \
|
||||
ESP_BLE_MESH_FEATURE_FRIEND | \
|
||||
ESP_BLE_MESH_FEATURE_LOW_POWER)
|
||||
|
||||
#define ESP_BLE_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000)
|
||||
#define ESP_BLE_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xC000 && (addr) <= 0xFF00)
|
||||
#define ESP_BLE_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xC000)
|
||||
#define ESP_BLE_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xFF00 && (addr) <= 0xFFFB)
|
||||
#define ESP_BLE_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000)
|
||||
#define ESP_BLE_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xC000 && (addr) <= 0xFF00)
|
||||
#define ESP_BLE_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xC000)
|
||||
#define ESP_BLE_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xFF00 && (addr) <= 0xFFFB)
|
||||
|
||||
#define ESP_BLE_MESH_INVALID_NODE_INDEX 0xFFFF
|
||||
#define ESP_BLE_MESH_INVALID_NODE_INDEX 0xFFFF
|
||||
|
||||
#define ESP_BLE_MESH_PROV_RECORD_MAX_ID 0x0013
|
||||
|
||||
/** @def ESP_BLE_MESH_TRANSMIT
|
||||
*
|
||||
@ -238,7 +258,9 @@ typedef enum {
|
||||
ESP_BLE_MESH_PROV_OOB_NFC = BIT(4),
|
||||
ESP_BLE_MESH_PROV_OOB_NUMBER = BIT(5),
|
||||
ESP_BLE_MESH_PROV_OOB_STRING = BIT(6),
|
||||
/* 7 - 10 are reserved */
|
||||
ESP_BLE_MESH_PROV_CERT_BASED = BIT(7),
|
||||
ESP_BLE_MESH_PROV_RECORDS = BIT(8),
|
||||
/* 9 - 10 are reserved */
|
||||
ESP_BLE_MESH_PROV_OOB_ON_BOX = BIT(11),
|
||||
ESP_BLE_MESH_PROV_OOB_IN_BOX = BIT(12),
|
||||
ESP_BLE_MESH_PROV_OOB_ON_PAPER = BIT(13),
|
||||
@ -317,34 +339,83 @@ typedef enum {
|
||||
.input_action = in_act, \
|
||||
}
|
||||
|
||||
typedef uint8_t UINT8;
|
||||
typedef uint16_t UINT16;
|
||||
typedef uint32_t UINT32;
|
||||
typedef uint64_t UINT64;
|
||||
|
||||
#define BT_OCTET32_LEN 32
|
||||
typedef UINT8 BT_OCTET32[BT_OCTET32_LEN]; /* octet array: size 32 */
|
||||
typedef uint8_t UINT8 __attribute__((deprecated));
|
||||
typedef uint16_t UINT16 __attribute__((deprecated));
|
||||
typedef uint32_t UINT32 __attribute__((deprecated));
|
||||
typedef uint64_t UINT64 __attribute__((deprecated));
|
||||
|
||||
#ifndef BT_OCTET32_LEN
|
||||
#define BT_OCTET32_LEN 32
|
||||
typedef UINT8 BT_OCTET32[BT_OCTET32_LEN] __attribute__((deprecated));
|
||||
#endif
|
||||
|
||||
#ifndef BD_ADDR_LEN
|
||||
#define BD_ADDR_LEN 6
|
||||
typedef uint8_t BD_ADDR[BD_ADDR_LEN];
|
||||
typedef uint8_t BD_ADDR[BD_ADDR_LEN] __attribute__((deprecated));
|
||||
#endif
|
||||
|
||||
typedef uint8_t esp_ble_mesh_bd_addr_t[BD_ADDR_LEN];
|
||||
|
||||
#define ESP_BLE_MESH_ADDR_TYPE_PUBLIC 0x00
|
||||
#define ESP_BLE_MESH_ADDR_TYPE_RANDOM 0x01
|
||||
#define ESP_BLE_MESH_ADDR_TYPE_RPA_PUBLIC 0x02
|
||||
#define ESP_BLE_MESH_ADDR_TYPE_RPA_RANDOM 0x03
|
||||
#define ESP_BLE_MESH_ADDR_TYPE_PUBLIC 0x00
|
||||
#define ESP_BLE_MESH_ADDR_TYPE_RANDOM 0x01
|
||||
#define ESP_BLE_MESH_ADDR_TYPE_RPA_PUBLIC 0x02
|
||||
#define ESP_BLE_MESH_ADDR_TYPE_RPA_RANDOM 0x03
|
||||
/// BLE device address type
|
||||
typedef uint8_t esp_ble_mesh_addr_type_t;
|
||||
|
||||
#define ESP_BLE_MESH_DIRECTED_FORWARDING_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_DIRECTED_FORWARDING_ENABLED 0x01
|
||||
|
||||
#define ESP_BLE_MESH_DIRECTED_RELAY_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_DIRECTED_RELAY_ENABLED 0x01
|
||||
|
||||
#define ESP_BLE_MESH_DIRECTED_PROXY_IGNORE 0xFF
|
||||
#define ESP_BLE_MESH_DIRECTED_PROXY_USE_DEFAULT_IGNORE 0xFF
|
||||
#define ESP_BLE_MESH_DIRECTED_FRIEND_IGNORE 0xFF
|
||||
|
||||
#define ESP_BLE_MESH_DIRECTED_PROXY_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_DIRECTED_PROXY_ENABLED 0x01
|
||||
#define ESP_BLE_MESH_DIRECTED_PROXY_NOT_SUPPORTED 0x02
|
||||
|
||||
#define ESP_BLE_MESH_DIRECTED_PROXY_USE_DEF_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_DIRECTED_PROXY_USE_DEF_ENABLED 0x01
|
||||
#define ESP_BLE_MESH_DIRECTED_PROXY_USE_DEF_NOT_SUPPORTED 0x02
|
||||
|
||||
#define ESP_BLE_MESH_DIRECTED_FRIEND_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_DIRECTED_FRIEND_ENABLED 0x01
|
||||
#define ESP_BLE_MESH_DIRECTED_FRIEND_NOT_SUPPORTED 0x02
|
||||
|
||||
#define ESP_BLE_MESH_DIRECTED_PUB_POLICY_FLOODING 0x00
|
||||
#define ESP_BLE_MESH_DIRECTED_PUB_POLICY_FORWARD 0x01
|
||||
|
||||
#define ESP_BLE_MESH_PROXY_USE_DIRECTED_DISABLED 0x00
|
||||
#define ESP_BLE_MESH_PROXY_USE_DIRECTED_ENABLED 0x01
|
||||
|
||||
#define ESP_BLE_MESH_FLOODING_CRED 0x00 /* Managed flooding security credentials */
|
||||
#define ESP_BLE_MESH_FRIENDSHIP_CRED 0x01 /* Friendship security credentials */
|
||||
#define ESP_BLE_MESH_DIRECTED_CRED 0x02 /* Directed security credentials */
|
||||
|
||||
#define ESP_BLE_MESH_TAG_SEND_SEGMENTED BIT(0) /* Tagged with send-segmented */
|
||||
#define ESP_BLE_MESH_TAG_IMMUTABLE_CRED BIT(1) /* Tagged with immutable-credentials */
|
||||
#define ESP_BLE_MESH_TAG_USE_DIRECTED BIT(2) /* Tagged with use-directed */
|
||||
#define ESP_BLE_MESH_TAG_RELAY BIT(3) /* Tagged as relay */
|
||||
#define ESP_BLE_MESH_TAG_FRIENDSHIP BIT(4) /* Tagged as a friendship PDU */
|
||||
|
||||
#define ESP_BLE_MESH_SEG_SZMIC_SHORT 0 /* Using 4-octets TransMIC for a segmented message */
|
||||
#define ESP_BLE_MESH_SEG_SZMIC_LONG 1 /* Using 8-octets TransMIC for a segmented message */
|
||||
|
||||
/** BLE Mesh deinit parameters */
|
||||
typedef struct {
|
||||
bool erase_flash; /*!< Indicate if erasing flash when deinit mesh stack */
|
||||
} esp_ble_mesh_deinit_param_t;
|
||||
|
||||
/** Format of Unicast Address Range */
|
||||
typedef struct {
|
||||
uint16_t len_present:1, /*!< Indicate the presence or absence of the RangeLength field */
|
||||
range_start:15; /*!< 15 least significant bits of the starting unicast address */
|
||||
uint8_t range_length; /*!< Number of addresses in the range (0x02 - 0xFF) */
|
||||
} esp_ble_mesh_uar_t;
|
||||
|
||||
typedef struct esp_ble_mesh_model esp_ble_mesh_model_t;
|
||||
|
||||
/** Abstraction that describes a BLE Mesh Element.
|
||||
@ -374,7 +445,8 @@ typedef struct {
|
||||
uint16_t publish_addr; /*!< Publish Address. */
|
||||
uint16_t app_idx:12, /*!< Publish AppKey Index. */
|
||||
cred:1, /*!< Friendship Credentials Flag. */
|
||||
send_rel:1; /*!< Force reliable sending (segment acks) */
|
||||
send_rel:1, /*!< Force reliable sending (segment acks) */
|
||||
send_szmic:1; /*!< Size of TransMIC when publishing a Segmented Access message */
|
||||
|
||||
uint8_t ttl; /*!< Publish Time to Live. */
|
||||
uint8_t retransmit; /*!< Retransmit Count & Interval Steps. */
|
||||
@ -384,7 +456,11 @@ typedef struct {
|
||||
fast_period:1, /*!< Use FastPeriodDivisor */
|
||||
count:3; /*!< Retransmissions left. */
|
||||
|
||||
uint32_t period_start; /*!< Start of the current period. */
|
||||
uint32_t period_start; /*!< Start of the current period. */
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
uint8_t directed_pub_policy; /*!< Directed publish policy */
|
||||
#endif
|
||||
|
||||
/** @brief Publication buffer, containing the publication message.
|
||||
*
|
||||
@ -402,7 +478,7 @@ typedef struct {
|
||||
struct k_delayed_work timer;
|
||||
|
||||
/** Role of the device that is going to publish messages */
|
||||
uint8_t dev_role;
|
||||
uint8_t dev_role __attribute__((deprecated));
|
||||
} esp_ble_mesh_model_pub_t;
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_PUB_DEFINE
|
||||
@ -418,7 +494,6 @@ typedef struct {
|
||||
static esp_ble_mesh_model_pub_t _name = { \
|
||||
.update = (uint32_t)NULL, \
|
||||
.msg = &bt_mesh_pub_msg_##_name, \
|
||||
.dev_role = _role, \
|
||||
}
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_OP
|
||||
@ -472,7 +547,7 @@ struct esp_ble_mesh_model {
|
||||
const uint16_t model_id; /*!< 16-bit model identifier */
|
||||
struct {
|
||||
uint16_t company_id; /*!< 16-bit company identifier */
|
||||
uint16_t model_id; /*!< 16-bit model identifier */
|
||||
uint16_t model_id; /*!< 16-bit model identifier */
|
||||
} vnd; /*!< Structure encapsulating a model ID with a company ID */
|
||||
};
|
||||
|
||||
@ -524,26 +599,41 @@ typedef struct {
|
||||
/** Destination address of a received message. Not used for sending. */
|
||||
uint16_t recv_dst;
|
||||
|
||||
/** RSSI of received packet. Not used for sending. */
|
||||
/** RSSI of a received message. Not used for sending. */
|
||||
int8_t recv_rssi;
|
||||
|
||||
/** Received TTL value. Not used for sending. */
|
||||
uint8_t recv_ttl: 7;
|
||||
/** Opcode of a received message. Not used for sending. */
|
||||
uint32_t recv_op;
|
||||
|
||||
/** Force sending reliably by using segment acknowledgement */
|
||||
uint8_t send_rel: 1;
|
||||
/** Received TTL value. Not used for sending. */
|
||||
uint8_t recv_ttl;
|
||||
|
||||
/** Security credentials of a received message. Not used for sending. */
|
||||
uint8_t recv_cred;
|
||||
|
||||
/** Tag of a received message. Not used for sending. */
|
||||
uint8_t recv_tag;
|
||||
|
||||
/** Force sending reliably by using segment acknowledgement. */
|
||||
uint8_t send_rel:1 __attribute__((deprecated));
|
||||
|
||||
/** Size of TransMIC when sending a Segmented Access message. */
|
||||
uint8_t send_szmic:1;
|
||||
|
||||
/** TTL, or ESP_BLE_MESH_TTL_DEFAULT for default TTL. */
|
||||
uint8_t send_ttl;
|
||||
|
||||
/** Opcode of a received message. Not used for sending message. */
|
||||
uint32_t recv_op;
|
||||
/** Security credentials used for sending the message */
|
||||
uint8_t send_cred;
|
||||
|
||||
/** Tag used for sending the message. */
|
||||
uint8_t send_tag;
|
||||
|
||||
/** Model corresponding to the message, no need to be initialized before sending message */
|
||||
esp_ble_mesh_model_t *model;
|
||||
esp_ble_mesh_model_t *model __attribute__((deprecated));
|
||||
|
||||
/** Indicate if the message is sent by a node server model, no need to be initialized before sending message */
|
||||
bool srv_send;
|
||||
bool srv_send __attribute__((deprecated));
|
||||
} esp_ble_mesh_msg_ctx_t;
|
||||
|
||||
/** Provisioning properties & capabilities.
|
||||
@ -576,6 +666,9 @@ typedef struct {
|
||||
/** Callback used to notify to set OOB Public Key. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t oob_pub_key_cb;
|
||||
|
||||
/** OOB type */
|
||||
uint8_t oob_type;
|
||||
|
||||
/** Static OOB value */
|
||||
const uint8_t *static_val;
|
||||
/** Static OOB value length */
|
||||
@ -668,6 +761,12 @@ typedef struct {
|
||||
esp_ble_mesh_cb_t provisioner_link_close;
|
||||
/** Callback used to indicate that a device is provisioned. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t provisioner_prov_comp;
|
||||
/** Callback used to indicate that certificate based provisioning needs to start. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t cert_based_prov_start;
|
||||
/** Callback used to indicate that provisioner has received provisioning records list successfully. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t records_list_get;
|
||||
/** Callback used to indicate that provisioner has received a complete provisioning record successfully. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t prov_record_recv_comp;
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
||||
} esp_ble_mesh_prov_t;
|
||||
|
||||
@ -698,8 +797,8 @@ typedef uint8_t esp_ble_mesh_dev_add_flag_t;
|
||||
|
||||
/** Information of the device which is going to be added for provisioning. */
|
||||
typedef struct {
|
||||
esp_ble_mesh_bd_addr_t addr; /*!< Device address */
|
||||
esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */
|
||||
esp_ble_mesh_bd_addr_t addr; /*!< Device address */
|
||||
esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */
|
||||
uint8_t uuid[16]; /*!< Device UUID */
|
||||
uint16_t oob_info; /*!< Device OOB Info */
|
||||
/*!< ADD_DEV_START_PROV_NOW_FLAG shall not be set if the bearer has both PB-ADV and PB-GATT enabled */
|
||||
@ -710,14 +809,16 @@ typedef struct {
|
||||
#define DEL_DEV_UUID_FLAG BIT(1)
|
||||
/** Information of the device which is going to be deleted. */
|
||||
typedef struct {
|
||||
/** Union of Device information */
|
||||
union {
|
||||
/** Device address */
|
||||
struct {
|
||||
esp_ble_mesh_bd_addr_t addr; /*!< Device address */
|
||||
esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */
|
||||
esp_ble_mesh_bd_addr_t addr; /*!< Device address */
|
||||
esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */
|
||||
};
|
||||
uint8_t uuid[16]; /*!< Device UUID */
|
||||
uint8_t uuid[16]; /*!< Device UUID */
|
||||
};
|
||||
uint8_t flag; /*!< BIT0: device address; BIT1: device UUID */
|
||||
uint8_t flag; /*!< BIT0: device address; BIT1: device UUID */
|
||||
} esp_ble_mesh_device_delete_t;
|
||||
|
||||
#define PROV_DATA_NET_IDX_FLAG BIT(0)
|
||||
@ -725,6 +826,7 @@ typedef struct {
|
||||
#define PROV_DATA_IV_INDEX_FLAG BIT(2)
|
||||
/** Information of the provisioner which is going to be updated. */
|
||||
typedef struct {
|
||||
/** Provisioning data */
|
||||
union {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t flags; /*!< Flags */
|
||||
@ -828,6 +930,13 @@ typedef enum {
|
||||
ESP_BLE_MESH_PROVISIONER_PROV_LINK_OPEN_EVT, /*!< Provisioner establish a BLE Mesh link event */
|
||||
ESP_BLE_MESH_PROVISIONER_PROV_LINK_CLOSE_EVT, /*!< Provisioner close a BLE Mesh link event */
|
||||
ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT, /*!< Provisioner provisioning done event */
|
||||
ESP_BLE_MESH_PROVISIONER_CERT_BASED_PROV_START_EVT, /*!< Provisioner initiate a certificate based provisioning */
|
||||
ESP_BLE_MESH_PROVISIONER_RECV_PROV_RECORDS_LIST_EVT, /*!< Provisioner receive provisioning records list event */
|
||||
ESP_BLE_MESH_PROVISIONER_PROV_RECORD_RECV_COMP_EVT, /*!< Provisioner receive provisioning record complete event */
|
||||
ESP_BLE_MESH_PROVISIONER_SEND_PROV_RECORDS_GET_EVT, /*!< Provisioner send provisioning records get to device event */
|
||||
ESP_BLE_MESH_PROVISIONER_SEND_PROV_RECORD_REQUEST_EVT, /*!< Provisioner send provisioning record request to device event */
|
||||
ESP_BLE_MESH_PROVISIONER_SEND_PROV_INVITE_EVT, /*!< Provisioner send provisioning invite to device event */
|
||||
ESP_BLE_MESH_PROVISIONER_SEND_LINK_CLOSE_EVT, /*!< Provisioner send link close to device event */
|
||||
ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT, /*!< Provisioner add a device to the list which contains devices that are waiting/going to be provisioned completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT, /*!< Provisioner start to provision an unprovisioned device completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device completion event */
|
||||
@ -877,8 +986,10 @@ typedef enum {
|
||||
ESP_BLE_MESH_PROXY_CLIENT_SET_FILTER_TYPE_COMP_EVT, /*!< Proxy Client set filter type completion event */
|
||||
ESP_BLE_MESH_PROXY_CLIENT_ADD_FILTER_ADDR_COMP_EVT, /*!< Proxy Client add filter address completion event */
|
||||
ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT, /*!< Proxy Client remove filter address completion event */
|
||||
ESP_BLE_MESH_PROXY_CLIENT_DIRECTED_PROXY_SET_COMP_EVT, /*!< Proxy Client directed proxy set completion event */
|
||||
ESP_BLE_MESH_PROXY_SERVER_CONNECTED_EVT, /*!< Proxy Server establishes connection successfully event */
|
||||
ESP_BLE_MESH_PROXY_SERVER_DISCONNECTED_EVT, /*!< Proxy Server terminates connection successfully event */
|
||||
ESP_BLE_MESH_PROXY_CLIENT_SEND_SOLIC_PDU_COMP_EVT, /*!< Proxy Client send Solicitation PDU completion event */
|
||||
ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT, /*!< Local model subscribes group address completion event */
|
||||
ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT, /*!< Local model unsubscribes group address completion event */
|
||||
ESP_BLE_MESH_DEINIT_MESH_COMP_EVT, /*!< De-initialize BLE Mesh stack completion event */
|
||||
@ -924,6 +1035,7 @@ typedef union {
|
||||
*/
|
||||
struct ble_mesh_link_close_evt_param {
|
||||
esp_ble_mesh_prov_bearer_t bearer; /*!< Type of the bearer used when device link is closed */
|
||||
uint8_t reason; /*!< Reason of the closed provisioning link */
|
||||
} node_prov_link_close; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_NODE_PROV_OUTPUT_NUMBER_EVT
|
||||
@ -1030,7 +1142,7 @@ typedef union {
|
||||
esp_ble_mesh_bd_addr_t addr; /*!< Device address of the unprovisioned device */
|
||||
esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */
|
||||
uint16_t oob_info; /*!< OOB Info of the unprovisioned device */
|
||||
uint8_t adv_type; /*!< Avertising type of the unprovisioned device */
|
||||
uint8_t adv_type; /*!< Advertising type of the unprovisioned device */
|
||||
esp_ble_mesh_prov_bearer_t bearer; /*!< Bearer of the unprovisioned device */
|
||||
int8_t rssi; /*!< RSSI of the received advertising packet */
|
||||
} provisioner_recv_unprov_adv_pkt; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT */
|
||||
@ -1075,6 +1187,7 @@ typedef union {
|
||||
esp_ble_mesh_input_action_t action; /*!< Action of device Input OOB Authentication */
|
||||
uint8_t size; /*!< Size of device Input OOB Authentication */
|
||||
uint8_t link_idx; /*!< Index of the provisioning link */
|
||||
/** Union of output OOB */
|
||||
union {
|
||||
char string[8]; /*!< String output by the Provisioner */
|
||||
uint32_t number; /*!< Number output by the Provisioner */
|
||||
@ -1097,6 +1210,62 @@ typedef union {
|
||||
uint8_t element_num; /*!< Element count of the provisioned device */
|
||||
uint16_t netkey_idx; /*!< NetKey Index of the provisioned device */
|
||||
} provisioner_prov_complete; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_CERT_BASED_PROV_START_EVT
|
||||
*/
|
||||
struct ble_mesh_provisioner_cert_based_prov_start_evt_param {
|
||||
uint16_t link_idx; /*!< Index of the provisioning link */
|
||||
} provisioner_cert_based_prov_start; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_CERT_BASED_PROV_START_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_RECV_PROV_RECORDS_LIST_EVT
|
||||
*/
|
||||
struct ble_mesh_provisioner_recv_prov_records_list_evt_param {
|
||||
uint16_t link_idx; /*!< Index of the provisioning link */
|
||||
uint16_t len; /*!< Length of message */
|
||||
uint8_t *msg; /*!< Lists the Record IDs of the provisioning records stored on the Provisionee */
|
||||
} recv_provisioner_records_list; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_RECV_PROV_RECORDS_LIST_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_PROV_RECORD_RECV_COMP_EVT
|
||||
*/
|
||||
struct ble_mesh_provisioner_prov_record_recv_comp_evt_param {
|
||||
uint8_t status; /*!< Indicates whether or not the request was handled successfully */
|
||||
uint16_t link_idx; /*!< Index of the provisioning link */
|
||||
uint16_t record_id; /*!< Identifies the provisioning record for which the request is made */
|
||||
uint16_t frag_offset; /*!< The starting offset of the requested fragment in the provisioning record data */
|
||||
uint16_t total_len; /*!< Total length of the provisioning record data stored on the Provisionee */
|
||||
uint8_t *record; /*!< Provisioning record data fragment */
|
||||
} provisioner_prov_record_recv_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_RECORD_RECV_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_SEND_PROV_RECORDS_GET_EVT
|
||||
*/
|
||||
struct ble_mesh_provisioner_send_prov_records_get_evt_param {
|
||||
int err_code; /*!< Indicate the result of send Provisioning Records List Get message */
|
||||
uint16_t link_idx; /*!< Index of the provisioning link */
|
||||
} provisioner_send_records_get; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SEND_PROV_RECORDS_GET_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_SEND_PROV_RECORD_REQUEST_EVT
|
||||
*/
|
||||
struct ble_mesh_provisioner_send_prov_record_req_evt_param {
|
||||
int err_code; /*!< Indicate the result of send Provisioning Record Request message */
|
||||
uint16_t link_idx; /*!< Index of the provisioning link */
|
||||
uint16_t record_id; /*!< Identifies the provisioning record for which the request is made */
|
||||
uint16_t frag_offset; /*!< The starting offset of the requested fragment in the provisioning record data */
|
||||
uint16_t max_size; /*!< The maximum size of the provisioning record fragment that the Provisioner can receive */
|
||||
} provisioner_send_record_req; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SEND_PROV_RECORD_REQUEST_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_SEND_PROV_INVITE_EVT
|
||||
*/
|
||||
struct ble_mesh_provisioner_send_prov_invite_evt_param {
|
||||
uint16_t link_idx; /*!< Index of the provisioning link */
|
||||
int err_code; /*!< Indicate the result of send Provisioning Invite message */
|
||||
} provisioner_send_prov_invite; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SEND_PROV_INVITE_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_SEND_LINK_CLOSE_EVT
|
||||
*/
|
||||
struct ble_mesh_provisioner_send_link_close_evt_param {
|
||||
uint16_t link_idx; /*!< Index of the provisioning link */
|
||||
int err_code; /*!< Indicate the result of send Link Close message */
|
||||
} provisioner_send_link_close; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SEND_LINK_CLOSE_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT
|
||||
*/
|
||||
@ -1461,6 +1630,14 @@ typedef union {
|
||||
uint8_t conn_handle; /*!< Proxy connection handle */
|
||||
uint16_t net_idx; /*!< Corresponding NetKey Index */
|
||||
} proxy_client_remove_filter_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROXY_CLIENT_DIRECTED_PROXY_CONTROL_COMP_EVT
|
||||
*/
|
||||
struct ble_mesh_proxy_client_directed_proxy_set_param {
|
||||
int err_code; /*!< Indicate the result of Proxy Client directed proxy control address */
|
||||
uint8_t conn_handle; /*!< Proxy connection handle */
|
||||
uint16_t net_idx; /*!< Corresponding NetKey Index */
|
||||
} proxy_client_directed_proxy_set_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_DIRECTED_PROXY_SET_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROXY_SERVER_CONNECTED_EVT
|
||||
*/
|
||||
@ -1474,6 +1651,15 @@ typedef union {
|
||||
uint8_t conn_handle; /*!< Proxy connection handle */
|
||||
uint8_t reason; /*!< Proxy disconnect reason */
|
||||
} proxy_server_disconnected; /*!< Event parameter of ESP_BLE_MESH_PROXY_SERVER_DISCONNECTED_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROXY_CLIENT_SEND_SOLIC_PDU_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of Proxy Client send Solicitation PDU */
|
||||
uint16_t net_idx; /*!< Corresponding NetKey Index */
|
||||
uint16_t ssrc; /*!< Solicitation SRC */
|
||||
uint16_t dst; /*!< Solicitation DST */
|
||||
} proxy_client_send_solic_pdu_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_SEND_SOLIC_PDU_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT
|
||||
*/
|
||||
@ -1500,7 +1686,7 @@ typedef union {
|
||||
struct ble_mesh_deinit_mesh_comp_param {
|
||||
int err_code; /*!< Indicate the result of BLE Mesh deinitialization */
|
||||
} deinit_mesh_comp; /*!< Event parameter of ESP_BLE_MESH_DEINIT_MESH_COMP_EVT */
|
||||
} esp_ble_mesh_prov_cb_param_t;
|
||||
} esp_ble_mesh_prov_cb_param_t; /*!< Event parameters of ESP_BLE_MESH_DEINIT_MESH_COMP_EVT */
|
||||
|
||||
/**
|
||||
* @brief BLE Mesh models related Model ID and Opcode definitions
|
||||
@ -1511,6 +1697,24 @@ typedef union {
|
||||
#define ESP_BLE_MESH_MODEL_ID_CONFIG_CLI 0x0001
|
||||
#define ESP_BLE_MESH_MODEL_ID_HEALTH_SRV 0x0002
|
||||
#define ESP_BLE_MESH_MODEL_ID_HEALTH_CLI 0x0003
|
||||
#define ESP_BLE_MESH_MODEL_ID_RPR_SRV 0x0004
|
||||
#define ESP_BLE_MESH_MODEL_ID_RPR_CLI 0x0005
|
||||
#define ESP_BLE_MESH_MODEL_ID_DF_SRV 0x0006
|
||||
#define ESP_BLE_MESH_MODEL_ID_DF_CLI 0x0007
|
||||
#define ESP_BLE_MESH_MODEL_ID_BRC_SRV 0x0008
|
||||
#define ESP_BLE_MESH_MODEL_ID_BRC_CLI 0x0009
|
||||
#define ESP_BLE_MESH_MODEL_ID_PRB_SRV 0x000A
|
||||
#define ESP_BLE_MESH_MODEL_ID_PRB_CLI 0x000B
|
||||
#define ESP_BLE_MESH_MODEL_ID_ODP_SRV 0x000C
|
||||
#define ESP_BLE_MESH_MODEL_ID_ODP_CLI 0x000D
|
||||
#define ESP_BLE_MESH_MODEL_ID_SAR_SRV 0x000E
|
||||
#define ESP_BLE_MESH_MODEL_ID_SAR_CLI 0x000F
|
||||
#define ESP_BLE_MESH_MODEL_ID_AGG_SRV 0x0010
|
||||
#define ESP_BLE_MESH_MODEL_ID_AGG_CLI 0x0011
|
||||
#define ESP_BLE_MESH_MODEL_ID_LCD_SRV 0x0012
|
||||
#define ESP_BLE_MESH_MODEL_ID_LCD_CLI 0x0013
|
||||
#define ESP_BLE_MESH_MODEL_ID_SRPL_SRV 0x0014
|
||||
#define ESP_BLE_MESH_MODEL_ID_SRPL_CLI 0x0015
|
||||
|
||||
/*!< Models from the Mesh Model Specification */
|
||||
#define ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV 0x1000
|
||||
@ -1565,6 +1769,8 @@ typedef union {
|
||||
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SRV 0x130f
|
||||
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV 0x1310
|
||||
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_CLI 0x1311
|
||||
#define ESP_BLE_MESH_MODEL_ID_MBT_SRV 0x1400
|
||||
#define ESP_BLE_MESH_MODEL_ID_MBT_CLI 0x1401
|
||||
|
||||
/**
|
||||
* esp_ble_mesh_opcode_config_client_get_t belongs to esp_ble_mesh_opcode_t, this typedef is only
|
||||
@ -1686,6 +1892,10 @@ typedef uint8_t esp_ble_mesh_cfg_status_t;
|
||||
#define ESP_BLE_MESH_CFG_STATUS_CANNOT_SET 0x0F
|
||||
#define ESP_BLE_MESH_CFG_STATUS_UNSPECIFIED_ERROR 0x10
|
||||
#define ESP_BLE_MESH_CFG_STATUS_INVALID_BINDING 0x11
|
||||
#define ESP_BLE_MESH_CFG_STATUS_INVALID_PATH_ENTRY 0x12
|
||||
#define ESP_BLE_MESH_CFG_STATUS_CANNOT_GET 0x13
|
||||
#define ESP_BLE_MESH_CFG_STATUS_OBSOLETE_INFO 0x14
|
||||
#define ESP_BLE_MESH_CFG_STATUS_INVALID_BEARER 0x15
|
||||
|
||||
/**
|
||||
* esp_ble_mesh_opcode_health_client_get_t belongs to esp_ble_mesh_opcode_t, this typedef is
|
||||
@ -2037,11 +2247,12 @@ typedef struct {
|
||||
/** Client Model user data context. */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the client model. Initialized by the stack. */
|
||||
int op_pair_size; /*!< Size of the op_pair */
|
||||
uint32_t op_pair_size; /*!< Size of the op_pair */
|
||||
const esp_ble_mesh_client_op_pair_t *op_pair; /*!< Table containing get/set message opcode and corresponding status message opcode */
|
||||
uint32_t publish_status; /*!< Callback used to handle the received unsolicited message. Initialized by the stack. */
|
||||
void *internal_data; /*!< Pointer to the internal data of client model */
|
||||
uint8_t msg_role; /*!< Role of the device (Node/Provisioner) that is going to send messages */
|
||||
void *vendor_data; /*!< Pointer to the vendor data of client model */
|
||||
uint8_t msg_role __attribute__((deprecated)); /*!< Role of the device (Node/Provisioner) that is going to send messages */
|
||||
} esp_ble_mesh_client_t;
|
||||
|
||||
/** Common parameters of the messages sent by Client Model. */
|
||||
@ -2051,7 +2262,7 @@ typedef struct {
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< The context used to send message */
|
||||
int32_t msg_timeout; /*!< Timeout value (ms) to get response to the sent message */
|
||||
/*!< Note: if using default timeout value in menuconfig, make sure to set this value to 0 */
|
||||
uint8_t msg_role; /*!< Role of the device - Node/Provisioner */
|
||||
uint8_t msg_role __attribute__((deprecated)); /*!< Role of the device - Node/Provisioner */
|
||||
} esp_ble_mesh_client_common_param_t;
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ extern "C" {
|
||||
NULL, NULL, cli_data)
|
||||
|
||||
/** Configuration Server Model context */
|
||||
typedef struct esp_ble_mesh_cfg_srv {
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to Configuration Server Model */
|
||||
|
||||
uint8_t net_transmit; /*!< Network Transmit state */
|
||||
@ -316,7 +316,7 @@ typedef struct {
|
||||
} esp_ble_mesh_cfg_net_transmit_set_t;
|
||||
|
||||
/** Parameters of Config Model Heartbeat Publication Set. */
|
||||
typedef struct {
|
||||
typedef struct {
|
||||
uint16_t dst; /*!< Destination address for Heartbeat messages */
|
||||
uint8_t count; /*!< Number of Heartbeat messages to be sent */
|
||||
uint8_t period; /*!< Period for sending Heartbeat messages */
|
||||
@ -610,6 +610,7 @@ typedef enum {
|
||||
* @brief Configuration Server model related context.
|
||||
*/
|
||||
|
||||
/** Parameters of Config Model Publication Set */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
uint16_t pub_addr; /*!< Publish Address */
|
||||
@ -622,6 +623,19 @@ typedef struct {
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_state_change_cfg_mod_pub_set_t;
|
||||
|
||||
/** Parameters of Config Model Publication Virtual Address Set */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
uint8_t label_uuid[16]; /*!< Label UUID */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
bool cred_flag; /*!< Friendship Credential Flag */
|
||||
uint8_t pub_ttl; /*!< Publish TTL */
|
||||
uint8_t pub_period; /*!< Publish Period */
|
||||
uint8_t pub_retransmit; /*!< Publish Retransmit */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_state_change_cfg_mod_pub_va_set_t;
|
||||
|
||||
/** Parameters of Config Model Subscription Add */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
@ -705,6 +719,7 @@ typedef union {
|
||||
* The recv_op in ctx can be used to decide which state is changed.
|
||||
*/
|
||||
esp_ble_mesh_state_change_cfg_mod_pub_set_t mod_pub_set; /*!< Config Model Publication Set */
|
||||
esp_ble_mesh_state_change_cfg_mod_pub_va_set_t mod_pub_va_set; /*!< Config Model Publication Virtual Address Set */
|
||||
esp_ble_mesh_state_change_cfg_model_sub_add_t mod_sub_add; /*!< Config Model Subscription Add */
|
||||
esp_ble_mesh_state_change_cfg_model_sub_delete_t mod_sub_delete; /*!< Config Model Subscription Delete */
|
||||
esp_ble_mesh_state_change_cfg_netkey_add_t netkey_add; /*!< Config NetKey Add */
|
||||
|
@ -134,7 +134,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t ctl_lightness; /*!< Target value of light ctl lightness state */
|
||||
uint16_t ctl_temperatrue; /*!< Target value of light ctl temperature state */
|
||||
uint16_t ctl_temperature; /*!< Target value of light ctl temperature state */
|
||||
int16_t ctl_delta_uv; /*!< Target value of light ctl delta UV state */
|
||||
uint8_t tid; /*!< Transaction ID */
|
||||
uint8_t trans_time; /*!< Time to complete state transition (optional) */
|
||||
@ -144,7 +144,7 @@ typedef struct {
|
||||
/** Parameters of Light CTL Temperature Set */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t ctl_temperatrue; /*!< Target value of light ctl temperature state */
|
||||
uint16_t ctl_temperature; /*!< Target value of light ctl temperature state */
|
||||
int16_t ctl_delta_uv; /*!< Target value of light ctl delta UV state */
|
||||
uint8_t tid; /*!< Transaction ID */
|
||||
uint8_t trans_time; /*!< Time to complete state transition (optional) */
|
||||
|
@ -141,7 +141,7 @@ typedef struct {
|
||||
} esp_ble_mesh_sensor_settings_status_cb_t;
|
||||
|
||||
/** Parameters of Sensor Setting Status */
|
||||
typedef struct {
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate id optional parameters are included */
|
||||
uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
|
||||
uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
|
@ -468,7 +468,7 @@ esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_pa
|
||||
#define ESP_BLE_MESH_TIME_NONE 0x00 /*!< Time Role - None */
|
||||
#define ESP_BLE_MESH_TIME_AUTHORITY 0x01 /*!< Time Role - Mesh Time Authority */
|
||||
#define ESP_BLE_MESH_TIME_RELAY 0x02 /*!< Time Role - Mesh Time Relay */
|
||||
#define ESP_BLE_MESH_TIME_CLINET 0x03 /*!< Time Role - Mesh Time Client */
|
||||
#define ESP_BLE_MESH_TIME_CLIENT 0x03 /*!< Time Role - Mesh Time Client */
|
||||
|
||||
#define ESP_BLE_MESH_SCENE_SUCCESS 0x00 /*!< Scene operation - Success */
|
||||
#define ESP_BLE_MESH_SCENE_REG_FULL 0x01 /*!< Scene operation - Scene Register Full */
|
||||
@ -482,7 +482,7 @@ typedef struct {
|
||||
uint8_t uncertainty; /*!< The value of the Uncertainty field */
|
||||
uint8_t time_zone_offset_curr; /*!< The value of the Time Zone Offset Current field */
|
||||
uint8_t time_zone_offset_new; /*!< The value of the Time Zone Offset New state */
|
||||
uint8_t tai_zone_change[5]; /*!< The value of the TAI of Zone Chaneg field */
|
||||
uint8_t tai_zone_change[5]; /*!< The value of the TAI of Zone Change field */
|
||||
uint16_t time_authority : 1, /*!< The value of the Time Authority bit */
|
||||
tai_utc_delta_curr : 15; /*!< The value of the TAI-UTC Delta Current state */
|
||||
uint16_t tai_utc_delta_new : 15; /*!< The value of the TAI-UTC Delta New state */
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "btc_ble_mesh_ble.h"
|
||||
#include "adv.h"
|
||||
#include "scan.h"
|
||||
#include "mesh_bearer_adapt.h"
|
||||
#include "mesh/adapter.h"
|
||||
#include "esp_ble_mesh_ble_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_BLE_COEX_SUPPORT
|
||||
|
@ -7,12 +7,12 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_config_model.h"
|
||||
#include "foundation.h"
|
||||
#include "esp_ble_mesh_config_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_CFG_CLI
|
||||
#include "cfg_cli.h"
|
||||
#include "mesh/cfg_cli.h"
|
||||
|
||||
/* Configuration Client Model related functions */
|
||||
|
||||
@ -50,7 +50,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
dst->cfg_client_get_state.get_state = (esp_ble_mesh_cfg_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_cfg_client_get_state_t));
|
||||
if (dst->cfg_client_get_state.get_state) {
|
||||
memcpy(dst->cfg_client_get_state.get_state, src->cfg_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_cfg_client_get_state_t));
|
||||
sizeof(esp_ble_mesh_cfg_client_get_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
@ -70,7 +70,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
dst->cfg_client_set_state.set_state = (esp_ble_mesh_cfg_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_cfg_client_set_state_t));
|
||||
if (dst->cfg_client_set_state.set_state) {
|
||||
memcpy(dst->cfg_client_set_state.set_state, src->cfg_client_set_state.set_state,
|
||||
sizeof(esp_ble_mesh_cfg_client_set_state_t));
|
||||
sizeof(esp_ble_mesh_cfg_client_set_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
@ -143,8 +143,8 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
case ESP_BLE_MESH_CFG_CLIENT_PUBLISH_EVT:
|
||||
if (p_src_data->params) {
|
||||
switch (p_src_data->params->opcode) {
|
||||
case OP_DEV_COMP_DATA_GET:
|
||||
case OP_DEV_COMP_DATA_STATUS:
|
||||
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_STATUS:
|
||||
if (p_src_data->status_cb.comp_data_status.composition_data) {
|
||||
length = p_src_data->status_cb.comp_data_status.composition_data->len;
|
||||
p_dest_data->status_cb.comp_data_status.composition_data = bt_mesh_alloc_buf(length);
|
||||
@ -157,10 +157,10 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
p_src_data->status_cb.comp_data_status.composition_data->len);
|
||||
}
|
||||
break;
|
||||
case OP_MOD_SUB_GET:
|
||||
case OP_MOD_SUB_GET_VND:
|
||||
case OP_MOD_SUB_LIST:
|
||||
case OP_MOD_SUB_LIST_VND:
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_LIST:
|
||||
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_LIST:
|
||||
if (p_src_data->status_cb.model_sub_list.sub_addr) {
|
||||
length = p_src_data->status_cb.model_sub_list.sub_addr->len;
|
||||
p_dest_data->status_cb.model_sub_list.sub_addr = bt_mesh_alloc_buf(length);
|
||||
@ -173,8 +173,8 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
p_src_data->status_cb.model_sub_list.sub_addr->len);
|
||||
}
|
||||
break;
|
||||
case OP_NET_KEY_GET:
|
||||
case OP_NET_KEY_LIST:
|
||||
case ESP_BLE_MESH_MODEL_OP_NET_KEY_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_NET_KEY_LIST:
|
||||
if (p_src_data->status_cb.netkey_list.net_idx) {
|
||||
length = p_src_data->status_cb.netkey_list.net_idx->len;
|
||||
p_dest_data->status_cb.netkey_list.net_idx = bt_mesh_alloc_buf(length);
|
||||
@ -187,8 +187,8 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
p_src_data->status_cb.netkey_list.net_idx->len);
|
||||
}
|
||||
break;
|
||||
case OP_APP_KEY_GET:
|
||||
case OP_APP_KEY_LIST:
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_LIST:
|
||||
if (p_src_data->status_cb.appkey_list.app_idx) {
|
||||
length = p_src_data->status_cb.appkey_list.app_idx->len;
|
||||
p_dest_data->status_cb.appkey_list.app_idx = bt_mesh_alloc_buf(length);
|
||||
@ -201,10 +201,10 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
p_src_data->status_cb.appkey_list.app_idx->len);
|
||||
}
|
||||
break;
|
||||
case OP_SIG_MOD_APP_GET:
|
||||
case OP_VND_MOD_APP_GET:
|
||||
case OP_SIG_MOD_APP_LIST:
|
||||
case OP_VND_MOD_APP_LIST:
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_LIST:
|
||||
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_LIST:
|
||||
if (p_src_data->status_cb.model_app_list.app_idx) {
|
||||
length = p_src_data->status_cb.model_app_list.app_idx->len;
|
||||
p_dest_data->status_cb.model_app_list.app_idx = bt_mesh_alloc_buf(length);
|
||||
@ -245,28 +245,28 @@ static void btc_ble_mesh_config_client_free_req_data(btc_msg_t *msg)
|
||||
case ESP_BLE_MESH_CFG_CLIENT_PUBLISH_EVT:
|
||||
if (arg->params) {
|
||||
switch (arg->params->opcode) {
|
||||
case OP_DEV_COMP_DATA_GET:
|
||||
case OP_DEV_COMP_DATA_STATUS:
|
||||
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_STATUS:
|
||||
bt_mesh_free_buf(arg->status_cb.comp_data_status.composition_data);
|
||||
break;
|
||||
case OP_MOD_SUB_GET:
|
||||
case OP_MOD_SUB_GET_VND:
|
||||
case OP_MOD_SUB_LIST:
|
||||
case OP_MOD_SUB_LIST_VND:
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_LIST:
|
||||
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_LIST:
|
||||
bt_mesh_free_buf(arg->status_cb.model_sub_list.sub_addr);
|
||||
break;
|
||||
case OP_NET_KEY_GET:
|
||||
case OP_NET_KEY_LIST:
|
||||
case ESP_BLE_MESH_MODEL_OP_NET_KEY_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_NET_KEY_LIST:
|
||||
bt_mesh_free_buf(arg->status_cb.netkey_list.net_idx);
|
||||
break;
|
||||
case OP_APP_KEY_GET:
|
||||
case OP_APP_KEY_LIST:
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_LIST:
|
||||
bt_mesh_free_buf(arg->status_cb.appkey_list.app_idx);
|
||||
break;
|
||||
case OP_SIG_MOD_APP_GET:
|
||||
case OP_VND_MOD_APP_GET:
|
||||
case OP_SIG_MOD_APP_LIST:
|
||||
case OP_VND_MOD_APP_LIST:
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_LIST:
|
||||
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_LIST:
|
||||
bt_mesh_free_buf(arg->status_cb.model_app_list.app_idx);
|
||||
break;
|
||||
default:
|
||||
@ -287,8 +287,6 @@ static void btc_ble_mesh_config_client_callback(esp_ble_mesh_cfg_client_cb_param
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_CONFIG_CLIENT)) {
|
||||
return;
|
||||
@ -311,7 +309,7 @@ void bt_mesh_config_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
if (!model || !ctx || len > sizeof(cb_params.status_cb)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -349,14 +347,14 @@ void bt_mesh_config_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
memcpy(&cb_params.status_cb, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_config_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_config_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_config_client_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
@ -367,7 +365,6 @@ void btc_ble_mesh_config_client_publish_callback(uint32_t opcode, struct bt_mesh
|
||||
|
||||
bt_mesh_config_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
@ -400,15 +397,7 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
|
||||
break;
|
||||
}
|
||||
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = BLE_MESH_KEY_DEV;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, true);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BEACON_GET:
|
||||
@ -461,8 +450,6 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
|
||||
BT_ERR("Invalid Configuration Get opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
@ -480,15 +467,7 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = BLE_MESH_KEY_DEV;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, true);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BEACON_SET:
|
||||
@ -609,8 +588,6 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
|
||||
BT_ERR("Invalid Configuration Set opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
|
||||
@ -649,7 +626,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_config_client_arg_deep_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg)
|
||||
@ -670,7 +646,6 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_config_client_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_CFG_CLI */
|
||||
@ -691,8 +666,6 @@ static void btc_ble_mesh_config_server_callback(esp_ble_mesh_cfg_server_cb_param
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_CONFIG_SERVER)) {
|
||||
return;
|
||||
@ -705,14 +678,15 @@ static void btc_ble_mesh_config_server_callback(esp_ble_mesh_cfg_server_cb_param
|
||||
btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_cfg_server_cb_param_t), NULL, NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_config_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_config_server_cb_evt_to_btc(uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_cfg_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
if (!model || !ctx || len > sizeof(cb_params.value)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -737,11 +711,10 @@ void bt_mesh_config_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
memcpy(&cb_params.value, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_config_server_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg)
|
||||
|
@ -7,11 +7,12 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_generic_model.h"
|
||||
#include "esp_ble_mesh_generic_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_GENERIC_CLIENT
|
||||
#include "generic_client.h"
|
||||
#include "mesh/generic_client.h"
|
||||
|
||||
/* Generic Client Models related functions */
|
||||
|
||||
@ -357,8 +358,6 @@ static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_GENERIC_CLIENT)) {
|
||||
return;
|
||||
@ -381,7 +380,7 @@ void bt_mesh_generic_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
if (!model || !ctx || len > sizeof(cb_params.status_cb)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -419,14 +418,14 @@ void bt_mesh_generic_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
memcpy(&cb_params.status_cb, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_generic_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_generic_client_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
@ -437,15 +436,13 @@ void btc_ble_mesh_generic_client_publish_callback(uint32_t opcode, struct bt_mes
|
||||
|
||||
bt_mesh_generic_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_client_common_param_t *params = NULL;
|
||||
btc_ble_mesh_generic_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_generic_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
btc_ble_mesh_generic_client_args_t *arg = NULL;
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@ -455,52 +452,31 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
arg = (btc_ble_mesh_generic_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE: {
|
||||
params = arg->generic_client_get_state.params;
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
common.ctx.app_idx = params->ctx.app_idx;
|
||||
common.ctx.addr = params->ctx.addr;
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE:
|
||||
btc_ble_mesh_set_client_common_param(arg->generic_client_get_state.params, ¶m, false);
|
||||
|
||||
cb.params = arg->generic_client_get_state.params;
|
||||
cb.error_code = bt_mesh_generic_client_get_state(&common, arg->generic_client_get_state.get_state);
|
||||
cb.error_code = bt_mesh_generic_client_get_state(¶m, arg->generic_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE: {
|
||||
params = arg->generic_client_set_state.params;
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
common.ctx.app_idx = params->ctx.app_idx;
|
||||
common.ctx.addr = params->ctx.addr;
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE:
|
||||
btc_ble_mesh_set_client_common_param(arg->generic_client_set_state.params, ¶m, false);
|
||||
|
||||
cb.params = arg->generic_client_set_state.params;
|
||||
cb.error_code = bt_mesh_generic_client_set_state(&common, arg->generic_client_set_state.set_state);
|
||||
cb.error_code = bt_mesh_generic_client_set_state(¶m, arg->generic_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_client_arg_deep_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
|
||||
@ -521,7 +497,6 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_client_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
|
||||
@ -674,8 +649,6 @@ static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_GENERIC_SERVER)) {
|
||||
return;
|
||||
@ -689,14 +662,15 @@ static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_
|
||||
btc_ble_mesh_generic_server_copy_req_data, btc_ble_mesh_generic_server_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_generic_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (model == NULL || ctx == NULL) {
|
||||
if (model == NULL || ctx == NULL || len > sizeof(cb_params.value)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -725,13 +699,13 @@ void bt_mesh_generic_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
cb_params.ctx.recv_cred = ctx->recv_cred;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
memcpy(&cb_params.value, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_server_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg)
|
||||
@ -752,7 +726,6 @@ void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_server_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
|
||||
|
@ -7,12 +7,12 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_health_model.h"
|
||||
#include "foundation.h"
|
||||
#include "esp_ble_mesh_health_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_HEALTH_CLI
|
||||
#include "health_cli.h"
|
||||
#include "mesh/health_cli.h"
|
||||
|
||||
/* Health Client Model related functions */
|
||||
|
||||
@ -136,7 +136,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
case ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT:
|
||||
if (p_src_data->params) {
|
||||
switch (p_src_data->params->opcode) {
|
||||
case OP_HEALTH_CURRENT_STATUS:
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_CURRENT_STATUS:
|
||||
if (p_src_data->status_cb.current_status.fault_array) {
|
||||
length = p_src_data->status_cb.current_status.fault_array->len;
|
||||
p_dest_data->status_cb.current_status.fault_array = bt_mesh_alloc_buf(length);
|
||||
@ -149,10 +149,10 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
p_src_data->status_cb.current_status.fault_array->len);
|
||||
}
|
||||
break;
|
||||
case OP_HEALTH_FAULT_GET:
|
||||
case OP_HEALTH_FAULT_CLEAR:
|
||||
case OP_HEALTH_FAULT_TEST:
|
||||
case OP_HEALTH_FAULT_STATUS:
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_STATUS:
|
||||
if (p_src_data->status_cb.fault_status.fault_array) {
|
||||
length = p_src_data->status_cb.fault_status.fault_array->len;
|
||||
p_dest_data->status_cb.fault_status.fault_array = bt_mesh_alloc_buf(length);
|
||||
@ -193,13 +193,13 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
|
||||
case ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT:
|
||||
if (arg->params) {
|
||||
switch (arg->params->opcode) {
|
||||
case OP_HEALTH_CURRENT_STATUS:
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_CURRENT_STATUS:
|
||||
bt_mesh_free_buf(arg->status_cb.current_status.fault_array);
|
||||
break;
|
||||
case OP_HEALTH_FAULT_GET:
|
||||
case OP_HEALTH_FAULT_CLEAR:
|
||||
case OP_HEALTH_FAULT_TEST:
|
||||
case OP_HEALTH_FAULT_STATUS:
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_STATUS:
|
||||
bt_mesh_free_buf(arg->status_cb.fault_status.fault_array);
|
||||
break;
|
||||
default:
|
||||
@ -220,8 +220,6 @@ static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_pa
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_HEALTH_CLIENT)) {
|
||||
return;
|
||||
@ -244,7 +242,7 @@ void bt_mesh_health_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
if (!model || !ctx || len > sizeof(cb_params.status_cb)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -282,14 +280,14 @@ void bt_mesh_health_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
memcpy(&cb_params.status_cb, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_health_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
@ -300,7 +298,6 @@ void btc_ble_mesh_health_publish_callback(uint32_t opcode, struct bt_mesh_model
|
||||
|
||||
bt_mesh_health_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
@ -318,15 +315,7 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = params->ctx.app_idx;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, false);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
|
||||
@ -339,8 +328,6 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param
|
||||
BT_ERR("Invalid Health Get opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
@ -353,15 +340,7 @@ static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = params->ctx.app_idx;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, false);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
|
||||
@ -384,8 +363,6 @@ static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param
|
||||
BT_ERR("Invalid Health Set opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
|
||||
@ -426,7 +403,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_client_arg_deep_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
|
||||
@ -447,13 +423,12 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_client_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_HEALTH_SRV
|
||||
#include "health_srv.h"
|
||||
#include "mesh/health_srv.h"
|
||||
|
||||
/* Health Server Model related functions */
|
||||
|
||||
@ -531,8 +506,6 @@ static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_pa
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_HEALTH_SERVER)) {
|
||||
return;
|
||||
@ -570,7 +543,6 @@ void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_server_arg_deep_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg)
|
||||
@ -591,7 +563,6 @@ void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_server_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, uint16_t company_id)
|
||||
|
@ -7,11 +7,12 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_lighting_model.h"
|
||||
#include "esp_ble_mesh_lighting_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
|
||||
#include "lighting_client.h"
|
||||
#include "mesh/lighting_client.h"
|
||||
|
||||
/* Lighting Client Models related functions */
|
||||
|
||||
@ -79,7 +80,7 @@ void btc_ble_mesh_lighting_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_lighting_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -165,7 +166,7 @@ static void btc_ble_mesh_lighting_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_light_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -201,8 +202,6 @@ static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_p
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_LIGHTING_CLIENT)) {
|
||||
return;
|
||||
@ -225,7 +224,7 @@ void bt_mesh_lighting_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
if (!model || !ctx || len > sizeof(cb_params.status_cb)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -263,14 +262,14 @@ void bt_mesh_lighting_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
memcpy(&cb_params.status_cb, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lighting_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_lighting_client_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
@ -281,17 +280,15 @@ void btc_ble_mesh_lighting_client_publish_callback(uint32_t opcode, struct bt_me
|
||||
|
||||
bt_mesh_lighting_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_client_common_param_t *params = NULL;
|
||||
btc_ble_mesh_lighting_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_light_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -299,59 +296,38 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
|
||||
arg = (btc_ble_mesh_lighting_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE: {
|
||||
params = arg->light_client_get_state.params;
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
common.ctx.app_idx = params->ctx.app_idx;
|
||||
common.ctx.addr = params->ctx.addr;
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE:
|
||||
btc_ble_mesh_set_client_common_param(arg->light_client_get_state.params, ¶m, false);
|
||||
|
||||
cb.params = arg->light_client_get_state.params;
|
||||
cb.error_code = bt_mesh_light_client_get_state(&common, arg->light_client_get_state.get_state);
|
||||
cb.error_code = bt_mesh_light_client_get_state(¶m, arg->light_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: {
|
||||
params = arg->light_client_set_state.params;
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
common.ctx.app_idx = params->ctx.app_idx;
|
||||
common.ctx.addr = params->ctx.addr;
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE:
|
||||
btc_ble_mesh_set_client_common_param(arg->light_client_set_state.params, ¶m, false);
|
||||
|
||||
cb.params = arg->light_client_set_state.params;
|
||||
cb.error_code = bt_mesh_light_client_set_state(&common, arg->light_client_set_state.set_state);
|
||||
cb.error_code = bt_mesh_light_client_set_state(¶m, arg->light_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_client_arg_deep_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_light_client_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -365,7 +341,6 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_client_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
|
||||
@ -462,13 +437,13 @@ static void btc_ble_mesh_lighting_server_free_req_data(btc_msg_t *msg)
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT:
|
||||
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
|
||||
bt_mesh_free_buf(arg->value.state_change.lc_property_set.property_value);
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT:
|
||||
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
|
||||
bt_mesh_free_buf(arg->value.set.lc_property.property_value);
|
||||
}
|
||||
break;
|
||||
@ -486,8 +461,6 @@ static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_c
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_LIGHTING_SERVER)) {
|
||||
return;
|
||||
@ -501,14 +474,15 @@ static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_c
|
||||
btc_ble_mesh_lighting_server_copy_req_data, btc_ble_mesh_lighting_server_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_lighting_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (model == NULL || ctx == NULL) {
|
||||
if (model == NULL || ctx == NULL || len > sizeof(cb_params.value)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -542,11 +516,10 @@ void bt_mesh_lighting_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_mode
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
memcpy(&cb_params.value, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_server_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg)
|
||||
@ -567,7 +540,6 @@ void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_server_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,11 +7,12 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_sensor_model.h"
|
||||
#include "esp_ble_mesh_sensor_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_SENSOR_CLI
|
||||
#include "sensor_client.h"
|
||||
#include "mesh/sensor_client.h"
|
||||
|
||||
/* Sensor Client Models related functions */
|
||||
|
||||
@ -439,8 +440,6 @@ static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_pa
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_SENSOR_CLIENT)) {
|
||||
return;
|
||||
@ -463,7 +462,7 @@ void bt_mesh_sensor_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
if (!model || !ctx || len > sizeof(cb_params.status_cb)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -501,14 +500,14 @@ void bt_mesh_sensor_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
memcpy(&cb_params.status_cb, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sensor_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_sensor_client_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
@ -519,15 +518,13 @@ void btc_ble_mesh_sensor_client_publish_callback(uint32_t opcode, struct bt_mesh
|
||||
|
||||
bt_mesh_sensor_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_client_common_param_t *params = NULL;
|
||||
btc_ble_mesh_sensor_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_sensor_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
btc_ble_mesh_sensor_client_args_t *arg = NULL;
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@ -537,52 +534,31 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
||||
arg = (btc_ble_mesh_sensor_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE: {
|
||||
params = arg->sensor_client_get_state.params;
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
common.ctx.app_idx = params->ctx.app_idx;
|
||||
common.ctx.addr = params->ctx.addr;
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE:
|
||||
btc_ble_mesh_set_client_common_param(arg->sensor_client_get_state.params, ¶m, false);
|
||||
|
||||
cb.params = arg->sensor_client_get_state.params;
|
||||
cb.error_code = bt_mesh_sensor_client_get_state(&common, arg->sensor_client_get_state.get_state);
|
||||
cb.error_code = bt_mesh_sensor_client_get_state(¶m, arg->sensor_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE: {
|
||||
params = arg->sensor_client_set_state.params;
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
common.ctx.app_idx = params->ctx.app_idx;
|
||||
common.ctx.addr = params->ctx.addr;
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE:
|
||||
btc_ble_mesh_set_client_common_param(arg->sensor_client_set_state.params, ¶m, false);
|
||||
|
||||
cb.params = arg->sensor_client_set_state.params;
|
||||
cb.error_code = bt_mesh_sensor_client_set_state(&common, arg->sensor_client_set_state.set_state);
|
||||
cb.error_code = bt_mesh_sensor_client_set_state(¶m, arg->sensor_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_client_arg_deep_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
|
||||
@ -603,7 +579,6 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_client_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
|
||||
@ -771,7 +746,7 @@ static void btc_ble_mesh_sensor_server_free_req_data(btc_msg_t *msg)
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT:
|
||||
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
|
||||
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.trigger_delta_down);
|
||||
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.trigger_delta_up);
|
||||
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.fast_cadence_low);
|
||||
@ -790,7 +765,7 @@ static void btc_ble_mesh_sensor_server_free_req_data(btc_msg_t *msg)
|
||||
break;
|
||||
case ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT:
|
||||
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
|
||||
bt_mesh_free_buf(arg->value.set.sensor_cadence.cadence);
|
||||
} else if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ||
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) {
|
||||
@ -806,8 +781,6 @@ static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_pa
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_SENSOR_SERVER)) {
|
||||
return;
|
||||
@ -821,14 +794,15 @@ static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_pa
|
||||
btc_ble_mesh_sensor_server_copy_req_data, btc_ble_mesh_sensor_server_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_sensor_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (model == NULL || ctx == NULL) {
|
||||
if (model == NULL || ctx == NULL || len > sizeof(cb_params.value)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -859,11 +833,10 @@ void bt_mesh_sensor_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
memcpy(&cb_params.value, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_server_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg)
|
||||
@ -884,7 +857,6 @@ void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_server_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */
|
||||
|
@ -7,11 +7,12 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_time_scene_model.h"
|
||||
#include "esp_ble_mesh_time_scene_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
|
||||
#include "time_scene_client.h"
|
||||
#include "mesh/time_scene_client.h"
|
||||
|
||||
/* Time and Scenes Client Models related functions */
|
||||
|
||||
@ -79,7 +80,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -166,7 +167,7 @@ static void btc_ble_mesh_time_scene_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -203,8 +204,6 @@ static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_clie
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT)) {
|
||||
return;
|
||||
@ -227,7 +226,7 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
if (!model || !ctx || len > sizeof(cb_params.status_cb)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -265,14 +264,14 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
memcpy(&cb_params.status_cb, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_time_scene_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
@ -283,17 +282,15 @@ void btc_ble_mesh_time_scene_client_publish_callback(uint32_t opcode, struct bt_
|
||||
|
||||
bt_mesh_time_scene_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_client_common_param_t *params = NULL;
|
||||
esp_ble_mesh_time_scene_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -301,59 +298,38 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
arg = (btc_ble_mesh_time_scene_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE: {
|
||||
params = arg->time_scene_client_get_state.params;
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
common.ctx.app_idx = params->ctx.app_idx;
|
||||
common.ctx.addr = params->ctx.addr;
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE:
|
||||
btc_ble_mesh_set_client_common_param(arg->time_scene_client_get_state.params, ¶m, false);
|
||||
|
||||
cb.params = arg->time_scene_client_get_state.params;
|
||||
cb.error_code = bt_mesh_time_scene_client_get_state(&common, arg->time_scene_client_get_state.get_state);
|
||||
cb.error_code = bt_mesh_time_scene_client_get_state(¶m, arg->time_scene_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE: {
|
||||
params = arg->time_scene_client_set_state.params;
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
common.ctx.app_idx = params->ctx.app_idx;
|
||||
common.ctx.addr = params->ctx.addr;
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE:
|
||||
btc_ble_mesh_set_client_common_param(arg->time_scene_client_set_state.params, ¶m, false);
|
||||
|
||||
cb.params = arg->time_scene_client_set_state.params;
|
||||
cb.error_code = bt_mesh_time_scene_client_set_state(&common, arg->time_scene_client_set_state.set_state);
|
||||
cb.error_code = bt_mesh_time_scene_client_set_state(¶m, arg->time_scene_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_time_scene_client_arg_deep_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -367,7 +343,6 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_time_scene_client_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
|
||||
@ -390,8 +365,6 @@ static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_serv
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_TIME_SCENE_SERVER)) {
|
||||
return;
|
||||
@ -404,14 +377,15 @@ static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_serv
|
||||
btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL, NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_time_scene_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (model == NULL || ctx == NULL) {
|
||||
if (model == NULL || ctx == NULL || len > sizeof(cb_params.value)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
@ -445,11 +419,10 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_mo
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
memcpy(&cb_params.value, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_time_scene_server_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg)
|
||||
@ -468,8 +441,6 @@ void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg)
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "btc/btc_manage.h"
|
||||
#include "mesh_bearer_adapt.h"
|
||||
#include "mesh/adapter.h"
|
||||
#include "esp_ble_mesh_ble_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -47,7 +47,8 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
|
||||
void btc_ble_mesh_config_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_config_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_config_client_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
@ -63,7 +64,8 @@ typedef enum {
|
||||
BTC_BLE_MESH_EVT_CONFIG_SERVER_MAX,
|
||||
} btc_ble_mesh_config_server_evt_t;
|
||||
|
||||
void bt_mesh_config_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_config_server_cb_evt_to_btc(uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
|
@ -47,7 +47,8 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
|
||||
|
||||
void btc_ble_mesh_generic_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_generic_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_generic_client_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
@ -63,7 +64,8 @@ typedef enum {
|
||||
BTC_BLE_MESH_EVT_GENERIC_SERVER_MAX,
|
||||
} btc_ble_mesh_generic_server_evt_t;
|
||||
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
|
@ -47,7 +47,8 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_health_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_health_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
|
@ -47,7 +47,8 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
|
||||
|
||||
void btc_ble_mesh_lighting_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_lighting_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_lighting_client_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
@ -64,7 +65,8 @@ typedef enum {
|
||||
BTC_BLE_MESH_EVT_LIGHTING_SERVER_MAX,
|
||||
} btc_ble_mesh_lighting_server_evt_t;
|
||||
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BTC_BLE_MESH_MODEL_COMMON_H_
|
||||
#define _BTC_BLE_MESH_MODEL_COMMON_H_
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "mesh/access.h"
|
||||
#include "mesh/client_common.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static inline void btc_ble_mesh_set_client_common_param(esp_ble_mesh_client_common_param_t *input,
|
||||
bt_mesh_client_common_param_t *output,
|
||||
bool use_dev_key)
|
||||
{
|
||||
if (input && output) {
|
||||
output->opcode = input->opcode;
|
||||
output->model = (struct bt_mesh_model *)input->model;
|
||||
output->ctx.net_idx = input->ctx.net_idx;
|
||||
output->ctx.app_idx = use_dev_key ? BLE_MESH_KEY_DEV : input->ctx.app_idx;
|
||||
output->ctx.addr = input->ctx.addr;
|
||||
output->ctx.send_szmic = input->ctx.send_szmic;
|
||||
output->ctx.send_ttl = input->ctx.send_ttl;
|
||||
output->ctx.send_cred = input->ctx.send_cred;
|
||||
output->ctx.send_tag = input->ctx.send_tag;
|
||||
output->msg_timeout = input->msg_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_MODEL_COMMON_H_ */
|
@ -8,11 +8,10 @@
|
||||
#define _BTC_BLE_MESH_PROV_H_
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "mesh_byteorder.h"
|
||||
#include "mesh_config.h"
|
||||
#include "mesh_main.h"
|
||||
#include "mesh/byteorder.h"
|
||||
#include "mesh/config.h"
|
||||
#include "mesh/main.h"
|
||||
#include "fast_prov.h"
|
||||
#include "provisioner_prov.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -65,6 +64,10 @@ typedef enum {
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_UID,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_INDEX,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_UID,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_SEND_PROV_RECORDS_GET,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_SEND_PROV_RECORD_REQUEST,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_SEND_PROV_INVITE,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_SEND_LINK_CLOSE,
|
||||
BTC_BLE_MESH_ACT_SET_FAST_PROV_INFO,
|
||||
BTC_BLE_MESH_ACT_SET_FAST_PROV_ACTION,
|
||||
BTC_BLE_MESH_ACT_LPN_ENABLE,
|
||||
@ -75,6 +78,8 @@ typedef enum {
|
||||
BTC_BLE_MESH_ACT_PROXY_CLIENT_SET_FILTER_TYPE,
|
||||
BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR,
|
||||
BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR,
|
||||
BTC_BLE_MESH_ACT_PROXY_CLIENT_DIRECTED_PROXY_SET,
|
||||
BTC_BLE_MESH_ACT_PROXY_CLIENT_SEND_SOLIC_PDU,
|
||||
BTC_BLE_MESH_ACT_MODEL_SUBSCRIBE_GROUP_ADDR,
|
||||
BTC_BLE_MESH_ACT_MODEL_UNSUBSCRIBE_GROUP_ADDR,
|
||||
BTC_BLE_MESH_ACT_DEINIT_MESH,
|
||||
@ -248,6 +253,21 @@ typedef union {
|
||||
struct {
|
||||
char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1];
|
||||
} delete_settings_with_uid;
|
||||
struct {
|
||||
uint16_t link_idx;
|
||||
} send_prov_records_get;
|
||||
struct {
|
||||
uint16_t link_idx;
|
||||
uint16_t record_id;
|
||||
uint16_t frag_offset;
|
||||
uint16_t max_size;
|
||||
} send_prov_record_req;
|
||||
struct {
|
||||
uint16_t link_idx;
|
||||
} send_prov_invite;
|
||||
struct {
|
||||
uint16_t link_idx;
|
||||
} send_link_close;
|
||||
struct ble_mesh_set_fast_prov_info_args {
|
||||
uint16_t unicast_min;
|
||||
uint16_t unicast_max;
|
||||
@ -295,6 +315,16 @@ typedef union {
|
||||
uint16_t addr_num;
|
||||
uint16_t *addr;
|
||||
} proxy_client_remove_filter_addr;
|
||||
struct ble_mesh_proxy_client_directed_proxy_set_args {
|
||||
uint8_t conn_handle;
|
||||
uint16_t net_idx;
|
||||
uint8_t use_directed;
|
||||
} proxy_client_directed_proxy_set;
|
||||
struct {
|
||||
uint16_t net_idx;
|
||||
uint16_t ssrc;
|
||||
uint16_t dst;
|
||||
} proxy_client_send_solic_pdu;
|
||||
struct ble_mesh_model_sub_group_addr_args {
|
||||
uint16_t element_addr;
|
||||
uint16_t company_id;
|
||||
@ -315,7 +345,7 @@ typedef union {
|
||||
typedef union {
|
||||
struct ble_mesh_model_publish_args {
|
||||
esp_ble_mesh_model_t *model;
|
||||
uint8_t device_role;
|
||||
uint8_t device_role __attribute__((deprecated));
|
||||
} model_publish;
|
||||
struct ble_mesh_model_send_args {
|
||||
esp_ble_mesh_model_t *model;
|
||||
@ -324,7 +354,7 @@ typedef union {
|
||||
bool need_rsp;
|
||||
uint16_t length;
|
||||
uint8_t *data;
|
||||
uint8_t device_role;
|
||||
uint8_t device_role __attribute__((deprecated));
|
||||
int32_t msg_timeout;
|
||||
} model_send;
|
||||
struct ble_mesh_server_model_update_state_args {
|
||||
@ -389,6 +419,11 @@ void btc_ble_mesh_model_cb_handler(btc_msg_t *msg);
|
||||
void btc_ble_mesh_prov_call_handler(btc_msg_t *msg);
|
||||
void btc_ble_mesh_prov_cb_handler(btc_msg_t *msg);
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
int btc_ble_mesh_enable_directed_forwarding(uint16_t net_idx, bool directed_forwarding,
|
||||
bool directed_forwarding_relay);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -47,7 +47,8 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
|
||||
void btc_ble_mesh_sensor_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_sensor_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_sensor_client_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
@ -63,7 +64,8 @@ typedef enum {
|
||||
BTC_BLE_MESH_EVT_SENSOR_SERVER_MAX,
|
||||
} btc_ble_mesh_sensor_server_evt_t;
|
||||
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
|
@ -45,7 +45,10 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
@ -62,7 +65,8 @@ typedef enum {
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_MAX,
|
||||
} btc_ble_mesh_time_scene_server_evt_t;
|
||||
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
|
@ -18,8 +18,8 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "mesh_atomic.h"
|
||||
#include "mesh_mutex.h"
|
||||
#include "mesh/atomic.h"
|
||||
#include "mesh/mutex.h"
|
||||
|
||||
#ifndef CONFIG_ATOMIC_OPERATIONS_BUILTIN
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "mesh_common.h"
|
||||
#include "mesh/common.h"
|
||||
|
||||
int net_buf_id(struct net_buf *buf)
|
||||
{
|
||||
@ -281,7 +281,7 @@ uint32_t net_buf_simple_pull_le24(struct net_buf_simple *buf)
|
||||
{
|
||||
struct uint24 {
|
||||
uint32_t u24:24;
|
||||
} __packed val;
|
||||
} __attribute__((packed)) val;
|
||||
|
||||
val = UNALIGNED_GET((struct uint24 *)buf->data);
|
||||
net_buf_simple_pull(buf, sizeof(val));
|
||||
@ -293,7 +293,7 @@ uint32_t net_buf_simple_pull_be24(struct net_buf_simple *buf)
|
||||
{
|
||||
struct uint24 {
|
||||
uint32_t u24:24;
|
||||
} __packed val;
|
||||
} __attribute__((packed)) val;
|
||||
|
||||
val = UNALIGNED_GET((struct uint24 *)buf->data);
|
||||
net_buf_simple_pull(buf, sizeof(val));
|
||||
@ -325,7 +325,7 @@ uint64_t net_buf_simple_pull_le48(struct net_buf_simple *buf)
|
||||
{
|
||||
struct uint48 {
|
||||
uint64_t u48:48;
|
||||
} __packed val;
|
||||
} __attribute__((packed)) val;
|
||||
|
||||
val = UNALIGNED_GET((struct uint48 *)buf->data);
|
||||
net_buf_simple_pull(buf, sizeof(val));
|
||||
@ -337,7 +337,7 @@ uint64_t net_buf_simple_pull_be48(struct net_buf_simple *buf)
|
||||
{
|
||||
struct uint48 {
|
||||
uint64_t u48:48;
|
||||
} __packed val;
|
||||
} __attribute__((packed)) val;
|
||||
|
||||
val = UNALIGNED_GET((struct uint48 *)buf->data);
|
||||
net_buf_simple_pull(buf, sizeof(val));
|
||||
@ -459,7 +459,7 @@ struct net_buf *net_buf_ref(struct net_buf *buf)
|
||||
return buf;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
|
||||
#if CONFIG_BLE_MESH_NET_BUF_LOG
|
||||
void net_buf_unref_debug(struct net_buf *buf, const char *func, int line)
|
||||
#else
|
||||
void net_buf_unref(struct net_buf *buf)
|
||||
@ -471,7 +471,7 @@ void net_buf_unref(struct net_buf *buf)
|
||||
struct net_buf *frags = buf->frags;
|
||||
struct net_buf_pool *pool = NULL;
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
|
||||
#if CONFIG_BLE_MESH_NET_BUF_LOG
|
||||
if (!buf->ref) {
|
||||
NET_BUF_ERR("%s():%d: buf %p double free", func, line,
|
||||
buf);
|
||||
@ -491,7 +491,7 @@ void net_buf_unref(struct net_buf *buf)
|
||||
pool = buf->pool;
|
||||
|
||||
pool->uninit_count++;
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
|
||||
#if CONFIG_BLE_MESH_NET_BUF_POOL_USAGE
|
||||
pool->avail_count++;
|
||||
NET_BUF_DBG("Unref, pool %p, avail_count %d, uninit_count %d",
|
||||
pool, pool->avail_count, pool->uninit_count);
|
||||
@ -533,7 +533,7 @@ static uint8_t *data_alloc(struct net_buf *buf, size_t *size, int32_t timeout)
|
||||
return pool->alloc->cb->alloc(buf, size, timeout);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
|
||||
#if CONFIG_BLE_MESH_NET_BUF_LOG
|
||||
struct net_buf *net_buf_alloc_len_debug(struct net_buf_pool *pool, size_t size,
|
||||
int32_t timeout, const char *func, int line)
|
||||
#else
|
||||
@ -594,7 +594,7 @@ success:
|
||||
net_buf_reset(buf);
|
||||
|
||||
pool->uninit_count--;
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
|
||||
#if CONFIG_BLE_MESH_NET_BUF_POOL_USAGE
|
||||
pool->avail_count--;
|
||||
NET_BUF_ASSERT(pool->avail_count >= 0);
|
||||
#endif
|
||||
@ -602,7 +602,7 @@ success:
|
||||
return buf;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
|
||||
#if CONFIG_BLE_MESH_NET_BUF_LOG
|
||||
struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool,
|
||||
int32_t timeout, const char *func,
|
||||
int line)
|
||||
@ -656,7 +656,7 @@ struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag)
|
||||
return head;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
|
||||
#if CONFIG_BLE_MESH_NET_BUF_LOG
|
||||
struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
|
||||
struct net_buf *frag,
|
||||
const char *func, int line)
|
||||
@ -678,7 +678,7 @@ struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag)
|
||||
|
||||
frag->frags = NULL;
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
|
||||
#if CONFIG_BLE_MESH_NET_BUF_LOG
|
||||
net_buf_unref_debug(frag, func, line);
|
||||
#else
|
||||
net_buf_unref(frag);
|
@ -9,9 +9,9 @@
|
||||
|
||||
#include "esp_random.h"
|
||||
|
||||
#include "mesh_main.h"
|
||||
#include "client_common.h"
|
||||
#include "mesh_common.h"
|
||||
#include "mesh/main.h"
|
||||
#include "mesh/client_common.h"
|
||||
#include "mesh/common.h"
|
||||
|
||||
IRAM_ATTR void *bt_mesh_malloc(size_t size)
|
||||
{
|
||||
@ -72,25 +72,6 @@ void bt_mesh_free_buf(struct net_buf_simple *buf)
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send)
|
||||
{
|
||||
bt_mesh_client_user_data_t *client = NULL;
|
||||
|
||||
if (srv_send) {
|
||||
BT_DBG("Message is sent by a server model");
|
||||
return NODE;
|
||||
}
|
||||
|
||||
if (!model || !model->user_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return ROLE_NVAL;
|
||||
}
|
||||
|
||||
client = (bt_mesh_client_user_data_t *)model->user_data;
|
||||
|
||||
return client->msg_role;
|
||||
}
|
||||
|
||||
int bt_mesh_rand(void *buf, size_t len)
|
||||
{
|
||||
if (buf == NULL || len == 0) {
|
@ -9,7 +9,7 @@
|
||||
#ifndef _BLE_MESH_ATOMIC_H_
|
||||
#define _BLE_MESH_ATOMIC_H_
|
||||
|
||||
#include "mesh_types.h"
|
||||
#include "mesh/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
@ -11,10 +11,10 @@
|
||||
#ifndef _BLE_MESH_BUF_H_
|
||||
#define _BLE_MESH_BUF_H_
|
||||
|
||||
#include "mesh_config.h"
|
||||
#include "mesh_types.h"
|
||||
#include "mesh_slist.h"
|
||||
#include "mesh_compiler.h"
|
||||
#include "mesh/config.h"
|
||||
#include "mesh/types.h"
|
||||
#include "mesh/slist.h"
|
||||
#include "mesh/compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -816,7 +816,7 @@ struct net_buf_pool {
|
||||
/** Number of uninitialized buffers */
|
||||
uint16_t uninit_count;
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
|
||||
#if CONFIG_BLE_MESH_NET_BUF_POOL_USAGE
|
||||
/** Amount of available buffers in the pool. */
|
||||
int16_t avail_count;
|
||||
|
||||
@ -837,7 +837,7 @@ struct net_buf_pool {
|
||||
struct net_buf *const __bufs;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
|
||||
#if CONFIG_BLE_MESH_NET_BUF_POOL_USAGE
|
||||
#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _destroy) \
|
||||
{ \
|
||||
.alloc = _alloc, \
|
||||
@ -962,11 +962,11 @@ int net_buf_id(struct net_buf *buf);
|
||||
*
|
||||
* @return New buffer or NULL if out of buffers.
|
||||
*/
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
|
||||
#if CONFIG_BLE_MESH_NET_BUF_LOG
|
||||
struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, int32_t timeout,
|
||||
const char *func, int line);
|
||||
#define net_buf_alloc_fixed(_pool, _timeout) \
|
||||
net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
|
||||
net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
|
||||
#else
|
||||
struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, int32_t timeout);
|
||||
#endif
|
||||
@ -1031,7 +1031,7 @@ struct net_buf *net_buf_slist_get(sys_slist_t *list);
|
||||
*
|
||||
* @param buf A valid pointer on a buffer
|
||||
*/
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
|
||||
#if CONFIG_BLE_MESH_NET_BUF_LOG
|
||||
void net_buf_unref_debug(struct net_buf *buf, const char *func, int line);
|
||||
#define net_buf_unref(_buf) \
|
||||
net_buf_unref_debug(_buf, __func__, __LINE__)
|
||||
@ -1630,12 +1630,12 @@ struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag);
|
||||
* @return Pointer to the buffer following the fragment, or NULL if it
|
||||
* had no further fragments.
|
||||
*/
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
|
||||
#if CONFIG_BLE_MESH_NET_BUF_LOG
|
||||
struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
|
||||
struct net_buf *frag,
|
||||
const char *func, int line);
|
||||
#define net_buf_frag_del(_parent, _frag) \
|
||||
net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
|
||||
net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
|
||||
#else
|
||||
struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag);
|
||||
#endif
|
@ -7,8 +7,8 @@
|
||||
#ifndef _BLE_MESH_BYTEORDER_H_
|
||||
#define _BLE_MESH_BYTEORDER_H_
|
||||
|
||||
#include "mesh_types.h"
|
||||
#include "mesh_trace.h"
|
||||
#include "mesh/types.h"
|
||||
#include "mesh/trace.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -335,7 +335,7 @@ static inline void sys_put_le16(uint16_t val, uint8_t dst[2])
|
||||
* @brief Put a 24-bit integer as little-endian to arbitrary location.
|
||||
*
|
||||
* Put a 24-bit integer, originally in host endianness, to a
|
||||
* potentially unaligned memory location in littel-endian format.
|
||||
* potentially unaligned memory location in little-endian format.
|
||||
*
|
||||
* @param val 24-bit integer in host endianness.
|
||||
* @param dst Destination memory address to store the result.
|
@ -17,11 +17,11 @@
|
||||
#include "esp_attr.h"
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
#include "mesh_byteorder.h"
|
||||
#include "mesh_ffs.h"
|
||||
#include "mesh_trace.h"
|
||||
#include "mesh_mutex.h"
|
||||
#include "mesh_access.h"
|
||||
#include "mesh/byteorder.h"
|
||||
#include "mesh/ffs.h"
|
||||
#include "mesh/trace.h"
|
||||
#include "mesh/mutex.h"
|
||||
#include "mesh/access.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -51,20 +51,6 @@ struct net_buf_simple *bt_mesh_alloc_buf(uint16_t size);
|
||||
*/
|
||||
void bt_mesh_free_buf(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief This function gets device role for stack internal use.
|
||||
*
|
||||
* @Note Currently Provisioner only support client models, Node supports
|
||||
* client models and server models. Hence if srv_send is set to be
|
||||
* TRUE, then role NODE will be returned.
|
||||
*
|
||||
* @param[in] model: Pointer to the model structure
|
||||
* @param[in] srv_send: Indicate if the message is sent by a server model
|
||||
*
|
||||
* @return 0 - Node, 1 - Provisioner
|
||||
*/
|
||||
uint8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send);
|
||||
|
||||
int bt_mesh_rand(void *buf, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
@ -13,6 +13,17 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BLE_MESH_PBA_SAME_TIME
|
||||
#define CONFIG_BLE_MESH_PBA_SAME_TIME 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BLE_MESH_PBG_SAME_TIME
|
||||
#define CONFIG_BLE_MESH_PBG_SAME_TIME 0
|
||||
#endif
|
||||
|
||||
#define CONFIG_BLE_MESH_PRIVATE_BEACON (CONFIG_BLE_MESH_PRB_SRV || \
|
||||
CONFIG_BLE_MESH_PRB_CLI)
|
||||
|
||||
#define CONFIG_BLE_MESH_GENERIC_CLIENT (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI || \
|
||||
CONFIG_BLE_MESH_GENERIC_LEVEL_CLI || \
|
||||
CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI || \
|
||||
@ -40,6 +51,9 @@ extern "C" {
|
||||
#define CONFIG_BLE_MESH_BLE_COEX_SUPPORT (CONFIG_BLE_MESH_SUPPORT_BLE_ADV || \
|
||||
CONFIG_BLE_MESH_SUPPORT_BLE_SCAN)
|
||||
|
||||
#define CONFIG_BLE_MESH_PROXY_SOLIC (CONFIG_BLE_MESH_PROXY_SOLIC_PDU_RX || \
|
||||
CONFIG_BLE_MESH_PROXY_SOLIC_PDU_TX)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -21,7 +21,7 @@
|
||||
#define _BLE_MESH_DLIST_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include "mesh_util.h"
|
||||
#include "mesh/utils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
@ -8,8 +8,8 @@
|
||||
#ifndef _BLE_MESH_FFS_H_
|
||||
#define _BLE_MESH_FFS_H_
|
||||
|
||||
#include "mesh_types.h"
|
||||
#include "mesh_compiler.h"
|
||||
#include "mesh/types.h"
|
||||
#include "mesh/compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
@ -13,8 +13,8 @@
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "mesh_config.h"
|
||||
#include "mesh_types.h"
|
||||
#include "mesh/config.h"
|
||||
#include "mesh/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
@ -7,9 +7,9 @@
|
||||
#ifndef _BLE_MESH_MUTEX_H_
|
||||
#define _BLE_MESH_MUTEX_H_
|
||||
|
||||
#include "mesh_kernel.h"
|
||||
#include "mesh_slist.h"
|
||||
#include "mesh_atomic.h"
|
||||
#include "mesh/kernel.h"
|
||||
#include "mesh/slist.h"
|
||||
#include "mesh/atomic.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -27,6 +27,11 @@ void bt_mesh_mutex_free(bt_mesh_mutex_t *mutex);
|
||||
void bt_mesh_mutex_lock(bt_mesh_mutex_t *mutex);
|
||||
void bt_mesh_mutex_unlock(bt_mesh_mutex_t *mutex);
|
||||
|
||||
void bt_mesh_r_mutex_create(bt_mesh_mutex_t *mutex);
|
||||
void bt_mesh_r_mutex_free(bt_mesh_mutex_t *mutex);
|
||||
void bt_mesh_r_mutex_lock(bt_mesh_mutex_t *mutex);
|
||||
void bt_mesh_r_mutex_unlock(bt_mesh_mutex_t *mutex);
|
||||
|
||||
void bt_mesh_alarm_lock(void);
|
||||
void bt_mesh_alarm_unlock(void);
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "mesh_util.h"
|
||||
#include "mesh/utils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
@ -8,9 +8,9 @@
|
||||
#ifndef _BLE_MESH_TIMER_H_
|
||||
#define _BLE_MESH_TIMER_H_
|
||||
|
||||
#include "mesh_types.h"
|
||||
#include "mesh_slist.h"
|
||||
#include "mesh_atomic.h"
|
||||
#include "mesh/types.h"
|
||||
#include "mesh/slist.h"
|
||||
#include "mesh/atomic.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -50,15 +50,15 @@ struct k_work;
|
||||
typedef void (*k_work_handler_t)(struct k_work *work);
|
||||
|
||||
struct k_work {
|
||||
void *_reserved;
|
||||
k_work_handler_t handler;
|
||||
int index;
|
||||
void *user_data;
|
||||
};
|
||||
|
||||
#define _K_WORK_INITIALIZER(work_handler) \
|
||||
{ \
|
||||
._reserved = NULL, \
|
||||
.handler = work_handler, \
|
||||
.user_data = NULL, \
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,6 +119,18 @@ struct k_work {
|
||||
*/
|
||||
#define K_HOURS(h) K_MINUTES((h) * 60)
|
||||
|
||||
/**
|
||||
* @brief Generate timeout delay from days.
|
||||
*
|
||||
* This macro generates a timeout delay that that instructs a kernel API
|
||||
* to wait up to @a d days to perform the requested operation.
|
||||
*
|
||||
* @param d Duration in days.
|
||||
*
|
||||
* @return Timeout delay value.
|
||||
*/
|
||||
#define K_DAYS(d) K_HOURS((d) * 24)
|
||||
|
||||
/**
|
||||
* @brief Generate infinite timeout delay.
|
||||
*
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include "esp_log.h"
|
||||
#include "mesh_util.h"
|
||||
#include "mesh/utils.h"
|
||||
#include "esp_rom_sys.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -92,7 +92,7 @@ extern "C" {
|
||||
#define BT_DBG(fmt, args...)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG) && (!CONFIG_BLE_MESH_NO_LOG)
|
||||
#if (CONFIG_BLE_MESH_NET_BUF_LOG && !CONFIG_BLE_MESH_NO_LOG)
|
||||
#define NET_BUF_ERR(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_WARN(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_INFO(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
@ -106,7 +106,7 @@ extern "C" {
|
||||
#define NET_BUF_ASSERT(cond)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_SIMPLE_LOG) && (!CONFIG_BLE_MESH_NO_LOG)
|
||||
#if (CONFIG_BLE_MESH_NET_BUF_SIMPLE_LOG && !CONFIG_BLE_MESH_NO_LOG)
|
||||
#define NET_BUF_SIMPLE_ERR(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_SIMPLE_WARN(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_SIMPLE_INFO(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
@ -11,12 +11,12 @@
|
||||
* Misc utilities usable by the kernel and application code.
|
||||
*/
|
||||
|
||||
#ifndef _BLE_MESH_UTIL_H_
|
||||
#define _BLE_MESH_UTIL_H_
|
||||
#ifndef _BLE_MESH_UTILS_H_
|
||||
#define _BLE_MESH_UTILS_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include "esp_bit_defs.h"
|
||||
#include "mesh_types.h"
|
||||
#include "mesh/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -26,13 +26,13 @@ extern "C" {
|
||||
* Those are available for 32 bits architectures:
|
||||
*/
|
||||
#ifndef POINTER_TO_UINT
|
||||
#define POINTER_TO_UINT(x) ((uint32_t) (x))
|
||||
#define POINTER_TO_UINT(x) ((uint32_t) (x))
|
||||
#endif
|
||||
#ifndef UINT_TO_POINTER
|
||||
#define UINT_TO_POINTER(x) ((void *) (x))
|
||||
#endif
|
||||
#ifndef POINTER_TO_INT
|
||||
#define POINTER_TO_INT(x) ((int32_t) (x))
|
||||
#define POINTER_TO_INT(x) ((int32_t) (x))
|
||||
#endif
|
||||
#ifndef INT_TO_POINTER
|
||||
#define INT_TO_POINTER(x) ((void *) (x))
|
||||
@ -108,7 +108,7 @@ extern "C" {
|
||||
* evaluation version.
|
||||
*/
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/** @brief Return smaller value of two provided expressions.
|
||||
@ -117,15 +117,15 @@ extern "C" {
|
||||
* evaluation version.
|
||||
*/
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(n) (1UL << (n))
|
||||
#define BIT(n) (1UL << (n))
|
||||
#endif
|
||||
|
||||
#ifndef BIT_MASK
|
||||
#define BIT_MASK(n) (BIT(n) - 1)
|
||||
#define BIT_MASK(n) (BIT(n) - 1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -188,4 +188,4 @@ void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLE_MESH_UTIL_H_ */
|
||||
#endif /* _BLE_MESH_UTILS_H_ */
|
@ -6,7 +6,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "mesh_kernel.h"
|
||||
#include "mesh/kernel.h"
|
||||
|
||||
void k_sleep(int32_t duration)
|
||||
{
|
@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "mesh_common.h"
|
||||
#include "mesh/common.h"
|
||||
|
||||
static bt_mesh_mutex_t alarm_lock;
|
||||
static bt_mesh_mutex_t list_lock;
|
||||
@ -74,10 +74,54 @@ void bt_mesh_mutex_unlock(bt_mesh_mutex_t *mutex)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void bt_mesh_alarm_mutex_new(void)
|
||||
void bt_mesh_r_mutex_create(bt_mesh_mutex_t *mutex)
|
||||
{
|
||||
if (!alarm_lock.mutex) {
|
||||
bt_mesh_mutex_create(&alarm_lock);
|
||||
if (!mutex) {
|
||||
BT_ERR("Create, invalid recursive mutex");
|
||||
return;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
||||
mutex->buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
||||
mutex->buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#endif
|
||||
__ASSERT(mutex->buffer, "Failed to create recursive mutex buffer");
|
||||
mutex->mutex = xSemaphoreCreateRecursiveMutexStatic(mutex->buffer);
|
||||
__ASSERT(mutex->mutex, "Failed to create static recursive mutex");
|
||||
#else /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||
mutex->mutex = xSemaphoreCreateRecursiveMutex();
|
||||
__ASSERT(mutex->mutex, "Failed to create recursive mutex");
|
||||
#endif /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||
}
|
||||
|
||||
void bt_mesh_r_mutex_free(bt_mesh_mutex_t *mutex)
|
||||
{
|
||||
bt_mesh_mutex_free(mutex);
|
||||
}
|
||||
|
||||
void bt_mesh_r_mutex_lock(bt_mesh_mutex_t *mutex)
|
||||
{
|
||||
if (!mutex) {
|
||||
BT_ERR("Lock, invalid recursive mutex");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mutex->mutex) {
|
||||
xSemaphoreTakeRecursive(mutex->mutex, portMAX_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_r_mutex_unlock(bt_mesh_mutex_t *mutex)
|
||||
{
|
||||
if (!mutex) {
|
||||
BT_ERR("Unlock, invalid recursive mutex");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mutex->mutex) {
|
||||
xSemaphoreGiveRecursive(mutex->mutex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,13 +135,6 @@ void bt_mesh_alarm_unlock(void)
|
||||
bt_mesh_mutex_unlock(&alarm_lock);
|
||||
}
|
||||
|
||||
static inline void bt_mesh_list_mutex_new(void)
|
||||
{
|
||||
if (!list_lock.mutex) {
|
||||
bt_mesh_mutex_create(&list_lock);
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_list_lock(void)
|
||||
{
|
||||
bt_mesh_mutex_lock(&list_lock);
|
||||
@ -108,13 +145,6 @@ void bt_mesh_list_unlock(void)
|
||||
bt_mesh_mutex_unlock(&list_lock);
|
||||
}
|
||||
|
||||
static inline void bt_mesh_buf_mutex_new(void)
|
||||
{
|
||||
if (!buf_lock.mutex) {
|
||||
bt_mesh_mutex_create(&buf_lock);
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_buf_lock(void)
|
||||
{
|
||||
bt_mesh_mutex_lock(&buf_lock);
|
||||
@ -125,13 +155,6 @@ void bt_mesh_buf_unlock(void)
|
||||
bt_mesh_mutex_unlock(&buf_lock);
|
||||
}
|
||||
|
||||
static inline void bt_mesh_atomic_mutex_new(void)
|
||||
{
|
||||
if (!atomic_lock.mutex) {
|
||||
bt_mesh_mutex_create(&atomic_lock);
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_atomic_lock(void)
|
||||
{
|
||||
bt_mesh_mutex_lock(&atomic_lock);
|
||||
@ -144,38 +167,18 @@ void bt_mesh_atomic_unlock(void)
|
||||
|
||||
void bt_mesh_mutex_init(void)
|
||||
{
|
||||
bt_mesh_alarm_mutex_new();
|
||||
bt_mesh_list_mutex_new();
|
||||
bt_mesh_buf_mutex_new();
|
||||
bt_mesh_atomic_mutex_new();
|
||||
bt_mesh_mutex_create(&alarm_lock);
|
||||
bt_mesh_mutex_create(&list_lock);
|
||||
bt_mesh_mutex_create(&buf_lock);
|
||||
bt_mesh_mutex_create(&atomic_lock);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static inline void bt_mesh_alarm_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&alarm_lock);
|
||||
}
|
||||
|
||||
static inline void bt_mesh_list_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&list_lock);
|
||||
}
|
||||
|
||||
static inline void bt_mesh_buf_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&buf_lock);
|
||||
}
|
||||
|
||||
static inline void bt_mesh_atomic_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&atomic_lock);
|
||||
}
|
||||
|
||||
void bt_mesh_mutex_deinit(void)
|
||||
{
|
||||
bt_mesh_alarm_mutex_free();
|
||||
bt_mesh_list_mutex_free();
|
||||
bt_mesh_buf_mutex_free();
|
||||
bt_mesh_atomic_mutex_free();
|
||||
bt_mesh_mutex_free(&alarm_lock);
|
||||
bt_mesh_mutex_free(&list_lock);
|
||||
bt_mesh_mutex_free(&buf_lock);
|
||||
bt_mesh_mutex_free(&atomic_lock);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
@ -12,12 +12,12 @@
|
||||
#include "osi/alarm.h"
|
||||
#include "osi/hash_functions.h"
|
||||
|
||||
#include "mesh_common.h"
|
||||
#include "provisioner_prov.h"
|
||||
#include "mesh/config.h"
|
||||
#include "mesh/common.h"
|
||||
|
||||
static hash_map_t *bm_alarm_hash_map;
|
||||
static const size_t BLE_MESH_GENERAL_ALARM_HASH_MAP_SIZE = 20 + CONFIG_BLE_MESH_PBA_SAME_TIME + \
|
||||
CONFIG_BLE_MESH_PBG_SAME_TIME;
|
||||
static const size_t BLE_MESH_ALARM_HASH_MAP_SIZE = 20 + CONFIG_BLE_MESH_PBA_SAME_TIME +
|
||||
CONFIG_BLE_MESH_PBG_SAME_TIME;
|
||||
|
||||
typedef struct alarm_t {
|
||||
/* timer id point to here */
|
||||
@ -45,7 +45,7 @@ uint32_t k_uptime_get_32(void)
|
||||
|
||||
void bt_mesh_timer_init(void)
|
||||
{
|
||||
bm_alarm_hash_map = hash_map_new(BLE_MESH_GENERAL_ALARM_HASH_MAP_SIZE,
|
||||
bm_alarm_hash_map = hash_map_new(BLE_MESH_ALARM_HASH_MAP_SIZE,
|
||||
hash_function_pointer, NULL,
|
||||
(data_free_fn)osi_alarm_free, NULL);
|
||||
__ASSERT(bm_alarm_hash_map, "Failed to create hash map");
|
||||
@ -73,42 +73,53 @@ int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
|
||||
k_work_init(&work->work, handler);
|
||||
|
||||
bt_mesh_alarm_lock();
|
||||
if (!hash_map_has_key(bm_alarm_hash_map, (void *)work)) {
|
||||
alarm = osi_alarm_new("bt_mesh", (osi_alarm_callback_t)handler, (void *)&work->work, 0);
|
||||
if (alarm == NULL) {
|
||||
BT_ERR("Alarm not created");
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EIO;
|
||||
}
|
||||
if (!hash_map_set(bm_alarm_hash_map, work, (void *)alarm)) {
|
||||
BT_ERR("Alarm not set");
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
||||
alarm = hash_map_get(bm_alarm_hash_map, work);
|
||||
if (alarm == NULL) {
|
||||
BT_ERR("Init, alarm not found");
|
||||
if (alarm) {
|
||||
BT_ERR("Init, alarm already exists");
|
||||
bt_mesh_alarm_unlock();
|
||||
return -ENODEV;
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
alarm = osi_alarm_new("bt_mesh", (osi_alarm_callback_t)handler, (void *)&work->work, 0);
|
||||
if (alarm == NULL) {
|
||||
BT_ERR("Init, alarm not created");
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (!hash_map_set(bm_alarm_hash_map, work, (void *)alarm)) {
|
||||
BT_ERR("Init, alarm not set");
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
// Just init the work timer only, don't start it.
|
||||
osi_alarm_cancel(alarm);
|
||||
|
||||
bt_mesh_alarm_unlock();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int k_delayed_work_submit(struct k_delayed_work *work, int32_t delay)
|
||||
{
|
||||
osi_alarm_t *alarm = NULL;
|
||||
|
||||
if (!work || !bm_alarm_hash_map) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* If delay is 0, call the corresponding timeout handler. */
|
||||
if (delay == 0) {
|
||||
k_work_submit(&work->work);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
|
||||
alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("Submit, alarm not found");
|
||||
bt_mesh_alarm_unlock();
|
||||
@ -118,19 +129,30 @@ int k_delayed_work_submit(struct k_delayed_work *work, int32_t delay)
|
||||
// Cancel the alarm first, before start the alarm.
|
||||
osi_alarm_cancel(alarm);
|
||||
osi_alarm_set(alarm, delay);
|
||||
|
||||
bt_mesh_alarm_unlock();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int k_delayed_work_submit_periodic(struct k_delayed_work *work, int32_t period)
|
||||
{
|
||||
osi_alarm_t *alarm = NULL;
|
||||
|
||||
if (!work || !bm_alarm_hash_map) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* If period is 0, call the corresponding timeout handler. */
|
||||
if (period == 0) {
|
||||
k_work_submit(&work->work);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
|
||||
alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("Submit, alarm not found");
|
||||
bt_mesh_alarm_unlock();
|
||||
@ -140,19 +162,24 @@ int k_delayed_work_submit_periodic(struct k_delayed_work *work, int32_t period)
|
||||
/* Cancel the alarm first before starting it. */
|
||||
osi_alarm_cancel(alarm);
|
||||
osi_alarm_set_periodic(alarm, period);
|
||||
|
||||
bt_mesh_alarm_unlock();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int k_delayed_work_cancel(struct k_delayed_work *work)
|
||||
{
|
||||
osi_alarm_t *alarm = NULL;
|
||||
|
||||
if (!work || !bm_alarm_hash_map) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
|
||||
alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("Cancel, alarm not found");
|
||||
bt_mesh_alarm_unlock();
|
||||
@ -161,19 +188,24 @@ int k_delayed_work_cancel(struct k_delayed_work *work)
|
||||
|
||||
osi_alarm_cancel(alarm);
|
||||
alarm->deadline_us = 0;
|
||||
|
||||
bt_mesh_alarm_unlock();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int k_delayed_work_free(struct k_delayed_work *work)
|
||||
{
|
||||
osi_alarm_t *alarm = NULL;
|
||||
|
||||
if (!work || !bm_alarm_hash_map) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, work);
|
||||
|
||||
alarm = hash_map_get(bm_alarm_hash_map, work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("Free, alarm not found");
|
||||
bt_mesh_alarm_unlock();
|
||||
@ -182,12 +214,15 @@ int k_delayed_work_free(struct k_delayed_work *work)
|
||||
|
||||
osi_alarm_cancel(alarm);
|
||||
hash_map_erase(bm_alarm_hash_map, work);
|
||||
|
||||
bt_mesh_alarm_unlock();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t k_delayed_work_remaining_get(struct k_delayed_work *work)
|
||||
{
|
||||
osi_alarm_t *alarm = NULL;
|
||||
int32_t time = 0;
|
||||
|
||||
if (!work || !bm_alarm_hash_map) {
|
||||
@ -196,7 +231,8 @@ int32_t k_delayed_work_remaining_get(struct k_delayed_work *work)
|
||||
}
|
||||
|
||||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
|
||||
alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("Get time, alarm not found");
|
||||
bt_mesh_alarm_unlock();
|
||||
@ -204,6 +240,8 @@ int32_t k_delayed_work_remaining_get(struct k_delayed_work *work)
|
||||
}
|
||||
|
||||
time = osi_alarm_get_remaining_ms(alarm);
|
||||
|
||||
bt_mesh_alarm_unlock();
|
||||
|
||||
return time;
|
||||
}
|
@ -9,9 +9,9 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "mesh_types.h"
|
||||
#include "mesh_util.h"
|
||||
#include "mesh_trace.h"
|
||||
#include "mesh/types.h"
|
||||
#include "mesh/utils.h"
|
||||
#include "mesh/trace.h"
|
||||
|
||||
const char *bt_hex(const void *buf, size_t len)
|
||||
{
|
@ -12,19 +12,28 @@
|
||||
|
||||
#include "mesh.h"
|
||||
#include "adv.h"
|
||||
#include "lpn.h"
|
||||
#include "friend.h"
|
||||
#include "transport.h"
|
||||
#include "access.h"
|
||||
#include "foundation.h"
|
||||
#include "mesh_main.h"
|
||||
#include "mesh_common.h"
|
||||
#include "mesh/main.h"
|
||||
#include "mesh/common.h"
|
||||
#include "fast_prov.h"
|
||||
#include "provisioner_main.h"
|
||||
#include "pvnr_mgmt.h"
|
||||
|
||||
#include "mesh_v1.1/utils.h"
|
||||
|
||||
#define BLE_MESH_SDU_MAX_LEN 384
|
||||
|
||||
static const struct bt_mesh_comp *dev_comp;
|
||||
extern const struct bt_mesh_comp *comp_0;
|
||||
static uint16_t dev_primary_addr;
|
||||
|
||||
static int model_send(struct bt_mesh_model *model,
|
||||
struct bt_mesh_net_tx *tx, bool implicit_bind,
|
||||
struct net_buf_simple *msg,
|
||||
const struct bt_mesh_send_cb *cb, void *cb_data);
|
||||
|
||||
void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
|
||||
struct bt_mesh_elem *elem,
|
||||
bool vnd, bool primary,
|
||||
@ -33,13 +42,13 @@ void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
|
||||
{
|
||||
int i, j;
|
||||
|
||||
if (dev_comp == NULL) {
|
||||
if (comp_0 == NULL) {
|
||||
BT_ERR("Invalid device composition");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < dev_comp->elem_count; i++) {
|
||||
struct bt_mesh_elem *elem = &dev_comp->elem[i];
|
||||
for (i = 0; i < comp_0->elem_count; i++) {
|
||||
struct bt_mesh_elem *elem = &comp_0->elem[i];
|
||||
|
||||
for (j = 0; j < elem->model_count; j++) {
|
||||
struct bt_mesh_model *model = &elem->models[j];
|
||||
@ -88,9 +97,9 @@ int32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod)
|
||||
|
||||
if (mod->pub->fast_period) {
|
||||
return period >> mod->pub->period_div;
|
||||
} else {
|
||||
return period;
|
||||
}
|
||||
|
||||
return period;
|
||||
}
|
||||
|
||||
static int32_t next_period(struct bt_mesh_model *mod)
|
||||
@ -169,43 +178,49 @@ static const struct bt_mesh_send_cb pub_sent_cb = {
|
||||
static int publish_retransmit(struct bt_mesh_model *mod)
|
||||
{
|
||||
struct bt_mesh_model_pub *pub = mod->pub;
|
||||
if (!pub) {
|
||||
struct bt_mesh_app_key *key = NULL;
|
||||
struct net_buf_simple *sdu = NULL;
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
struct bt_mesh_net_tx tx = {
|
||||
.ctx = &ctx,
|
||||
.src = bt_mesh_model_elem(mod)->addr,
|
||||
.xmit = bt_mesh_net_transmit_get(),
|
||||
};
|
||||
int err = 0;
|
||||
|
||||
if (!pub || !pub->msg) {
|
||||
BT_ERR("Model has no publication support");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
struct bt_mesh_app_key *key = NULL;
|
||||
struct net_buf_simple *sdu = NULL;
|
||||
struct bt_mesh_msg_ctx ctx = {
|
||||
.addr = pub->addr,
|
||||
.send_ttl = pub->ttl,
|
||||
.model = mod,
|
||||
.srv_send = (pub->dev_role == NODE ? true : false),
|
||||
};
|
||||
struct bt_mesh_net_tx tx = {
|
||||
.ctx = &ctx,
|
||||
.src = bt_mesh_model_elem(mod)->addr,
|
||||
.xmit = bt_mesh_net_transmit_get(),
|
||||
.friend_cred = pub->cred,
|
||||
};
|
||||
int err = 0;
|
||||
|
||||
key = bt_mesh_tx_appkey_get(pub->dev_role, pub->key);
|
||||
key = bt_mesh_app_key_get(pub->key);
|
||||
if (!key) {
|
||||
BT_ERR("AppKey 0x%03x not exists", pub->key);
|
||||
BT_ERR("Publish, AppKey 0x%03x not found", pub->key);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
tx.sub = bt_mesh_tx_netkey_get(pub->dev_role, key->net_idx);
|
||||
tx.sub = bt_mesh_subnet_get(key->net_idx);
|
||||
if (!tx.sub) {
|
||||
BT_ERR("Subnet 0x%04x not exists", key->net_idx);
|
||||
BT_ERR("Publish, NetKey 0x%04x not found", key->net_idx);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
ctx.addr = pub->addr;
|
||||
ctx.net_idx = key->net_idx;
|
||||
ctx.app_idx = key->app_idx;
|
||||
ctx.send_ttl = pub->ttl;
|
||||
ctx.send_cred = pub->cred ? BLE_MESH_FRIENDSHIP_CRED : BLE_MESH_FLOODING_CRED;
|
||||
ctx.send_szmic = pub->send_szmic;
|
||||
if (pub->send_rel) {
|
||||
/* Tag with send-segmented */
|
||||
ctx.send_tag |= BLE_MESH_TAG_SEND_SEGMENTED;
|
||||
}
|
||||
|
||||
sdu = bt_mesh_alloc_buf(pub->msg->len + BLE_MESH_MIC_SHORT);
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
bt_mesh_model_pub_use_directed(&tx, pub->directed_pub_policy);
|
||||
#endif
|
||||
|
||||
sdu = bt_mesh_alloc_buf(pub->msg->len + BLE_MESH_MIC_LONG);
|
||||
if (!sdu) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
@ -215,7 +230,7 @@ static int publish_retransmit(struct bt_mesh_model *mod)
|
||||
|
||||
pub->count--;
|
||||
|
||||
err = bt_mesh_trans_send(&tx, sdu, &pub_sent_cb, mod);
|
||||
err = model_send(mod, &tx, true, sdu, &pub_sent_cb, mod);
|
||||
|
||||
bt_mesh_free_buf(sdu);
|
||||
return err;
|
||||
@ -237,8 +252,6 @@ static void mod_publish(struct k_work *work)
|
||||
int32_t period_ms = 0;
|
||||
int err = 0;
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
period_ms = bt_mesh_model_pub_period_get(pub->mod);
|
||||
BT_INFO("Publish period %u ms", period_ms);
|
||||
|
||||
@ -254,7 +267,6 @@ static void mod_publish(struct k_work *work)
|
||||
k_delayed_work_submit(&pub->timer, period_ms);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -282,24 +294,24 @@ static void mod_publish(struct k_work *work)
|
||||
|
||||
struct bt_mesh_elem *bt_mesh_model_elem(struct bt_mesh_model *mod)
|
||||
{
|
||||
return &dev_comp->elem[mod->elem_idx];
|
||||
return &comp_0->elem[mod->elem_idx];
|
||||
}
|
||||
|
||||
struct bt_mesh_model *bt_mesh_model_get(bool vnd, uint8_t elem_idx, uint8_t mod_idx)
|
||||
{
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
|
||||
if (!dev_comp) {
|
||||
BT_ERR("dev_comp not initialized");
|
||||
if (!comp_0) {
|
||||
BT_ERR("comp_0 not initialized");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (elem_idx >= dev_comp->elem_count) {
|
||||
if (elem_idx >= comp_0->elem_count) {
|
||||
BT_ERR("Invalid element index %u", elem_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
elem = &dev_comp->elem[elem_idx];
|
||||
elem = &comp_0->elem[elem_idx];
|
||||
|
||||
if (vnd) {
|
||||
if (mod_idx >= elem->vnd_model_count) {
|
||||
@ -346,7 +358,7 @@ static void mod_init(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
||||
}
|
||||
|
||||
mod->flags = 0;
|
||||
mod->elem_idx = elem - dev_comp->elem;
|
||||
mod->elem_idx = elem - comp_0->elem;
|
||||
if (vnd) {
|
||||
mod->model_idx = mod - elem->vnd_models;
|
||||
} else {
|
||||
@ -371,7 +383,7 @@ int bt_mesh_comp_register(const struct bt_mesh_comp *comp)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_comp = comp;
|
||||
comp_0 = comp;
|
||||
|
||||
bt_mesh_model_foreach(mod_init, &err);
|
||||
|
||||
@ -423,13 +435,13 @@ int bt_mesh_comp_deregister(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
if (dev_comp == NULL) {
|
||||
if (comp_0 == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bt_mesh_model_foreach(mod_deinit, &err);
|
||||
|
||||
dev_comp = NULL;
|
||||
comp_0 = NULL;
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -441,10 +453,10 @@ void bt_mesh_comp_provision(uint16_t addr)
|
||||
|
||||
dev_primary_addr = addr;
|
||||
|
||||
BT_INFO("Primary address 0x%04x, element count %u", addr, dev_comp->elem_count);
|
||||
BT_INFO("Primary address 0x%04x, element count %u", addr, comp_0->elem_count);
|
||||
|
||||
for (i = 0; i < dev_comp->elem_count; i++) {
|
||||
struct bt_mesh_elem *elem = &dev_comp->elem[i];
|
||||
for (i = 0; i < comp_0->elem_count; i++) {
|
||||
struct bt_mesh_elem *elem = &comp_0->elem[i];
|
||||
|
||||
elem->addr = addr++;
|
||||
|
||||
@ -455,8 +467,6 @@ void bt_mesh_comp_provision(uint16_t addr)
|
||||
|
||||
void bt_mesh_comp_unprovision(void)
|
||||
{
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
dev_primary_addr = BLE_MESH_ADDR_UNASSIGNED;
|
||||
}
|
||||
|
||||
@ -511,16 +521,16 @@ struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr)
|
||||
uint16_t index = 0U;
|
||||
|
||||
if (BLE_MESH_ADDR_IS_UNICAST(addr)) {
|
||||
index = (addr - dev_comp->elem[0].addr);
|
||||
if (index < dev_comp->elem_count) {
|
||||
return &dev_comp->elem[index];
|
||||
} else {
|
||||
return NULL;
|
||||
index = (addr - comp_0->elem[0].addr);
|
||||
if (index < comp_0->elem_count) {
|
||||
return &comp_0->elem[index];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (index = 0; index < dev_comp->elem_count; index++) {
|
||||
struct bt_mesh_elem *elem = &dev_comp->elem[index];
|
||||
for (index = 0; index < comp_0->elem_count; index++) {
|
||||
struct bt_mesh_elem *elem = &comp_0->elem[index];
|
||||
|
||||
if (bt_mesh_elem_find_group(elem, addr)) {
|
||||
return elem;
|
||||
@ -532,7 +542,7 @@ struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr)
|
||||
|
||||
uint8_t bt_mesh_elem_count(void)
|
||||
{
|
||||
return dev_comp->elem_count;
|
||||
return comp_0->elem_count;
|
||||
}
|
||||
|
||||
static bool model_has_key(struct bt_mesh_model *mod, uint16_t key)
|
||||
@ -548,15 +558,20 @@ static bool model_has_key(struct bt_mesh_model *mod, uint16_t key)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool model_has_dst(struct bt_mesh_model *model, uint16_t dst)
|
||||
static bool model_has_dst(struct bt_mesh_model *model,
|
||||
struct bt_mesh_subnet *sub,
|
||||
uint16_t dst)
|
||||
{
|
||||
if (BLE_MESH_ADDR_IS_UNICAST(dst)) {
|
||||
return (dev_comp->elem[model->elem_idx].addr == dst);
|
||||
} else if (BLE_MESH_ADDR_IS_GROUP(dst) || BLE_MESH_ADDR_IS_VIRTUAL(dst)) {
|
||||
return (comp_0->elem[model->elem_idx].addr == dst);
|
||||
}
|
||||
|
||||
if (BLE_MESH_ADDR_IS_GROUP(dst) || BLE_MESH_ADDR_IS_VIRTUAL(dst)) {
|
||||
return !!bt_mesh_model_find_group(model, dst);
|
||||
}
|
||||
|
||||
return (model->elem_idx == 0 && bt_mesh_fixed_group_match(dst));
|
||||
return (model->elem_idx == 0 && (bt_mesh_fixed_group_match(dst) ||
|
||||
bt_mesh_fixed_direct_match(sub, dst)));
|
||||
}
|
||||
|
||||
static const struct bt_mesh_model_op *find_op(struct bt_mesh_model *models,
|
||||
@ -581,7 +596,7 @@ static const struct bt_mesh_model_op *find_op(struct bt_mesh_model *models,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int get_opcode(struct net_buf_simple *buf, uint32_t *opcode)
|
||||
static int get_opcode(struct net_buf_simple *buf, uint32_t *opcode, bool pull_buf)
|
||||
{
|
||||
switch (buf->data[0] >> 6) {
|
||||
case 0x00:
|
||||
@ -591,34 +606,51 @@ static int get_opcode(struct net_buf_simple *buf, uint32_t *opcode)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*opcode = net_buf_simple_pull_u8(buf);
|
||||
*opcode = pull_buf ? net_buf_simple_pull_u8(buf) : buf->data[0];
|
||||
return 0;
|
||||
|
||||
case 0x02:
|
||||
if (buf->len < 2) {
|
||||
BT_ERR("Too short payload for 2-octet OpCode");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*opcode = net_buf_simple_pull_be16(buf);
|
||||
*opcode = pull_buf ? net_buf_simple_pull_be16(buf) : sys_get_be16(buf->data);
|
||||
return 0;
|
||||
|
||||
case 0x03:
|
||||
if (buf->len < 3) {
|
||||
BT_ERR("Too short payload for 3-octet OpCode");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*opcode = net_buf_simple_pull_u8(buf) << 16;
|
||||
/* Using LE for the CID since the model layer is defined as
|
||||
* little-endian in the mesh spec and using BT_MESH_MODEL_OP_3
|
||||
* will declare the opcode in this way.
|
||||
*/
|
||||
*opcode |= net_buf_simple_pull_le16(buf);
|
||||
if (pull_buf) {
|
||||
*opcode = net_buf_simple_pull_u8(buf) << 16;
|
||||
/* Using LE for the CID since the model layer is defined as
|
||||
* little-endian in the mesh spec and using BT_MESH_MODEL_OP_3
|
||||
* will declare the opcode in this way.
|
||||
*/
|
||||
*opcode |= net_buf_simple_pull_le16(buf);
|
||||
} else {
|
||||
*opcode = buf->data[0] << 16 | sys_get_le16(&buf->data[1]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int bt_mesh_get_opcode(struct net_buf_simple *buf,
|
||||
uint32_t *opcode, bool pull_buf)
|
||||
{
|
||||
if (buf == NULL || buf->len == 0 || opcode == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return get_opcode(buf, opcode, pull_buf);
|
||||
}
|
||||
|
||||
bool bt_mesh_fixed_group_match(uint16_t addr)
|
||||
{
|
||||
/* Check for fixed group addresses */
|
||||
@ -636,6 +668,22 @@ bool bt_mesh_fixed_group_match(uint16_t addr)
|
||||
}
|
||||
}
|
||||
|
||||
bool bt_mesh_fixed_direct_match(struct bt_mesh_subnet *sub, uint16_t addr)
|
||||
{
|
||||
/* A message sent to the all-directed-forwarding-nodes address
|
||||
* shall be processed by the primary element of all nodes that
|
||||
* have directed forwarding functionality enabled.
|
||||
*/
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
if (addr == BLE_MESH_ADDR_DIRECTS && sub &&
|
||||
sub->directed_forwarding == BLE_MESH_DIRECTED_FORWARDING_ENABLED) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_model *models = NULL, *model = NULL;
|
||||
@ -648,15 +696,15 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
||||
rx->ctx.addr, rx->ctx.recv_dst);
|
||||
BT_INFO("recv, len %u: %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
if (get_opcode(buf, &opcode) < 0) {
|
||||
if (get_opcode(buf, &opcode, true) < 0) {
|
||||
BT_WARN("Unable to decode OpCode");
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("OpCode 0x%08x", opcode);
|
||||
|
||||
for (i = 0; i < dev_comp->elem_count; i++) {
|
||||
struct bt_mesh_elem *elem = &dev_comp->elem[i];
|
||||
for (i = 0; i < comp_0->elem_count; i++) {
|
||||
struct bt_mesh_elem *elem = &comp_0->elem[i];
|
||||
struct net_buf_simple_state state = {0};
|
||||
|
||||
/* SIG models cannot contain 3-byte (vendor) OpCodes, and
|
||||
@ -681,7 +729,7 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!model_has_dst(model, rx->ctx.recv_dst)) {
|
||||
if (!model_has_dst(model, rx->sub, rx->ctx.recv_dst)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -690,17 +738,28 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* The following three operations are added by Espressif.
|
||||
* 1. Update the "recv_op" with the opcode got from the buf;
|
||||
* 2. Update the model pointer with the found model;
|
||||
* 3. Update the "srv_send" to be true when received a message.
|
||||
* This flag will be used when a server model sends a status
|
||||
* message, and has no impact on the client messages.
|
||||
* Most of these info will be used by the application layer.
|
||||
/* The following operation is added by Espressif.
|
||||
* Update the "recv_op" with the opcode got from the buf;
|
||||
*/
|
||||
rx->ctx.recv_op = opcode;
|
||||
rx->ctx.model = model;
|
||||
rx->ctx.srv_send = true;
|
||||
|
||||
/* The message is transmitted by a model in response to a message that
|
||||
* it has received.
|
||||
*
|
||||
* The TTL field shall be set to the value of the Default TTL state.
|
||||
*
|
||||
* The response message shall use master security credentials. However,
|
||||
* the security credentials may be changed by a lower layer unless the
|
||||
* received message uses the master security credentials. If the received
|
||||
* message uses master security credentials, then the response message
|
||||
* shall be tagged with the immutable-credentials tag, and the security
|
||||
* credentials will not be changed by any lower layer.
|
||||
*/
|
||||
rx->ctx.send_ttl = BLE_MESH_TTL_DEFAULT;
|
||||
if (rx->ctx.recv_cred == BLE_MESH_FLOODING_CRED) {
|
||||
rx->ctx.send_tag |= BLE_MESH_TAG_IMMUTABLE_CRED;
|
||||
rx->ctx.send_cred = BLE_MESH_FLOODING_CRED;
|
||||
}
|
||||
|
||||
/* The callback will likely parse the buffer, so store
|
||||
* the parsing state in case multiple models receive
|
||||
@ -737,18 +796,19 @@ void bt_mesh_model_msg_init(struct net_buf_simple *msg, uint32_t opcode)
|
||||
}
|
||||
}
|
||||
|
||||
static bool ready_to_send(uint8_t role, uint16_t dst)
|
||||
static bool ready_to_send(uint16_t dst)
|
||||
{
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned() && role == NODE) {
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) {
|
||||
return true;
|
||||
} else if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en() && role == PROVISIONER) {
|
||||
if (!bt_mesh_provisioner_check_msg_dst(dst)) {
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en()) {
|
||||
if (bt_mesh_provisioner_check_msg_dst(dst) == false &&
|
||||
bt_mesh_elem_find(dst) == false) {
|
||||
BT_ERR("Failed to find DST 0x%04x", dst);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else if (IS_ENABLED(CONFIG_BLE_MESH_FAST_PROV) && bt_mesh_is_provisioned() && role == FAST_PROV) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -759,23 +819,23 @@ static int model_send(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *msg,
|
||||
const struct bt_mesh_send_cb *cb, void *cb_data)
|
||||
{
|
||||
uint8_t role = 0U;
|
||||
|
||||
role = bt_mesh_get_device_role(model, tx->ctx->srv_send);
|
||||
if (role == ROLE_NVAL) {
|
||||
BT_ERR("Failed to get model role");
|
||||
return -EINVAL;
|
||||
}
|
||||
int err = 0;
|
||||
|
||||
BT_INFO("send, app_idx 0x%04x src 0x%04x dst 0x%04x",
|
||||
tx->ctx->app_idx, tx->src, tx->ctx->addr);
|
||||
BT_INFO("send, len %u: %s", msg->len, bt_hex(msg->data, msg->len));
|
||||
|
||||
if (!ready_to_send(role, tx->ctx->addr)) {
|
||||
if (ready_to_send(tx->ctx->addr) == false) {
|
||||
BT_ERR("Not ready to send");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (tx->ctx->send_ttl != BLE_MESH_TTL_DEFAULT &&
|
||||
tx->ctx->send_ttl > BLE_MESH_TTL_MAX) {
|
||||
BT_ERR("Too big send TTL 0x%02x", tx->ctx->send_ttl);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (net_buf_simple_tailroom(msg) < BLE_MESH_MIC_SHORT) {
|
||||
BT_ERR("Not enough tailroom for TransMIC");
|
||||
return -EINVAL;
|
||||
@ -791,7 +851,43 @@ static int model_send(struct bt_mesh_model *model,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return bt_mesh_trans_send(tx, msg, cb, cb_data);
|
||||
if (bt_mesh_valid_security_cred(tx) == false) {
|
||||
BT_ERR("Can not use security cred 0x%02x", tx->ctx->send_cred);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
bt_mesh_choose_better_security_cred(tx);
|
||||
|
||||
err = bt_mesh_trans_send(tx, msg, cb, cb_data);
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
bt_mesh_is_directed_path_needed(tx);
|
||||
#endif
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_model_send_implicit(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,bool implicit_bind,
|
||||
struct net_buf_simple *msg,
|
||||
const struct bt_mesh_send_cb *cb, void *cb_data)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
|
||||
sub = bt_mesh_subnet_get(ctx->net_idx);
|
||||
if (!sub) {
|
||||
BT_ERR("Send, NetKey 0x%04x not found", ctx->net_idx);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
struct bt_mesh_net_tx tx = {
|
||||
.sub = sub,
|
||||
.ctx = ctx,
|
||||
.src = bt_mesh_model_elem(model)->addr,
|
||||
.xmit = bt_mesh_net_transmit_get(),
|
||||
};
|
||||
|
||||
return model_send(model, &tx, implicit_bind, msg, cb, cb_data);
|
||||
}
|
||||
|
||||
int bt_mesh_model_send(struct bt_mesh_model *model,
|
||||
@ -800,28 +896,18 @@ int bt_mesh_model_send(struct bt_mesh_model *model,
|
||||
const struct bt_mesh_send_cb *cb, void *cb_data)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
uint8_t role = 0U;
|
||||
|
||||
role = bt_mesh_get_device_role(model, ctx->srv_send);
|
||||
if (role == ROLE_NVAL) {
|
||||
BT_ERR("Failed to get model role");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
sub = bt_mesh_tx_netkey_get(role, ctx->net_idx);
|
||||
sub = bt_mesh_subnet_get(ctx->net_idx);
|
||||
if (!sub) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", ctx->net_idx);
|
||||
return -EINVAL;
|
||||
BT_ERR("Send, NetKey 0x%04x not found", ctx->net_idx);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
ctx->model = model;
|
||||
|
||||
struct bt_mesh_net_tx tx = {
|
||||
.sub = sub,
|
||||
.ctx = ctx,
|
||||
.src = bt_mesh_model_elem(model)->addr,
|
||||
.sub = sub,
|
||||
.ctx = ctx,
|
||||
.src = bt_mesh_model_elem(model)->addr,
|
||||
.xmit = bt_mesh_net_transmit_get(),
|
||||
.friend_cred = 0,
|
||||
};
|
||||
|
||||
return model_send(model, &tx, false, msg, cb, cb_data);
|
||||
@ -832,19 +918,14 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
|
||||
struct bt_mesh_model_pub *pub = model->pub;
|
||||
struct bt_mesh_app_key *key = NULL;
|
||||
struct net_buf_simple *sdu = NULL;
|
||||
struct bt_mesh_msg_ctx ctx = {
|
||||
.model = model,
|
||||
};
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
struct bt_mesh_net_tx tx = {
|
||||
.sub = NULL,
|
||||
.ctx = &ctx,
|
||||
.src = bt_mesh_model_elem(model)->addr,
|
||||
.ctx = &ctx,
|
||||
.src = bt_mesh_model_elem(model)->addr,
|
||||
.xmit = bt_mesh_net_transmit_get(),
|
||||
};
|
||||
int err = 0;
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!pub || !pub->msg) {
|
||||
BT_ERR("Model has no publication support");
|
||||
return -ENOTSUP;
|
||||
@ -855,12 +936,6 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
key = bt_mesh_tx_appkey_get(pub->dev_role, pub->key);
|
||||
if (!key) {
|
||||
BT_ERR("Invalid AppKeyIndex 0x%03x", pub->key);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
if (pub->msg->len + BLE_MESH_MIC_SHORT > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SDU_MAX_LEN)) {
|
||||
BT_ERR("Message does not fit maximum SDU size");
|
||||
return -EMSGSIZE;
|
||||
@ -871,27 +946,39 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
|
||||
k_delayed_work_cancel(&pub->timer);
|
||||
}
|
||||
|
||||
ctx.addr = pub->addr;
|
||||
ctx.send_rel = pub->send_rel;
|
||||
ctx.send_ttl = pub->ttl;
|
||||
ctx.net_idx = key->net_idx;
|
||||
ctx.app_idx = key->app_idx;
|
||||
ctx.srv_send = pub->dev_role == NODE ? true : false;
|
||||
|
||||
tx.friend_cred = pub->cred;
|
||||
|
||||
tx.sub = bt_mesh_tx_netkey_get(pub->dev_role, ctx.net_idx);
|
||||
if (!tx.sub) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", ctx.net_idx);
|
||||
key = bt_mesh_app_key_get(pub->key);
|
||||
if (!key) {
|
||||
BT_ERR("Publish, AppKey 0x%03x not found", pub->key);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
tx.sub = bt_mesh_subnet_get(ctx.net_idx);
|
||||
if (!tx.sub) {
|
||||
BT_ERR("Publish, NetKey 0x%04x not found", ctx.net_idx);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
ctx.addr = pub->addr;
|
||||
ctx.net_idx = key->net_idx;
|
||||
ctx.app_idx = key->app_idx;
|
||||
ctx.send_ttl = pub->ttl;
|
||||
ctx.send_cred = pub->cred ? BLE_MESH_FRIENDSHIP_CRED : BLE_MESH_FLOODING_CRED;
|
||||
ctx.send_szmic = pub->send_szmic;
|
||||
if (pub->send_rel) {
|
||||
/* Tag with send-segmented */
|
||||
ctx.send_tag |= BLE_MESH_TAG_SEND_SEGMENTED;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
bt_mesh_model_pub_use_directed(&tx, pub->directed_pub_policy);
|
||||
#endif
|
||||
|
||||
pub->count = BLE_MESH_PUB_TRANSMIT_COUNT(pub->retransmit);
|
||||
|
||||
BT_INFO("Publish Retransmit Count %u Interval %ums", pub->count,
|
||||
BLE_MESH_PUB_TRANSMIT_INT(pub->retransmit));
|
||||
|
||||
sdu = bt_mesh_alloc_buf(pub->msg->len + BLE_MESH_MIC_SHORT);
|
||||
sdu = bt_mesh_alloc_buf(pub->msg->len + BLE_MESH_MIC_LONG);
|
||||
if (!sdu) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
@ -915,7 +1002,7 @@ struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
|
||||
|
||||
for (i = 0; i < elem->vnd_model_count; i++) {
|
||||
if (elem->vnd_models[i].vnd.company == company &&
|
||||
elem->vnd_models[i].vnd.id == id) {
|
||||
elem->vnd_models[i].vnd.id == id) {
|
||||
return &elem->vnd_models[i];
|
||||
}
|
||||
}
|
||||
@ -938,56 +1025,26 @@ struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, uint16_t id)
|
||||
|
||||
const struct bt_mesh_comp *bt_mesh_comp_get(void)
|
||||
{
|
||||
return dev_comp;
|
||||
return comp_0;
|
||||
}
|
||||
|
||||
/* APIs used by messages encryption in upper transport layer & network layer */
|
||||
struct bt_mesh_subnet *bt_mesh_tx_netkey_get(uint8_t role, uint16_t net_idx)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned() && role == NODE) {
|
||||
sub = bt_mesh_subnet_get(net_idx);
|
||||
} else if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en() && role == PROVISIONER) {
|
||||
sub = bt_mesh_provisioner_subnet_get(net_idx);
|
||||
} else if (IS_ENABLED(CONFIG_BLE_MESH_FAST_PROV) && bt_mesh_is_provisioned() && role == FAST_PROV) {
|
||||
sub = bt_mesh_fast_prov_subnet_get(net_idx);
|
||||
}
|
||||
|
||||
return sub;
|
||||
}
|
||||
|
||||
const uint8_t *bt_mesh_tx_devkey_get(uint8_t role, uint16_t dst)
|
||||
const uint8_t *bt_mesh_dev_key_get(uint16_t dst)
|
||||
{
|
||||
const uint8_t *key = NULL;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned() && role == NODE) {
|
||||
key = bt_mesh.dev_key;
|
||||
} else if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en() && role == PROVISIONER) {
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) {
|
||||
if (!IS_ENABLED(CONFIG_BLE_MESH_FAST_PROV)) {
|
||||
key = bt_mesh.dev_key;
|
||||
} else {
|
||||
key = bt_mesh_fast_prov_dev_key_get(dst);
|
||||
}
|
||||
} else if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en()) {
|
||||
key = bt_mesh_provisioner_dev_key_get(dst);
|
||||
} else if (IS_ENABLED(CONFIG_BLE_MESH_FAST_PROV) && bt_mesh_is_provisioned() && role == FAST_PROV) {
|
||||
key = bt_mesh_fast_prov_dev_key_get(dst);
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
struct bt_mesh_app_key *bt_mesh_tx_appkey_get(uint8_t role, uint16_t app_idx)
|
||||
{
|
||||
struct bt_mesh_app_key *key = NULL;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned() && role == NODE) {
|
||||
key = bt_mesh_app_key_find(app_idx);
|
||||
} else if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en() && role == PROVISIONER) {
|
||||
key = bt_mesh_provisioner_app_key_find(app_idx);
|
||||
} else if (IS_ENABLED(CONFIG_BLE_MESH_FAST_PROV) && bt_mesh_is_provisioned() && role == FAST_PROV) {
|
||||
key = bt_mesh_fast_prov_app_key_find(app_idx);
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/* APIs used by messages decryption in network layer & upper transport layer */
|
||||
size_t bt_mesh_rx_netkey_size(void)
|
||||
{
|
||||
size_t size = 0U;
|
||||
@ -1048,6 +1105,9 @@ size_t bt_mesh_rx_devkey_size(void)
|
||||
#if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER
|
||||
if (bt_mesh_is_provisioned()) {
|
||||
size = 1;
|
||||
if (bt_mesh_dev_key_ca_valid()) {
|
||||
size += 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1059,6 +1119,9 @@ size_t bt_mesh_rx_devkey_size(void)
|
||||
|
||||
#if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
|
||||
size = 1;
|
||||
if (bt_mesh_dev_key_ca_valid()) {
|
||||
size += 1;
|
||||
}
|
||||
if (bt_mesh_is_provisioner_en()) {
|
||||
size += 1;
|
||||
}
|
||||
@ -1073,7 +1136,11 @@ const uint8_t *bt_mesh_rx_devkey_get(size_t index, uint16_t src)
|
||||
|
||||
#if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER
|
||||
if (bt_mesh_is_provisioned()) {
|
||||
key = bt_mesh.dev_key;
|
||||
if (index == 0) {
|
||||
key = bt_mesh.dev_key;
|
||||
} else if (index == 1) {
|
||||
key = bt_mesh.dev_key_ca;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1084,8 +1151,18 @@ const uint8_t *bt_mesh_rx_devkey_get(size_t index, uint16_t src)
|
||||
#endif
|
||||
|
||||
#if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
|
||||
if (index < 1) {
|
||||
if (index == 0) {
|
||||
key = bt_mesh.dev_key;
|
||||
} else if (index == 1 && bt_mesh_dev_key_ca_valid()) {
|
||||
/* 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.
|
||||
* 2. bt_mesh_is_provisioner_en() is true, it should be return bt_mesh_provisioner_dev_key_get(src).
|
||||
*
|
||||
* If index == 2, that means bt_mesh_dev_key_ca_valid() and bt_mesh_is_provisioner_en() are true.
|
||||
* So the previous round of function bt_mesh_rx_devkey_get(1, src) will return bt_mesh.dev_key_ca.
|
||||
* 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;
|
||||
} else {
|
||||
key = bt_mesh_provisioner_dev_key_get(src);
|
||||
}
|
@ -31,8 +31,13 @@ struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr);
|
||||
|
||||
uint16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, uint16_t addr);
|
||||
|
||||
int bt_mesh_get_opcode(struct net_buf_simple *buf,
|
||||
uint32_t *opcode, bool pull_buf);
|
||||
|
||||
bool bt_mesh_fixed_group_match(uint16_t addr);
|
||||
|
||||
bool bt_mesh_fixed_direct_match(struct bt_mesh_subnet *sub, uint16_t addr);
|
||||
|
||||
void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
|
||||
struct bt_mesh_elem *elem,
|
||||
bool vnd, bool primary,
|
||||
@ -55,11 +60,7 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf);
|
||||
int bt_mesh_comp_register(const struct bt_mesh_comp *comp);
|
||||
int bt_mesh_comp_deregister(void);
|
||||
|
||||
struct bt_mesh_subnet *bt_mesh_tx_netkey_get(uint8_t role, uint16_t net_idx);
|
||||
|
||||
const uint8_t *bt_mesh_tx_devkey_get(uint8_t role, uint16_t dst);
|
||||
|
||||
struct bt_mesh_app_key *bt_mesh_tx_appkey_get(uint8_t role, uint16_t app_idx);
|
||||
const uint8_t *bt_mesh_dev_key_get(uint16_t dst);
|
||||
|
||||
size_t bt_mesh_rx_netkey_size(void);
|
||||
|
@ -11,18 +11,18 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "mesh_kernel.h"
|
||||
#include "mesh.h"
|
||||
#include "mesh_hci.h"
|
||||
#include "mesh_common.h"
|
||||
#include "adv.h"
|
||||
#include "mesh.h"
|
||||
#include "mesh/hci.h"
|
||||
#include "mesh/kernel.h"
|
||||
#include "mesh/common.h"
|
||||
#include "beacon.h"
|
||||
#include "prov.h"
|
||||
#include "prov_node.h"
|
||||
#include "foundation.h"
|
||||
#include "proxy_server.h"
|
||||
#include "proxy_client.h"
|
||||
#include "provisioner_prov.h"
|
||||
#include "mesh_bearer_adapt.h"
|
||||
#include "prov_pvnr.h"
|
||||
#include "mesh/adapter.h"
|
||||
|
||||
/* Convert from ms to 0.625ms units */
|
||||
#define ADV_SCAN_UNIT(_ms) ((_ms) * 8 / 5)
|
||||
@ -63,7 +63,7 @@ static struct bt_mesh_queue adv_queue;
|
||||
#define BLE_MESH_ADV_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + 1)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
#if CONFIG_BLE_MESH_RELAY_ADV_BUF
|
||||
NET_BUF_POOL_DEFINE(relay_adv_buf_pool, CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT,
|
||||
BLE_MESH_ADV_DATA_SIZE, BLE_MESH_ADV_USER_DATA_SIZE, NULL);
|
||||
|
||||
@ -79,7 +79,7 @@ static QueueSetHandle_t mesh_queue_set;
|
||||
#define BLE_MESH_MAX_TIME_INTERVAL 0xFFFFFFFF
|
||||
|
||||
static bool ignore_relay_packet(uint32_t timestamp);
|
||||
#endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
#endif /* CONFIG_BLE_MESH_RELAY_ADV_BUF */
|
||||
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
||||
/* length + advertising data + length + scan response data */
|
||||
@ -175,9 +175,21 @@ static inline int adv_send(struct net_buf *buf)
|
||||
param.interval_min = ADV_SCAN_UNIT(adv_int);
|
||||
param.interval_max = param.interval_min;
|
||||
|
||||
bt_mesh_adv_buf_ref_debug(__func__, buf, 4U, BLE_MESH_BUF_REF_SMALL);
|
||||
|
||||
err = bt_le_adv_start(¶m, &ad, 1, NULL, 0);
|
||||
#if CONFIG_BLE_MESH_PROXY_SOLIC_PDU_TX
|
||||
if (BLE_MESH_ADV(buf)->type == BLE_MESH_ADV_PROXY_SOLIC) {
|
||||
bt_mesh_adv_buf_ref_debug(__func__, buf, 3U, BLE_MESH_BUF_REF_SMALL);
|
||||
struct bt_mesh_adv_data solic_ad[3] = {
|
||||
BLE_MESH_ADV_DATA_BYTES(BLE_MESH_DATA_FLAGS, (BLE_MESH_AD_GENERAL | BLE_MESH_AD_NO_BREDR)),
|
||||
BLE_MESH_ADV_DATA_BYTES(BLE_MESH_DATA_UUID16_ALL, 0x29, 0x18),
|
||||
BLE_MESH_ADV_DATA(BLE_MESH_DATA_SVC_DATA16, buf->data, buf->len),
|
||||
};
|
||||
err = bt_le_adv_start(¶m, solic_ad, 3, NULL, 0);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
bt_mesh_adv_buf_ref_debug(__func__, buf, 4U, BLE_MESH_BUF_REF_SMALL);
|
||||
err = bt_le_adv_start(¶m, &ad, 1, NULL, 0);
|
||||
}
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
||||
} else {
|
||||
struct bt_mesh_ble_adv_data data = {0};
|
||||
@ -238,7 +250,7 @@ static inline TickType_t K_WAIT(int32_t val)
|
||||
|
||||
static void adv_thread(void *p)
|
||||
{
|
||||
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
#if CONFIG_BLE_MESH_RELAY_ADV_BUF
|
||||
QueueSetMemberHandle_t handle = NULL;
|
||||
#endif
|
||||
bt_mesh_msg_t msg = {0};
|
||||
@ -250,9 +262,9 @@ static void adv_thread(void *p)
|
||||
|
||||
while (1) {
|
||||
*buf = NULL;
|
||||
#if !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
#if !CONFIG_BLE_MESH_RELAY_ADV_BUF
|
||||
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
xQueueReceive(adv_queue.handle, &msg, K_NO_WAIT);
|
||||
while (!(*buf)) {
|
||||
int32_t timeout = 0;
|
||||
@ -266,9 +278,9 @@ static void adv_thread(void *p)
|
||||
#else
|
||||
xQueueReceive(adv_queue.handle, &msg, portMAX_DELAY);
|
||||
#endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */
|
||||
#else /* !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
#else /* !CONFIG_BLE_MESH_RELAY_ADV_BUF */
|
||||
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
handle = xQueueSelectFromSet(mesh_queue_set, K_NO_WAIT);
|
||||
if (handle) {
|
||||
if (uxQueueMessagesWaiting(adv_queue.handle)) {
|
||||
@ -304,7 +316,7 @@ static void adv_thread(void *p)
|
||||
}
|
||||
}
|
||||
#endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */
|
||||
#endif /* !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
#endif /* !CONFIG_BLE_MESH_RELAY_ADV_BUF */
|
||||
|
||||
if (*buf == NULL) {
|
||||
continue;
|
||||
@ -313,11 +325,11 @@ static void adv_thread(void *p)
|
||||
/* busy == 0 means this was canceled */
|
||||
if (BLE_MESH_ADV(*buf)->busy) {
|
||||
BLE_MESH_ADV(*buf)->busy = 0U;
|
||||
#if !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
#if !CONFIG_BLE_MESH_RELAY_ADV_BUF
|
||||
if (adv_send(*buf)) {
|
||||
BT_WARN("Failed to send adv packet");
|
||||
}
|
||||
#else /* !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
#else /* !CONFIG_BLE_MESH_RELAY_ADV_BUF */
|
||||
if (msg.relay && ignore_relay_packet(msg.timestamp)) {
|
||||
/* If the interval between "current time - msg.timestamp" is bigger than
|
||||
* BLE_MESH_RELAY_TIME_INTERVAL, this relay packet will not be sent.
|
||||
@ -329,7 +341,7 @@ static void adv_thread(void *p)
|
||||
BT_WARN("Failed to send adv packet");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* !CONFIG_BLE_MESH_RELAY_ADV_BUF */
|
||||
} else {
|
||||
bt_mesh_adv_buf_ref_debug(__func__, *buf, 1U, BLE_MESH_BUF_REF_EQUAL);
|
||||
net_buf_unref(*buf);
|
||||
@ -343,7 +355,7 @@ static void adv_thread(void *p)
|
||||
struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
|
||||
bt_mesh_adv_alloc_t get_id,
|
||||
enum bt_mesh_adv_type type,
|
||||
uint8_t xmit, int32_t timeout)
|
||||
int32_t timeout)
|
||||
{
|
||||
struct bt_mesh_adv *adv = NULL;
|
||||
struct net_buf *buf = NULL;
|
||||
@ -367,7 +379,6 @@ struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
|
||||
(void)memset(adv, 0, sizeof(*adv));
|
||||
|
||||
adv->type = type;
|
||||
adv->xmit = xmit;
|
||||
|
||||
return buf;
|
||||
}
|
||||
@ -390,11 +401,10 @@ void bt_mesh_unref_buf_from_pool(struct net_buf_pool *pool)
|
||||
}
|
||||
}
|
||||
|
||||
struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, uint8_t xmit,
|
||||
int32_t timeout)
|
||||
struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, int32_t timeout)
|
||||
{
|
||||
return bt_mesh_adv_create_from_pool(&adv_buf_pool, adv_alloc, type,
|
||||
xmit, timeout);
|
||||
return bt_mesh_adv_create_from_pool(&adv_buf_pool, adv_alloc,
|
||||
type, timeout);
|
||||
}
|
||||
|
||||
void bt_mesh_adv_buf_ref_debug(const char *func, struct net_buf *buf,
|
||||
@ -433,14 +443,10 @@ static void bt_mesh_unref_buf(bt_mesh_msg_t *msg)
|
||||
}
|
||||
net_buf_unref(buf);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void bt_mesh_task_post(bt_mesh_msg_t *msg, uint32_t timeout, bool front)
|
||||
{
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
if (adv_queue.handle == NULL) {
|
||||
BT_ERR("Invalid adv queue");
|
||||
return;
|
||||
@ -459,7 +465,8 @@ static void bt_mesh_task_post(bt_mesh_msg_t *msg, uint32_t timeout, bool front)
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
||||
void bt_mesh_adv_send(struct net_buf *buf, uint8_t xmit,
|
||||
const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data)
|
||||
{
|
||||
bt_mesh_msg_t msg = {
|
||||
@ -472,6 +479,7 @@ void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
||||
BLE_MESH_ADV(buf)->cb = cb;
|
||||
BLE_MESH_ADV(buf)->cb_data = cb_data;
|
||||
BLE_MESH_ADV(buf)->busy = 1U;
|
||||
BLE_MESH_ADV(buf)->xmit = xmit;
|
||||
|
||||
bt_mesh_adv_buf_ref_debug(__func__, buf, 3U, BLE_MESH_BUF_REF_SMALL);
|
||||
|
||||
@ -486,12 +494,10 @@ void bt_mesh_adv_update(void)
|
||||
.arg = NULL,
|
||||
};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
bt_mesh_task_post(&msg, K_NO_WAIT, false);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
#if CONFIG_BLE_MESH_RELAY_ADV_BUF
|
||||
static bool ignore_relay_packet(uint32_t timestamp)
|
||||
{
|
||||
uint32_t now = k_uptime_get_32();
|
||||
@ -511,11 +517,10 @@ static struct bt_mesh_adv *relay_adv_alloc(int id)
|
||||
return &relay_adv_pool[id];
|
||||
}
|
||||
|
||||
struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, uint8_t xmit,
|
||||
int32_t timeout)
|
||||
struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, int32_t timeout)
|
||||
{
|
||||
return bt_mesh_adv_create_from_pool(&relay_adv_buf_pool, relay_adv_alloc, type,
|
||||
xmit, timeout);
|
||||
return bt_mesh_adv_create_from_pool(&relay_adv_buf_pool, relay_adv_alloc,
|
||||
type, timeout);
|
||||
}
|
||||
|
||||
static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
||||
@ -523,8 +528,6 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
||||
QueueSetMemberHandle_t handle = NULL;
|
||||
bt_mesh_msg_t old_msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
if (relay_queue.handle == NULL) {
|
||||
BT_ERR("Invalid relay queue");
|
||||
return;
|
||||
@ -534,8 +537,7 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* If failed to send packet to the relay queue(queue is full), we will
|
||||
/* If failed to send packet to the relay queue(queue is full), we will
|
||||
* remove the oldest packet in the queue and put the new one into it.
|
||||
*/
|
||||
handle = xQueueSelectFromSet(mesh_queue_set, K_NO_WAIT);
|
||||
@ -561,8 +563,10 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data, uint16_t src, uint16_t dst)
|
||||
void bt_mesh_relay_adv_send(struct net_buf *buf, uint8_t xmit,
|
||||
uint16_t src, uint16_t dst,
|
||||
const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data)
|
||||
{
|
||||
bt_mesh_msg_t msg = {
|
||||
.relay = true,
|
||||
@ -574,6 +578,7 @@ void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *c
|
||||
BLE_MESH_ADV(buf)->cb = cb;
|
||||
BLE_MESH_ADV(buf)->cb_data = cb_data;
|
||||
BLE_MESH_ADV(buf)->busy = 1U;
|
||||
BLE_MESH_ADV(buf)->xmit = xmit;
|
||||
|
||||
msg.arg = (void *)net_buf_ref(buf);
|
||||
msg.src = src;
|
||||
@ -587,7 +592,7 @@ uint16_t bt_mesh_get_stored_relay_count(void)
|
||||
{
|
||||
return (uint16_t)uxQueueMessagesWaiting(relay_queue.handle);
|
||||
}
|
||||
#endif /* #if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
#endif /* #if CONFIG_BLE_MESH_RELAY_ADV_BUF */
|
||||
|
||||
void bt_mesh_adv_init(void)
|
||||
{
|
||||
@ -611,7 +616,7 @@ void bt_mesh_adv_init(void)
|
||||
__ASSERT(adv_queue.handle, "Failed to create static queue");
|
||||
#endif /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
#if CONFIG_BLE_MESH_RELAY_ADV_BUF
|
||||
#if !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
relay_queue.handle = xQueueCreate(BLE_MESH_RELAY_QUEUE_SIZE, sizeof(bt_mesh_msg_t));
|
||||
__ASSERT(relay_queue.handle, "Failed to create relay queue");
|
||||
@ -636,7 +641,7 @@ void bt_mesh_adv_init(void)
|
||||
__ASSERT(mesh_queue_set, "Failed to create queue set");
|
||||
xQueueAddToSet(adv_queue.handle, mesh_queue_set);
|
||||
xQueueAddToSet(relay_queue.handle, mesh_queue_set);
|
||||
#endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
#endif /* CONFIG_BLE_MESH_RELAY_ADV_BUF */
|
||||
|
||||
#if (CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && \
|
||||
(CONFIG_SPIRAM_CACHE_WORKAROUND || !CONFIG_IDF_TARGET_ESP32) && \
|
||||
@ -674,7 +679,7 @@ void bt_mesh_adv_deinit(void)
|
||||
adv_task.task = NULL;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
#if CONFIG_BLE_MESH_RELAY_ADV_BUF
|
||||
xQueueRemoveFromSet(adv_queue.handle, mesh_queue_set);
|
||||
xQueueRemoveFromSet(relay_queue.handle, mesh_queue_set);
|
||||
|
||||
@ -685,14 +690,14 @@ void bt_mesh_adv_deinit(void)
|
||||
relay_queue.buffer = NULL;
|
||||
heap_caps_free(relay_queue.storage);
|
||||
relay_queue.storage = NULL;
|
||||
#endif
|
||||
#endif /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||
|
||||
bt_mesh_unref_buf_from_pool(&relay_adv_buf_pool);
|
||||
memset(relay_adv_pool, 0, sizeof(relay_adv_pool));
|
||||
|
||||
vQueueDelete(mesh_queue_set);
|
||||
mesh_queue_set = NULL;
|
||||
#endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
#endif /* CONFIG_BLE_MESH_RELAY_ADV_BUF */
|
||||
|
||||
vQueueDelete(adv_queue.handle);
|
||||
adv_queue.handle = NULL;
|
||||
@ -701,14 +706,14 @@ void bt_mesh_adv_deinit(void)
|
||||
adv_queue.buffer = NULL;
|
||||
heap_caps_free(adv_queue.storage);
|
||||
adv_queue.storage = NULL;
|
||||
#endif
|
||||
#endif /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||
|
||||
bt_mesh_unref_buf_from_pool(&adv_buf_pool);
|
||||
memset(adv_pool, 0, sizeof(adv_pool));
|
||||
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
||||
bt_mesh_ble_adv_deinit();
|
||||
#endif
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
@ -718,10 +723,10 @@ static struct bt_mesh_adv *ble_adv_alloc(int id)
|
||||
return &ble_adv_pool[id];
|
||||
}
|
||||
|
||||
static struct net_buf *bt_mesh_ble_adv_create(enum bt_mesh_adv_type type, uint8_t xmit, int32_t timeout)
|
||||
static struct net_buf *bt_mesh_ble_adv_create(enum bt_mesh_adv_type type, int32_t timeout)
|
||||
{
|
||||
return bt_mesh_adv_create_from_pool(&ble_adv_buf_pool, ble_adv_alloc, type,
|
||||
xmit, timeout);
|
||||
return bt_mesh_adv_create_from_pool(&ble_adv_buf_pool, ble_adv_alloc,
|
||||
type, timeout);
|
||||
}
|
||||
|
||||
static void bt_mesh_ble_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
||||
@ -789,11 +794,7 @@ static void ble_adv_send_end(int err, void *cb_data)
|
||||
}
|
||||
|
||||
if (tx->param.count) {
|
||||
if (tx->param.period) {
|
||||
k_delayed_work_submit(&tx->resend, tx->param.period);
|
||||
} else {
|
||||
k_work_submit(&tx->resend.work);
|
||||
}
|
||||
k_delayed_work_submit(&tx->resend, tx->param.period);
|
||||
} else {
|
||||
ble_adv_tx_reset(tx, true);
|
||||
}
|
||||
@ -806,7 +807,9 @@ static struct bt_mesh_send_cb ble_adv_send_cb = {
|
||||
|
||||
static void ble_adv_resend(struct k_work *work)
|
||||
{
|
||||
struct ble_adv_tx *tx = CONTAINER_OF(work, struct ble_adv_tx, resend.work);
|
||||
struct ble_adv_tx *tx = CONTAINER_OF(work,
|
||||
struct ble_adv_tx,
|
||||
resend.work);
|
||||
bool front = false;
|
||||
|
||||
if (tx->buf == NULL) {
|
||||
@ -880,7 +883,7 @@ int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
buf = bt_mesh_ble_adv_create(BLE_MESH_ADV_BLE, 0U, K_NO_WAIT);
|
||||
buf = bt_mesh_ble_adv_create(BLE_MESH_ADV_BLE, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
BT_ERR("No empty ble adv buffer");
|
||||
return -ENOBUFS;
|
@ -10,24 +10,24 @@
|
||||
#ifndef _ADV_H_
|
||||
#define _ADV_H_
|
||||
|
||||
#include "mesh_access.h"
|
||||
#include "mesh_bearer_adapt.h"
|
||||
#include "mesh/access.h"
|
||||
#include "mesh/adapter.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Maximum advertising data payload for a single data type */
|
||||
#define BLE_MESH_ADV_DATA_SIZE 29
|
||||
#define BLE_MESH_ADV_DATA_SIZE 29
|
||||
|
||||
/* The user data is a pointer (4 bytes) to struct bt_mesh_adv */
|
||||
#define BLE_MESH_ADV_USER_DATA_SIZE 4
|
||||
#define BLE_MESH_ADV_USER_DATA_SIZE 4
|
||||
|
||||
#define BLE_MESH_ADV(buf) (*(struct bt_mesh_adv **)net_buf_user_data(buf))
|
||||
#define BLE_MESH_ADV(buf) (*(struct bt_mesh_adv **)net_buf_user_data(buf))
|
||||
|
||||
typedef struct bt_mesh_msg {
|
||||
bool relay; /* Flag indicates if the packet is a relayed one */
|
||||
void *arg; /* Pointer to the struct net_buf */
|
||||
bool relay; /* Flag indicates if the packet is a relayed one */
|
||||
void *arg; /* Pointer to the struct net_buf */
|
||||
uint16_t src; /* Source address for relay packets */
|
||||
uint16_t dst; /* Destination address for relay packets */
|
||||
uint32_t timestamp; /* Timestamp recorded when the relay packet is posted to queue */
|
||||
@ -39,6 +39,7 @@ enum bt_mesh_adv_type {
|
||||
BLE_MESH_ADV_BEACON,
|
||||
BLE_MESH_ADV_URI,
|
||||
BLE_MESH_ADV_BLE,
|
||||
BLE_MESH_ADV_PROXY_SOLIC,
|
||||
};
|
||||
|
||||
struct bt_mesh_adv {
|
||||
@ -52,9 +53,7 @@ struct bt_mesh_adv {
|
||||
|
||||
typedef struct bt_mesh_adv *(*bt_mesh_adv_alloc_t)(int id);
|
||||
|
||||
/* xmit_count: Number of retransmissions, i.e. 0 == 1 transmission */
|
||||
struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, uint8_t xmit,
|
||||
int32_t timeout);
|
||||
struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, int32_t timeout);
|
||||
|
||||
typedef enum {
|
||||
BLE_MESH_BUF_REF_EQUAL,
|
||||
@ -68,18 +67,20 @@ void bt_mesh_adv_buf_ref_debug(const char *func, struct net_buf *buf,
|
||||
struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
|
||||
bt_mesh_adv_alloc_t get_id,
|
||||
enum bt_mesh_adv_type type,
|
||||
uint8_t xmit, int32_t timeout);
|
||||
int32_t timeout);
|
||||
|
||||
void bt_mesh_unref_buf_from_pool(struct net_buf_pool *pool);
|
||||
|
||||
void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
||||
void bt_mesh_adv_send(struct net_buf *buf, uint8_t xmit,
|
||||
const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data);
|
||||
|
||||
struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, uint8_t xmit,
|
||||
int32_t timeout);
|
||||
struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, int32_t timeout);
|
||||
|
||||
void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data, uint16_t src, uint16_t dst);
|
||||
void bt_mesh_relay_adv_send(struct net_buf *buf, uint8_t xmit,
|
||||
uint16_t src, uint16_t dst,
|
||||
const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data);
|
||||
|
||||
uint16_t bt_mesh_get_stored_relay_count(void);
|
||||
|
@ -11,41 +11,45 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "adv.h"
|
||||
#include "scan.h"
|
||||
#include "mesh.h"
|
||||
#include "prov.h"
|
||||
#include "crypto.h"
|
||||
#include "beacon.h"
|
||||
#include "access.h"
|
||||
#include "foundation.h"
|
||||
#include "proxy_client.h"
|
||||
#include "mesh_main.h"
|
||||
#include "provisioner_prov.h"
|
||||
#include "provisioner_main.h"
|
||||
#include "mesh/main.h"
|
||||
#include "prov_common.h"
|
||||
#include "prov_node.h"
|
||||
#include "prov_pvnr.h"
|
||||
#include "pvnr_mgmt.h"
|
||||
#include "mesh/common.h"
|
||||
|
||||
#include "mesh_v1.1/utils.h"
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_UNPROVISIONED_BEACON_INTERVAL)
|
||||
#define UNPROVISIONED_INTERVAL K_SECONDS(CONFIG_BLE_MESH_UNPROVISIONED_BEACON_INTERVAL)
|
||||
#define UNPROV_BEACON_INTERVAL K_SECONDS(CONFIG_BLE_MESH_UNPROVISIONED_BEACON_INTERVAL)
|
||||
#else
|
||||
#define UNPROVISIONED_INTERVAL K_SECONDS(5)
|
||||
#define UNPROV_BEACON_INTERVAL K_SECONDS(5)
|
||||
#endif
|
||||
#define PROVISIONED_INTERVAL K_SECONDS(10)
|
||||
|
||||
#define BEACON_TYPE_UNPROVISIONED 0x00
|
||||
#define BEACON_TYPE_SECURE 0x01
|
||||
#define SECURE_BEACON_INTERVAL K_SECONDS(10)
|
||||
|
||||
/* 3 transmissions, 20ms interval */
|
||||
#define UNPROV_XMIT BLE_MESH_TRANSMIT(2, 20)
|
||||
|
||||
/* 1 transmission, 20ms interval */
|
||||
#define PROV_XMIT BLE_MESH_TRANSMIT(0, 20)
|
||||
#define SNB_XMIT BLE_MESH_TRANSMIT(0, 20)
|
||||
|
||||
#define SNB_NET_IDX_SET(_val) ((void *)((uint32_t)(_val)))
|
||||
#define SNB_NET_IDX_GET(_ptr) ((uint32_t)(_ptr))
|
||||
/* For a device, using the snb_timer when sending Unprovisioned Device Beacon;
|
||||
* For a node, using the snb_timer when sending Secure Network Beacon.
|
||||
*/
|
||||
static struct k_delayed_work snb_timer;
|
||||
|
||||
static struct k_delayed_work beacon_timer;
|
||||
|
||||
static struct bt_mesh_subnet *cache_check(uint8_t data[21])
|
||||
struct bt_mesh_subnet *cache_check(uint8_t data[21], bool private_beacon)
|
||||
{
|
||||
size_t subnet_size = 0U;
|
||||
uint8_t *cache = NULL;
|
||||
int i = 0;
|
||||
|
||||
subnet_size = bt_mesh_rx_netkey_size();
|
||||
@ -57,7 +61,13 @@ static struct bt_mesh_subnet *cache_check(uint8_t data[21])
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!memcmp(sub->beacon_cache, data, 21)) {
|
||||
#if CONFIG_BLE_MESH_PRIVATE_BEACON
|
||||
cache = private_beacon ? sub->mpb_cache : sub->snb_cache;
|
||||
#else
|
||||
cache = sub->snb_cache;
|
||||
#endif
|
||||
|
||||
if (!memcmp(cache, data, 21)) {
|
||||
return sub;
|
||||
}
|
||||
}
|
||||
@ -65,19 +75,26 @@ static struct bt_mesh_subnet *cache_check(uint8_t data[21])
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void cache_add(uint8_t data[21], struct bt_mesh_subnet *sub)
|
||||
void cache_add(uint8_t data[21], struct bt_mesh_subnet *sub, bool private_beacon)
|
||||
{
|
||||
memcpy(sub->beacon_cache, data, 21);
|
||||
#if CONFIG_BLE_MESH_PRIVATE_BEACON
|
||||
if (private_beacon) {
|
||||
memcpy(sub->mpb_cache, data, 21);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
memcpy(sub->snb_cache, data, 21);
|
||||
}
|
||||
}
|
||||
|
||||
static void beacon_complete(int err, void *user_data)
|
||||
static void secure_beacon_complete(int err, void *user_data)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
uint16_t net_idx = BLE_MESH_KEY_UNUSED;
|
||||
|
||||
BT_DBG("err %d", err);
|
||||
|
||||
net_idx = (uint16_t)SNB_NET_IDX_GET(user_data);
|
||||
net_idx = (uint16_t)NET_IDX_GET(user_data);
|
||||
|
||||
/* For node, directly updating the "beacon_sent" timestamp is fine,
|
||||
* since the subnet is pre-allocated.
|
||||
@ -86,20 +103,14 @@ static void beacon_complete(int err, void *user_data)
|
||||
* a chance that the subnet is removed just before the completion of
|
||||
* sending the Secure Network Beacon.
|
||||
*/
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) {
|
||||
sub = bt_mesh_subnet_get(net_idx);
|
||||
} else if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) &&
|
||||
bt_mesh_is_provisioner_en()) {
|
||||
sub = bt_mesh_provisioner_subnet_get(net_idx);
|
||||
}
|
||||
|
||||
sub = bt_mesh_subnet_get(net_idx);
|
||||
if (sub) {
|
||||
sub->beacon_sent = k_uptime_get_32();
|
||||
sub->snb_sent = k_uptime_get_32();
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_beacon_create(struct bt_mesh_subnet *sub,
|
||||
struct net_buf_simple *buf)
|
||||
void bt_mesh_secure_beacon_create(struct bt_mesh_subnet *sub,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
uint8_t flags = bt_mesh_net_flags(sub);
|
||||
struct bt_mesh_subnet_keys *keys = NULL;
|
||||
@ -122,26 +133,21 @@ void bt_mesh_beacon_create(struct bt_mesh_subnet *sub,
|
||||
|
||||
net_buf_simple_add_mem(buf, sub->auth, 8);
|
||||
|
||||
BT_INFO("net_idx 0x%03x iv_index 0x%08x flags 0x%02x",
|
||||
BT_DBG("SNB: net_idx 0x%03x iv_index 0x%08x flags 0x%02x",
|
||||
sub->net_idx, bt_mesh.iv_index, flags);
|
||||
BT_DBG("NetID %s Auth %s", bt_hex(keys->net_id, 8),
|
||||
BT_DBG("SNB: NetID %s Auth %s", bt_hex(keys->net_id, 8),
|
||||
bt_hex(sub->auth, 8));
|
||||
}
|
||||
|
||||
/* If the interval has passed or is within 5 seconds from now send a beacon */
|
||||
#define BEACON_THRESHOLD(sub) (K_SECONDS(10 * ((sub)->beacons_last + 1)) - K_SECONDS(5))
|
||||
|
||||
static int secure_beacon_send(void)
|
||||
{
|
||||
static const struct bt_mesh_send_cb send_cb = {
|
||||
.end = beacon_complete,
|
||||
.end = secure_beacon_complete,
|
||||
};
|
||||
uint32_t now = k_uptime_get_32();
|
||||
size_t subnet_size = 0U;
|
||||
int i = 0;
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
subnet_size = bt_mesh_rx_netkey_size();
|
||||
|
||||
for (i = 0; i < subnet_size; i++) {
|
||||
@ -153,128 +159,137 @@ static int secure_beacon_send(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
time_diff = now - sub->beacon_sent;
|
||||
time_diff = now - sub->snb_sent;
|
||||
if (time_diff < K_SECONDS(600) &&
|
||||
time_diff < BEACON_THRESHOLD(sub)) {
|
||||
time_diff < BEACON_THRESHOLD(sub->snb_last)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a node enables the Proxy Client functionality, and it
|
||||
/* If a node enables the Proxy Client functionality, and it
|
||||
* succeeds to send Secure Network Beacon with GATT bearer,
|
||||
* here we will continue to send Secure Network Beacon of
|
||||
* other subnets.
|
||||
*/
|
||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)
|
||||
if (bt_mesh_proxy_client_beacon_send(sub)) {
|
||||
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
if (bt_mesh_proxy_client_beacon_send(sub, false)) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
buf = bt_mesh_adv_create(BLE_MESH_ADV_BEACON, PROV_XMIT,
|
||||
K_NO_WAIT);
|
||||
buf = bt_mesh_adv_create(BLE_MESH_ADV_BEACON, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
BT_ERR("Out of beacon buffer");
|
||||
BT_ERR("Out of secure beacon buffer");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
bt_mesh_beacon_create(sub, &buf->b);
|
||||
bt_mesh_secure_beacon_create(sub, &buf->b);
|
||||
|
||||
/* Care should be taken here. Previously the user_data is the
|
||||
* pointer of a subnet. When the device is a Provisioner, its
|
||||
* subnet is created dynamically. If the corresponding subnet
|
||||
* is removed right after the Secure Network Beacon is sent,
|
||||
* update its "beacon_sent" timestamp in beacon_complete() will
|
||||
* cause exception.
|
||||
* update its "snb_sent" timestamp in secure_beacon_complete()
|
||||
* will cause exception.
|
||||
* Here we use the "net_idx" of the subnet instead. And in the
|
||||
* beacon_complete(), we will try to get the subnet before
|
||||
* updating its "beacon_sent" timestamp.
|
||||
* secure_beacon_complete(), we will try to get the subnet before
|
||||
* updating its "snb_sent" timestamp.
|
||||
*/
|
||||
bt_mesh_adv_send(buf, &send_cb, SNB_NET_IDX_SET(sub->net_idx));
|
||||
bt_mesh_adv_send(buf, SNB_XMIT, &send_cb, NET_IDX_SET(sub->net_idx));
|
||||
net_buf_unref(buf);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NODE)
|
||||
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_ADV)
|
||||
static int unprovisioned_beacon_send(void)
|
||||
{
|
||||
#if defined(CONFIG_BLE_MESH_PB_ADV)
|
||||
const struct bt_mesh_prov *prov = NULL;
|
||||
uint8_t uri_hash[16] = { 0 };
|
||||
uint8_t uri_hash[16] = {0};
|
||||
struct net_buf *buf = NULL;
|
||||
uint16_t oob_info = 0U;
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
if (bt_mesh_prov_get() == NULL) {
|
||||
BT_ERR("No provisioning context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
buf = bt_mesh_adv_create(BLE_MESH_ADV_BEACON, UNPROV_XMIT, K_NO_WAIT);
|
||||
buf = bt_mesh_adv_create(BLE_MESH_ADV_BEACON, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
BT_ERR("Out of beacon buffer");
|
||||
BT_ERR("Out of unprov beacon buffer");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
prov = bt_mesh_prov_get();
|
||||
|
||||
net_buf_add_u8(buf, BEACON_TYPE_UNPROVISIONED);
|
||||
net_buf_add_mem(buf, prov->uuid, 16);
|
||||
net_buf_add_mem(buf, bt_mesh_prov_get()->uuid, 16);
|
||||
|
||||
if (prov->uri && bt_mesh_s1(prov->uri, uri_hash) == 0) {
|
||||
oob_info = prov->oob_info | BLE_MESH_PROV_OOB_URI;
|
||||
if (bt_mesh_prov_get()->uri &&
|
||||
bt_mesh_s1(bt_mesh_prov_get()->uri, uri_hash) == 0) {
|
||||
oob_info = bt_mesh_prov_get()->oob_info | BLE_MESH_PROV_OOB_URI;
|
||||
} else {
|
||||
oob_info = prov->oob_info;
|
||||
oob_info = bt_mesh_prov_get()->oob_info;
|
||||
}
|
||||
|
||||
net_buf_add_be16(buf, oob_info);
|
||||
net_buf_add_mem(buf, uri_hash, 4);
|
||||
|
||||
bt_mesh_adv_send(buf, NULL, NULL);
|
||||
bt_mesh_adv_send(buf, UNPROV_XMIT, NULL, NULL);
|
||||
net_buf_unref(buf);
|
||||
|
||||
if (prov->uri) {
|
||||
size_t len;
|
||||
if (bt_mesh_prov_get()->uri) {
|
||||
size_t len = 0;
|
||||
|
||||
buf = bt_mesh_adv_create(BLE_MESH_ADV_URI, UNPROV_XMIT,
|
||||
K_NO_WAIT);
|
||||
buf = bt_mesh_adv_create(BLE_MESH_ADV_URI, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
BT_ERR("Unable to allocate URI buffer");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
len = strlen(prov->uri);
|
||||
len = strlen(bt_mesh_prov_get()->uri);
|
||||
|
||||
if (net_buf_tailroom(buf) < len) {
|
||||
BT_WARN("Too long URI to fit advertising data");
|
||||
} else {
|
||||
net_buf_add_mem(buf, prov->uri, len);
|
||||
bt_mesh_adv_send(buf, NULL, NULL);
|
||||
net_buf_add_mem(buf, bt_mesh_prov_get()->uri, len);
|
||||
bt_mesh_adv_send(buf, UNPROV_XMIT, NULL, NULL);
|
||||
}
|
||||
|
||||
net_buf_unref(buf);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_PB_ADV */
|
||||
return 0;
|
||||
}
|
||||
#else /* CONFIG_BLE_MESH_NODE */
|
||||
#else /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_ADV) */
|
||||
static int unprovisioned_beacon_send(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_NODE */
|
||||
#endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_ADV) */
|
||||
|
||||
static void update_beacon_observation(void)
|
||||
void update_beacon_observation(bool private_beacon)
|
||||
{
|
||||
static bool first_half;
|
||||
static bool snb_first_half;
|
||||
size_t subnet_size = 0U;
|
||||
int i = 0;
|
||||
|
||||
/* Observation period is 20 seconds, whereas the beacon timer
|
||||
* runs every 10 seconds. We process what's happened during the
|
||||
* window only after the second half.
|
||||
* runs every 10 seconds. We process what's happened during
|
||||
* the window only after the second half.
|
||||
*/
|
||||
first_half = !first_half;
|
||||
if (first_half) {
|
||||
return;
|
||||
#if CONFIG_BLE_MESH_PRB_SRV
|
||||
static bool mpb_first_half;
|
||||
|
||||
if (private_beacon) {
|
||||
mpb_first_half = !mpb_first_half;
|
||||
if (mpb_first_half) {
|
||||
return;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
snb_first_half = !snb_first_half;
|
||||
if (snb_first_half) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
subnet_size = bt_mesh_rx_netkey_size();
|
||||
@ -286,8 +301,16 @@ static void update_beacon_observation(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
sub->beacons_last = sub->beacons_cur;
|
||||
sub->beacons_cur = 0U;
|
||||
#if CONFIG_BLE_MESH_PRB_SRV
|
||||
if (private_beacon) {
|
||||
sub->mpb_last = sub->mpb_cur;
|
||||
sub->mpb_cur = 0U;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
sub->snb_last = sub->snb_cur;
|
||||
sub->snb_cur = 0U;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,34 +322,31 @@ static bool ready_to_send(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
static void beacon_send(struct k_work *work)
|
||||
static void secure_beacon_send_timeout(struct k_work *work)
|
||||
{
|
||||
/* Don't send anything if we have an active provisioning link */
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_node() &&
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PROV) && bt_prov_active()) {
|
||||
k_delayed_work_submit(&beacon_timer, UNPROVISIONED_INTERVAL);
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PROV) && bt_mesh_prov_active()) {
|
||||
k_delayed_work_submit(&snb_timer, UNPROV_BEACON_INTERVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
if (ready_to_send()) {
|
||||
update_beacon_observation();
|
||||
update_beacon_observation(false);
|
||||
|
||||
secure_beacon_send();
|
||||
|
||||
/* Only resubmit if beaconing is still enabled */
|
||||
if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED ||
|
||||
bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_INITIATOR)) {
|
||||
k_delayed_work_submit(&beacon_timer,
|
||||
PROVISIONED_INTERVAL);
|
||||
if (bt_mesh_secure_beacon_get() == BLE_MESH_SECURE_BEACON_ENABLED ||
|
||||
bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_INITIATOR)) {
|
||||
k_delayed_work_submit(&snb_timer, SECURE_BEACON_INTERVAL);
|
||||
}
|
||||
} else {
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_node()) {
|
||||
unprovisioned_beacon_send();
|
||||
k_delayed_work_submit(&beacon_timer, UNPROVISIONED_INTERVAL);
|
||||
k_delayed_work_submit(&snb_timer, UNPROV_BEACON_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void secure_beacon_recv(struct net_buf_simple *buf)
|
||||
@ -339,12 +359,12 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
|
||||
bool new_key = false;
|
||||
uint8_t flags = 0U;
|
||||
|
||||
if (buf->len < 21) {
|
||||
BT_ERR("Too short secure beacon (len %u)", buf->len);
|
||||
if (buf->len != 21) {
|
||||
BT_ERR("Malformed secure beacon (len %u)", buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
sub = cache_check(buf->data);
|
||||
sub = cache_check(buf->data, false);
|
||||
if (sub) {
|
||||
/* We've seen this beacon before - just update the stats */
|
||||
goto update_stats;
|
||||
@ -361,9 +381,9 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
|
||||
BT_DBG("flags 0x%02x id %s iv_index 0x%08x",
|
||||
flags, bt_hex(net_id, 8), iv_index);
|
||||
|
||||
sub = bt_mesh_subnet_find(net_id, flags, iv_index, auth, &new_key);
|
||||
sub = bt_mesh_subnet_find_with_snb(net_id, flags, iv_index, auth, &new_key);
|
||||
if (!sub) {
|
||||
BT_DBG("No subnet that matched beacon");
|
||||
BT_DBG("No subnet that matched secure beacon");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -372,16 +392,16 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
|
||||
return;
|
||||
}
|
||||
|
||||
cache_add(data, sub);
|
||||
cache_add(data, sub, false);
|
||||
|
||||
/* Spec v1.0.1, Section 3.8.4:
|
||||
* If a node on a primary subnet receives an update on
|
||||
/* If we have NetKey0 accept initiation only from it.
|
||||
*
|
||||
* Spec v1.1, Section 3.8.4:
|
||||
* If a device on a primary subnet receives an update on
|
||||
* the primary subnet, it shall propagate the IV update
|
||||
* to all other subnets. If a node on a primary subnet
|
||||
* to all other subnets. If a device on a primary subnet
|
||||
* receives an IV update on any other subnet, the update
|
||||
* shall be ignored.
|
||||
* If a node on a primary subnet receives an key update
|
||||
* on any other subnet, the update shall not be ignored.
|
||||
*/
|
||||
if (bt_mesh_primary_subnet_exist() &&
|
||||
sub->net_idx != BLE_MESH_KEY_PRIMARY &&
|
||||
@ -391,12 +411,12 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
|
||||
goto update_stats;
|
||||
}
|
||||
|
||||
BT_INFO("net_idx 0x%03x iv_index 0x%08x current iv_index 0x%08x",
|
||||
BT_DBG("SNB: net_idx 0x%03x iv_index 0x%08x current iv_index 0x%08x",
|
||||
sub->net_idx, iv_index, bt_mesh.iv_index);
|
||||
|
||||
if (bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_INITIATOR) &&
|
||||
(bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_IN_PROGRESS) ==
|
||||
BLE_MESH_IV_UPDATE(flags))) {
|
||||
(bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_IN_PROGRESS) ==
|
||||
BLE_MESH_IV_UPDATE(flags))) {
|
||||
bt_mesh_beacon_ivu_initiator(false);
|
||||
}
|
||||
|
||||
@ -412,7 +432,7 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
|
||||
|
||||
kr_change = bt_mesh_kr_update(sub, BLE_MESH_KEY_REFRESH(flags), new_key);
|
||||
if (kr_change) {
|
||||
bt_mesh_net_beacon_update(sub);
|
||||
bt_mesh_net_secure_beacon_update(sub);
|
||||
}
|
||||
|
||||
if (iv_change) {
|
||||
@ -424,9 +444,9 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
|
||||
}
|
||||
|
||||
update_stats:
|
||||
if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED &&
|
||||
sub->beacons_cur < 0xff) {
|
||||
sub->beacons_cur++;
|
||||
if (bt_mesh_secure_beacon_get() == BLE_MESH_SECURE_BEACON_ENABLED &&
|
||||
sub->snb_cur < 0xff) {
|
||||
sub->snb_cur++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -445,14 +465,28 @@ void bt_mesh_beacon_recv(struct net_buf_simple *buf, int8_t rssi)
|
||||
switch (type) {
|
||||
case BEACON_TYPE_UNPROVISIONED:
|
||||
BT_DBG("Unprovisioned device beacon received");
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) &&
|
||||
bt_mesh_is_provisioner_en()) {
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
|
||||
bt_mesh_is_provisioner_en()) {
|
||||
bt_mesh_provisioner_unprov_beacon_recv(buf, rssi);
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_RPR_SRV) &&
|
||||
bt_mesh_is_provisioned()) {
|
||||
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_rpr_srv_unprov_beacon_recv(buf, bt_mesh_get_adv_type(), addr, rssi);
|
||||
}
|
||||
break;
|
||||
case BEACON_TYPE_SECURE:
|
||||
secure_beacon_recv(buf);
|
||||
break;
|
||||
#if CONFIG_BLE_MESH_PRIVATE_BEACON
|
||||
case BEACON_TYPE_PRIVATE:
|
||||
bt_mesh_private_beacon_recv(buf);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
BT_DBG("Unknown beacon type 0x%02x", type);
|
||||
break;
|
||||
@ -461,13 +495,31 @@ void bt_mesh_beacon_recv(struct net_buf_simple *buf, int8_t rssi)
|
||||
|
||||
void bt_mesh_beacon_init(void)
|
||||
{
|
||||
k_delayed_work_init(&beacon_timer, beacon_send);
|
||||
/* secure beacon init */
|
||||
if (k_delayed_work_init(&snb_timer, secure_beacon_send_timeout)) {
|
||||
BT_ERR("Failed to create a snb_timer");
|
||||
return;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_PRB_SRV
|
||||
/* private beacon init */
|
||||
if (bt_mesh_private_beacon_timer_init()) {
|
||||
BT_ERR("Failed to create a mpb_timer");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
void bt_mesh_beacon_deinit(void)
|
||||
{
|
||||
k_delayed_work_free(&beacon_timer);
|
||||
/* secure beacon deinit */
|
||||
k_delayed_work_free(&snb_timer);
|
||||
|
||||
#if CONFIG_BLE_MESH_PRB_SRV
|
||||
/* private beacon deinit */
|
||||
bt_mesh_private_beacon_timer_free();
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
@ -476,20 +528,32 @@ void bt_mesh_beacon_ivu_initiator(bool enable)
|
||||
bt_mesh_atomic_set_bit_to(bt_mesh.flags, BLE_MESH_IVU_INITIATOR, enable);
|
||||
|
||||
if (enable) {
|
||||
k_work_submit(&beacon_timer.work);
|
||||
} else if (bt_mesh_beacon_get() == BLE_MESH_BEACON_DISABLED) {
|
||||
k_delayed_work_cancel(&beacon_timer);
|
||||
k_delayed_work_submit(&snb_timer, K_NO_WAIT);
|
||||
#if CONFIG_BLE_MESH_PRB_SRV
|
||||
if (bt_mesh_private_beacon_state_get() == BLE_MESH_PRIVATE_BEACON_ENABLED) {
|
||||
bt_mesh_private_beacon_timer_submit(K_NO_WAIT);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (bt_mesh_secure_beacon_get() == BLE_MESH_SECURE_BEACON_DISABLED) {
|
||||
k_delayed_work_cancel(&snb_timer);
|
||||
}
|
||||
#if CONFIG_BLE_MESH_PRB_SRV
|
||||
if (bt_mesh_private_beacon_state_get() == BLE_MESH_PRIVATE_BEACON_DISABLED) {
|
||||
bt_mesh_private_beacon_timer_cancel();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_beacon_enable(void)
|
||||
void bt_mesh_secure_beacon_enable(void)
|
||||
{
|
||||
size_t subnet_size = 0U;
|
||||
int i = 0;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_node() &&
|
||||
!bt_mesh_is_provisioned()) {
|
||||
k_work_submit(&beacon_timer.work);
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) &&
|
||||
bt_mesh_is_node() && !bt_mesh_is_provisioned()) {
|
||||
k_delayed_work_submit(&snb_timer, K_NO_WAIT);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -502,18 +566,18 @@ void bt_mesh_beacon_enable(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
sub->beacons_last = 0U;
|
||||
sub->beacons_cur = 0U;
|
||||
sub->snb_last = 0U;
|
||||
sub->snb_cur = 0U;
|
||||
|
||||
bt_mesh_net_beacon_update(sub);
|
||||
bt_mesh_net_secure_beacon_update(sub);
|
||||
}
|
||||
|
||||
k_work_submit(&beacon_timer.work);
|
||||
k_delayed_work_submit(&snb_timer, K_NO_WAIT);
|
||||
}
|
||||
|
||||
void bt_mesh_beacon_disable(void)
|
||||
void bt_mesh_secure_beacon_disable(void)
|
||||
{
|
||||
if (!bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_INITIATOR)) {
|
||||
k_delayed_work_cancel(&beacon_timer);
|
||||
k_delayed_work_cancel(&snb_timer);
|
||||
}
|
||||
}
|
46
components/bt/esp_ble_mesh/core/beacon.h
Normal file
46
components/bt/esp_ble_mesh/core/beacon.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* Bluetooth Mesh */
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BEACON_H_
|
||||
#define _BEACON_H_
|
||||
|
||||
#include "net.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BEACON_TYPE_UNPROVISIONED 0x00
|
||||
#define BEACON_TYPE_SECURE 0x01
|
||||
#define BEACON_TYPE_PRIVATE 0x02
|
||||
|
||||
#define NET_IDX_SET(_val) ((void *)((uint32_t)(_val)))
|
||||
#define NET_IDX_GET(_ptr) ((uint32_t)(_ptr))
|
||||
|
||||
/* If the interval has passed or is within 5 seconds from now send a beacon */
|
||||
#define BEACON_THRESHOLD(last) (K_SECONDS(10 * ((last) + 1)) - K_SECONDS(5))
|
||||
|
||||
void bt_mesh_secure_beacon_enable(void);
|
||||
void bt_mesh_secure_beacon_disable(void);
|
||||
|
||||
void bt_mesh_beacon_ivu_initiator(bool enable);
|
||||
|
||||
void bt_mesh_beacon_recv(struct net_buf_simple *buf, int8_t rssi);
|
||||
|
||||
void bt_mesh_secure_beacon_create(struct bt_mesh_subnet *sub,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_beacon_init(void);
|
||||
|
||||
void bt_mesh_beacon_deinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BEACON_H_ */
|
@ -18,15 +18,20 @@
|
||||
#include "osi/future.h"
|
||||
#include "device/controller.h"
|
||||
|
||||
#if CONFIG_MBEDTLS_HARDWARE_AES
|
||||
#include "mbedtls/aes.h"
|
||||
#endif
|
||||
|
||||
#include <tinycrypt/aes.h>
|
||||
#include <tinycrypt/constants.h>
|
||||
|
||||
#include "mesh_hci.h"
|
||||
#include "mesh_bearer_adapt.h"
|
||||
#include "mesh_common.h"
|
||||
#include "provisioner_prov.h"
|
||||
#include "mesh/hci.h"
|
||||
#include "mesh/adapter.h"
|
||||
#include "mesh/common.h"
|
||||
#include "prov_pvnr.h"
|
||||
#include "net.h"
|
||||
|
||||
#include "mesh_v1.1/utils.h"
|
||||
|
||||
struct bt_mesh_dev bt_mesh_dev;
|
||||
|
||||
@ -48,14 +53,15 @@ struct bt_mesh_dev bt_mesh_dev;
|
||||
|
||||
/* P-256 Variables */
|
||||
static uint8_t bt_mesh_public_key[64];
|
||||
static BT_OCTET32 bt_mesh_private_key;
|
||||
static uint8_t bt_mesh_private_key[32];
|
||||
|
||||
/* Scan related functions */
|
||||
static bt_mesh_scan_cb_t *bt_mesh_scan_dev_found_cb;
|
||||
static void bt_mesh_scan_result_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data);
|
||||
|
||||
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER || \
|
||||
(CONFIG_BLE_MESH_RPR_SRV && CONFIG_BLE_MESH_PB_GATT)
|
||||
/* Using UUID with a fixed pattern 0x96 for BLE Mesh GATT Proxy Server */
|
||||
#define BLE_MESH_GATTS_APP_UUID_BYTE 0x96
|
||||
/* the gatt database list to save the attribute table */
|
||||
@ -65,7 +71,7 @@ static sys_slist_t bt_mesh_gatts_db;
|
||||
static struct bt_mesh_conn bt_mesh_gatts_conn[BLE_MESH_MAX_CONN];
|
||||
static struct bt_mesh_conn_cb *bt_mesh_gatts_conn_cb;
|
||||
static tBTA_GATTS_IF bt_mesh_gatts_if;
|
||||
static BD_ADDR bt_mesh_gatts_addr;
|
||||
static uint8_t bt_mesh_gatts_addr[BLE_MESH_ADDR_LEN];
|
||||
static uint16_t svc_handle, char_handle;
|
||||
static future_t *future_mesh;
|
||||
|
||||
@ -74,7 +80,8 @@ static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(uint16_t hand
|
||||
#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)
|
||||
/* Using UUID with a fixed pattern 0x97 for BLE Mesh GATT Proxy Client */
|
||||
#define BLE_MESH_GATTC_APP_UUID_BYTE 0x97
|
||||
static struct gattc_prov_info {
|
||||
@ -176,14 +183,14 @@ static bool valid_adv_param(const struct bt_mesh_adv_param *param)
|
||||
if (!(param->options & BLE_MESH_ADV_OPT_CONNECTABLE)) {
|
||||
#if BLE_MESH_DEV
|
||||
if (bt_mesh_dev.hci_version < BLE_MESH_HCI_VERSION_5_0 &&
|
||||
param->interval_min < 0x00a0) {
|
||||
param->interval_min < 0x00a0) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (param->interval_min > param->interval_max ||
|
||||
param->interval_min < 0x0020 || param->interval_max > 0x4000) {
|
||||
param->interval_min < 0x0020 || param->interval_max > 0x4000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -234,12 +241,12 @@ static void start_adv_completed_cb(uint8_t status)
|
||||
static bool valid_scan_param(const struct bt_mesh_scan_param *param)
|
||||
{
|
||||
if (param->type != BLE_MESH_SCAN_PASSIVE &&
|
||||
param->type != BLE_MESH_SCAN_ACTIVE) {
|
||||
param->type != BLE_MESH_SCAN_ACTIVE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (param->filter_dup != BLE_MESH_SCAN_FILTER_DUP_DISABLE &&
|
||||
param->filter_dup != BLE_MESH_SCAN_FILTER_DUP_ENABLE) {
|
||||
param->filter_dup != BLE_MESH_SCAN_FILTER_DUP_ENABLE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -261,7 +268,7 @@ static bool valid_scan_param(const struct bt_mesh_scan_param *param)
|
||||
static int start_le_scan(uint8_t scan_type, uint16_t interval, uint16_t window,
|
||||
uint8_t filter_dup, uint8_t scan_fil_policy)
|
||||
{
|
||||
UINT8 addr_type_own = BLE_MESH_ADDR_PUBLIC; /* Currently only support Public Address */
|
||||
uint8_t addr_type_own = BLE_MESH_ADDR_PUBLIC; /* Currently only support Public Address */
|
||||
tGATT_IF client_if = 0xFF; /* Default GATT interface id */
|
||||
|
||||
BLE_MESH_BTM_CHECK_STATUS(
|
||||
@ -297,7 +304,7 @@ static void bt_mesh_scan_result_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARC
|
||||
net_buf_simple_init_with_data(&buf, p_data->inq_res.p_eir, p_data->inq_res.adv_data_len);
|
||||
|
||||
if (bt_mesh_scan_dev_found_cb) {
|
||||
bt_mesh_scan_dev_found_cb(&addr, p_data->inq_res.rssi, p_data->inq_res.ble_evt_type, &buf);
|
||||
bt_mesh_scan_dev_found_cb(&addr, p_data->inq_res.rssi, p_data->inq_res.ble_evt_type, &buf, p_data->inq_res.scan_rsp_len);
|
||||
}
|
||||
} else if (event == BTA_DM_INQ_CMPL_EVT) {
|
||||
BT_INFO("Scan completed, number of scan response %d", p_data->inq_cmpl.num_resps);
|
||||
@ -360,7 +367,13 @@ int bt_le_adv_start(const struct bt_mesh_adv_param *param,
|
||||
} else {
|
||||
adv_type = BLE_MESH_ADV_NONCONN_IND;
|
||||
}
|
||||
addr_type_own = BLE_MESH_ADDR_PUBLIC; /* Currently only support Public Address */
|
||||
|
||||
#if CONFIG_BLE_MESH_PRB_SRV
|
||||
addr_type_own = bt_mesh_private_beacon_update_addr_type(ad);
|
||||
#else
|
||||
addr_type_own = BLE_MESH_ADDR_PUBLIC;
|
||||
#endif
|
||||
|
||||
channel_map = BLE_MESH_ADV_CHNL_37 | BLE_MESH_ADV_CHNL_38 | BLE_MESH_ADV_CHNL_39;
|
||||
adv_fil_pol = BLE_MESH_AP_SCAN_CONN_ALL;
|
||||
p_start_adv_cb = start_adv_completed_cb;
|
||||
@ -502,7 +515,7 @@ int bt_le_update_white_list(struct bt_mesh_white_list *wl)
|
||||
}
|
||||
|
||||
if (BTM_BleUpdateAdvWhitelist(wl->add_remove, wl->remote_bda,
|
||||
wl->addr_type, (tBTM_UPDATE_WHITELIST_CBACK *)wl->update_wl_comp_cb) == false) {
|
||||
wl->addr_type, (tBTM_UPDATE_WHITELIST_CBACK *)wl->update_wl_comp_cb) == false) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
@ -511,7 +524,7 @@ int bt_le_update_white_list(struct bt_mesh_white_list *wl)
|
||||
#endif
|
||||
|
||||
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
{
|
||||
switch (event) {
|
||||
@ -740,7 +753,7 @@ struct gatts_incl {
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
uint16_t uuid16;
|
||||
} __packed;
|
||||
} __attribute__((packed));
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
@ -790,7 +803,7 @@ struct gatts_chrc {
|
||||
uint16_t uuid16;
|
||||
uint8_t uuid[16];
|
||||
};
|
||||
} __packed;
|
||||
} __attribute__((packed));
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
@ -845,8 +858,6 @@ static void bta_uuid_to_bt_mesh_uuid(tBT_UUID *bta_uuid, const struct bt_mesh_uu
|
||||
} else {
|
||||
BT_ERR("Invalid mesh uuid type %d", uuid->type);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int gatts_register(struct bt_mesh_gatt_service *svc)
|
||||
@ -1099,7 +1110,8 @@ int bt_mesh_gatts_set_local_device_name(const char *name)
|
||||
#endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */
|
||||
|
||||
#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;
|
||||
@ -1117,7 +1129,7 @@ uint8_t bt_mesh_gattc_get_free_conn_count(void)
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
|
||||
if (bt_mesh_gattc_info[i].conn.handle == 0xFFFF &&
|
||||
bt_mesh_gattc_info[i].service_uuid == 0x0000) {
|
||||
bt_mesh_gattc_info[i].service_uuid == 0x0000) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
@ -1155,13 +1167,13 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid)
|
||||
int i;
|
||||
|
||||
if (!addr || !memcmp(addr->val, zero, BLE_MESH_ADDR_LEN) ||
|
||||
(addr->type > BLE_ADDR_RANDOM)) {
|
||||
(addr->type > BLE_ADDR_RANDOM)) {
|
||||
BT_ERR("Invalid remote address");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (service_uuid != BLE_MESH_UUID_MESH_PROV_VAL &&
|
||||
service_uuid != BLE_MESH_UUID_MESH_PROXY_VAL) {
|
||||
service_uuid != BLE_MESH_UUID_MESH_PROXY_VAL) {
|
||||
BT_ERR("Invalid service uuid 0x%04x", service_uuid);
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -1178,7 +1190,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid)
|
||||
/* Find empty element in queue to store device info */
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
|
||||
if ((bt_mesh_gattc_info[i].conn.handle == 0xFFFF) &&
|
||||
(bt_mesh_gattc_info[i].service_uuid == 0x0000)) {
|
||||
(bt_mesh_gattc_info[i].service_uuid == 0x0000)) {
|
||||
memcpy(bt_mesh_gattc_info[i].addr.val, addr->val, BLE_MESH_ADDR_LEN);
|
||||
bt_mesh_gattc_info[i].addr.type = addr->type;
|
||||
/* Service to be found after exchanging mtu size */
|
||||
@ -1281,7 +1293,6 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn)
|
||||
}
|
||||
|
||||
BT_ERR("Conn %p not found", conn);
|
||||
return;
|
||||
}
|
||||
|
||||
/** Mesh Provisioning Service: 0x1827
|
||||
@ -1306,7 +1317,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
BT_DBG("BTA_GATTC_REG_EVT");
|
||||
|
||||
if (p_data->reg_oper.app_uuid.len == LEN_UUID_128 &&
|
||||
!memcmp(p_data->reg_oper.app_uuid.uu.uuid128, uuid, 16)) {
|
||||
!memcmp(p_data->reg_oper.app_uuid.uu.uuid128, uuid, 16)) {
|
||||
bt_mesh_gattc_if = p_data->reg_oper.client_if;
|
||||
BT_DBG("bt_mesh_gattc_if is %d", bt_mesh_gattc_if);
|
||||
}
|
||||
@ -1388,7 +1399,8 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
BTA_GATTC_GetDBSizeByType(p_data->search_cmpl.conn_id, BTGATT_DB_CHARACTERISTIC,
|
||||
bt_mesh_gattc_info[i].start_handle, bt_mesh_gattc_info[i].end_handle,
|
||||
BTA_GATTC_INVALID_HANDLE, &count);
|
||||
if (count != 2) {
|
||||
if (count != 3 && count != 2) {
|
||||
BT_ERR("Invalid characteristic num(%d) within Mesh Provisioning/Proxy Service", count);
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
}
|
||||
@ -1562,8 +1574,8 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
}
|
||||
|
||||
if (memcmp(bt_mesh_gattc_info[i].addr.val, p_data->notify.bda, BLE_MESH_ADDR_LEN) ||
|
||||
bt_mesh_gattc_info[i].data_out_handle != p_data->notify.handle ||
|
||||
p_data->notify.is_notify == false) {
|
||||
bt_mesh_gattc_info[i].data_out_handle != p_data->notify.handle ||
|
||||
p_data->notify.is_notify == false) {
|
||||
BT_ERR("Notification error");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
@ -1572,7 +1584,8 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
if (bt_mesh_gattc_info[i].service_uuid == BLE_MESH_UUID_MESH_PROV_VAL) {
|
||||
if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->prov_notify != NULL) {
|
||||
len = bt_mesh_gattc_conn_cb->prov_notify(&bt_mesh_gattc_info[i].conn,
|
||||
p_data->notify.value, p_data->notify.len);
|
||||
p_data->notify.value,
|
||||
p_data->notify.len);
|
||||
if (len < 0) {
|
||||
BT_ERR("prov_notify failed");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
@ -1582,7 +1595,8 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
} else if (bt_mesh_gattc_info[i].service_uuid == BLE_MESH_UUID_MESH_PROXY_VAL) {
|
||||
if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->proxy_notify != NULL) {
|
||||
len = bt_mesh_gattc_conn_cb->proxy_notify(&bt_mesh_gattc_info[i].conn,
|
||||
p_data->notify.value, p_data->notify.len);
|
||||
p_data->notify.value,
|
||||
p_data->notify.len);
|
||||
if (len < 0) {
|
||||
BT_ERR("proxy_notify failed");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
@ -1721,14 +1735,15 @@ void bt_mesh_gatt_init(void)
|
||||
BTA_GATT_SetLocalMTU(GATT_DEF_BLE_MTU_SIZE);
|
||||
|
||||
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
tBT_UUID gatts_app_uuid = {LEN_UUID_128, {0}};
|
||||
memset(&gatts_app_uuid.uu.uuid128, BLE_MESH_GATTS_APP_UUID_BYTE, LEN_UUID_128);
|
||||
BTA_GATTS_AppRegister(&gatts_app_uuid, bt_mesh_bta_gatts_cb);
|
||||
#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)
|
||||
tBT_UUID gattc_app_uuid = {LEN_UUID_128, {0}};
|
||||
for (int i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
|
||||
bt_mesh_gattc_info[i].conn.handle = 0xFFFF;
|
||||
@ -1744,7 +1759,7 @@ void bt_mesh_gatt_init(void)
|
||||
void bt_mesh_gatt_deinit(void)
|
||||
{
|
||||
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
BTA_GATTS_AppDeregister(bt_mesh_gatts_if);
|
||||
memset(bt_mesh_gatts_addr, 0, BLE_MESH_ADDR_LEN);
|
||||
bt_mesh_gatts_if = 0U;
|
||||
@ -1753,7 +1768,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)
|
||||
BTA_GATTC_AppDeregister(bt_mesh_gattc_if);
|
||||
bt_mesh_gattc_if = 0U;
|
||||
for (int i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
|
||||
@ -1774,8 +1790,6 @@ void bt_mesh_gatt_deinit(void)
|
||||
|
||||
void bt_mesh_adapt_init(void)
|
||||
{
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* initialization of P-256 parameters */
|
||||
p_256_init_curve(KEY_LENGTH_DWORDS_P256);
|
||||
|
||||
@ -1795,7 +1809,7 @@ void bt_mesh_set_private_key(const uint8_t pri_key[32])
|
||||
|
||||
const uint8_t *bt_mesh_pub_key_get(void)
|
||||
{
|
||||
BT_OCTET32 private_key = {0};
|
||||
uint8_t private_key[32] = {0};
|
||||
Point public_key = {0};
|
||||
|
||||
if (bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_HAS_PUB_KEY)) {
|
||||
@ -1842,17 +1856,17 @@ bool bt_mesh_check_public_key(const uint8_t key[64])
|
||||
return ECC_CheckPointIsInElliCur_P256((Point *)&check);
|
||||
}
|
||||
|
||||
int bt_mesh_dh_key_gen(const uint8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const uint8_t idx)
|
||||
int bt_mesh_dh_key_gen(const uint8_t remote_pub_key[64], uint8_t dhkey[32])
|
||||
{
|
||||
BT_OCTET32 private_key = {0};
|
||||
uint8_t private_key[32] = {0};
|
||||
Point peer_pub_key = {0};
|
||||
Point new_pub_key = {0};
|
||||
|
||||
BT_DBG("private key = %s", bt_hex(bt_mesh_private_key, BT_OCTET32_LEN));
|
||||
|
||||
memcpy(private_key, bt_mesh_private_key, BT_OCTET32_LEN);
|
||||
memcpy(peer_pub_key.x, remote_pk, BT_OCTET32_LEN);
|
||||
memcpy(peer_pub_key.y, &remote_pk[BT_OCTET32_LEN], BT_OCTET32_LEN);
|
||||
memcpy(peer_pub_key.x, remote_pub_key, BT_OCTET32_LEN);
|
||||
memcpy(peer_pub_key.y, &remote_pub_key[BT_OCTET32_LEN], BT_OCTET32_LEN);
|
||||
|
||||
BT_DBG("remote public key x = %s", bt_hex(peer_pub_key.x, BT_OCTET32_LEN));
|
||||
BT_DBG("remote public key y = %s", bt_hex(peer_pub_key.y, BT_OCTET32_LEN));
|
||||
@ -1862,9 +1876,7 @@ int bt_mesh_dh_key_gen(const uint8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, cons
|
||||
BT_DBG("new public key x = %s", bt_hex(new_pub_key.x, 32));
|
||||
BT_DBG("new public key y = %s", bt_hex(new_pub_key.y, 32));
|
||||
|
||||
if (cb != NULL) {
|
||||
cb((const uint8_t *)new_pub_key.x, idx);
|
||||
}
|
||||
memcpy(dhkey, new_pub_key.x, 32);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1959,10 +1971,10 @@ int bt_mesh_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16],
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
#if CONFIG_BLE_MESH_USE_DUPLICATE_SCAN
|
||||
int bt_mesh_update_exceptional_list(uint8_t sub_code, uint32_t type, void *info)
|
||||
{
|
||||
BD_ADDR value = {0};
|
||||
uint8_t value[BLE_MESH_ADDR_LEN] = {0};
|
||||
|
||||
if ((sub_code > BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN) ||
|
||||
(sub_code < BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN &&
|
@ -14,17 +14,17 @@
|
||||
#include "btc_ble_mesh_config_model.h"
|
||||
|
||||
#include "mesh.h"
|
||||
#include "mesh_config.h"
|
||||
#include "mesh/config.h"
|
||||
#include "foundation.h"
|
||||
#include "mesh_common.h"
|
||||
#include "cfg_cli.h"
|
||||
#include "mesh/common.h"
|
||||
#include "mesh/cfg_cli.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_CFG_CLI
|
||||
|
||||
static const bt_mesh_client_op_pair_t cfg_op_pair[] = {
|
||||
{ OP_BEACON_GET, OP_BEACON_STATUS },
|
||||
{ OP_BEACON_SET, OP_BEACON_STATUS },
|
||||
{ OP_DEV_COMP_DATA_GET, OP_DEV_COMP_DATA_STATUS },
|
||||
{ OP_COMP_DATA_GET, OP_COMP_DATA_STATUS },
|
||||
{ OP_DEFAULT_TTL_GET, OP_DEFAULT_TTL_STATUS },
|
||||
{ OP_DEFAULT_TTL_SET, OP_DEFAULT_TTL_STATUS },
|
||||
{ OP_GATT_PROXY_GET, OP_GATT_PROXY_STATUS },
|
||||
@ -73,40 +73,17 @@ static const bt_mesh_client_op_pair_t cfg_op_pair[] = {
|
||||
|
||||
static bt_mesh_mutex_t cfg_client_lock;
|
||||
|
||||
static inline void bt_mesh_cfg_client_mutex_new(void)
|
||||
{
|
||||
if (!cfg_client_lock.mutex) {
|
||||
bt_mesh_mutex_create(&cfg_client_lock);
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static inline void bt_mesh_cfg_client_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&cfg_client_lock);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
static inline void bt_mesh_cfg_client_lock(void)
|
||||
{
|
||||
bt_mesh_mutex_lock(&cfg_client_lock);
|
||||
}
|
||||
|
||||
static inline void bt_mesh_cfg_client_unlock(void)
|
||||
{
|
||||
bt_mesh_mutex_unlock(&cfg_client_lock);
|
||||
}
|
||||
|
||||
static void timeout_handler(struct k_work *work)
|
||||
{
|
||||
struct k_delayed_work *timer = NULL;
|
||||
bt_mesh_client_node_t *node = NULL;
|
||||
struct bt_mesh_model *model = NULL;
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
uint32_t opcode = 0U;
|
||||
|
||||
BT_WARN("Receive configuration status message timeout");
|
||||
|
||||
bt_mesh_cfg_client_lock();
|
||||
bt_mesh_mutex_lock(&cfg_client_lock);
|
||||
|
||||
timer = CONTAINER_OF(work, struct k_delayed_work, work);
|
||||
|
||||
@ -115,15 +92,14 @@ static void timeout_handler(struct k_work *work)
|
||||
if (node) {
|
||||
memcpy(&ctx, &node->ctx, sizeof(ctx));
|
||||
opcode = node->opcode;
|
||||
model = node->model;
|
||||
bt_mesh_client_free_node(node);
|
||||
bt_mesh_config_client_cb_evt_to_btc(
|
||||
opcode, BTC_BLE_MESH_EVT_CONFIG_CLIENT_TIMEOUT, ctx.model, &ctx, NULL, 0);
|
||||
opcode, BTC_BLE_MESH_EVT_CONFIG_CLIENT_TIMEOUT, model, &ctx, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
bt_mesh_cfg_client_unlock();
|
||||
|
||||
return;
|
||||
bt_mesh_mutex_unlock(&cfg_client_lock);
|
||||
}
|
||||
|
||||
static void cfg_client_recv_status(struct bt_mesh_model *model,
|
||||
@ -143,7 +119,7 @@ static void cfg_client_recv_status(struct bt_mesh_model *model,
|
||||
buf.data = (uint8_t *)status;
|
||||
buf.len = (uint16_t)len;
|
||||
|
||||
bt_mesh_cfg_client_lock();
|
||||
bt_mesh_mutex_lock(&cfg_client_lock);
|
||||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, &buf, true);
|
||||
if (!node) {
|
||||
@ -151,7 +127,7 @@ static void cfg_client_recv_status(struct bt_mesh_model *model,
|
||||
} else {
|
||||
switch (node->opcode) {
|
||||
case OP_BEACON_GET:
|
||||
case OP_DEV_COMP_DATA_GET:
|
||||
case OP_COMP_DATA_GET:
|
||||
case OP_DEFAULT_TTL_GET:
|
||||
case OP_GATT_PROXY_GET:
|
||||
case OP_RELAY_GET:
|
||||
@ -213,10 +189,10 @@ static void cfg_client_recv_status(struct bt_mesh_model *model,
|
||||
}
|
||||
}
|
||||
|
||||
bt_mesh_cfg_client_unlock();
|
||||
bt_mesh_mutex_unlock(&cfg_client_lock);
|
||||
|
||||
switch (ctx->recv_op) {
|
||||
case OP_DEV_COMP_DATA_STATUS: {
|
||||
case OP_COMP_DATA_STATUS: {
|
||||
struct bt_mesh_cfg_comp_data_status *val = status;
|
||||
bt_mesh_free_buf(val->comp_data);
|
||||
break;
|
||||
@ -649,7 +625,7 @@ static void net_trans_status(struct bt_mesh_model *model,
|
||||
}
|
||||
|
||||
const struct bt_mesh_model_op bt_mesh_cfg_cli_op[] = {
|
||||
{ OP_DEV_COMP_DATA_STATUS, 15, comp_data_status },
|
||||
{ OP_COMP_DATA_STATUS, 15, comp_data_status },
|
||||
{ OP_BEACON_STATUS, 1, beacon_status },
|
||||
{ OP_DEFAULT_TTL_STATUS, 1, ttl_status },
|
||||
{ OP_FRIEND_STATUS, 1, friend_status },
|
||||
@ -707,7 +683,7 @@ static int send_msg_with_le16(bt_mesh_client_common_param_t *param, uint32_t op,
|
||||
|
||||
int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, uint8_t page)
|
||||
{
|
||||
return send_msg_with_u8(param, OP_DEV_COMP_DATA_GET, page);
|
||||
return send_msg_with_u8(param, OP_COMP_DATA_GET, page);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_beacon_get(bt_mesh_client_common_param_t *param)
|
||||
@ -1264,27 +1240,28 @@ static int cfg_cli_init(struct bt_mesh_model *model)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!client->internal_data) {
|
||||
internal = bt_mesh_calloc(sizeof(config_internal_data_t));
|
||||
if (!internal) {
|
||||
BT_ERR("Allocate memory for Configuration Client internal data fail");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
sys_slist_init(&internal->queue);
|
||||
|
||||
client->model = model;
|
||||
client->op_pair_size = ARRAY_SIZE(cfg_op_pair);
|
||||
client->op_pair = cfg_op_pair;
|
||||
client->internal_data = internal;
|
||||
} else {
|
||||
bt_mesh_client_clear_list(client->internal_data);
|
||||
if (client->internal_data) {
|
||||
BT_WARN("%s, Already", __func__);
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
internal = bt_mesh_calloc(sizeof(config_internal_data_t));
|
||||
if (!internal) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
sys_slist_init(&internal->queue);
|
||||
|
||||
client->model = model;
|
||||
client->op_pair_size = ARRAY_SIZE(cfg_op_pair);
|
||||
client->op_pair = cfg_op_pair;
|
||||
client->internal_data = internal;
|
||||
|
||||
/* Configuration Model security is device-key based */
|
||||
model->keys[0] = BLE_MESH_KEY_DEV;
|
||||
|
||||
bt_mesh_cfg_client_mutex_new();
|
||||
bt_mesh_mutex_create(&cfg_client_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1319,7 +1296,7 @@ static int cfg_cli_deinit(struct bt_mesh_model *model)
|
||||
client->internal_data = NULL;
|
||||
}
|
||||
|
||||
bt_mesh_cfg_client_mutex_free();
|
||||
bt_mesh_mutex_free(&cfg_client_lock);
|
||||
|
||||
return 0;
|
||||
}
|
@ -18,104 +18,28 @@
|
||||
#include "lpn.h"
|
||||
#include "transport.h"
|
||||
#include "crypto.h"
|
||||
#include "net.h"
|
||||
#include "access.h"
|
||||
#include "beacon.h"
|
||||
#include "foundation.h"
|
||||
#include "friend.h"
|
||||
#include "settings.h"
|
||||
#include "cfg_srv.h"
|
||||
#include "mesh/cfg_srv.h"
|
||||
#include "proxy_server.h"
|
||||
#include "mesh_main.h"
|
||||
#include "mesh_common.h"
|
||||
#include "mesh/main.h"
|
||||
#include "mesh/common.h"
|
||||
|
||||
#define DEFAULT_TTL 7
|
||||
#include "mesh_v1.1/utils.h"
|
||||
|
||||
/* Maximum message length is 384 in BLE Mesh. Here for composition data,
|
||||
* due to 1 octet opcode and 4 octets TransMIC, 379 octets can be used to
|
||||
* store device composition data.
|
||||
*/
|
||||
#define COMP_DATA_MAX_LEN 379
|
||||
#define DEFAULT_TTL 7
|
||||
|
||||
static struct bt_mesh_cfg_srv *conf;
|
||||
|
||||
static struct label labels[CONFIG_BLE_MESH_LABEL_COUNT];
|
||||
|
||||
static int comp_add_elem(struct net_buf_simple *buf, struct bt_mesh_elem *elem,
|
||||
bool primary)
|
||||
{
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
int i;
|
||||
|
||||
if (net_buf_simple_tailroom(buf) <
|
||||
4 + (elem->model_count * 2U) + (elem->vnd_model_count * 4U)) {
|
||||
BT_ERR("Too large device composition");
|
||||
return -E2BIG;
|
||||
}
|
||||
|
||||
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 (i = 0; i < elem->model_count; i++) {
|
||||
mod = &elem->models[i];
|
||||
net_buf_simple_add_le16(buf, mod->id);
|
||||
}
|
||||
|
||||
for (i = 0; i < elem->vnd_model_count; i++) {
|
||||
mod = &elem->vnd_models[i];
|
||||
net_buf_simple_add_le16(buf, mod->vnd.company);
|
||||
net_buf_simple_add_le16(buf, mod->vnd.id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int comp_get_page_0(struct net_buf_simple *buf)
|
||||
{
|
||||
const struct bt_mesh_comp *comp = NULL;
|
||||
uint16_t feat = 0U;
|
||||
int i;
|
||||
|
||||
comp = bt_mesh_comp_get();
|
||||
|
||||
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 (i = 0; i < comp->elem_count; i++) {
|
||||
int err;
|
||||
|
||||
err = comp_add_elem(buf, &comp->elem[i], i == 0);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dev_comp_data_get(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
static void comp_data_get(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct net_buf_simple *sdu = NULL;
|
||||
uint8_t page = 0U;
|
||||
@ -124,23 +48,59 @@ static void dev_comp_data_get(struct bt_mesh_model *model,
|
||||
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
|
||||
bt_hex(buf->data, buf->len));
|
||||
|
||||
page = net_buf_simple_pull_u8(buf);
|
||||
if (page != 0U) {
|
||||
BT_WARN("Composition page %u not available", page);
|
||||
page = 0U;
|
||||
}
|
||||
/* TODO:
|
||||
*
|
||||
* When an element receives a Config Composition Data Get message with
|
||||
* the Page field of the message containing a value of a Composition
|
||||
* Data Page that the node contains, it shall respond with a Config
|
||||
* Composition Data Status message with the Page field set to the page
|
||||
* number of the Composition Data and the Data field set to the value
|
||||
* of the largest portion of the Composition Data Page that fits in the
|
||||
* Data field. If an element is reported in the Config Composition Data
|
||||
* Status message, the complete list of models supported by the element
|
||||
* shall be included in the elements description. If the complete list
|
||||
* of models does not fit in the Data field, the element shall not be
|
||||
* reported.
|
||||
*
|
||||
* When an element receives a Config Composition Data Get message with
|
||||
* the Page field of the message containing a reserved page number or a
|
||||
* page number the node does not support, it shall respond with a Config
|
||||
* Composition Data Status message 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 and with the Data field set to the value of the largest
|
||||
* portion of the Composition Data Page for that page number that fits in
|
||||
* the Data field. If an element is reported in a Config Composition Data
|
||||
* Status message, the complete list of models supported by the element
|
||||
* shall be included in the elements description. If the complete list of
|
||||
* models does not fit in the Data field, the element shall not be reported.
|
||||
*/
|
||||
|
||||
sdu = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, COMP_DATA_MAX_LEN));
|
||||
page = net_buf_simple_pull_u8(buf);
|
||||
|
||||
/* Check if the page exists, and if not, get the largest one
|
||||
* which is smaller than this page.
|
||||
*/
|
||||
page = bt_mesh_comp_page_check(page, false);
|
||||
|
||||
sdu = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_MAX_PDU_LEN_WITH_SMIC));
|
||||
if (!sdu) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_model_msg_init(sdu, OP_DEV_COMP_DATA_STATUS);
|
||||
|
||||
bt_mesh_model_msg_init(sdu, OP_COMP_DATA_STATUS);
|
||||
net_buf_simple_add_u8(sdu, page);
|
||||
if (comp_get_page_0(sdu) < 0) {
|
||||
BT_ERR("Unable to get composition page 0");
|
||||
|
||||
/* Mesh v1.1 updates:
|
||||
* If an element is reported in the Config Composition Data
|
||||
* Status message, the complete list of models supported by
|
||||
* the element shall be included in the elements description.
|
||||
* If the complete list of models does not fit in the Data
|
||||
* field, the element shall not be reported.
|
||||
*/
|
||||
if (bt_mesh_get_comp_data(sdu, page, 0, true)) {
|
||||
BT_ERR("Unable to get composition page 0x%02x", page);
|
||||
bt_mesh_free_buf(sdu);
|
||||
return;
|
||||
}
|
||||
@ -150,15 +110,14 @@ static void dev_comp_data_get(struct bt_mesh_model *model,
|
||||
}
|
||||
|
||||
bt_mesh_free_buf(sdu);
|
||||
return;
|
||||
}
|
||||
|
||||
static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem,
|
||||
struct net_buf_simple *buf, bool *vnd)
|
||||
{
|
||||
if (buf->len < 4) {
|
||||
uint16_t id = 0U;
|
||||
uint16_t company = 0U, id = 0U;
|
||||
|
||||
if (buf->len < 4) {
|
||||
id = net_buf_simple_pull_le16(buf);
|
||||
|
||||
BT_DBG("ID 0x%04x addr 0x%04x", id, elem->addr);
|
||||
@ -166,35 +125,17 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem,
|
||||
*vnd = false;
|
||||
|
||||
return bt_mesh_model_find(elem, id);
|
||||
} else {
|
||||
uint16_t company = 0U, id = 0U;
|
||||
|
||||
company = net_buf_simple_pull_le16(buf);
|
||||
id = net_buf_simple_pull_le16(buf);
|
||||
|
||||
BT_DBG("Company 0x%04x ID 0x%04x addr 0x%04x", company, id,
|
||||
elem->addr);
|
||||
|
||||
*vnd = true;
|
||||
|
||||
return bt_mesh_model_find_vnd(elem, company, id);
|
||||
}
|
||||
}
|
||||
|
||||
static bool app_key_is_valid(uint16_t app_idx)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh.app_keys); i++) {
|
||||
struct bt_mesh_app_key *key = &bt_mesh.app_keys[i];
|
||||
|
||||
if (key->net_idx != BLE_MESH_KEY_UNUSED &&
|
||||
key->app_idx == app_idx) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
company = net_buf_simple_pull_le16(buf);
|
||||
id = net_buf_simple_pull_le16(buf);
|
||||
|
||||
BT_DBG("Company 0x%04x ID 0x%04x addr 0x%04x", company, id,
|
||||
elem->addr);
|
||||
|
||||
*vnd = true;
|
||||
|
||||
return bt_mesh_model_find_vnd(elem, company, id);
|
||||
}
|
||||
|
||||
static bool mod_pub_app_key_bound(struct bt_mesh_model *model,
|
||||
@ -208,7 +149,7 @@ static bool mod_pub_app_key_bound(struct bt_mesh_model *model,
|
||||
}
|
||||
}
|
||||
|
||||
BT_ERR("Appkey(0x%02x) not bound to this model.", app_idx);
|
||||
BT_ERR("AppKey(0x%02x) not bound to this model", app_idx);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -255,7 +196,7 @@ static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr,
|
||||
/* For case MESH/NODE/CFG/MP/BI-03-C, need to check if appkey
|
||||
* is bound to model identified by the ModelIdentifier.
|
||||
*/
|
||||
if (!bt_mesh_app_key_find(app_idx) ||
|
||||
if (!bt_mesh_app_key_get(app_idx) ||
|
||||
!mod_pub_app_key_bound(model, app_idx)) {
|
||||
return STATUS_INVALID_APPKEY;
|
||||
}
|
||||
@ -293,7 +234,7 @@ static uint8_t mod_bind(struct bt_mesh_model *model, uint16_t key_idx)
|
||||
|
||||
BT_DBG("model %p key_idx 0x%03x", model, key_idx);
|
||||
|
||||
if (!app_key_is_valid(key_idx)) {
|
||||
if (!bt_mesh_app_key_get(key_idx)) {
|
||||
return STATUS_INVALID_APPKEY;
|
||||
}
|
||||
|
||||
@ -325,7 +266,7 @@ static uint8_t mod_unbind(struct bt_mesh_model *model, uint16_t key_idx, bool st
|
||||
|
||||
BT_DBG("model %p key_idx 0x%03x store %u", model, key_idx, store);
|
||||
|
||||
if (!app_key_is_valid(key_idx)) {
|
||||
if (!bt_mesh_app_key_get(key_idx)) {
|
||||
return STATUS_INVALID_APPKEY;
|
||||
}
|
||||
|
||||
@ -379,7 +320,7 @@ static uint8_t app_key_set(uint16_t net_idx, uint16_t app_idx, const uint8_t val
|
||||
return STATUS_INVALID_NETKEY;
|
||||
}
|
||||
|
||||
key = bt_mesh_app_key_find(app_idx);
|
||||
key = bt_mesh_app_key_get(app_idx);
|
||||
if (update) {
|
||||
if (!key) {
|
||||
return STATUS_INVALID_APPKEY;
|
||||
@ -403,24 +344,24 @@ static uint8_t app_key_set(uint16_t net_idx, uint16_t app_idx, const uint8_t val
|
||||
if (key->updated) {
|
||||
if (memcmp(keys->val, val, 16)) {
|
||||
return STATUS_CANNOT_UPDATE;
|
||||
} else {
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
key->updated = true;
|
||||
} else {
|
||||
if (key) {
|
||||
if (key->net_idx == net_idx &&
|
||||
!memcmp(key->keys[0].val, val, 16)) {
|
||||
!memcmp(key->keys[0].val, val, 16)) {
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (key->net_idx == net_idx) {
|
||||
return STATUS_IDX_ALREADY_STORED;
|
||||
} else {
|
||||
return STATUS_INVALID_NETKEY;
|
||||
}
|
||||
|
||||
return STATUS_INVALID_NETKEY;
|
||||
}
|
||||
|
||||
key = bt_mesh_app_key_alloc(app_idx);
|
||||
@ -569,7 +510,7 @@ static void app_key_del(struct bt_mesh_model *model,
|
||||
goto send_status;
|
||||
}
|
||||
|
||||
key = bt_mesh_app_key_find(key_app_idx);
|
||||
key = bt_mesh_app_key_get(key_app_idx);
|
||||
if (!key) {
|
||||
/* Treat as success since the client might have missed a
|
||||
* previous response and is resending the request.
|
||||
@ -679,7 +620,7 @@ static void beacon_get(struct bt_mesh_model *model,
|
||||
bt_hex(buf->data, buf->len));
|
||||
|
||||
bt_mesh_model_msg_init(&msg, OP_BEACON_STATUS);
|
||||
net_buf_simple_add_u8(&msg, bt_mesh_beacon_get());
|
||||
net_buf_simple_add_u8(&msg, bt_mesh_secure_beacon_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Beacon Status");
|
||||
@ -708,9 +649,9 @@ static void beacon_set(struct bt_mesh_model *model,
|
||||
}
|
||||
|
||||
if (cfg->beacon) {
|
||||
bt_mesh_beacon_enable();
|
||||
bt_mesh_secure_beacon_enable();
|
||||
} else {
|
||||
bt_mesh_beacon_disable();
|
||||
bt_mesh_secure_beacon_disable();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -719,7 +660,7 @@ static void beacon_set(struct bt_mesh_model *model,
|
||||
}
|
||||
|
||||
bt_mesh_model_msg_init(&msg, OP_BEACON_STATUS);
|
||||
net_buf_simple_add_u8(&msg, bt_mesh_beacon_get());
|
||||
net_buf_simple_add_u8(&msg, bt_mesh_secure_beacon_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Beacon Status");
|
||||
@ -818,7 +759,7 @@ static void gatt_proxy_set(struct bt_mesh_model *model,
|
||||
}
|
||||
|
||||
if (!IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) ||
|
||||
bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_NOT_SUPPORTED) {
|
||||
bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_NOT_SUPPORTED) {
|
||||
goto send_status;
|
||||
}
|
||||
|
||||
@ -835,6 +776,23 @@ static void gatt_proxy_set(struct bt_mesh_model *model,
|
||||
|
||||
cfg->gatt_proxy = buf->data[0];
|
||||
|
||||
#if CONFIG_BLE_MESH_PRB_SRV
|
||||
/* If the value of the GATT Proxy state of the node is 0x01 (see Table 4.21),
|
||||
* then the value of the Private GATT Proxy state shall be Disable (0x00).
|
||||
*/
|
||||
if (buf->data[0] == BLE_MESH_GATT_PROXY_ENABLED) {
|
||||
bt_mesh_disable_private_gatt_proxy();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
/* If the value of the GATT Proxy state of the node is 0x00,
|
||||
* then the value of the directed proxy state shall be 0x00,
|
||||
* directed proxy use directed default shall be 0x02.
|
||||
*/
|
||||
bt_mesh_disable_directed_proxy_state(ctx->net_idx);
|
||||
#endif
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||
bt_mesh_store_cfg();
|
||||
}
|
||||
@ -1464,7 +1422,8 @@ static void mod_sub_add(struct bt_mesh_model *model,
|
||||
goto send_status;
|
||||
}
|
||||
|
||||
BT_BQB(BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_NODE | BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_TNPT,
|
||||
BT_BQB(BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_NODE | \
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_TNPT,
|
||||
"SubGroupAddr: 0x%x", sub_addr);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mod->groups); i++) {
|
||||
@ -1492,6 +1451,10 @@ send_status:
|
||||
send_mod_sub_status(model, ctx, status, elem_addr, sub_addr,
|
||||
mod_id, vnd);
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
bt_mesh_directed_forwarding_node_solicitation(mod, bt_mesh_subnet_get(ctx->net_idx));
|
||||
#endif
|
||||
|
||||
if (status == STATUS_SUCCESS) {
|
||||
bt_mesh_cfg_server_state_change_t change = {0};
|
||||
change.cfg_mod_sub_add.elem_addr = elem_addr;
|
||||
@ -1868,7 +1831,8 @@ static void mod_sub_va_add(struct bt_mesh_model *model,
|
||||
goto send_status;
|
||||
}
|
||||
|
||||
BT_BQB(BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_NODE | BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_TNPT,
|
||||
BT_BQB(BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_NODE | \
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_TNPT,
|
||||
"SubVirtualAddr: 0x%x", sub_addr);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mod->groups); i++) {
|
||||
@ -2230,11 +2194,24 @@ static void net_key_add(struct bt_mesh_model *model,
|
||||
}
|
||||
|
||||
/* Make sure we have valid beacon data to be sent */
|
||||
bt_mesh_net_beacon_update(sub);
|
||||
bt_mesh_net_secure_beacon_update(sub);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
|
||||
sub->node_id = BLE_MESH_NODE_IDENTITY_STOPPED;
|
||||
bt_mesh_proxy_server_beacon_send(sub);
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_SRV && CONFIG_BLE_MESH_SUPPORT_DIRECTED_PROXY
|
||||
/* When the Directed Proxy Server is added to a new subnet, and the
|
||||
* Proxy_Client_Type parameter for the connection is either Unset or
|
||||
* Directed_Proxy_Client, then the Directed Proxy Server shall send a
|
||||
* DIRECTED_PROXY_CAPABILITIES_STATUS message for that subnet to the
|
||||
* Proxy Client.
|
||||
*/
|
||||
if (sub->directed_proxy != BLE_MESH_DIRECTED_PROXY_NOT_SUPPORTED) {
|
||||
bt_mesh_directed_proxy_server_directed_proxy_caps_send(sub, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
bt_mesh_adv_update();
|
||||
} else {
|
||||
sub->node_id = BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED;
|
||||
@ -2242,6 +2219,12 @@ static void net_key_add(struct bt_mesh_model *model,
|
||||
|
||||
send_net_key_status(model, ctx, idx, STATUS_SUCCESS);
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
if (bt_mesh_directed_forwarding_sub_init(sub)) {
|
||||
BT_ERR("Failed to init subnet for directed forward");
|
||||
}
|
||||
#endif
|
||||
|
||||
bt_mesh_cfg_server_state_change_t change = {0};
|
||||
change.cfg_netkey_add.net_idx = sub->net_idx;
|
||||
memcpy(change.cfg_netkey_add.net_key, sub->keys[0].net, 16);
|
||||
@ -2313,7 +2296,7 @@ static void net_key_update(struct bt_mesh_model *model,
|
||||
bt_mesh_store_subnet(sub);
|
||||
}
|
||||
|
||||
bt_mesh_net_beacon_update(sub);
|
||||
bt_mesh_net_secure_beacon_update(sub);
|
||||
|
||||
send_net_key_status(model, ctx, idx, STATUS_SUCCESS);
|
||||
|
||||
@ -2326,8 +2309,6 @@ static void net_key_update(struct bt_mesh_model *model,
|
||||
|
||||
static void hb_pub_disable(struct bt_mesh_cfg_srv *cfg)
|
||||
{
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
cfg->hb_pub.dst = BLE_MESH_ADDR_UNASSIGNED;
|
||||
cfg->hb_pub.count = 0U;
|
||||
cfg->hb_pub.ttl = 0U;
|
||||
@ -2369,9 +2350,44 @@ static void net_key_del(struct bt_mesh_model *model,
|
||||
goto send_status;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_SRV && CONFIG_BLE_MESH_SUPPORT_DIRECTED_PROXY
|
||||
/* When the Directed Proxy Server is deleted from a subnet, and the
|
||||
* Proxy_Client_Type parameter for the connection is either Unset or
|
||||
* Directed_Proxy_Client, then the Directed Proxy Server shall set
|
||||
* the Use_Directed parameter of the connection for the deleted subnet
|
||||
* to 0x00, shall set the Proxy_Client_Address_Range parameter of the
|
||||
* connection for the deleted subnet to the Unassigned value, and shall
|
||||
* send a DIRECTED_PROXY_CAPABILITIES_STATUS message for the deleted
|
||||
* subnet to the Proxy Client.
|
||||
*/
|
||||
if (sub->directed_proxy != BLE_MESH_DIRECTED_PROXY_NOT_SUPPORTED) {
|
||||
/* Directed Proxy Caps Status must be sent before the subnet is deleted */
|
||||
bt_mesh_directed_proxy_server_directed_proxy_caps_send(sub, true);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_SETTINGS
|
||||
bt_mesh_clear_directed_forwarding_table_data(del_idx);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
bt_mesh_subnet_del(sub, true);
|
||||
status = STATUS_SUCCESS;
|
||||
|
||||
#if CONFIG_BLE_MESH_BRC_SRV
|
||||
/**
|
||||
* TODO: When a NetKey is deleted from the NetKey List state,
|
||||
* and subnet bridge functionality is supported, then all the
|
||||
* Bridging Table state entries with one of the values of the
|
||||
* NetKeyIndex1 and NetKeyIndex2 fields that matches the NetKey
|
||||
* Index of the deleted NetKey are removed.
|
||||
*/
|
||||
bt_mesh_delete_netkey_in_bridge_table(del_idx);
|
||||
#endif /* CONFIG_BLE_MESH_BRC_SRV */
|
||||
|
||||
#if CONFIG_BLE_MESH_RPR_SRV
|
||||
bt_mesh_rpr_srv_netkey_del(del_idx);
|
||||
#endif
|
||||
|
||||
send_status:
|
||||
send_net_key_status(model, ctx, del_idx, status);
|
||||
|
||||
@ -2489,18 +2505,25 @@ static void node_identity_set(struct bt_mesh_model *model,
|
||||
net_buf_simple_add_u8(&msg, STATUS_INVALID_NETKEY);
|
||||
net_buf_simple_add_le16(&msg, idx);
|
||||
net_buf_simple_add_u8(&msg, node_id);
|
||||
} else {
|
||||
net_buf_simple_add_u8(&msg, STATUS_SUCCESS);
|
||||
net_buf_simple_add_le16(&msg, idx);
|
||||
|
||||
} else {
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
|
||||
if (node_id) {
|
||||
if (node_id == BLE_MESH_NODE_IDENTITY_RUNNING) {
|
||||
#if CONFIG_BLE_MESH_PRB_SRV
|
||||
/* If the value of the Node Identity state of the node for
|
||||
* any subnet is 0x01, then the value of the Private Node
|
||||
* Identity state shall be Disable (0x00).
|
||||
*/
|
||||
disable_all_private_node_identity();
|
||||
#endif
|
||||
bt_mesh_proxy_server_identity_start(sub);
|
||||
} else {
|
||||
bt_mesh_proxy_server_identity_stop(sub);
|
||||
}
|
||||
bt_mesh_adv_update();
|
||||
}
|
||||
|
||||
net_buf_simple_add_u8(&msg, STATUS_SUCCESS);
|
||||
net_buf_simple_add_le16(&msg, idx);
|
||||
net_buf_simple_add_u8(&msg, sub->node_id);
|
||||
}
|
||||
|
||||
@ -2570,6 +2593,7 @@ static void mod_app_bind(struct bt_mesh_model *model,
|
||||
|
||||
status = mod_bind(mod, key_app_idx);
|
||||
|
||||
BT_INFO("bind app key %#x on mode %#x", key_app_idx, mod->id);
|
||||
send_status:
|
||||
BT_DBG("status 0x%02x", status);
|
||||
create_mod_app_status(&msg, mod, vnd, elem_addr, key_app_idx, status,
|
||||
@ -2805,6 +2829,13 @@ static void friend_set(struct bt_mesh_model *model,
|
||||
|
||||
if (cfg->frnd == BLE_MESH_FRIEND_DISABLED) {
|
||||
bt_mesh_friend_clear_net_idx(BLE_MESH_KEY_ANY);
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_SRV && CONFIG_BLE_MESH_FRIEND
|
||||
/* If the value of the friend state of the node is 0x00,
|
||||
* then the value of the directed friend state shall be 0x00.
|
||||
*/
|
||||
bt_mesh_disable_directed_friend_state(ctx->net_idx);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -2925,8 +2956,8 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
BT_DBG("%u -> %u", sub->kr_phase, phase);
|
||||
|
||||
if (phase < BLE_MESH_KR_PHASE_2 || phase > BLE_MESH_KR_PHASE_3 ||
|
||||
(sub->kr_phase == BLE_MESH_KR_NORMAL &&
|
||||
phase == BLE_MESH_KR_PHASE_2)) {
|
||||
(sub->kr_phase == BLE_MESH_KR_NORMAL &&
|
||||
phase == BLE_MESH_KR_PHASE_2)) {
|
||||
BT_WARN("Prohibited transition %u -> %u", sub->kr_phase, phase);
|
||||
return;
|
||||
}
|
||||
@ -2941,7 +2972,7 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
bt_mesh_store_subnet(sub);
|
||||
}
|
||||
|
||||
bt_mesh_net_beacon_update(sub);
|
||||
bt_mesh_net_secure_beacon_update(sub);
|
||||
} else if ((sub->kr_phase == BLE_MESH_KR_PHASE_1 ||
|
||||
sub->kr_phase == BLE_MESH_KR_PHASE_2) &&
|
||||
phase == BLE_MESH_KR_PHASE_3) {
|
||||
@ -2950,11 +2981,11 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
bt_mesh_net_revoke_keys(sub);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) ||
|
||||
IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
||||
friend_cred_refresh(ctx->net_idx);
|
||||
IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
||||
friend_cred_refresh(sub->net_idx);
|
||||
}
|
||||
|
||||
bt_mesh_net_beacon_update(sub);
|
||||
bt_mesh_net_secure_beacon_update(sub);
|
||||
}
|
||||
|
||||
send_krp_status(model, ctx, idx, sub->kr_phase, STATUS_SUCCESS);
|
||||
@ -2968,35 +2999,39 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
|
||||
static uint8_t hb_log(uint16_t val)
|
||||
{
|
||||
if (!val) {
|
||||
switch (val) {
|
||||
case 0x0000:
|
||||
return 0x00;
|
||||
} else if (val == 0xffff) {
|
||||
return 0xff;
|
||||
} else {
|
||||
case 0xFFFF:
|
||||
return 0xFF;
|
||||
default:
|
||||
return 32 - __builtin_clz(val);
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t hb_pub_count_log(uint16_t val)
|
||||
{
|
||||
if (!val) {
|
||||
switch (val) {
|
||||
case 0x0000:
|
||||
return 0x00;
|
||||
} else if (val == 0x01) {
|
||||
case 0x0001:
|
||||
return 0x01;
|
||||
} else if (val == 0xffff) {
|
||||
return 0xff;
|
||||
} else {
|
||||
case 0xFFFF:
|
||||
return 0xFF;
|
||||
default:
|
||||
return 32 - __builtin_clz(val - 1) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
static uint16_t hb_pwr2(uint8_t val, uint8_t sub)
|
||||
{
|
||||
if (!val) {
|
||||
switch (val) {
|
||||
case 0x00:
|
||||
return 0x0000;
|
||||
} else if (val == 0xff || val == 0x11) {
|
||||
return 0xffff;
|
||||
} else {
|
||||
case 0x11:
|
||||
case 0xFF:
|
||||
return 0xFFFF;
|
||||
default:
|
||||
return (1 << (val - sub));
|
||||
}
|
||||
}
|
||||
@ -3008,7 +3043,7 @@ struct hb_pub_param {
|
||||
uint8_t ttl;
|
||||
uint16_t feat;
|
||||
uint16_t net_idx;
|
||||
} __packed;
|
||||
} __attribute__((packed));
|
||||
|
||||
static void hb_pub_send_status(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, uint8_t status,
|
||||
@ -3118,7 +3153,7 @@ static void heartbeat_pub_set(struct bt_mesh_model *model,
|
||||
* has been configured for periodic publishing.
|
||||
*/
|
||||
if (param->period_log && param->count_log) {
|
||||
k_work_submit(&cfg->hb_pub.timer.work);
|
||||
k_delayed_work_submit(&cfg->hb_pub.timer, K_NO_WAIT);
|
||||
} else {
|
||||
k_delayed_work_cancel(&cfg->hb_pub.timer);
|
||||
}
|
||||
@ -3137,7 +3172,7 @@ static void heartbeat_pub_set(struct bt_mesh_model *model,
|
||||
*/
|
||||
if (dst != BLE_MESH_ADDR_UNASSIGNED) {
|
||||
if (param->period_log && param->count_log) {
|
||||
k_work_submit(&cfg->hb_pub.timer.work);
|
||||
k_delayed_work_submit(&cfg->hb_pub.timer, K_NO_WAIT);
|
||||
} else {
|
||||
k_delayed_work_cancel(&cfg->hb_pub.timer);
|
||||
}
|
||||
@ -3209,14 +3244,14 @@ static void heartbeat_sub_set(struct bt_mesh_model *model,
|
||||
sub_src, sub_dst, sub_period);
|
||||
|
||||
if (sub_src != BLE_MESH_ADDR_UNASSIGNED &&
|
||||
!BLE_MESH_ADDR_IS_UNICAST(sub_src)) {
|
||||
!BLE_MESH_ADDR_IS_UNICAST(sub_src)) {
|
||||
BT_WARN("Prohibited source address");
|
||||
return;
|
||||
}
|
||||
|
||||
if (BLE_MESH_ADDR_IS_VIRTUAL(sub_dst) || BLE_MESH_ADDR_IS_RFU(sub_dst) ||
|
||||
(BLE_MESH_ADDR_IS_UNICAST(sub_dst) &&
|
||||
sub_dst != bt_mesh_primary_addr())) {
|
||||
(BLE_MESH_ADDR_IS_UNICAST(sub_dst) &&
|
||||
sub_dst != bt_mesh_primary_addr())) {
|
||||
BT_WARN("Prohibited destination address");
|
||||
return;
|
||||
}
|
||||
@ -3278,53 +3313,53 @@ static void heartbeat_sub_set(struct bt_mesh_model *model,
|
||||
}
|
||||
|
||||
const struct bt_mesh_model_op bt_mesh_cfg_srv_op[] = {
|
||||
{ OP_DEV_COMP_DATA_GET, 1, dev_comp_data_get },
|
||||
{ OP_APP_KEY_ADD, 19, app_key_add },
|
||||
{ OP_APP_KEY_UPDATE, 19, app_key_update },
|
||||
{ OP_APP_KEY_DEL, 3, app_key_del },
|
||||
{ OP_APP_KEY_GET, 2, app_key_get },
|
||||
{ OP_BEACON_GET, 0, beacon_get },
|
||||
{ OP_BEACON_SET, 1, beacon_set },
|
||||
{ OP_DEFAULT_TTL_GET, 0, default_ttl_get },
|
||||
{ OP_DEFAULT_TTL_SET, 1, default_ttl_set },
|
||||
{ OP_GATT_PROXY_GET, 0, gatt_proxy_get },
|
||||
{ OP_GATT_PROXY_SET, 1, gatt_proxy_set },
|
||||
{ OP_NET_TRANSMIT_GET, 0, net_transmit_get },
|
||||
{ OP_NET_TRANSMIT_SET, 1, net_transmit_set },
|
||||
{ OP_RELAY_GET, 0, relay_get },
|
||||
{ OP_RELAY_SET, 2, relay_set },
|
||||
{ OP_MOD_PUB_GET, 4, mod_pub_get },
|
||||
{ OP_MOD_PUB_SET, 11, mod_pub_set },
|
||||
{ OP_MOD_PUB_VA_SET, 24, mod_pub_va_set },
|
||||
{ OP_MOD_SUB_ADD, 6, mod_sub_add },
|
||||
{ OP_MOD_SUB_VA_ADD, 20, mod_sub_va_add },
|
||||
{ OP_MOD_SUB_DEL, 6, mod_sub_del },
|
||||
{ OP_MOD_SUB_VA_DEL, 20, mod_sub_va_del },
|
||||
{ OP_MOD_SUB_OVERWRITE, 6, mod_sub_overwrite },
|
||||
{ OP_MOD_SUB_VA_OVERWRITE, 20, mod_sub_va_overwrite },
|
||||
{ OP_MOD_SUB_DEL_ALL, 4, mod_sub_del_all },
|
||||
{ OP_MOD_SUB_GET, 4, mod_sub_get },
|
||||
{ OP_MOD_SUB_GET_VND, 6, mod_sub_get_vnd },
|
||||
{ OP_NET_KEY_ADD, 18, net_key_add },
|
||||
{ OP_NET_KEY_UPDATE, 18, net_key_update },
|
||||
{ OP_NET_KEY_DEL, 2, net_key_del },
|
||||
{ OP_NET_KEY_GET, 0, net_key_get },
|
||||
{ OP_NODE_IDENTITY_GET, 2, node_identity_get },
|
||||
{ OP_NODE_IDENTITY_SET, 3, node_identity_set },
|
||||
{ OP_MOD_APP_BIND, 6, mod_app_bind },
|
||||
{ OP_MOD_APP_UNBIND, 6, mod_app_unbind },
|
||||
{ OP_SIG_MOD_APP_GET, 4, mod_app_get },
|
||||
{ OP_VND_MOD_APP_GET, 6, mod_app_get },
|
||||
{ OP_NODE_RESET, 0, node_reset },
|
||||
{ OP_FRIEND_GET, 0, friend_get },
|
||||
{ OP_FRIEND_SET, 1, friend_set },
|
||||
{ OP_LPN_TIMEOUT_GET, 2, lpn_timeout_get },
|
||||
{ OP_KRP_GET, 2, krp_get },
|
||||
{ OP_KRP_SET, 3, krp_set },
|
||||
{ OP_HEARTBEAT_PUB_GET, 0, heartbeat_pub_get },
|
||||
{ OP_HEARTBEAT_PUB_SET, 9, heartbeat_pub_set },
|
||||
{ OP_HEARTBEAT_SUB_GET, 0, heartbeat_sub_get },
|
||||
{ OP_HEARTBEAT_SUB_SET, 5, heartbeat_sub_set },
|
||||
{ OP_COMP_DATA_GET, 1, comp_data_get },
|
||||
{ OP_APP_KEY_ADD, 19, app_key_add },
|
||||
{ OP_APP_KEY_UPDATE, 19, app_key_update },
|
||||
{ OP_APP_KEY_DEL, 3, app_key_del },
|
||||
{ OP_APP_KEY_GET, 2, app_key_get },
|
||||
{ OP_BEACON_GET, 0, beacon_get },
|
||||
{ OP_BEACON_SET, 1, beacon_set },
|
||||
{ OP_DEFAULT_TTL_GET, 0, default_ttl_get },
|
||||
{ OP_DEFAULT_TTL_SET, 1, default_ttl_set },
|
||||
{ OP_GATT_PROXY_GET, 0, gatt_proxy_get },
|
||||
{ OP_GATT_PROXY_SET, 1, gatt_proxy_set },
|
||||
{ OP_NET_TRANSMIT_GET, 0, net_transmit_get },
|
||||
{ OP_NET_TRANSMIT_SET, 1, net_transmit_set },
|
||||
{ OP_RELAY_GET, 0, relay_get },
|
||||
{ OP_RELAY_SET, 2, relay_set },
|
||||
{ OP_MOD_PUB_GET, 4, mod_pub_get },
|
||||
{ OP_MOD_PUB_SET, 11, mod_pub_set },
|
||||
{ OP_MOD_PUB_VA_SET, 24, mod_pub_va_set },
|
||||
{ OP_MOD_SUB_ADD, 6, mod_sub_add },
|
||||
{ OP_MOD_SUB_VA_ADD, 20, mod_sub_va_add },
|
||||
{ OP_MOD_SUB_DEL, 6, mod_sub_del },
|
||||
{ OP_MOD_SUB_VA_DEL, 20, mod_sub_va_del },
|
||||
{ OP_MOD_SUB_OVERWRITE, 6, mod_sub_overwrite },
|
||||
{ OP_MOD_SUB_VA_OVERWRITE, 20, mod_sub_va_overwrite },
|
||||
{ OP_MOD_SUB_DEL_ALL, 4, mod_sub_del_all },
|
||||
{ OP_MOD_SUB_GET, 4, mod_sub_get },
|
||||
{ OP_MOD_SUB_GET_VND, 6, mod_sub_get_vnd },
|
||||
{ OP_NET_KEY_ADD, 18, net_key_add },
|
||||
{ OP_NET_KEY_UPDATE, 18, net_key_update },
|
||||
{ OP_NET_KEY_DEL, 2, net_key_del },
|
||||
{ OP_NET_KEY_GET, 0, net_key_get },
|
||||
{ OP_NODE_IDENTITY_GET, 2, node_identity_get },
|
||||
{ OP_NODE_IDENTITY_SET, 3, node_identity_set },
|
||||
{ OP_MOD_APP_BIND, 6, mod_app_bind },
|
||||
{ OP_MOD_APP_UNBIND, 6, mod_app_unbind },
|
||||
{ OP_SIG_MOD_APP_GET, 4, mod_app_get },
|
||||
{ OP_VND_MOD_APP_GET, 6, mod_app_get },
|
||||
{ OP_NODE_RESET, 0, node_reset },
|
||||
{ OP_FRIEND_GET, 0, friend_get },
|
||||
{ OP_FRIEND_SET, 1, friend_set },
|
||||
{ OP_LPN_TIMEOUT_GET, 2, lpn_timeout_get },
|
||||
{ OP_KRP_GET, 2, krp_get },
|
||||
{ OP_KRP_SET, 3, krp_set },
|
||||
{ OP_HEARTBEAT_PUB_GET, 0, heartbeat_pub_get },
|
||||
{ OP_HEARTBEAT_PUB_SET, 9, heartbeat_pub_set },
|
||||
{ OP_HEARTBEAT_SUB_GET, 0, heartbeat_sub_get },
|
||||
{ OP_HEARTBEAT_SUB_SET, 5, heartbeat_sub_set },
|
||||
BLE_MESH_MODEL_OP_END,
|
||||
};
|
||||
|
||||
@ -3376,6 +3411,21 @@ static bool conf_is_valid(struct bt_mesh_cfg_srv *cfg)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IS_ENABLED(CONFIG_BLE_MESH_RELAY)) {
|
||||
BT_INFO("Relay not supported");
|
||||
cfg->relay = BLE_MESH_RELAY_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if (!IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
|
||||
BT_INFO("GATT Proxy not supported");
|
||||
cfg->gatt_proxy = BLE_MESH_GATT_PROXY_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if (!IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
||||
BT_INFO("Friend not supported");
|
||||
cfg->frnd = BLE_MESH_FRIEND_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3489,8 +3539,6 @@ void bt_mesh_cfg_reset(bool store)
|
||||
struct bt_mesh_cfg_srv *cfg = conf;
|
||||
int i;
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!cfg) {
|
||||
return;
|
||||
}
|
||||
@ -3589,13 +3637,13 @@ uint8_t bt_mesh_relay_retransmit_get(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t bt_mesh_beacon_get(void)
|
||||
uint8_t bt_mesh_secure_beacon_get(void)
|
||||
{
|
||||
if (conf) {
|
||||
return conf->beacon;
|
||||
}
|
||||
|
||||
return BLE_MESH_BEACON_DISABLED;
|
||||
return BLE_MESH_SECURE_BEACON_DISABLED;
|
||||
}
|
||||
|
||||
uint8_t bt_mesh_gatt_proxy_get(void)
|
@ -14,10 +14,15 @@
|
||||
#include <tinycrypt/aes.h>
|
||||
#include <tinycrypt/constants.h>
|
||||
#include <tinycrypt/cmac_mode.h>
|
||||
#include <tinycrypt/hmac.h>
|
||||
#include <tinycrypt/sha256.h>
|
||||
|
||||
#include "crypto.h"
|
||||
#include "mesh_common.h"
|
||||
#include "mesh_bearer_adapt.h"
|
||||
#include "mesh/config.h"
|
||||
#include "mesh/common.h"
|
||||
#include "mesh/adapter.h"
|
||||
|
||||
#include "mesh_v1.1/utils.h"
|
||||
|
||||
#define NET_MIC_LEN(pdu) (((pdu)[1] & 0x80) ? 8 : 4)
|
||||
#define APP_MIC_LEN(aszmic) ((aszmic) ? 8 : 4)
|
||||
@ -512,7 +517,7 @@ static int bt_mesh_ccm_encrypt(const uint8_t key[16], uint8_t nonce[13],
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_PROXY)
|
||||
#if CONFIG_BLE_MESH_PROXY
|
||||
static void create_proxy_nonce(uint8_t nonce[13], const uint8_t *pdu,
|
||||
uint32_t iv_index)
|
||||
{
|
||||
@ -538,7 +543,7 @@ static void create_proxy_nonce(uint8_t nonce[13], const uint8_t *pdu,
|
||||
/* IV Index */
|
||||
sys_put_be32(iv_index, &nonce[9]);
|
||||
}
|
||||
#endif /* PROXY */
|
||||
#endif /* CONFIG_BLE_MESH_PROXY */
|
||||
|
||||
static void create_net_nonce(uint8_t nonce[13], const uint8_t *pdu,
|
||||
uint32_t iv_index)
|
||||
@ -593,7 +598,7 @@ int bt_mesh_net_obfuscate(uint8_t *pdu, uint32_t iv_index,
|
||||
}
|
||||
|
||||
int bt_mesh_net_encrypt(const uint8_t key[16], struct net_buf_simple *buf,
|
||||
uint32_t iv_index, bool proxy)
|
||||
uint32_t iv_index, bool proxy, bool proxy_solic)
|
||||
{
|
||||
uint8_t mic_len = NET_MIC_LEN(buf->data);
|
||||
uint8_t nonce[13] = {0};
|
||||
@ -603,15 +608,22 @@ int bt_mesh_net_encrypt(const uint8_t key[16], struct net_buf_simple *buf,
|
||||
mic_len);
|
||||
BT_DBG("PDU (len %u) %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_PROXY)
|
||||
#if CONFIG_BLE_MESH_PROXY
|
||||
if (proxy) {
|
||||
create_proxy_nonce(nonce, buf->data, iv_index);
|
||||
#if CONFIG_BLE_MESH_PROXY_SOLIC
|
||||
if (proxy_solic) {
|
||||
bt_mesh_create_proxy_solic_nonce(nonce, buf->data, iv_index);
|
||||
} else
|
||||
#endif /* CONFIG_BLE_MESH_PROXY_SOLIC */
|
||||
{
|
||||
create_proxy_nonce(nonce, buf->data, iv_index);
|
||||
}
|
||||
} else {
|
||||
create_net_nonce(nonce, buf->data, iv_index);
|
||||
}
|
||||
#else
|
||||
#else /* CONFIG_BLE_MESH_PROXY */
|
||||
create_net_nonce(nonce, buf->data, iv_index);
|
||||
#endif
|
||||
#endif /* CONFIG_BLE_MESH_PROXY */
|
||||
|
||||
BT_DBG("Nonce %s", bt_hex(nonce, 13));
|
||||
|
||||
@ -625,7 +637,7 @@ int bt_mesh_net_encrypt(const uint8_t key[16], struct net_buf_simple *buf,
|
||||
}
|
||||
|
||||
int bt_mesh_net_decrypt(const uint8_t key[16], struct net_buf_simple *buf,
|
||||
uint32_t iv_index, bool proxy)
|
||||
uint32_t iv_index, bool proxy, bool proxy_solic)
|
||||
{
|
||||
uint8_t mic_len = NET_MIC_LEN(buf->data);
|
||||
uint8_t nonce[13] = {0};
|
||||
@ -634,15 +646,22 @@ int bt_mesh_net_decrypt(const uint8_t key[16], struct net_buf_simple *buf,
|
||||
BT_DBG("iv_index %u, key %s mic_len %u", iv_index, bt_hex(key, 16),
|
||||
mic_len);
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_PROXY)
|
||||
#if CONFIG_BLE_MESH_PROXY
|
||||
if (proxy) {
|
||||
create_proxy_nonce(nonce, buf->data, iv_index);
|
||||
#if CONFIG_BLE_MESH_PROXY_SOLIC
|
||||
if (proxy_solic) {
|
||||
bt_mesh_create_proxy_solic_nonce(nonce, buf->data, iv_index);
|
||||
} else
|
||||
#endif /* CONFIG_BLE_MESH_PROXY_SOLIC */
|
||||
{
|
||||
create_proxy_nonce(nonce, buf->data, iv_index);
|
||||
}
|
||||
} else {
|
||||
create_net_nonce(nonce, buf->data, iv_index);
|
||||
}
|
||||
#else
|
||||
#else /* CONFIG_BLE_MESH_PROXY */
|
||||
create_net_nonce(nonce, buf->data, iv_index);
|
||||
#endif
|
||||
#endif /* CONFIG_BLE_MESH_PROXY */
|
||||
|
||||
BT_DBG("Nonce %s", bt_hex(nonce, 13));
|
||||
|
||||
@ -849,9 +868,9 @@ int bt_mesh_prov_encrypt(const uint8_t key[16], uint8_t nonce[13],
|
||||
}
|
||||
#endif
|
||||
|
||||
int bt_mesh_beacon_auth(const uint8_t beacon_key[16], uint8_t flags,
|
||||
const uint8_t net_id[8], uint32_t iv_index,
|
||||
uint8_t auth[8])
|
||||
int bt_mesh_secure_beacon_auth(const uint8_t beacon_key[16], uint8_t flags,
|
||||
const uint8_t net_id[8], uint32_t iv_index,
|
||||
uint8_t auth[8])
|
||||
{
|
||||
uint8_t msg[13] = {0}, tmp[16] = {0};
|
||||
int err = 0;
|
@ -11,7 +11,7 @@
|
||||
#define _CRYPTO_H_
|
||||
|
||||
#include <string.h>
|
||||
#include "mesh_buf.h"
|
||||
#include "mesh/buf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -70,8 +70,8 @@ static inline int bt_mesh_identity_key(const uint8_t net_key[16],
|
||||
return bt_mesh_id128(net_key, "nkik", identity_key);
|
||||
}
|
||||
|
||||
static inline int bt_mesh_beacon_key(const uint8_t net_key[16],
|
||||
uint8_t beacon_key[16])
|
||||
static inline int bt_mesh_secure_beacon_key(const uint8_t net_key[16],
|
||||
uint8_t beacon_key[16])
|
||||
{
|
||||
return bt_mesh_id128(net_key, "nkbk", beacon_key);
|
||||
}
|
||||
@ -80,6 +80,10 @@ int bt_mesh_beacon_auth(const uint8_t beacon_key[16], uint8_t flags,
|
||||
const uint8_t net_id[8], uint32_t iv_index,
|
||||
uint8_t auth[8]);
|
||||
|
||||
int bt_mesh_secure_beacon_auth(const uint8_t beacon_key[16], uint8_t flags,
|
||||
const uint8_t net_id[8], uint32_t iv_index,
|
||||
uint8_t auth[8]);
|
||||
|
||||
static inline int bt_mesh_app_id(const uint8_t app_key[16], uint8_t app_id[1])
|
||||
{
|
||||
return bt_mesh_k4(app_key, app_id);
|
||||
@ -133,10 +137,10 @@ int bt_mesh_net_obfuscate(uint8_t *pdu, uint32_t iv_index,
|
||||
const uint8_t privacy_key[16]);
|
||||
|
||||
int bt_mesh_net_encrypt(const uint8_t key[16], struct net_buf_simple *buf,
|
||||
uint32_t iv_index, bool proxy);
|
||||
uint32_t iv_index, bool proxy, bool proxy_solic);
|
||||
|
||||
int bt_mesh_net_decrypt(const uint8_t key[16], struct net_buf_simple *buf,
|
||||
uint32_t iv_index, bool proxy);
|
||||
uint32_t iv_index, bool proxy, bool proxy_solic);
|
||||
|
||||
int bt_mesh_app_encrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic,
|
||||
struct net_buf_simple *buf, const uint8_t *ad,
|
@ -8,13 +8,14 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "mesh.h"
|
||||
#include "mesh_common.h"
|
||||
#include "mesh/common.h"
|
||||
#include "mesh/main.h"
|
||||
#include "access.h"
|
||||
#include "beacon.h"
|
||||
#include "foundation.h"
|
||||
#include "proxy_client.h"
|
||||
#include "provisioner_prov.h"
|
||||
#include "provisioner_main.h"
|
||||
#include "prov_pvnr.h"
|
||||
#include "pvnr_mgmt.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_FAST_PROV
|
||||
|
||||
@ -24,16 +25,27 @@
|
||||
|
||||
const uint8_t *bt_mesh_fast_prov_dev_key_get(uint16_t dst)
|
||||
{
|
||||
const uint8_t *key = NULL;
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(dst)) {
|
||||
BT_ERR("Invalid unicast address 0x%04x", dst);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (dst == bt_mesh_primary_addr()) {
|
||||
if (bt_mesh_is_provisioner_en() == false) {
|
||||
return bt_mesh.dev_key;
|
||||
}
|
||||
|
||||
return bt_mesh_provisioner_dev_key_get(dst);
|
||||
/* For fast provisioning, try to find the DevKey from
|
||||
* the database firstly. If the dst is not in the DB,
|
||||
* then we will directly use the DevKey.
|
||||
*/
|
||||
key = bt_mesh_provisioner_dev_key_get(dst);
|
||||
if (key) {
|
||||
return key;
|
||||
}
|
||||
|
||||
return bt_mesh.dev_key;
|
||||
}
|
||||
|
||||
struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(uint16_t net_idx)
|
||||
@ -153,8 +165,8 @@ uint8_t bt_mesh_set_fast_prov_action(uint8_t action)
|
||||
}
|
||||
|
||||
if (action == ACTION_ENTER) {
|
||||
if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) {
|
||||
bt_mesh_beacon_disable();
|
||||
if (bt_mesh_secure_beacon_get() == BLE_MESH_SECURE_BEACON_ENABLED) {
|
||||
bt_mesh_secure_beacon_disable();
|
||||
}
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
|
||||
bt_mesh_proxy_client_prov_enable();
|
||||
@ -167,8 +179,8 @@ uint8_t bt_mesh_set_fast_prov_action(uint8_t action)
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
|
||||
bt_mesh_proxy_client_prov_disable();
|
||||
}
|
||||
if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) {
|
||||
bt_mesh_beacon_enable();
|
||||
if (bt_mesh_secure_beacon_get() == BLE_MESH_SECURE_BEACON_ENABLED) {
|
||||
bt_mesh_secure_beacon_enable();
|
||||
}
|
||||
bt_mesh_atomic_and(bt_mesh.flags, ~(BIT(BLE_MESH_PROVISIONER) | BIT(BLE_MESH_VALID_PROV)));
|
||||
bt_mesh_provisioner_fast_prov_enable(false);
|
313
components/bt/esp_ble_mesh/core/foundation.h
Normal file
313
components/bt/esp_ble_mesh/core/foundation.h
Normal file
@ -0,0 +1,313 @@
|
||||
/* Bluetooth Mesh */
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef _FOUNDATION_H_
|
||||
#define _FOUNDATION_H_
|
||||
|
||||
#include "mesh/byteorder.h"
|
||||
#include "net.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OP_APP_KEY_ADD BLE_MESH_MODEL_OP_1(0x00)
|
||||
#define OP_APP_KEY_UPDATE BLE_MESH_MODEL_OP_1(0x01)
|
||||
#define OP_COMP_DATA_STATUS BLE_MESH_MODEL_OP_1(0x02)
|
||||
#define OP_MOD_PUB_SET BLE_MESH_MODEL_OP_1(0x03)
|
||||
#define OP_HEALTH_CURRENT_STATUS BLE_MESH_MODEL_OP_1(0x04)
|
||||
#define OP_HEALTH_FAULT_STATUS BLE_MESH_MODEL_OP_1(0x05)
|
||||
#define OP_HEARTBEAT_PUB_STATUS BLE_MESH_MODEL_OP_1(0x06)
|
||||
#define OP_APP_KEY_DEL BLE_MESH_MODEL_OP_2(0x80, 0x00)
|
||||
#define OP_APP_KEY_GET BLE_MESH_MODEL_OP_2(0x80, 0x01)
|
||||
#define OP_APP_KEY_LIST BLE_MESH_MODEL_OP_2(0x80, 0x02)
|
||||
#define OP_APP_KEY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x03)
|
||||
#define OP_ATTENTION_GET BLE_MESH_MODEL_OP_2(0x80, 0x04)
|
||||
#define OP_ATTENTION_SET BLE_MESH_MODEL_OP_2(0x80, 0x05)
|
||||
#define OP_ATTENTION_SET_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x06)
|
||||
#define OP_ATTENTION_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x07)
|
||||
#define OP_COMP_DATA_GET BLE_MESH_MODEL_OP_2(0x80, 0x08)
|
||||
#define OP_BEACON_GET BLE_MESH_MODEL_OP_2(0x80, 0x09)
|
||||
#define OP_BEACON_SET BLE_MESH_MODEL_OP_2(0x80, 0x0A)
|
||||
#define OP_BEACON_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x0B)
|
||||
#define OP_DEFAULT_TTL_GET BLE_MESH_MODEL_OP_2(0x80, 0x0C)
|
||||
#define OP_DEFAULT_TTL_SET BLE_MESH_MODEL_OP_2(0x80, 0x0D)
|
||||
#define OP_DEFAULT_TTL_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x0E)
|
||||
#define OP_FRIEND_GET BLE_MESH_MODEL_OP_2(0x80, 0x0F)
|
||||
#define OP_FRIEND_SET BLE_MESH_MODEL_OP_2(0x80, 0x10)
|
||||
#define OP_FRIEND_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x11)
|
||||
#define OP_GATT_PROXY_GET BLE_MESH_MODEL_OP_2(0x80, 0x12)
|
||||
#define OP_GATT_PROXY_SET BLE_MESH_MODEL_OP_2(0x80, 0x13)
|
||||
#define OP_GATT_PROXY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x14)
|
||||
#define OP_KRP_GET BLE_MESH_MODEL_OP_2(0x80, 0x15)
|
||||
#define OP_KRP_SET BLE_MESH_MODEL_OP_2(0x80, 0x16)
|
||||
#define OP_KRP_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x17)
|
||||
#define OP_MOD_PUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x18)
|
||||
#define OP_MOD_PUB_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x19)
|
||||
#define OP_MOD_PUB_VA_SET BLE_MESH_MODEL_OP_2(0x80, 0x1A)
|
||||
#define OP_MOD_SUB_ADD BLE_MESH_MODEL_OP_2(0x80, 0x1B)
|
||||
#define OP_MOD_SUB_DEL BLE_MESH_MODEL_OP_2(0x80, 0x1C)
|
||||
#define OP_MOD_SUB_DEL_ALL BLE_MESH_MODEL_OP_2(0x80, 0x1D)
|
||||
#define OP_MOD_SUB_OVERWRITE BLE_MESH_MODEL_OP_2(0x80, 0x1E)
|
||||
#define OP_MOD_SUB_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x1F)
|
||||
#define OP_MOD_SUB_VA_ADD BLE_MESH_MODEL_OP_2(0x80, 0x20)
|
||||
#define OP_MOD_SUB_VA_DEL BLE_MESH_MODEL_OP_2(0x80, 0x21)
|
||||
#define OP_MOD_SUB_VA_OVERWRITE BLE_MESH_MODEL_OP_2(0x80, 0x22)
|
||||
#define OP_NET_TRANSMIT_GET BLE_MESH_MODEL_OP_2(0x80, 0x23)
|
||||
#define OP_NET_TRANSMIT_SET BLE_MESH_MODEL_OP_2(0x80, 0x24)
|
||||
#define OP_NET_TRANSMIT_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x25)
|
||||
#define OP_RELAY_GET BLE_MESH_MODEL_OP_2(0x80, 0x26)
|
||||
#define OP_RELAY_SET BLE_MESH_MODEL_OP_2(0x80, 0x27)
|
||||
#define OP_RELAY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x28)
|
||||
#define OP_MOD_SUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x29)
|
||||
#define OP_MOD_SUB_LIST BLE_MESH_MODEL_OP_2(0x80, 0x2A)
|
||||
#define OP_MOD_SUB_GET_VND BLE_MESH_MODEL_OP_2(0x80, 0x2B)
|
||||
#define OP_MOD_SUB_LIST_VND BLE_MESH_MODEL_OP_2(0x80, 0x2C)
|
||||
#define OP_LPN_TIMEOUT_GET BLE_MESH_MODEL_OP_2(0x80, 0x2D)
|
||||
#define OP_LPN_TIMEOUT_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x2E)
|
||||
#define OP_HEALTH_FAULT_CLEAR BLE_MESH_MODEL_OP_2(0x80, 0x2F)
|
||||
#define OP_HEALTH_FAULT_CLEAR_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x30)
|
||||
#define OP_HEALTH_FAULT_GET BLE_MESH_MODEL_OP_2(0x80, 0x31)
|
||||
#define OP_HEALTH_FAULT_TEST BLE_MESH_MODEL_OP_2(0x80, 0x32)
|
||||
#define OP_HEALTH_FAULT_TEST_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x33)
|
||||
#define OP_HEALTH_PERIOD_GET BLE_MESH_MODEL_OP_2(0x80, 0x34)
|
||||
#define OP_HEALTH_PERIOD_SET BLE_MESH_MODEL_OP_2(0x80, 0x35)
|
||||
#define OP_HEALTH_PERIOD_SET_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x36)
|
||||
#define OP_HEALTH_PERIOD_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x37)
|
||||
#define OP_HEARTBEAT_PUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x38)
|
||||
#define OP_HEARTBEAT_PUB_SET BLE_MESH_MODEL_OP_2(0x80, 0x39)
|
||||
#define OP_HEARTBEAT_SUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x3A)
|
||||
#define OP_HEARTBEAT_SUB_SET BLE_MESH_MODEL_OP_2(0x80, 0x3B)
|
||||
#define OP_HEARTBEAT_SUB_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x3C)
|
||||
#define OP_MOD_APP_BIND BLE_MESH_MODEL_OP_2(0x80, 0x3D)
|
||||
#define OP_MOD_APP_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x3E)
|
||||
#define OP_MOD_APP_UNBIND BLE_MESH_MODEL_OP_2(0x80, 0x3F)
|
||||
#define OP_NET_KEY_ADD BLE_MESH_MODEL_OP_2(0x80, 0x40)
|
||||
#define OP_NET_KEY_DEL BLE_MESH_MODEL_OP_2(0x80, 0x41)
|
||||
#define OP_NET_KEY_GET BLE_MESH_MODEL_OP_2(0x80, 0x42)
|
||||
#define OP_NET_KEY_LIST BLE_MESH_MODEL_OP_2(0x80, 0x43)
|
||||
#define OP_NET_KEY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x44)
|
||||
#define OP_NET_KEY_UPDATE BLE_MESH_MODEL_OP_2(0x80, 0x45)
|
||||
#define OP_NODE_IDENTITY_GET BLE_MESH_MODEL_OP_2(0x80, 0x46)
|
||||
#define OP_NODE_IDENTITY_SET BLE_MESH_MODEL_OP_2(0x80, 0x47)
|
||||
#define OP_NODE_IDENTITY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x48)
|
||||
#define OP_NODE_RESET BLE_MESH_MODEL_OP_2(0x80, 0x49)
|
||||
#define OP_NODE_RESET_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x4A)
|
||||
#define OP_SIG_MOD_APP_GET BLE_MESH_MODEL_OP_2(0x80, 0x4B)
|
||||
#define OP_SIG_MOD_APP_LIST BLE_MESH_MODEL_OP_2(0x80, 0x4C)
|
||||
#define OP_VND_MOD_APP_GET BLE_MESH_MODEL_OP_2(0x80, 0x4D)
|
||||
#define OP_VND_MOD_APP_LIST BLE_MESH_MODEL_OP_2(0x80, 0x4E)
|
||||
|
||||
#define OP_REMOTE_PROV_SCAN_CAPS_GET BLE_MESH_MODEL_OP_2(0x80, 0x4F)
|
||||
#define OP_REMOTE_PROV_SCAN_CAPS_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x50)
|
||||
#define OP_REMOTE_PROV_SCAN_GET BLE_MESH_MODEL_OP_2(0x80, 0x51)
|
||||
#define OP_REMOTE_PROV_SCAN_START BLE_MESH_MODEL_OP_2(0x80, 0x52)
|
||||
#define OP_REMOTE_PROV_SCAN_STOP BLE_MESH_MODEL_OP_2(0x80, 0x53)
|
||||
#define OP_REMOTE_PROV_SCAN_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x54)
|
||||
#define OP_REMOTE_PROV_SCAN_REPORT BLE_MESH_MODEL_OP_2(0x80, 0x55)
|
||||
#define OP_REMOTE_PROV_EXTENDED_SCAN_START BLE_MESH_MODEL_OP_2(0x80, 0x56)
|
||||
#define OP_REMOTE_PROV_EXTENDED_SCAN_REPORT BLE_MESH_MODEL_OP_2(0x80, 0x57)
|
||||
#define OP_REMOTE_PROV_LINK_GET BLE_MESH_MODEL_OP_2(0x80, 0x58)
|
||||
#define OP_REMOTE_PROV_LINK_OPEN BLE_MESH_MODEL_OP_2(0x80, 0x59)
|
||||
#define OP_REMOTE_PROV_LINK_CLOSE BLE_MESH_MODEL_OP_2(0x80, 0x5A)
|
||||
#define OP_REMOTE_PROV_LINK_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x5B)
|
||||
#define OP_REMOTE_PROV_LINK_REPORT BLE_MESH_MODEL_OP_2(0x80, 0x5C)
|
||||
#define OP_REMOTE_PROV_PDU_SEND BLE_MESH_MODEL_OP_2(0x80, 0x5D)
|
||||
#define OP_REMOTE_PROV_PDU_OUTBOUND_REPORT BLE_MESH_MODEL_OP_2(0x80, 0x5E)
|
||||
#define OP_REMOTE_PROV_PDU_REPORT BLE_MESH_MODEL_OP_2(0x80, 0x5F)
|
||||
|
||||
#define OP_DIRECTED_CONTROL_GET BLE_MESH_MODEL_OP_2(0x80, 0x7B)
|
||||
#define OP_DIRECTED_CONTROL_SET BLE_MESH_MODEL_OP_2(0x80, 0x7C)
|
||||
#define OP_DIRECTED_CONTROL_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x7D)
|
||||
#define OP_PATH_METRIC_GET BLE_MESH_MODEL_OP_2(0x80, 0x7E)
|
||||
#define OP_PATH_METRIC_SET BLE_MESH_MODEL_OP_2(0x80, 0x7F)
|
||||
#define OP_PATH_METRIC_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x80)
|
||||
#define OP_DISCOVERY_TABLE_CAPS_GET BLE_MESH_MODEL_OP_2(0x80, 0x81)
|
||||
#define OP_DISCOVERY_TABLE_CAPS_SET BLE_MESH_MODEL_OP_2(0x80, 0x82)
|
||||
#define OP_DISCOVERY_TABLE_CAPS_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x83)
|
||||
#define OP_FORWARDING_TABLE_ADD BLE_MESH_MODEL_OP_2(0x80, 0x84)
|
||||
#define OP_FORWARDING_TABLE_DEL BLE_MESH_MODEL_OP_2(0x80, 0x85)
|
||||
#define OP_FORWARDING_TABLE_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x86)
|
||||
#define OP_FORWARDING_TABLE_DEPS_ADD BLE_MESH_MODEL_OP_2(0x80, 0x87)
|
||||
#define OP_FORWARDING_TABLE_DEPS_DEL BLE_MESH_MODEL_OP_2(0x80, 0x88)
|
||||
#define OP_FORWARDING_TABLE_DEPS_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x89)
|
||||
#define OP_FORWARDING_TABLE_DEPS_GET BLE_MESH_MODEL_OP_2(0x80, 0x8A)
|
||||
#define OP_FORWARDING_TABLE_DEPS_GET_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x8B)
|
||||
#define OP_FORWARDING_TABLE_ENTRIES_CNT_GET BLE_MESH_MODEL_OP_2(0x80, 0x8C)
|
||||
#define OP_FORWARDING_TABLE_ENTRIES_CNT_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x8D)
|
||||
#define OP_FORWARDING_TABLE_ENTRIES_GET BLE_MESH_MODEL_OP_2(0x80, 0x8E)
|
||||
#define OP_FORWARDING_TABLE_ENTRIES_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x8F)
|
||||
#define OP_WANTED_LANES_GET BLE_MESH_MODEL_OP_2(0x80, 0x90)
|
||||
#define OP_WANTED_LANES_SET BLE_MESH_MODEL_OP_2(0x80, 0x91)
|
||||
#define OP_WANTED_LANES_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x92)
|
||||
#define OP_TWO_WAY_PATH_GET BLE_MESH_MODEL_OP_2(0x80, 0x93)
|
||||
#define OP_TWO_WAY_PATH_SET BLE_MESH_MODEL_OP_2(0x80, 0x94)
|
||||
#define OP_TWO_WAY_PATH_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x95)
|
||||
#define OP_PATH_ECHO_INTERVAL_GET BLE_MESH_MODEL_OP_2(0x80, 0x96)
|
||||
#define OP_PATH_ECHO_INTERVAL_SET BLE_MESH_MODEL_OP_2(0x80, 0x97)
|
||||
#define OP_PATH_ECHO_INTERVAL_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x98)
|
||||
#define OP_DIRECTED_NET_TRANSMIT_GET BLE_MESH_MODEL_OP_2(0x80, 0x99)
|
||||
#define OP_DIRECTED_NET_TRANSMIT_SET BLE_MESH_MODEL_OP_2(0x80, 0x9A)
|
||||
#define OP_DIRECTED_NET_TRANSMIT_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x9B)
|
||||
#define OP_DIRECTED_RELAY_RETRANSMIT_GET BLE_MESH_MODEL_OP_2(0x80, 0x9C)
|
||||
#define OP_DIRECTED_RELAY_RETRANSMIT_SET BLE_MESH_MODEL_OP_2(0x80, 0x9D)
|
||||
#define OP_DIRECTED_RELAY_RETRANSMIT_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x9E)
|
||||
#define OP_RSSI_THRESHOLD_GET BLE_MESH_MODEL_OP_2(0x80, 0x9F)
|
||||
#define OP_RSSI_THRESHOLD_SET BLE_MESH_MODEL_OP_2(0x80, 0xA0)
|
||||
#define OP_RSSI_THRESHOLD_STATUS BLE_MESH_MODEL_OP_2(0x80, 0xA1)
|
||||
#define OP_DIRECTED_PATHS_GET BLE_MESH_MODEL_OP_2(0x80, 0xA2)
|
||||
#define OP_DIRECTED_PATHS_STATUS BLE_MESH_MODEL_OP_2(0x80, 0xA3)
|
||||
#define OP_DIRECTED_PUB_POLICY_GET BLE_MESH_MODEL_OP_2(0x80, 0xA4)
|
||||
#define OP_DIRECTED_PUB_POLICY_SET BLE_MESH_MODEL_OP_2(0x80, 0xA5)
|
||||
#define OP_DIRECTED_PUB_POLICY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0xA6)
|
||||
#define OP_PATH_DISCOVERY_TIMING_CTL_GET BLE_MESH_MODEL_OP_2(0x80, 0xA7)
|
||||
#define OP_PATH_DISCOVERY_TIMING_CTL_SET BLE_MESH_MODEL_OP_2(0x80, 0xA8)
|
||||
#define OP_PATH_DISCOVERY_TIMING_CTL_STATUS BLE_MESH_MODEL_OP_2(0x80, 0xA9)
|
||||
#define OP_DIRECTED_CTL_NET_TRANSMIT_GET BLE_MESH_MODEL_OP_2(0x80, 0xAB)
|
||||
#define OP_DIRECTED_CTL_NET_TRANSMIT_SET BLE_MESH_MODEL_OP_2(0x80, 0xAC)
|
||||
#define OP_DIRECTED_CTL_NET_TRANSMIT_STATUS BLE_MESH_MODEL_OP_2(0x80, 0xAD)
|
||||
#define OP_DIRECTED_CTL_RELAY_RETRANSMIT_GET BLE_MESH_MODEL_OP_2(0x80, 0xAE)
|
||||
#define OP_DIRECTED_CTL_RELAY_RETRANSMIT_SET BLE_MESH_MODEL_OP_2(0x80, 0xAF)
|
||||
#define OP_DIRECTED_CTL_RELAY_RETRANSMIT_STATUS BLE_MESH_MODEL_OP_2(0x80, 0xB0)
|
||||
|
||||
#define OP_SUBNET_BRIDGE_GET BLE_MESH_MODEL_OP_2(0x80, 0xB1)
|
||||
#define OP_SUBNET_BRIDGE_SET BLE_MESH_MODEL_OP_2(0x80, 0xB2)
|
||||
#define OP_SUBNET_BRIDGE_STATUS BLE_MESH_MODEL_OP_2(0x80, 0xB3)
|
||||
#define OP_BRIDGING_TABLE_ADD BLE_MESH_MODEL_OP_2(0x80, 0xB4)
|
||||
#define OP_BRIDGING_TABLE_REMOVE BLE_MESH_MODEL_OP_2(0x80, 0xB5)
|
||||
#define OP_BRIDGING_TABLE_STATUS BLE_MESH_MODEL_OP_2(0x80, 0xB6)
|
||||
#define OP_BRIDGED_SUBNETS_GET BLE_MESH_MODEL_OP_2(0x80, 0xB7)
|
||||
#define OP_BRIDGED_SUBNETS_LIST BLE_MESH_MODEL_OP_2(0x80, 0xB8)
|
||||
#define OP_BRIDGING_TABLE_GET BLE_MESH_MODEL_OP_2(0x80, 0xB9)
|
||||
#define OP_BRIDGING_TABLE_LIST BLE_MESH_MODEL_OP_2(0x80, 0xBA)
|
||||
#define OP_BRIDGING_TABLE_SIZE_GET BLE_MESH_MODEL_OP_2(0x80, 0xBB)
|
||||
#define OP_BRIDGING_TABLE_SIZE_STATUS BLE_MESH_MODEL_OP_2(0x80, 0xBC)
|
||||
|
||||
#define OP_PRIVATE_BEACON_GET BLE_MESH_MODEL_OP_2(0x80, 0x60)
|
||||
#define OP_PRIVATE_BEACON_SET BLE_MESH_MODEL_OP_2(0x80, 0x61)
|
||||
#define OP_PRIVATE_BEACON_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x62)
|
||||
#define OP_PRIVATE_GATT_PROXY_GET BLE_MESH_MODEL_OP_2(0x80, 0x63)
|
||||
#define OP_PRIVATE_GATT_PROXY_SET BLE_MESH_MODEL_OP_2(0x80, 0x64)
|
||||
#define OP_PRIVATE_GATT_PROXY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x65)
|
||||
#define OP_PRIVATE_NODE_IDENTITY_GET BLE_MESH_MODEL_OP_2(0x80, 0x66)
|
||||
#define OP_PRIVATE_NODE_IDENTITY_SET BLE_MESH_MODEL_OP_2(0x80, 0x67)
|
||||
#define OP_PRIVATE_NODE_IDENTITY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x68)
|
||||
|
||||
#define OP_ON_DEMAND_PRIVATE_PROXY_GET BLE_MESH_MODEL_OP_2(0x80, 0x69)
|
||||
#define OP_ON_DEMAND_PRIVATE_PROXY_SET BLE_MESH_MODEL_OP_2(0x80, 0x6A)
|
||||
#define OP_ON_DEMAND_PRIVATE_PROXY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x6B)
|
||||
|
||||
#define OP_SAR_TRANSMITTER_GET BLE_MESH_MODEL_OP_2(0x80, 0x6C)
|
||||
#define OP_SAR_TRANSMITTER_SET BLE_MESH_MODEL_OP_2(0x80, 0x6D)
|
||||
#define OP_SAR_TRANSMITTER_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x6E)
|
||||
#define OP_SAR_RECEIVER_GET BLE_MESH_MODEL_OP_2(0x80, 0x6F)
|
||||
#define OP_SAR_RECEIVER_SET BLE_MESH_MODEL_OP_2(0x80, 0x70)
|
||||
#define OP_SAR_RECEIVER_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x71)
|
||||
|
||||
#define OP_OPCODES_AGG_SEQUENCE BLE_MESH_MODEL_OP_2(0x80, 0x72)
|
||||
#define OP_OPCODES_AGG_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x73)
|
||||
|
||||
#define OP_LARGE_COMP_DATA_GET BLE_MESH_MODEL_OP_2(0x80, 0x74)
|
||||
#define OP_LARGE_COMP_DATA_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x75)
|
||||
#define OP_MODELS_METADATA_GET BLE_MESH_MODEL_OP_2(0x80, 0x76)
|
||||
#define OP_MODELS_METADATA_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x77)
|
||||
|
||||
#define OP_SOLIC_PDU_RPL_ITEMS_CLEAR BLE_MESH_MODEL_OP_2(0x80, 0x78)
|
||||
#define OP_SOLIC_PDU_RPL_ITEMS_CLEAR_UNACK BLE_MESH_MODEL_OP_2(0x80, 0x79)
|
||||
#define OP_SOLIC_PDU_RPL_ITEMS_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x7A)
|
||||
|
||||
#define STATUS_SUCCESS 0x00
|
||||
#define STATUS_INVALID_ADDRESS 0x01
|
||||
#define STATUS_INVALID_MODEL 0x02
|
||||
#define STATUS_INVALID_APPKEY 0x03
|
||||
#define STATUS_INVALID_NETKEY 0x04
|
||||
#define STATUS_INSUFF_RESOURCES 0x05
|
||||
#define STATUS_IDX_ALREADY_STORED 0x06
|
||||
#define STATUS_NVAL_PUB_PARAM 0x07
|
||||
#define STATUS_NOT_SUB_MOD 0x08
|
||||
#define STATUS_STORAGE_FAIL 0x09
|
||||
#define STATUS_FEAT_NOT_SUPP 0x0A
|
||||
#define STATUS_CANNOT_UPDATE 0x0B
|
||||
#define STATUS_CANNOT_REMOVE 0x0C
|
||||
#define STATUS_CANNOT_BIND 0x0D
|
||||
#define STATUS_TEMP_STATE_CHG_FAIL 0x0E
|
||||
#define STATUS_CANNOT_SET 0x0F
|
||||
#define STATUS_UNSPECIFIED 0x10
|
||||
#define STATUS_INVALID_BINDING 0x11
|
||||
#define STATUS_INVALID_PATH_ENTRY 0x12
|
||||
#define STATUS_CANNOT_GET 0x13
|
||||
#define STATUS_OBSOLETE_INFO 0x14
|
||||
#define STATUS_INVALID_BEARER 0x15
|
||||
|
||||
/* Defines the status codes for Opcodes Aggregator messages. */
|
||||
#define AGG_STATUS_SUCCESS 0x00
|
||||
#define AGG_STATUS_INVALID_ADDRESS 0x01
|
||||
#define AGG_STATUS_INVALID_MODEL 0x02
|
||||
#define AGG_STATUS_WRONG_ACCESS_KEY 0x03
|
||||
#define AGG_STATUS_WRONG_OPCODE 0x04
|
||||
#define AGG_STATUS_MSG_NOT_UNDERSTOOD 0x05
|
||||
|
||||
enum {
|
||||
BLE_MESH_VA_CHANGED, /* Label information changed */
|
||||
};
|
||||
|
||||
struct label {
|
||||
uint16_t ref;
|
||||
uint16_t addr;
|
||||
uint8_t uuid[16];
|
||||
bt_mesh_atomic_t flags[1];
|
||||
};
|
||||
|
||||
void bt_mesh_mod_sub_reset(bool store);
|
||||
|
||||
void bt_mesh_cfg_reset(bool store);
|
||||
|
||||
void bt_mesh_heartbeat(uint16_t src, uint16_t dst, uint8_t hops, uint16_t feat);
|
||||
|
||||
void bt_mesh_attention(struct bt_mesh_model *model, uint8_t time);
|
||||
|
||||
struct label *get_label(uint16_t index);
|
||||
|
||||
uint8_t *bt_mesh_label_uuid_get(uint16_t addr);
|
||||
|
||||
struct bt_mesh_hb_pub *bt_mesh_hb_pub_get(void);
|
||||
void bt_mesh_hb_pub_disable(void);
|
||||
struct bt_mesh_cfg_srv *bt_mesh_cfg_get(void);
|
||||
|
||||
uint8_t bt_mesh_net_transmit_get(void);
|
||||
uint8_t bt_mesh_relay_get(void);
|
||||
uint8_t bt_mesh_friend_get(void);
|
||||
uint8_t bt_mesh_relay_retransmit_get(void);
|
||||
uint8_t bt_mesh_secure_beacon_get(void);
|
||||
uint8_t bt_mesh_gatt_proxy_get(void);
|
||||
uint8_t bt_mesh_default_ttl_get(void);
|
||||
|
||||
void bt_mesh_subnet_del(struct bt_mesh_subnet *sub, bool store);
|
||||
|
||||
struct bt_mesh_app_key *bt_mesh_app_key_alloc(uint16_t app_idx);
|
||||
void bt_mesh_app_key_del(struct bt_mesh_app_key *key, bool store);
|
||||
|
||||
static inline void key_idx_pack(struct net_buf_simple *buf,
|
||||
uint16_t idx1, uint16_t idx2)
|
||||
{
|
||||
net_buf_simple_add_le16(buf, idx1 | ((idx2 & 0x00f) << 12));
|
||||
net_buf_simple_add_u8(buf, idx2 >> 4);
|
||||
}
|
||||
|
||||
static inline void key_idx_unpack(struct net_buf_simple *buf,
|
||||
uint16_t *idx1, uint16_t *idx2)
|
||||
{
|
||||
*idx1 = sys_get_le16(&buf->data[0]) & 0xfff;
|
||||
*idx2 = sys_get_le16(&buf->data[1]) >> 4;
|
||||
net_buf_simple_pull(buf, 3);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _FOUNDATION_H_ */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user