Fork ESP-IDF's bluetooth component
i want better sbc encoding, and no cla will stop me
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "btc_ble_mesh_agg_model.h"
|
||||
#include "esp_ble_mesh_agg_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_AGG_CLI
|
||||
esp_err_t esp_ble_mesh_register_agg_client_callback(esp_ble_mesh_agg_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_AGG_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_agg_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_agg_client_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_agg_client_args_t btc_arg = {0};
|
||||
btc_msg_t btc_msg = {0};
|
||||
|
||||
if (params == NULL || params->model == NULL || msg == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
btc_msg.sig = BTC_SIG_API_CALL;
|
||||
btc_msg.pid = BTC_PID_AGG_CLIENT;
|
||||
btc_msg.act = BTC_BLE_MESH_ACT_AGG_CLIENT_SEND;
|
||||
|
||||
btc_arg.agg_send.params = params;
|
||||
btc_arg.agg_send.msg = msg;
|
||||
|
||||
return (btc_transfer_context(&btc_msg, &btc_arg, sizeof(btc_ble_mesh_agg_client_args_t),
|
||||
btc_ble_mesh_agg_client_arg_deep_copy,
|
||||
btc_ble_mesh_agg_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_AGG_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_AGG_SRV
|
||||
esp_err_t esp_ble_mesh_register_agg_server_callback(esp_ble_mesh_agg_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_AGG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_AGG_SRV */
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc_ble_mesh_brc_model.h"
|
||||
#include "esp_ble_mesh_brc_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_BRC_CLI
|
||||
esp_err_t esp_ble_mesh_register_brc_client_callback(esp_ble_mesh_brc_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_BRC_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
static bool bridge_cfg_client_send_need_param(esp_ble_mesh_opcode_t opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_ADD:
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_REMOVE:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_brc_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_brc_client_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_brc_client_args_t btc_arg = {0};
|
||||
btc_msg_t btc_msg = {0};
|
||||
|
||||
if (params == NULL || params->model == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
|
||||
(bridge_cfg_client_send_need_param(params->opcode) && msg == NULL)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
btc_msg.sig = BTC_SIG_API_CALL;
|
||||
btc_msg.pid = BTC_PID_BRC_CLIENT;
|
||||
btc_msg.act = BTC_BLE_MESH_ACT_BRC_CLIENT_SEND;
|
||||
|
||||
btc_arg.brc_send.params = params;
|
||||
btc_arg.brc_send.msg = msg;
|
||||
|
||||
return (btc_transfer_context(&btc_msg, &btc_arg, sizeof(btc_ble_mesh_brc_client_args_t),
|
||||
btc_ble_mesh_brc_client_arg_deep_copy,
|
||||
btc_ble_mesh_brc_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_BRC_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_BRC_SRV
|
||||
esp_err_t esp_ble_mesh_register_brc_server_callback(esp_ble_mesh_brc_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_BRC_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_BRC_SRV */
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#include "mesh_v1.1/utils.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
#include "esp_ble_mesh_cm_data_api.h"
|
||||
|
||||
extern int bt_mesh_comp_1_register(const void *comp);
|
||||
extern int bt_mesh_models_metadata_register(const void *metadata, uint8_t metadata_page);
|
||||
|
||||
esp_err_t esp_ble_mesh_comp_1_register(const esp_ble_mesh_comp_1_t *comp)
|
||||
{
|
||||
if (comp == NULL || comp->element_count == 0 ||
|
||||
comp->elements == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
return bt_mesh_comp_1_register(comp);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_models_metadata_register(const esp_ble_mesh_models_metadata_t *metadata,
|
||||
uint8_t metadata_page)
|
||||
{
|
||||
if (metadata == NULL || metadata->element_count == 0 ||
|
||||
metadata->elements == NULL ||
|
||||
(metadata_page != 0 && metadata_page != 128)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
return bt_mesh_models_metadata_register(metadata, metadata_page);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "btc_ble_mesh_df_model.h"
|
||||
#include "esp_ble_mesh_df_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_CLI
|
||||
esp_err_t esp_ble_mesh_register_df_client_callback(esp_ble_mesh_df_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_DF_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
static bool directed_forwarding_client_get_need_param(esp_ble_mesh_opcode_t opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_CONTROL_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_PATH_METRIC_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_DISCOVERY_TABLE_CAPS_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_CNT_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_WANTED_LANES_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_TWO_WAY_PATH_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_PATH_ECHO_INTERVAL_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_PUB_POLICY_GET:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_df_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_df_client_get_t *get)
|
||||
{
|
||||
btc_ble_mesh_df_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (params == NULL || params->model == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
|
||||
(directed_forwarding_client_get_need_param(params->opcode) && get == 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_DF_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_DF_CLIENT_GET_STATE;
|
||||
|
||||
arg.df_get.params = params;
|
||||
arg.df_get.get = get;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_df_client_args_t),
|
||||
btc_ble_mesh_df_client_arg_deep_copy,
|
||||
btc_ble_mesh_df_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_df_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_df_client_set_t *set)
|
||||
{
|
||||
btc_ble_mesh_df_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (params == NULL || params->model == NULL || set == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr)) {
|
||||
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_DF_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_DF_CLIENT_SET_STATE;
|
||||
|
||||
arg.df_set.params = params;
|
||||
arg.df_set.set = set;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_df_client_args_t),
|
||||
btc_ble_mesh_df_client_arg_deep_copy,
|
||||
btc_ble_mesh_df_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DF_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
esp_err_t esp_ble_mesh_register_df_server_callback(esp_ble_mesh_df_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_DF_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DF_SRV */
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "btc_ble_mesh_lcd_model.h"
|
||||
#include "esp_ble_mesh_lcd_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_LCD_CLI
|
||||
esp_err_t esp_ble_mesh_register_lcd_client_callback(esp_ble_mesh_lcd_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_LCD_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_lcd_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_lcd_client_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_lcd_client_args_t btc_arg = {0};
|
||||
btc_msg_t btc_msg = {0};
|
||||
|
||||
if (params == NULL || params->model == NULL || msg == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
btc_msg.sig = BTC_SIG_API_CALL;
|
||||
btc_msg.pid = BTC_PID_LCD_CLIENT;
|
||||
btc_msg.act = BTC_BLE_MESH_ACT_LCD_CLIENT_SEND;
|
||||
|
||||
btc_arg.lcd_send.params = params;
|
||||
btc_arg.lcd_send.msg = msg;
|
||||
|
||||
return (btc_transfer_context(&btc_msg, &btc_arg, sizeof(btc_ble_mesh_lcd_client_args_t),
|
||||
btc_ble_mesh_lcd_client_arg_deep_copy,
|
||||
btc_ble_mesh_lcd_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_LCD_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_LCD_SRV
|
||||
esp_err_t esp_ble_mesh_register_lcd_server_callback(esp_ble_mesh_lcd_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_LCD_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_LCD_SRV */
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "btc_ble_mesh_odp_model.h"
|
||||
#include "esp_ble_mesh_odp_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_ODP_CLI
|
||||
esp_err_t esp_ble_mesh_register_odp_client_callback(esp_ble_mesh_odp_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_ODP_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_odp_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_odp_client_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_odp_client_args_t btc_arg = {0};
|
||||
btc_msg_t btc_msg = {0};
|
||||
|
||||
if (params == NULL || params->model == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
|
||||
(params->opcode == ESP_BLE_MESH_MODEL_OP_OD_PRIV_PROXY_SET && msg == NULL)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
btc_msg.sig = BTC_SIG_API_CALL;
|
||||
btc_msg.pid = BTC_PID_ODP_CLIENT;
|
||||
btc_msg.act = BTC_BLE_MESH_ACT_ODP_CLIENT_SEND;
|
||||
|
||||
btc_arg.odp_send.params = params;
|
||||
btc_arg.odp_send.msg = msg;
|
||||
|
||||
return (btc_transfer_context(&btc_msg, &btc_arg, sizeof(btc_ble_mesh_odp_client_args_t),
|
||||
btc_ble_mesh_odp_client_arg_deep_copy,
|
||||
btc_ble_mesh_odp_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_ODP_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_ODP_SRV
|
||||
esp_err_t esp_ble_mesh_register_odp_server_callback(esp_ble_mesh_odp_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_ODP_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_ODP_SRV */
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc_ble_mesh_prb_model.h"
|
||||
#include "esp_ble_mesh_prb_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_PRB_CLI
|
||||
esp_err_t esp_ble_mesh_register_prb_client_callback(esp_ble_mesh_prb_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_PRB_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
static bool private_beacon_client_send_need_param(esp_ble_mesh_opcode_t opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_BEACON_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_GATT_PROXY_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_NODE_IDENTITY_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_NODE_IDENTITY_SET:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_prb_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_prb_client_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_prb_client_args_t btc_arg = {0};
|
||||
btc_msg_t btc_msg = {0};
|
||||
|
||||
if (params == NULL || params->model == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
|
||||
(private_beacon_client_send_need_param(params->opcode) && msg == NULL)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
btc_msg.sig = BTC_SIG_API_CALL;
|
||||
btc_msg.pid = BTC_PID_PRB_CLIENT;
|
||||
btc_msg.act = BTC_BLE_MESH_ACT_PRB_CLIENT_SEND;
|
||||
|
||||
btc_arg.prb_send.params = params;
|
||||
btc_arg.prb_send.msg = msg;
|
||||
|
||||
return (btc_transfer_context(&btc_msg, &btc_arg, sizeof(btc_ble_mesh_prb_client_args_t),
|
||||
btc_ble_mesh_prb_client_arg_deep_copy,
|
||||
btc_ble_mesh_prb_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_PRB_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_PRB_SRV
|
||||
esp_err_t esp_ble_mesh_register_prb_server_callback(esp_ble_mesh_prb_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_PRB_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_PRB_SRV */
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "btc_ble_mesh_rpr_model.h"
|
||||
#include "esp_ble_mesh_rpr_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_RPR_CLI
|
||||
esp_err_t esp_ble_mesh_register_rpr_client_callback(esp_ble_mesh_rpr_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_RPR_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
static bool remote_prov_client_get_need_param(esp_ble_mesh_opcode_t opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_SCAN_START:
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_EXT_SCAN_START:
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_LINK_OPEN:
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_LINK_CLOSE:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_rpr_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_rpr_client_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_rpr_client_args_t arg = {0};
|
||||
btc_msg_t btc_msg = {0};
|
||||
|
||||
if (params == NULL || params->model == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
|
||||
(remote_prov_client_get_need_param(params->opcode) && msg == NULL)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
btc_msg.sig = BTC_SIG_API_CALL;
|
||||
btc_msg.pid = BTC_PID_RPR_CLIENT;
|
||||
btc_msg.act = BTC_BLE_MESH_ACT_RPR_CLIENT_SEND;
|
||||
|
||||
arg.rpr_send.params = params;
|
||||
arg.rpr_send.msg = msg;
|
||||
|
||||
return (btc_transfer_context(&btc_msg, &arg, sizeof(btc_ble_mesh_rpr_client_args_t),
|
||||
btc_ble_mesh_rpr_client_arg_deep_copy,
|
||||
btc_ble_mesh_rpr_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_rpr_client_action(esp_ble_mesh_rpr_client_act_type_t type,
|
||||
esp_ble_mesh_rpr_client_act_param_t *param)
|
||||
{
|
||||
btc_ble_mesh_rpr_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (type > ESP_BLE_MESH_RPR_CLIENT_ACT_MAX || param == 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_RPR_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_RPR_CLIENT_ACT;
|
||||
|
||||
arg.rpr_act.type = type;
|
||||
arg.rpr_act.param = param;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_rpr_client_args_t),
|
||||
btc_ble_mesh_rpr_client_arg_deep_copy,
|
||||
btc_ble_mesh_rpr_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_RPR_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_RPR_SRV
|
||||
esp_err_t esp_ble_mesh_register_rpr_server_callback(esp_ble_mesh_rpr_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_RPR_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_RPR_SRV */
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "btc_ble_mesh_sar_model.h"
|
||||
#include "esp_ble_mesh_sar_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_SAR_CLI
|
||||
esp_err_t esp_ble_mesh_register_sar_client_callback(esp_ble_mesh_sar_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_SAR_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_sar_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_sar_client_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_sar_client_args_t btc_arg = {0};
|
||||
btc_msg_t btc_msg = {0};
|
||||
|
||||
if (params == NULL || params->model == NULL || (msg == NULL &&
|
||||
(params->opcode == ESP_BLE_MESH_MODEL_OP_SAR_TRANSMITTER_SET ||
|
||||
params->opcode == ESP_BLE_MESH_MODEL_OP_SAR_RECEIVER_SET)) ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
btc_msg.sig = BTC_SIG_API_CALL;
|
||||
btc_msg.pid = BTC_PID_SAR_CLIENT;
|
||||
btc_msg.act = BTC_BLE_MESH_ACT_SAR_CLIENT_SEND;
|
||||
|
||||
btc_arg.sar_send.params = params;
|
||||
btc_arg.sar_send.msg = msg;
|
||||
|
||||
return (btc_transfer_context(&btc_msg, &btc_arg, sizeof(btc_ble_mesh_sar_client_args_t),
|
||||
btc_ble_mesh_sar_client_arg_deep_copy,
|
||||
btc_ble_mesh_sar_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SAR_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_SAR_SRV
|
||||
esp_err_t esp_ble_mesh_register_sar_server_callback(esp_ble_mesh_sar_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_SAR_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SAR_SRV */
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "btc_ble_mesh_srpl_model.h"
|
||||
#include "esp_ble_mesh_srpl_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_SRPL_CLI
|
||||
esp_err_t esp_ble_mesh_register_srpl_client_callback(esp_ble_mesh_srpl_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_SRPL_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_srpl_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_srpl_client_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_srpl_client_args_t btc_arg = {0};
|
||||
btc_msg_t btc_msg = {0};
|
||||
|
||||
if (params == NULL || params->model == NULL || msg == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
btc_msg.sig = BTC_SIG_API_CALL;
|
||||
btc_msg.pid = BTC_PID_SRPL_CLIENT;
|
||||
btc_msg.act = BTC_BLE_MESH_ACT_SRPL_CLIENT_SEND;
|
||||
|
||||
btc_arg.srpl_send.params = params;
|
||||
btc_arg.srpl_send.msg = msg;
|
||||
|
||||
return (btc_transfer_context(&btc_msg, &btc_arg, sizeof(btc_ble_mesh_srpl_client_args_t),
|
||||
btc_ble_mesh_srpl_client_arg_deep_copy,
|
||||
btc_ble_mesh_srpl_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SRPL_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_SRPL_SRV
|
||||
esp_err_t esp_ble_mesh_register_srpl_server_callback(esp_ble_mesh_srpl_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_SRPL_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SRPL_SRV */
|
||||
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_AGG_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_AGG_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Defines the Opcodes Aggregator message opcode. */
|
||||
#define ESP_BLE_MESH_MODEL_OP_AGG_SEQUENCE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x72)
|
||||
#define ESP_BLE_MESH_MODEL_OP_AGG_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x73)
|
||||
|
||||
/** Defines the status codes for Opcodes Aggregator messages. */
|
||||
#define ESP_BLE_MESH_AGG_STATUS_SUCCESS 0x00
|
||||
#define ESP_BLE_MESH_AGG_STATUS_INVALID_ADDRESS 0x01
|
||||
#define ESP_BLE_MESH_AGG_STATUS_INVALID_MODEL 0x02
|
||||
#define ESP_BLE_MESH_AGG_STATUS_WRONG_ACCESS_KEY 0x03
|
||||
#define ESP_BLE_MESH_AGG_STATUS_WRONG_OPCODE 0x04
|
||||
#define ESP_BLE_MESH_AGG_STATUS_MSG_NOT_UNDERSTOOD 0x05
|
||||
|
||||
/* A message that is not understood includes messages that have
|
||||
* one or more of the following conditions:
|
||||
* • The application opcode is unknown by the receiving element.
|
||||
* • The access message size for the application opcode is incorrect.
|
||||
* • The application parameters contain values that are currently
|
||||
* Prohibited.
|
||||
*/
|
||||
|
||||
/** Values of the Length_Format */
|
||||
#define ESP_BLE_MESH_AGG_ITEM_LENGTH_FORMAT_SHORT 0
|
||||
#define ESP_BLE_MESH_AGG_ITEM_LENGTH_FORMAT_LONG 1
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_AGG_SRV
|
||||
*
|
||||
* @brief Define a new Opcodes Aggregator Server model.
|
||||
*
|
||||
* @note If supported, the Opcodes Aggregator Server model shall be
|
||||
* supported by a primary element.
|
||||
*
|
||||
* @param srv_data Pointer to a unique Opcodes Aggregator Server
|
||||
* model user_data.
|
||||
*
|
||||
* @return New Opcodes Aggregator Server model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_AGG_SRV(srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_AGG_SRV, \
|
||||
NULL, NULL, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_AGG_CLI
|
||||
*
|
||||
* @brief Define a new Opcodes Aggregator Client model.
|
||||
*
|
||||
* @note If supported, the model shall be supported by the primary
|
||||
* element and shall not be supported by any secondary elements.
|
||||
*
|
||||
* @param cli_data Pointer to a unique Opcodes Aggregator Client
|
||||
* model user_data.
|
||||
*
|
||||
* @return New Opcodes Aggregator Client model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_AGG_CLI(cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_AGG_CLI, \
|
||||
NULL, NULL, cli_data)
|
||||
|
||||
/** Opcodes Aggregator Server model context */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to Opcodes Aggregator Server model */
|
||||
} esp_ble_mesh_agg_srv_t; /*!< Opcodes Aggregator Server model context */
|
||||
|
||||
/** Parameters of Aggregator Item */
|
||||
typedef struct {
|
||||
uint16_t length_format:1, /*!< 0: Length_Short; 1: Length_Long */
|
||||
length:15; /*!< Size of Opcode_And_Parameters field */
|
||||
const uint8_t *data; /*!< Opcode and parameters */
|
||||
} esp_ble_mesh_agg_item_t; /*!< Parameters of Aggregator Item */
|
||||
|
||||
/** Parameters of Opcodes Aggregator Sequence */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Element address */
|
||||
struct net_buf_simple *items; /*!< List of items with each item represented as an Aggregator Item */
|
||||
} esp_ble_mesh_agg_sequence_t; /*!< Parameters of Opcodes Aggregator Sequence */
|
||||
|
||||
/**
|
||||
* @brief Opcodes Aggregator Client model message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_agg_sequence_t agg_sequence; /*!< For ESP_BLE_MESH_MODEL_OP_AGG_SEQUENCE */
|
||||
} esp_ble_mesh_agg_client_msg_t; /*!< Opcodes Aggregator Client model message union */
|
||||
|
||||
/** Parameters of Opcodes Aggregator Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status of the most recent operation */
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
struct net_buf_simple *items; /*!< List of status items with each status item containing an unacknowledged access layer message or empty item (Optional) */
|
||||
} esp_ble_mesh_agg_status_t; /*!< Parameters of Opcodes Aggregator Status */
|
||||
|
||||
/** Result of sending Opcodes Aggregator Client messages */
|
||||
typedef struct {
|
||||
int err_code; /*!< Result of sending a message */
|
||||
} esp_ble_mesh_agg_client_send_cb_t; /*!< Result of sending Opcodes Aggregator Client messages */
|
||||
|
||||
/**
|
||||
* @brief Opcodes Aggregator Client model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_agg_status_t agg_status; /*!< For ESP_BLE_MESH_MODEL_OP_AGG_STATUS */
|
||||
} esp_ble_mesh_agg_client_recv_cb_t; /*!< Opcodes Aggregator Client model received message union */
|
||||
|
||||
/** Opcodes Aggregator Client model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< Client common parameters, used by all events */
|
||||
/** Union of AGG Client callback */
|
||||
union {
|
||||
esp_ble_mesh_agg_client_send_cb_t send; /*!< Result of sending a message */
|
||||
esp_ble_mesh_agg_client_recv_cb_t recv; /*!< Parameters of received status message */
|
||||
};
|
||||
} esp_ble_mesh_agg_client_cb_param_t; /*!< Opcodes Aggregator Client model callback parameters */
|
||||
|
||||
/** This enum value is the event of Opcodes Aggregator Client model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_AGG_CLIENT_SEND_COMP_EVT,
|
||||
ESP_BLE_MESH_AGG_CLIENT_SEND_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_AGG_CLIENT_RECV_RSP_EVT,
|
||||
ESP_BLE_MESH_AGG_CLIENT_RECV_PUB_EVT,
|
||||
ESP_BLE_MESH_AGG_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_agg_client_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Opcodes Aggregator Server model related context.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Opcodes Aggregator Server model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_agg_sequence_t agg_sequence; /*!< For ESP_BLE_MESH_MODEL_OP_AGG_SEQUENCE */
|
||||
} esp_ble_mesh_agg_server_recv_msg_t; /*!< Opcodes Aggregator Server model received message union */
|
||||
|
||||
/** Opcodes Aggregator Server model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
|
||||
/** Union of AGG Server callback */
|
||||
union {
|
||||
esp_ble_mesh_agg_server_recv_msg_t recv; /*!< Received message callback values */
|
||||
};
|
||||
} esp_ble_mesh_agg_server_cb_param_t; /*!< Opcodes Aggregator Server model callback parameters */
|
||||
|
||||
/** This enum value is the event of Opcodes Aggregator Server model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_AGG_SERVER_RECV_MSG_EVT,
|
||||
ESP_BLE_MESH_AGG_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_agg_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Opcodes Aggregator client and server model functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Opcodes Aggregator Client model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_agg_client_cb_t)(esp_ble_mesh_agg_client_cb_event_t event,
|
||||
esp_ble_mesh_agg_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Opcodes Aggregator Client model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_agg_client_callback(esp_ble_mesh_agg_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Set the value of Opcodes Aggregator Server model state with the corresponding set message.
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] msg: Pointer to Opcodes Aggregator Client message.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_agg_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_agg_client_msg_t *msg);
|
||||
|
||||
/**
|
||||
* @brief Opcodes Aggregator Server model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_agg_server_cb_t)(esp_ble_mesh_agg_server_cb_event_t event,
|
||||
esp_ble_mesh_agg_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Opcodes Aggregator Server model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_agg_server_callback(esp_ble_mesh_agg_server_cb_t callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_AGG_MODEL_API_H_ */
|
||||
@@ -0,0 +1,322 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_BRC_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_BRC_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB1)
|
||||
#define ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB2)
|
||||
#define ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB3)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_ADD ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB4)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_REMOVE ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB5)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB6)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB7)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB8)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB9)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0xBA)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_SIZE_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xBB)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_SIZE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0xBC)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_BRC_SRV
|
||||
*
|
||||
* @brief Define a new Bridge Configuration Server model.
|
||||
*
|
||||
* @note If supported, the model shall be supported by a primary element
|
||||
* and shall not be supported by any secondary elements.
|
||||
*
|
||||
* @param srv_data Pointer to a unique Bridge Configuration Server
|
||||
* model user_data.
|
||||
*
|
||||
* @return New Bridge Configuration Server model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_BRC_SRV(srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_BRC_SRV, \
|
||||
NULL, NULL, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_BRC_CLI
|
||||
*
|
||||
* @brief Define a new Bridge Configuration Client model.
|
||||
*
|
||||
* @note If supported, the model shall be supported by a primary element
|
||||
* and shall not be supported by any secondary elements.
|
||||
*
|
||||
* @param cli_data Pointer to a unique Bridge Configuration Client
|
||||
* model user_data.
|
||||
*
|
||||
* @return New Bridge Configuration Client model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_BRC_CLI(cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_BRC_CLI, \
|
||||
NULL, NULL, cli_data)
|
||||
|
||||
/** Parameters of subnet bridge table */
|
||||
typedef struct {
|
||||
uint8_t bridge_direction; /*!< Allowed directions for the bridged traffic */
|
||||
uint8_t bridge_net_idx[3]; /*!< Two NetKey Indexes are packed into three octets */
|
||||
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
|
||||
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
|
||||
} esp_ble_mesh_subnet_bridge_table_t; /*!< Entries of subnet bridge table */
|
||||
|
||||
#if CONFIG_BLE_MESH_BRC_SRV
|
||||
/** Bridge Configuration Server model context */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to Bridge Configuration Server model */
|
||||
|
||||
uint8_t subnet_bridge; /*!< Subnet Bridge state */
|
||||
uint16_t bridging_table_size; /*!< Bridging Table Size */
|
||||
|
||||
esp_ble_mesh_subnet_bridge_table_t bridge_table[CONFIG_BLE_MESH_MAX_BRIDGING_TABLE_ENTRY_COUNT]; /*!< Subnet Bridge table, used to storage bridging table entries */
|
||||
} esp_ble_mesh_brc_srv_t; /*!< Bridge Configuration Server model context */
|
||||
#endif
|
||||
|
||||
/** Parameters of Subnet Bridge Set */
|
||||
typedef struct {
|
||||
uint8_t subnet_bridge; /*!< New Subnet Bridge state */
|
||||
} esp_ble_mesh_subnet_bridge_set_t; /*!< Parameters of Subnet Bridge Set */
|
||||
|
||||
/** Parameters of Bridging Table Add */
|
||||
typedef struct {
|
||||
uint8_t bridge_direction; /*!< Allowed directions for the bridged traffic */
|
||||
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
|
||||
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
|
||||
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
|
||||
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
|
||||
} esp_ble_mesh_bridging_table_add_t; /*!< Parameters of Bridging Table Add */
|
||||
|
||||
/** Parameters of Bridging Table Remove */
|
||||
typedef struct {
|
||||
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
|
||||
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
|
||||
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
|
||||
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
|
||||
} esp_ble_mesh_bridging_table_remove_t; /*!< Parameters of Bridging Table Remove */
|
||||
|
||||
/** Parameters of Bridged Subnets Get */
|
||||
typedef struct {
|
||||
uint16_t bridge_filter:2, /*!< Filter to be applied when reporting the set of pairs of NetKey Indexes */
|
||||
bridge_net_idx:12; /*!< NetKey Index of any of the subnets */
|
||||
uint8_t bridge_start_idx; /*!< Start offset in units of Bridging Table state entries */
|
||||
} esp_ble_mesh_bridged_subnets_get_t; /*!< Parameters of Bridged Subnets Get */
|
||||
|
||||
/** Parameters of Bridging Table Get */
|
||||
typedef struct {
|
||||
uint16_t bridge_net_idx_1; /*!< NetKey Index of first subnet */
|
||||
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
|
||||
uint16_t bridge_start_idx; /*!< Start offset in units of Bridging Table state entries */
|
||||
} esp_ble_mesh_bridging_table_get_t; /*!< Parameters of Bridging Table Get */
|
||||
|
||||
/**
|
||||
* @brief Bridge Configuration Client model message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_bridged_subnets_get_t bridged_subnets_get; /*!< For ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_GET */
|
||||
esp_ble_mesh_bridging_table_get_t bridging_table_get; /*!< For ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_GET */
|
||||
esp_ble_mesh_subnet_bridge_set_t subnet_bridge_set; /*!< For ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_SET */
|
||||
esp_ble_mesh_bridging_table_add_t bridging_table_add; /*!< For ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_ADD */
|
||||
esp_ble_mesh_bridging_table_remove_t bridging_table_remove; /*!< For ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_REMOVE */
|
||||
} esp_ble_mesh_brc_client_msg_t; /*!< Bridge Configuration Client model message union */
|
||||
|
||||
/** Parameters of Subnet Bridge Status */
|
||||
typedef struct {
|
||||
uint8_t subnet_bridge; /*!< Current Subnet Bridge state */
|
||||
} esp_ble_mesh_subnet_bridge_status_t; /*!< Parameters of Subnet Bridge Status */
|
||||
|
||||
/** Parameters of Bridging Table Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the requesting message */
|
||||
uint8_t bridge_direction; /*!< Allowed directions for the bridged traffic */
|
||||
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
|
||||
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
|
||||
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
|
||||
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
|
||||
} esp_ble_mesh_bridging_table_status_t; /*!< Parameters of Bridging Table Status */
|
||||
|
||||
/** Bridged_Subnets_List entry format */
|
||||
typedef struct {
|
||||
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
|
||||
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
|
||||
} esp_ble_mesh_bridge_net_idx_pair_entry_t; /*!< Bridged_Subnets_List entry format */
|
||||
|
||||
/** Parameters of Bridged Subnets List */
|
||||
typedef struct {
|
||||
uint16_t bridge_filter:2, /*!< Filter applied to the set of pairs of NetKey Indexes */
|
||||
bridge_net_idx:12; /*!< NetKey Index used for filtering or ignored */
|
||||
uint8_t bridge_start_idx; /*!< Start offset in units of bridges */
|
||||
|
||||
uint8_t bridged_entry_list_size; /*!< Num of pairs of NetKey Indexes */
|
||||
esp_ble_mesh_bridge_net_idx_pair_entry_t *net_idx_pair; /*!< Filtered set of N pairs of NetKey Indexes */
|
||||
} esp_ble_mesh_bridged_subnets_list_t; /*!< Parameters of Bridged Subnets List */
|
||||
|
||||
/** Bridged_Addresses_List entry format */
|
||||
typedef struct {
|
||||
uint8_t bridge_direction; /*!< Allowed directions for bridged traffic */
|
||||
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
|
||||
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
|
||||
}esp_ble_mesh_bridged_addr_list_entry_t; /*!< Bridged_Addresses_List entry format */
|
||||
|
||||
/** Parameters of Bridging Table List */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the requesting message */
|
||||
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
|
||||
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
|
||||
uint16_t bridge_start_idx; /*!< Start offset in units of Bridging Table state entries */
|
||||
uint16_t bridged_addr_list_size; /*!< Num of pairs of entry */
|
||||
esp_ble_mesh_bridged_addr_list_entry_t *bridged_addr_list; /*!< List of bridged addresses and allowed traffic directions */
|
||||
} esp_ble_mesh_bridging_table_list_t; /*!< Parameters of Bridging Table List */
|
||||
|
||||
/** Parameters of Bridging Table Size Status */
|
||||
typedef struct {
|
||||
uint16_t bridging_table_size; /*!< Bridging Table Size state */
|
||||
} esp_ble_mesh_bridging_table_size_status_t; /*!< Parameters of Bridging Table Size Status */
|
||||
|
||||
/**
|
||||
* @brief Bridge Configuration Client model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_subnet_bridge_status_t subnet_bridge_status; /*!< ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_STATUS */
|
||||
esp_ble_mesh_bridging_table_status_t bridging_table_status; /*!< ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_STATUS */
|
||||
esp_ble_mesh_bridged_subnets_list_t bridged_subnets_list; /*!< ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_LIST */
|
||||
esp_ble_mesh_bridging_table_list_t bridging_table_list; /*!< ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_LIST */
|
||||
esp_ble_mesh_bridging_table_size_status_t bridging_table_size_status; /*!< ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_SIZE_STATUS */
|
||||
} esp_ble_mesh_brc_client_recv_cb_t;/*!< */
|
||||
|
||||
/** Result of sending Bridge Configuration Client messages */
|
||||
typedef struct {
|
||||
int err_code; /*!< Result of sending a message */
|
||||
} esp_ble_mesh_brc_client_send_cb_t; /*!< Result of sending Bridge Configuration Client messages */
|
||||
|
||||
/** Bridge Configuration Client model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< Client common parameters, used by all events. */
|
||||
/** Union of Bridge Configuration Client callback */
|
||||
union {
|
||||
esp_ble_mesh_brc_client_send_cb_t send; /*!< Result of sending a message */
|
||||
esp_ble_mesh_brc_client_recv_cb_t recv; /*!< Parameters of received status message */
|
||||
};
|
||||
} esp_ble_mesh_brc_client_cb_param_t; /*!< Bridge Configuration Client model callback parameters */
|
||||
|
||||
/** This enum value is the event of Bridge Configuration Client model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_BRC_CLIENT_SEND_COMP_EVT,
|
||||
ESP_BLE_MESH_BRC_CLIENT_SEND_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_BRC_CLIENT_RECV_RSP_EVT,
|
||||
ESP_BLE_MESH_BRC_CLIENT_RECV_PUB_EVT,
|
||||
ESP_BLE_MESH_BRC_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_brc_client_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bridge Configuration Server model related context.
|
||||
*/
|
||||
/** Parameters of Bridging Table Add */
|
||||
typedef struct {
|
||||
uint8_t bridge_direction; /*!< Allowed directions for the bridged traffic */
|
||||
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
|
||||
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
|
||||
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
|
||||
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
|
||||
} esp_ble_mesh_state_change_bridging_table_add_t; /*!< Parameters of Bridging Table Add */
|
||||
|
||||
/** Parameters of Bridging Table Remove */
|
||||
typedef struct {
|
||||
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
|
||||
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
|
||||
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
|
||||
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
|
||||
} esp_ble_mesh_state_change_bridging_table_remove_t; /*!< Parameters of Bridging Table Remove */
|
||||
|
||||
/**
|
||||
* @brief Bridge Configuration Server model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* The recv_op in ctx can be used to decide which state is changed.
|
||||
*/
|
||||
esp_ble_mesh_state_change_bridging_table_add_t bridging_table_add; /*!< Bridging Table Add */
|
||||
esp_ble_mesh_state_change_bridging_table_remove_t bridging_table_remove; /*!< Bridging Table Remove*/
|
||||
} esp_ble_mesh_brc_server_state_change_t; /*!< Bridge Configuration Server model state change value union */
|
||||
|
||||
/**
|
||||
* @brief Bridge Configuration Server model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_brc_server_state_change_t state_change; /*!< For ESP_BLE_MESH_BRC_SERVER_STATE_CHANGE_EVT */
|
||||
} esp_ble_mesh_brc_server_cb_value_t; /*!< Bridge Configuration Server model callback value union */
|
||||
|
||||
/** Bridge Configuration Server model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
|
||||
esp_ble_mesh_brc_server_cb_value_t value; /*!< Value of the received configuration messages */
|
||||
} esp_ble_mesh_brc_server_cb_param_t; /*!< Bridge Configuration Server model callback parameters */
|
||||
|
||||
/** This enum value is the event of Bridge Configuration Server model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_BRC_SERVER_STATE_CHANGE_EVT,
|
||||
ESP_BLE_MESH_BRC_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_brc_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Bridge Configuration client and server model functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Bridge Configuration Client model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_brc_client_cb_t)(esp_ble_mesh_brc_client_cb_event_t event,
|
||||
esp_ble_mesh_brc_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Bridge Configuration Server model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_brc_server_cb_t)(esp_ble_mesh_brc_server_cb_event_t event,
|
||||
esp_ble_mesh_brc_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Bridge Configuration Client model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_brc_client_callback(esp_ble_mesh_brc_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Bridge Configuration Server model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_brc_server_callback(esp_ble_mesh_brc_server_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Get/Set the value of Bridge Configuration Server model state with the corresponding message.
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] msg: Pointer to Bridge Configuration Client message.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_brc_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_brc_client_msg_t *msg);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_BRC_MODEL_API_H_ */
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_CM_DATA_API_H_
|
||||
#define _ESP_BLE_MESH_CM_DATA_API_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!< Definitions of the format of Extended_Model_Items indicator */
|
||||
#define ESP_BLE_MESH_MODEL_ITEM_SHORT 0
|
||||
#define ESP_BLE_MESH_MODEL_ITEM_LONG 1
|
||||
|
||||
/* The value of the Element_Offset field is mapped to an integer value.
|
||||
* |----------------|-------------------|
|
||||
* | Element_Offset | Represented Value |
|
||||
* |----------------|-------------------|
|
||||
* | 0 | 0 |
|
||||
* | 1 | 1 |
|
||||
* | 2 | 2 |
|
||||
* | 3 | 3 |
|
||||
* | 4 | -4 |
|
||||
* | 5 | -3 |
|
||||
* | 6 | -2 |
|
||||
* | 7 | -1 |
|
||||
* |----------------|-------------------|
|
||||
*/
|
||||
|
||||
/** Format of Extended Model Item */
|
||||
typedef struct {
|
||||
/** Union of Extended Model Item */
|
||||
union {
|
||||
uint8_t element_offset:3, /*!< Element address modifier, in the range -4 to 3. See above. */
|
||||
model_item_idx:5; /*!< Model Index, in the range 0 to 31 */
|
||||
/** Extended Model Item long format */
|
||||
struct {
|
||||
int8_t element_offset; /*!< Element address modifier, in the range -128 to 127 */
|
||||
uint8_t model_item_idx; /*!< Model index, in the range 0 to 255 */
|
||||
} long_fmt; /*!< Extended Model Item long format */
|
||||
};
|
||||
} esp_ble_mesh_extended_model_item_t; /*!< Format of Extended Model Item */
|
||||
|
||||
/** Format of Model Item */
|
||||
typedef struct {
|
||||
uint8_t corresponding_present:1, /*!< Corresponding_Group_ID field indicator */
|
||||
format:1, /*!< Format of Extended_Model_Items indicator */
|
||||
extended_items_count:6; /*!< Number of Extended Model Items in the Extended_Model_Items field */
|
||||
uint8_t corresponding_group_id; /*!< Corresponding group identifier */
|
||||
esp_ble_mesh_extended_model_item_t *const extended_model_items; /*!< List of Extended Model Items */
|
||||
} esp_ble_mesh_model_item_t; /*!< Format of Model Item */
|
||||
|
||||
/** Format of element of Composition Data Page 1 */
|
||||
typedef struct {
|
||||
const uint8_t num_s; /*!< A count of SIG Models Items in this element */
|
||||
const uint8_t num_v; /*!< A count of Vendor Models Items in this element */
|
||||
|
||||
esp_ble_mesh_model_item_t *const model_items_s; /*!< A sequence of "num_s" SIG Model Items */
|
||||
esp_ble_mesh_model_item_t *const model_items_v; /*!< A sequence of "num_v" Vendor Model Items */
|
||||
} esp_ble_mesh_comp_1_elem_t; /*!< Format of element of Composition Data Page 1 */
|
||||
|
||||
/** Format of Composition Data Page 1 */
|
||||
typedef struct {
|
||||
size_t element_count; /*!< Element count */
|
||||
esp_ble_mesh_comp_1_elem_t *elements; /*!< A sequence of element descriptions */
|
||||
} esp_ble_mesh_comp_1_t; /*!< Format of Composition Data Page 1 */
|
||||
|
||||
/** Format of Metadata entry */
|
||||
typedef struct {
|
||||
uint16_t metadata_len; /*!< Size of the Metadata field */
|
||||
uint16_t metadata_id; /*!< Bluetooth assigned number for the Metadata Identifier */
|
||||
const uint8_t *metadata; /*!< Model’s metadata */
|
||||
} esp_ble_mesh_metadata_entry_t; /*!< Format of Metadata entry */
|
||||
|
||||
/** Format of Metadata item */
|
||||
typedef struct {
|
||||
/** Union of model ID */
|
||||
union {
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
/** Vendor model identifier */
|
||||
struct {
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} vnd; /*!< Vendor model identifier */
|
||||
};
|
||||
uint8_t metadata_entries_num; /*!< Number of metadata entries */
|
||||
esp_ble_mesh_metadata_entry_t *const metadata_entries; /*!< List of model’s metadata */
|
||||
} esp_ble_mesh_metadata_item_t; /*!< Format of Metadata item */
|
||||
|
||||
/** Format of Metadata element of Models Metadata Page 0/128 */
|
||||
typedef struct {
|
||||
const uint8_t items_num_s; /*!< Number of metadata items for SIG models in the element */
|
||||
const uint8_t items_num_v; /*!< Number of metadata items for Vendor models in the element */
|
||||
|
||||
esp_ble_mesh_metadata_item_t *const metadata_items_s; /*!< List of metadata items for SIG models in the element */
|
||||
esp_ble_mesh_metadata_item_t *const metadata_items_v; /*!< List of metadata items for Vendor models in the element */
|
||||
} esp_ble_mesh_metadata_elem_t; /*!< Format of Metadata element of Models Metadata Page 0/128 */
|
||||
|
||||
/** Format of the Models Metadata Page 0/128 */
|
||||
typedef struct {
|
||||
size_t element_count; /*!< Element count */
|
||||
esp_ble_mesh_metadata_elem_t *elements; /*!< List of metadata for models for each element */
|
||||
} esp_ble_mesh_models_metadata_t; /*!< Format of the Models Metadata Page 0/128 */
|
||||
|
||||
/**
|
||||
* @brief Register Composition Data Page 1.
|
||||
*
|
||||
* @param[in] comp: Pointer to Composition Data Page 1.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_comp_1_register(const esp_ble_mesh_comp_1_t *comp);
|
||||
|
||||
/**
|
||||
* @brief Register Models Metadata Page 0 or 128.
|
||||
*
|
||||
* @param[in] metadata: Pointer to Models Metadata Page 0 or 128.
|
||||
* @param[in] metadata_page: Models Metadata Page number, i.e. 0 or 128.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_models_metadata_register(const esp_ble_mesh_models_metadata_t *metadata,
|
||||
uint8_t metadata_page);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_CM_DATA_API_H_ */
|
||||
@@ -0,0 +1,746 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_DF_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_DF_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_CONTROL_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x7B)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_CONTROL_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x7C)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_CONTROL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x7D)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PATH_METRIC_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x7E)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PATH_METRIC_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x7F)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PATH_METRIC_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x80)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DISCOVERY_TABLE_CAPS_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x81)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DISCOVERY_TABLE_CAPS_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x82)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DISCOVERY_TABLE_CAPS_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x83)
|
||||
#define ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ADD ESP_BLE_MESH_MODEL_OP_2(0x80, 0x84)
|
||||
#define ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEL ESP_BLE_MESH_MODEL_OP_2(0x80, 0x85)
|
||||
#define ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x86)
|
||||
#define ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_ADD ESP_BLE_MESH_MODEL_OP_2(0x80, 0x87)
|
||||
#define ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_DEL ESP_BLE_MESH_MODEL_OP_2(0x80, 0x88)
|
||||
#define ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x89)
|
||||
#define ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x8A)
|
||||
#define ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_GET_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x8B)
|
||||
#define ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_CNT_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x8C)
|
||||
#define ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_CNT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x8D)
|
||||
#define ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x8E)
|
||||
#define ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x8F)
|
||||
#define ESP_BLE_MESH_MODEL_OP_WANTED_LANES_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x90)
|
||||
#define ESP_BLE_MESH_MODEL_OP_WANTED_LANES_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x91)
|
||||
#define ESP_BLE_MESH_MODEL_OP_WANTED_LANES_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x92)
|
||||
#define ESP_BLE_MESH_MODEL_OP_TWO_WAY_PATH_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x93)
|
||||
#define ESP_BLE_MESH_MODEL_OP_TWO_WAY_PATH_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x94)
|
||||
#define ESP_BLE_MESH_MODEL_OP_TWO_WAY_PATH_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x95)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PATH_ECHO_INTERVAL_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x96)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PATH_ECHO_INTERVAL_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x97)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PATH_ECHO_INTERVAL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x98)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_NET_TRANSMIT_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x99)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_NET_TRANSMIT_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x9A)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_NET_TRANSMIT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x9B)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_RELAY_RETRANSMIT_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x9C)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_RELAY_RETRANSMIT_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x9D)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_RELAY_RETRANSMIT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x9E)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RSSI_THRESHOLD_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x9F)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RSSI_THRESHOLD_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xA0)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RSSI_THRESHOLD_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0xA1)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_PATHS_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xA2)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_PATHS_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0xA3)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_PUB_POLICY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xA4)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_PUB_POLICY_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xA5)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_PUB_POLICY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0xA6)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PATH_DISCOVERY_TIMING_CTL_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xA7)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PATH_DISCOVERY_TIMING_CTL_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xA8)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PATH_DISCOVERY_TIMING_CTL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0xA9)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_NET_TRANSMIT_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xAB)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_NET_TRANSMIT_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xAC)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_NET_TRANSMIT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0xAD)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_RELAY_RETRANSMIT_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xAE)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_RELAY_RETRANSMIT_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xAF)
|
||||
#define ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_RELAY_RETRANSMIT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB0)
|
||||
|
||||
#define ESP_BLE_MESH_PATH_DISC_INTERVAL_5_SEC 0
|
||||
#define ESP_BLE_MESH_PATH_DISC_INTERVAL_30_SEC 1
|
||||
|
||||
#define ESP_BLE_MESH_LANE_DISC_GUARD_INTERVAL_2_SEC 0
|
||||
#define ESP_BLE_MESH_LANE_DISC_GUARD_INTERVAL_10_SEC 1
|
||||
|
||||
#define ESP_BLE_MESH_DIRECTED_PUB_POLICY_MANAGED_FLOODING 0x00
|
||||
#define ESP_BLE_MESH_DIRECTED_PUB_POLICY_DIRECTED_FORWARDING 0x01
|
||||
|
||||
#define ESP_BLE_MESH_GET_FILTER_MASK(fp, nfp, pom, dm) \
|
||||
(((dm) << 3) | ((pom) << 2) | ((nfp) << 1) | (fp))
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_DF_SRV
|
||||
*
|
||||
* @brief Define a new Directed Forwarding Configuration Server model.
|
||||
*
|
||||
* @note If supported, the model shall be supported by a primary element
|
||||
* and shall not be supported by any secondary elements.
|
||||
*
|
||||
* @param srv_data Pointer to a unique Directed Forwarding Configuration
|
||||
* Server model user_data.
|
||||
*
|
||||
* @return New Directed Forwarding Configuration Server model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_DF_SRV(srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_DF_SRV, \
|
||||
NULL, NULL, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_DF_CLI
|
||||
*
|
||||
* @brief Define a new Directed Forwarding Configuration Client model.
|
||||
*
|
||||
* @note If supported, the model shall be supported by a primary element
|
||||
* and shall not be supported by any secondary elements.
|
||||
*
|
||||
* @param cli_data Pointer to a unique Directed Forwarding Configuration
|
||||
* Client model user_data.
|
||||
*
|
||||
* @return New Directed Forwarding Configuration Client model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_DF_CLI(cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_DF_CLI, \
|
||||
NULL, NULL, cli_data)
|
||||
|
||||
/** Directed Forwarding Configuration Server model context */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to Directed Forwarding Configuration Server model */
|
||||
|
||||
uint8_t directed_net_transmit; /*!< Directed Network Transmit state */
|
||||
uint8_t directed_relay_retransmit; /*!< Directed Relay Retransmit state */
|
||||
|
||||
int8_t default_rssi_threshold; /*!< Default RSSI Threshold state */
|
||||
uint8_t rssi_margin; /*!< RSSI Margin state */
|
||||
|
||||
uint16_t directed_node_paths; /*!< Directed Node Paths state */
|
||||
uint16_t directed_relay_paths; /*!< Directed Relay Paths state */
|
||||
uint16_t directed_proxy_paths; /*!< Directed Proxy Paths state */
|
||||
uint16_t directed_friend_paths; /*!< Directed Friend Paths state */
|
||||
|
||||
uint16_t path_monitor_interval; /*!< Path Monitoring Interval state */
|
||||
uint16_t path_disc_retry_interval; /*!< Path Discovery Retry Interval state */
|
||||
uint8_t path_disc_interval:1, /*!< Path Discovery Interval state */
|
||||
lane_disc_guard_interval:1; /*!< Lane Discovery Guard Interval state */
|
||||
|
||||
uint8_t directed_ctl_net_transmit; /*!< Directed Control Network Transmit state */
|
||||
uint8_t directed_ctl_relay_retransmit; /*!< Directed Control Relay Retransmit state */
|
||||
} esp_ble_mesh_df_srv_t;
|
||||
|
||||
/** Parameters of Directed Control Get. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
} esp_ble_mesh_directed_control_get_t;
|
||||
|
||||
/** Parameters of Directed Control Set. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t directed_forwarding; /*!< New Directed Forwarding state */
|
||||
uint8_t directed_relay; /*!< New Directed Relay state */
|
||||
uint8_t directed_proxy; /*!< New Directed Proxy state */
|
||||
uint8_t directed_proxy_use_default; /*!< New Directed Proxy Use Directed Default state or value to ignore */
|
||||
uint8_t directed_friend; /*!< New Directed Friend state or value to ignore */
|
||||
} esp_ble_mesh_directed_control_set_t;
|
||||
|
||||
/** Parameters of Path Metric Get. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
} esp_ble_mesh_path_metric_get_t;
|
||||
|
||||
/** Parameters of Path Metric Set. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t path_metric_type:3, /*!< New Path Metric Type state */
|
||||
path_lifetime:2; /*!< New Path Lifetime state */
|
||||
} esp_ble_mesh_path_metric_set_t;
|
||||
|
||||
/** Parameters of Discovery Table Capabilities Get. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
} esp_ble_mesh_discovery_table_caps_get_t;
|
||||
|
||||
/** Parameters of Discovery Table Capabilities Set. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t max_concurr_init; /*!< New Max Concurrent Init state */
|
||||
} esp_ble_mesh_discovery_table_caps_set_t;
|
||||
|
||||
/** Parameters of Forwarding Table Add. */
|
||||
typedef struct {
|
||||
uint16_t net_idx:12, /*!< NetKey Index */
|
||||
unicast_dst:1, /*!< Indicates whether or not the destination of the path is a unicast address */
|
||||
bw_path_validated:1; /*!< Indicates whether or not the backward path has been validated */
|
||||
esp_ble_mesh_uar_t path_origin; /*!< Unicast address range of the Path Origin */
|
||||
/** Path target address */
|
||||
union {
|
||||
esp_ble_mesh_uar_t path_target; /*!< Unicast address range of the Path Target */
|
||||
uint16_t multicast_dst; /*!< Multicast destination address */
|
||||
};
|
||||
uint16_t bearer_twd_path_origin; /*!< Index of the bearer toward the Path Origin */
|
||||
uint16_t bearer_twd_path_target; /*!< Index of the bearer toward the Path Target */
|
||||
} esp_ble_mesh_forwarding_table_add_t; /*!< Parameters of Forwarding Table Add */
|
||||
|
||||
/** Parameters of Forwarding Table Delete. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t path_origin; /*!< Primary element address of the Path Origin */
|
||||
uint16_t dst; /*!< Destination address */
|
||||
} esp_ble_mesh_forwarding_table_delete_t;
|
||||
|
||||
/** Parameters of Forwarding Table Dependents Add. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t path_origin; /*!< Primary element address of the Path Origin */
|
||||
uint16_t dst; /*!< Destination address */
|
||||
uint8_t dep_origin_uar_list_size; /*!< Number of entries in the Dependent_Origin_Unicast_Addr_Range_List field */
|
||||
uint8_t dep_target_uar_list_size; /*!< Number of entries in the Dependent_Target_Unicast_Addr_Range_List field */
|
||||
esp_ble_mesh_uar_t *dep_origin_uar_list; /*!< List of the unicast address ranges of the dependent nodes of the Path Origin */
|
||||
esp_ble_mesh_uar_t *dep_target_uar_list; /*!< List of the unicast address ranges of the dependent nodes of the Path Target */
|
||||
} esp_ble_mesh_forwarding_table_deps_add_t;
|
||||
|
||||
/** Parameters of Forwarding Table Dependents Delete. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t path_origin; /*!< Primary element address of the Path Origin */
|
||||
uint16_t dst; /*!< Destination address */
|
||||
uint8_t dep_origin_list_size; /*!< Number of entries in the Dependent_Origin_List field */
|
||||
uint8_t dep_target_list_size; /*!< Number of entries in the Dependent_Target_List field */
|
||||
uint16_t *dep_origin_list; /*!< List of the primary element addresses of the dependent nodes of the Path Origin */
|
||||
uint16_t *dep_target_list; /*!< List of the primary element addresses of the dependent nodes of the Path Target */
|
||||
} esp_ble_mesh_forwarding_table_deps_delete_t;
|
||||
|
||||
/** Parameters of Forwarding Table Entries Count Get. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
} esp_ble_mesh_forwarding_table_entries_cnt_get_t;
|
||||
|
||||
/** Parameters of Forwarding Table Entries Get. */
|
||||
typedef struct {
|
||||
uint16_t net_idx:12, /*!< NetKey Index */
|
||||
filter_mask:4; /*!< Filter to be applied to the Forwarding Table entries */
|
||||
uint16_t start_index; /*!< Start offset to read in units of Forwarding Table entries */
|
||||
uint16_t path_origin; /*!< Primary element address of the Path Origin */
|
||||
uint16_t dst; /*!< Destination address */
|
||||
|
||||
bool include_id; /*!< Indicate whether or not the Forwarding Table Update Identifier is present */
|
||||
uint16_t update_id; /*!< Last saved Forwarding Table Update Identifier (Optional) */
|
||||
} esp_ble_mesh_forwarding_table_entries_get_t;
|
||||
|
||||
/** Parameters of Forwarding Table Dependents Get. */
|
||||
typedef struct {
|
||||
uint16_t net_idx:12, /*!< NetKey Index */
|
||||
dep_list_mask:2, /*!< Filter applied to the lists of unicast address ranges for dependent nodes */
|
||||
fixed_path_flag:1; /*!< Indicate whether or not to return the unicast address ranges of dependent nodes in a fixed path entry */
|
||||
uint16_t start_index; /*!< Start offset in units of unicast address ranges */
|
||||
uint16_t path_origin; /*!< Primary element address of the Path Origin */
|
||||
uint16_t dst; /*!< Destination address */
|
||||
|
||||
bool include_id; /*!< Indicate whether or not the Forwarding Table Update Identifier is present */
|
||||
uint16_t update_id; /*!< Last saved Forwarding Table Update Identifier (Optional) */
|
||||
} esp_ble_mesh_forwarding_table_deps_get_t;
|
||||
|
||||
/** Parameters of Wanted Lanes Get. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
} esp_ble_mesh_wanted_lanes_get_t;
|
||||
|
||||
/** Parameters of Wanted Lanes Set. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t wanted_lanes; /*!< New Wanted Lanes state */
|
||||
} esp_ble_mesh_wanted_lanes_set_t;
|
||||
|
||||
/** Parameters of Two Way Path Get. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
} esp_ble_mesh_two_way_path_get_t;
|
||||
|
||||
/** Parameters of Two Way Path Set. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t two_way_path:1; /*!< Two way path flag */
|
||||
} esp_ble_mesh_two_way_path_set_t;
|
||||
|
||||
/** Parameters of Path Echo Interval Get. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
} esp_ble_mesh_path_echo_interval_get_t;
|
||||
|
||||
/** Parameters of Path Echo Interval Set. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t unicast_echo_interval; /*!< New Unicast Echo Interval state or indication of no state change */
|
||||
uint8_t multicast_echo_interval; /*!< New Multicast Echo Interval state or indication of no state change */
|
||||
} esp_ble_mesh_path_echo_interval_set_t;
|
||||
|
||||
/** Parameters of Directed Network Transmit Set. */
|
||||
typedef struct {
|
||||
uint8_t net_transmit; /*!< New Directed Network Transmit state */
|
||||
} esp_ble_mesh_directed_net_transmit_set_t;
|
||||
|
||||
/** Parameters of Directed Relay Retransmit Set. */
|
||||
typedef struct {
|
||||
uint8_t relay_retransmit; /*!< New Directed Relay Retransmit state */
|
||||
} esp_ble_mesh_directed_relay_retransmit_set_t;
|
||||
|
||||
/** Parameters of RSSI Threshold Set. */
|
||||
typedef struct {
|
||||
uint8_t rssi_margin; /*!< New RSSI Margin state */
|
||||
} esp_ble_mesh_rssi_threshold_set_t;
|
||||
|
||||
/** Parameters of Directed Publish Policy Get. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Address of the element */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_directed_publish_policy_get_t;
|
||||
|
||||
/** Parameters of Directed Publish Policy Set. */
|
||||
typedef struct {
|
||||
uint8_t direct_pub_policy; /*!< New Directed Publish Policy state */
|
||||
uint16_t element_addr; /*!< Address of the element */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_directed_publish_policy_set_t;
|
||||
|
||||
/** Parameters of Path Discovery Timing Control Set. */
|
||||
typedef struct {
|
||||
uint16_t path_monitor_interval; /*!< New Path Monitoring Interval state */
|
||||
uint16_t path_disc_retry_interval; /*!< New Path Discovery Retry Interval state */
|
||||
uint8_t path_disc_interval:1, /*!< New Path Discovery Interval state */
|
||||
lane_disc_guard_interval:1; /*!< New Lane Discovery Guard Interval state */
|
||||
} esp_ble_mesh_path_discovery_timing_ctl_set_t;
|
||||
|
||||
/** Parameters of Directed Control Network Transmit Set. */
|
||||
typedef struct {
|
||||
uint8_t net_transmit; /*!< New Directed Control Network Transmit Count state */
|
||||
} esp_ble_mesh_directed_ctl_net_transmit_set_t;
|
||||
|
||||
/** Parameters of Directed Control Relay Retransmit Set. */
|
||||
typedef struct {
|
||||
uint8_t relay_retransmit; /*!< New Directed Control Relay Retransmit Count state */
|
||||
} esp_ble_mesh_directed_ctl_relay_retransmit_set_t;
|
||||
|
||||
/**
|
||||
* @brief Directed Forwarding Configuration Client model get message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_directed_control_get_t directed_control_get; /*!< For ESP_BLE_MESH_MODEL_OP_DIRECTED_CONTROL_GET */
|
||||
esp_ble_mesh_path_metric_get_t path_metric_get; /*!< For ESP_BLE_MESH_MODEL_OP_PATH_METRIC_GET */
|
||||
esp_ble_mesh_discovery_table_caps_get_t disc_table_caps_get; /*!< For ESP_BLE_MESH_MODEL_OP_DISCOVERY_TABLE_CAPS_GET */
|
||||
esp_ble_mesh_forwarding_table_entries_cnt_get_t forwarding_table_entries_cnt_get; /*!< For ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_CNT_GET */
|
||||
esp_ble_mesh_forwarding_table_entries_get_t forwarding_table_entries_get; /*!< For ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_GET */
|
||||
esp_ble_mesh_forwarding_table_deps_get_t forwarding_table_deps_get; /*!< For ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_GET */
|
||||
esp_ble_mesh_wanted_lanes_get_t wanted_lanes_get; /*!< For ESP_BLE_MESH_MODEL_OP_WANTED_LANES_GET */
|
||||
esp_ble_mesh_two_way_path_get_t two_way_path_get; /*!< For ESP_BLE_MESH_MODEL_OP_TWO_WAY_PATH_GET */
|
||||
esp_ble_mesh_path_echo_interval_get_t path_echo_interval_get; /*!< For ESP_BLE_MESH_MODEL_OP_PATH_ECHO_INTERVAL_GET */
|
||||
esp_ble_mesh_directed_publish_policy_get_t directed_pub_policy_get; /*!< For ESP_BLE_MESH_MODEL_OP_DIRECTED_PUB_POLICY_GET */
|
||||
} esp_ble_mesh_df_client_get_t;
|
||||
|
||||
/**
|
||||
* @brief Directed Forwarding Configuration Client model set message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_directed_control_set_t directed_control_set; /*!< For ESP_BLE_MESH_MODEL_OP_DIRECTED_CONTROL_SET */
|
||||
esp_ble_mesh_path_metric_set_t path_metric_set; /*!< For ESP_BLE_MESH_MODEL_OP_PATH_METRIC_SET */
|
||||
esp_ble_mesh_discovery_table_caps_set_t disc_table_caps_set; /*!< For ESP_BLE_MESH_MODEL_OP_DISCOVERY_TABLE_CAPS_SET */
|
||||
esp_ble_mesh_forwarding_table_add_t forwarding_table_add; /*!< For ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ADD */
|
||||
esp_ble_mesh_forwarding_table_delete_t forwarding_table_del; /*!< For ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEL */
|
||||
esp_ble_mesh_forwarding_table_deps_add_t forwarding_table_deps_add; /*!< For ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_ADD */
|
||||
esp_ble_mesh_forwarding_table_deps_delete_t forwarding_table_deps_del; /*!< For ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_DEL */
|
||||
esp_ble_mesh_wanted_lanes_set_t wanted_lanes_set; /*!< For ESP_BLE_MESH_MODEL_OP_WANTED_LANES_SET */
|
||||
esp_ble_mesh_two_way_path_set_t two_way_path_set; /*!< For ESP_BLE_MESH_MODEL_OP_TWO_WAY_PATH_SET */
|
||||
esp_ble_mesh_path_echo_interval_set_t path_echo_interval_set; /*!< For ESP_BLE_MESH_MODEL_OP_PATH_ECHO_INTERVAL_SET */
|
||||
esp_ble_mesh_directed_net_transmit_set_t directed_net_transmit_set; /*!< For ESP_BLE_MESH_MODEL_OP_DIRECTED_NET_TRANSMIT_SET */
|
||||
esp_ble_mesh_directed_relay_retransmit_set_t directed_relay_retransmit_set; /*!< For ESP_BLE_MESH_MODEL_OP_DIRECTED_RELAY_RETRANSMIT_SET */
|
||||
esp_ble_mesh_rssi_threshold_set_t rssi_threshold_set; /*!< For ESP_BLE_MESH_MODEL_OP_RSSI_THRESHOLD_SET */
|
||||
esp_ble_mesh_directed_publish_policy_set_t directed_pub_policy_set; /*!< For ESP_BLE_MESH_MODEL_OP_DIRECTED_PUB_POLICY_SET */
|
||||
esp_ble_mesh_path_discovery_timing_ctl_set_t path_disc_timing_ctl_set; /*!< For ESP_BLE_MESH_MODEL_OP_PATH_DISCOVERY_TIMING_CTL_SET */
|
||||
esp_ble_mesh_directed_ctl_net_transmit_set_t directed_ctl_net_transmit_set; /*!< For ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_NET_TRANSMIT_SET */
|
||||
esp_ble_mesh_directed_ctl_relay_retransmit_set_t directed_ctl_relay_retransmit_set; /*!< For ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_RELAY_RETRANSMIT_SET */
|
||||
} esp_ble_mesh_df_client_set_t;
|
||||
|
||||
/** Parameters of Directed Control Status. */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status code for the requesting message */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t directed_forwarding; /*!< Current Directed Forwarding state */
|
||||
uint8_t directed_relay; /*!< Current Directed Relay state */
|
||||
uint8_t directed_proxy; /*!< Current Directed Proxy state */
|
||||
uint8_t directed_proxy_use_default; /*!< Current Directed Proxy Use Directed Default state or 0xFF */
|
||||
uint8_t directed_friend; /*!< Current Directed Friend state */
|
||||
} esp_ble_mesh_directed_control_status_t;
|
||||
|
||||
/** Parameters of Path Metric Status. */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status code for the requesting message */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t path_metric_type:3, /*!< Current Path Metric Type state */
|
||||
path_lifetime:2; /*!< Current Path Lifetime state */
|
||||
} esp_ble_mesh_path_metric_status_t;
|
||||
|
||||
/** Parameters of Discovery Table Capabilities Status. */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status code for the requesting message */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t max_concurr_init; /*!< Current Max Concurrent Init state */
|
||||
uint8_t max_disc_entries; /*!< Max Discovery Table Entries Count state */
|
||||
} esp_ble_mesh_discovery_table_caps_status_t;
|
||||
|
||||
/** Parameters of Forwarding Table Status. */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status code for the requesting message */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t path_origin; /*!< Primary element address of the Path Origin */
|
||||
uint16_t dst; /*!< Destination address */
|
||||
} esp_ble_mesh_forwarding_table_status_t;
|
||||
|
||||
/** Parameters of Forwarding Table Dependent Status. */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status code for the requesting message */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t path_origin; /*!< Primary element address of the Path Origin */
|
||||
uint16_t dst; /*!< Destination address */
|
||||
} esp_ble_mesh_forwarding_table_deps_status_t;
|
||||
|
||||
/** Parameters of Forwarding Table Entries Count Status. */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status code for the requesting message */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t update_id; /*!< Current Forwarding Table Update Identifier state */
|
||||
uint16_t fixed_entry_cnt; /*!< Number of fixed path entries in the Forwarding Table */
|
||||
uint16_t non_fixed_entry_cnt; /*!< Number of non-fixed path entries in the Forwarding Table */
|
||||
} esp_ble_mesh_forwarding_table_entries_cnt_status_t;
|
||||
|
||||
/** Parameters of Forwarding Table Entry. */
|
||||
typedef struct {
|
||||
uint16_t fixed_path_flag:1, /*!< Indicates whether the table entry is a fixed path entry or a non-fixed path entry */
|
||||
unicast_dst_flag:1, /*!< Indicates whether or not the destination of the path is a unicast address */
|
||||
bw_path_validated_flag:1, /*!< Indicates whether or not the backward path has been validated */
|
||||
bearer_twd_path_origin_ind:1, /*!< Indicates the presence or absence of the Bearer_Toward_Path_Origin field */
|
||||
bearer_twd_path_target_ind:1, /*!< Indicates the presence or absence of the Bearer_Toward_Path_Target field */
|
||||
dep_origin_list_size_ind:2, /*!< Indicates the size of the Dependent_Origin_List field */
|
||||
dep_target_list_size_ind:2; /*!< Indicates the size of the Dependent_Target_List field */
|
||||
|
||||
/* Only for non-fixed path entry */
|
||||
uint8_t lane_counter; /*!< Number of lanes in the path */
|
||||
uint16_t path_remaining_time; /*!< Path lifetime remaining */
|
||||
uint8_t path_origin_forward_number; /*!< Forwarding number of the Path Origin */
|
||||
|
||||
/* For fixed path entry and non-fixed path entry */
|
||||
esp_ble_mesh_uar_t path_origin; /*!< Path Origin unicast address range */
|
||||
uint16_t dep_origin_list_size; /*!< Current number of entries in the list of dependent nodes of the Path Origin */
|
||||
uint16_t bearer_twd_path_origin; /*!< Index of the bearer toward the Path Origin */
|
||||
esp_ble_mesh_uar_t path_target; /*!< Path Target unicast address range */
|
||||
uint16_t multicast_dst; /*!< Multicast destination address */
|
||||
uint16_t dep_target_list_size; /*!< Current number of entries in the list of dependent nodes of the Path Target */
|
||||
uint16_t bearer_twd_path_target; /*!< Index of the bearer toward the Path Target */
|
||||
} esp_ble_mesh_forwarding_table_entry_t;
|
||||
|
||||
/** Parameters of Forwarding Table Entries Status. */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status code for the requesting message */
|
||||
uint16_t net_idx:12, /*!< NetKey Index */
|
||||
filter_mask:4; /*!< Filter applied to the Forwarding Table entries */
|
||||
uint16_t start_index; /*!< Start offset in units of Forwarding Table entries */
|
||||
uint16_t path_origin; /*!< Primary element address of the Path Origin */
|
||||
uint16_t dst; /*!< Destination address */
|
||||
|
||||
bool include_id; /*!< Indicate whether or not the Forwarding Table Update Identifier is present */
|
||||
uint16_t update_id; /*!< Current Forwarding Table Update Identifier state */
|
||||
|
||||
uint8_t entry_list_size; /*!< Current number of entries in the list of Forwarding Table entries */
|
||||
esp_ble_mesh_forwarding_table_entry_t *entry_list; /*!< List of Forwarding Table entries */
|
||||
} esp_ble_mesh_forwarding_table_entries_status_t;
|
||||
|
||||
/** Parameters of Forwarding Table Dependents Get Status. */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status code for the requesting message */
|
||||
uint16_t net_idx:12, /*!< NetKey Index */
|
||||
dep_list_mask:2, /*!< Filter applied to the lists of unicast address ranges for dependent nodes */
|
||||
fixed_path_flag:1; /*!< Flag indicating whether or not to return the unicast address ranges of dependent nodes in a fixed path entry */
|
||||
uint16_t start_index; /*!< Start offset in units of unicast address ranges */
|
||||
uint16_t path_origin; /*!< Primary element address of the Path Origin */
|
||||
uint16_t dst; /*!< Destination address */
|
||||
|
||||
bool include_id; /*!< Indicate whether or not the Forwarding Table Update Identifier is present */
|
||||
uint16_t update_id; /*!< Current Forwarding Table Update Identifier state */
|
||||
|
||||
uint8_t dep_origin_uar_list_size; /*!< Number of unicast address ranges in the Dependent_Origin_Unicast_Addr_Range_List field */
|
||||
uint8_t dep_target_uar_list_size; /*!< Number of unicast address ranges in the Dependent_Target_Unicast_Addr_Range_List field */
|
||||
esp_ble_mesh_uar_t *dep_origin_uar_list; /*!< List of unicast address ranges of dependent nodes of the Path Origin */
|
||||
esp_ble_mesh_uar_t *dep_target_uar_list; /*!< List of unicast address ranges of dependent nodes of the Path Target */
|
||||
} esp_ble_mesh_forwarding_table_deps_get_status_t;
|
||||
|
||||
/** Parameters of Wanted Lanes Status. */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status code for the requesting message */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t wanted_lanes; /*!< Current Wanted Lanes state */
|
||||
} esp_ble_mesh_wanted_lanes_status_t;
|
||||
|
||||
/** Parameters of Two Way Path Status. */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status code for the requesting message */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t two_way_path; /*!< Current Two Way Path state */
|
||||
} esp_ble_mesh_two_way_path_status_t;
|
||||
|
||||
/** Parameters of Path Echo Interval Status. */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status code for the requesting message */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t unicast_echo_interval; /*!< Current Unicast Echo Interval state */
|
||||
uint8_t multicast_echo_interval; /*!< Current Multicast Echo Interval state */
|
||||
} esp_ble_mesh_path_echo_interval_status_t;
|
||||
|
||||
/** Parameters of Directed Network Transmit Status. */
|
||||
typedef struct {
|
||||
uint8_t net_transmit; /*!< Current Directed Network Transmit state */
|
||||
} esp_ble_mesh_directed_net_transmit_status_t;
|
||||
|
||||
/** Parameters of Directed Relay Retransmit Status. */
|
||||
typedef struct {
|
||||
uint8_t relay_retransmit; /*!< Current Directed Relay Retransmit state */
|
||||
} esp_ble_mesh_directed_relay_retransmit_status_t;
|
||||
|
||||
/** Parameters of RSSI Threshold Status. */
|
||||
typedef struct {
|
||||
uint8_t default_rssi_threshold; /*!< Default RSSI Threshold state */
|
||||
uint8_t rssi_margin; /*!< Current RSSI Margin state */
|
||||
} esp_ble_mesh_rssi_threshold_status_t;
|
||||
|
||||
/** Parameters of Directed Paths Status. */
|
||||
typedef struct {
|
||||
uint16_t directed_node_paths; /*!< Directed Node Paths state */
|
||||
uint16_t directed_relay_paths; /*!< Directed Relay Paths state */
|
||||
uint16_t directed_proxy_paths; /*!< Directed Proxy Paths state */
|
||||
uint16_t directed_friend_paths; /*!< Directed Friend Paths state */
|
||||
} esp_ble_mesh_directed_paths_status_t;
|
||||
|
||||
/** Parameters of Directed Publish Policy Status. */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status code for the requesting message */
|
||||
uint8_t directed_pub_policy; /*!< Current Directed Publish Policy state */
|
||||
uint16_t element_addr; /*!< Address of the element */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_directed_pub_policy_status_t;
|
||||
|
||||
/** Parameters of Path Discovery Timing Control Status. */
|
||||
typedef struct {
|
||||
uint16_t path_monitor_interval; /*!< Current Path Monitoring Interval state */
|
||||
uint16_t path_disc_retry_interval; /*!< Current Path Discovery Retry Interval state */
|
||||
uint8_t path_disc_interval:1, /*!< Current Path Discovery Interval state */
|
||||
lane_disc_guard_interval:1; /*!< Current Lane Discovery Guard Interval state */
|
||||
} esp_ble_mesh_path_disc_timing_ctl_status_cb_t;
|
||||
|
||||
/** Parameters of Directed Control Network Transmit Status. */
|
||||
typedef struct {
|
||||
uint8_t net_transmit; /*!< Current Directed Control Network Transmit state */
|
||||
} esp_ble_mesh_directed_ctl_net_transmit_status_t;
|
||||
|
||||
/** Parameters of Directed Control Relay Retransmit Status. */
|
||||
typedef struct {
|
||||
uint8_t relay_retransmit; /*!< Current Directed Control Relay Retransmit state */
|
||||
} esp_ble_mesh_directed_ctl_relay_retransmit_status_t;
|
||||
|
||||
/** Result of sending Directed Forwarding Configuration Client messages */
|
||||
typedef struct {
|
||||
int err_code; /*!< Result of sending a message */
|
||||
} esp_ble_mesh_df_client_send_cb_t;
|
||||
|
||||
/**
|
||||
* @brief Directed Forwarding Configuration Client model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_directed_control_status_t directed_control_status; /*!< ESP_BLE_MESH_MODEL_OP_DIRECTED_CONTROL_STATUS */
|
||||
esp_ble_mesh_path_metric_status_t path_metric_status; /*!< ESP_BLE_MESH_MODEL_OP_PATH_METRIC_STATUS */
|
||||
esp_ble_mesh_discovery_table_caps_status_t disc_table_caps_status; /*!< ESP_BLE_MESH_MODEL_OP_DISCOVERY_TABLE_CAPS_STATUS */
|
||||
esp_ble_mesh_forwarding_table_status_t forwarding_table_status; /*!< ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_STATUS */
|
||||
esp_ble_mesh_forwarding_table_deps_status_t forwarding_table_deps_status; /*!< ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_STATUS */
|
||||
esp_ble_mesh_forwarding_table_entries_cnt_status_t forwarding_table_entries_cnt_status; /*!< ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_CNT_STATUS */
|
||||
esp_ble_mesh_forwarding_table_entries_status_t forwarding_table_entries_status; /*!< ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_STATUS */
|
||||
esp_ble_mesh_forwarding_table_deps_get_status_t forwarding_table_deps_get_status; /*!< ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_GET_STATUS */
|
||||
esp_ble_mesh_wanted_lanes_status_t wanted_lanes_status; /*!< ESP_BLE_MESH_MODEL_OP_WANTED_LANES_STATUS */
|
||||
esp_ble_mesh_two_way_path_status_t two_way_path_status; /*!< ESP_BLE_MESH_MODEL_OP_TWO_WAY_PATH_STATUS */
|
||||
esp_ble_mesh_path_echo_interval_status_t path_echo_interval_status; /*!< ESP_BLE_MESH_MODEL_OP_PATH_ECHO_INTERVAL_STATUS */
|
||||
esp_ble_mesh_directed_net_transmit_status_t directed_net_transmit_status; /*!< ESP_BLE_MESH_MODEL_OP_DIRECTED_NET_TRANSMIT_STATUS */
|
||||
esp_ble_mesh_directed_relay_retransmit_status_t directed_relay_retransmit_status; /*!< ESP_BLE_MESH_MODEL_OP_DIRECTED_RELAY_RETRANSMIT_STATUS */
|
||||
esp_ble_mesh_rssi_threshold_status_t rssi_threshold_status; /*!< ESP_BLE_MESH_MODEL_OP_RSSI_THRESHOLD_STATUS */
|
||||
esp_ble_mesh_directed_paths_status_t directed_paths_status; /*!< ESP_BLE_MESH_MODEL_OP_DIRECTED_PATHS_STATUS */
|
||||
esp_ble_mesh_directed_pub_policy_status_t directed_pub_policy_status; /*!< ESP_BLE_MESH_MODEL_OP_DIRECTED_PUB_POLICY_STATUS */
|
||||
esp_ble_mesh_path_disc_timing_ctl_status_cb_t path_disc_timing_ctl_status; /*!< ESP_BLE_MESH_MODEL_OP_PATH_DISCOVERY_TIMING_CTL_STATUS */
|
||||
esp_ble_mesh_directed_ctl_net_transmit_status_t directed_ctl_net_transmit_status; /*!< ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_NET_TRANSMIT_STATUS */
|
||||
esp_ble_mesh_directed_ctl_relay_retransmit_status_t directed_ctl_relay_retransmit_status; /*!< ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_RELAY_RETRANSMIT_STATUS */
|
||||
} esp_ble_mesh_df_client_recv_cb_t;
|
||||
|
||||
/** Directed Forwarding Configuration Client model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< Client common parameters, used by all events. */
|
||||
/** Union of DF Client callback */
|
||||
union {
|
||||
esp_ble_mesh_df_client_send_cb_t send; /*!< Result of sending a message */
|
||||
esp_ble_mesh_df_client_recv_cb_t recv; /*!< Parameters of received status message */
|
||||
};
|
||||
} esp_ble_mesh_df_client_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Directed Forwarding Configuration Client model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_DF_CLIENT_SEND_COMP_EVT,
|
||||
ESP_BLE_MESH_DF_CLIENT_SEND_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_DF_CLIENT_RECV_GET_RSP_EVT,
|
||||
ESP_BLE_MESH_DF_CLIENT_RECV_SET_RSP_EVT,
|
||||
ESP_BLE_MESH_DF_CLIENT_RECV_PUB_EVT,
|
||||
ESP_BLE_MESH_DF_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_df_client_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Directed Forwarding Configuration Server model related context.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Directed Forwarding Configuration Server model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
uint8_t dummy; /*!< Event not used currently */
|
||||
} esp_ble_mesh_df_server_state_change_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_DF_TABLE_ACT_EMPTY,
|
||||
ESP_BLE_MESH_DF_TABLE_ADD,
|
||||
ESP_BLE_MESH_DF_TABLE_REMOVE,
|
||||
ESP_BLE_MESH_DF_TABLE_ENTRY_CHANGE,
|
||||
ESP_BLE_MESH_DF_TABLE_ACT_MAX_LIMIT,
|
||||
} esp_ble_mesh_df_table_action_t;
|
||||
|
||||
/** Parameters of directed forwarding table entry change */
|
||||
typedef struct {
|
||||
esp_ble_mesh_df_table_action_t action; /*!< Action of directed forwarding table */
|
||||
/** Union of directed forwarding table information */
|
||||
union {
|
||||
/** Structure of directed forwarding table add and remove */
|
||||
struct {
|
||||
esp_ble_mesh_uar_t path_origin; /*!< Primary element address of the Path Origin */
|
||||
esp_ble_mesh_uar_t path_target; /*!< Primary element address of the Path Target */
|
||||
|
||||
esp_ble_mesh_uar_t *dep_origin_data; /*!< List of the primary element addresses of the dependent nodes of the Path Origin */
|
||||
uint32_t dep_origin_num; /*!< Number of entries in the Dependent_Origin_List field of the message */
|
||||
|
||||
esp_ble_mesh_uar_t *dep_target_data; /*!< List of the primary element addresses of the dependent nodes of the Path Target */
|
||||
uint32_t dep_target_num; /*!< Number of entries in the Dependent_Target_List field of the message */
|
||||
|
||||
uint8_t fixed_path:1, /*!< Indicates whether the table entry is a fixed path entry or a non-fixed path entry */
|
||||
bw_path_validate:1, /*!< Indicates whether or not the backward path has been validated */
|
||||
path_not_ready:1; /*!< Flag indicating whether or not the path is ready for use */
|
||||
|
||||
uint8_t forward_number; /*!< Forwarding number of the Path Origin; If the entry is associated with a fixed path, the value is 0 */
|
||||
|
||||
uint8_t lane_counter; /*!< Number of lanes discovered; if the entry is associated with a fixed path, the value is 1.*/
|
||||
} df_table_entry_add_remove; /*!< Structure of directed forwarding table add and remove */
|
||||
/** Structure of directed forwarding table entry change */
|
||||
struct {
|
||||
uint8_t dummy; /*!< Event not used currently */
|
||||
} df_table_entry_change; /*!< Directed forwarding table entry change */
|
||||
} df_table_info; /*!< Directed forwarding table information */
|
||||
} esp_ble_mesh_df_server_table_change_t; /*!< Structure of directed forwarding table entry change */
|
||||
|
||||
/**
|
||||
* @brief Directed Forwarding Configuration Server model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_df_server_state_change_t state_change; /*!< For ESP_BLE_MESH_DF_SERVER_STATE_CHANGE_EVT */
|
||||
esp_ble_mesh_df_server_table_change_t table_change; /*!< For ESP_BLE_MESH_DF_SERVER_TABLE_CHANGE_EVT */
|
||||
} esp_ble_mesh_df_server_cb_value_t;
|
||||
|
||||
/** Directed Forwarding Configuration Server model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
|
||||
esp_ble_mesh_df_server_cb_value_t value; /*!< Value of the received configuration messages */
|
||||
} esp_ble_mesh_df_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Directed Forwarding Configuration Server model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_DF_SERVER_STATE_CHANGE_EVT,
|
||||
ESP_BLE_MESH_DF_SERVER_TABLE_CHANGE_EVT,
|
||||
ESP_BLE_MESH_DF_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_df_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Directed Forwarding Configuration client and server model functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Directed Forwarding Configuration Client model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_df_client_cb_t)(esp_ble_mesh_df_client_cb_event_t event,
|
||||
esp_ble_mesh_df_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Directed Forwarding Configuration Server model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_df_server_cb_t)(esp_ble_mesh_df_server_cb_event_t event,
|
||||
esp_ble_mesh_df_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Directed Forwarding Configuration Client model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_df_client_callback(esp_ble_mesh_df_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Directed Forwarding Configuration Server model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_df_server_callback(esp_ble_mesh_df_server_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Get the value of Directed Forwarding Configuration Server model state with the corresponding get message.
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] get: Pointer to a union, each kind of opcode corresponds to one structure inside.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_df_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_df_client_get_t *get);
|
||||
|
||||
/**
|
||||
* @brief Set the value of Directed Forwarding Configuration Server model state with the corresponding set message.
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] set: Pointer to a union, each kind of opcode corresponds to one structure inside.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_df_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_df_client_set_t *set);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_DF_MODEL_API_H_ */
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_LCD_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_LCD_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BLE_MESH_MODEL_OP_LARGE_COMP_DATA_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x74)
|
||||
#define ESP_BLE_MESH_MODEL_OP_LARGE_COMP_DATA_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x75)
|
||||
#define ESP_BLE_MESH_MODEL_OP_MODELS_METADATA_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x76)
|
||||
#define ESP_BLE_MESH_MODEL_OP_MODELS_METADATA_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x77)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_LCD_SRV
|
||||
*
|
||||
* @brief Define a new Large Composition Data Server model.
|
||||
*
|
||||
* @note If supported, the model shall be supported by a primary element
|
||||
* and shall not be supported by any secondary elements.
|
||||
*
|
||||
* @param srv_data Pointer to a unique Large Composition Data Server model user_data.
|
||||
*
|
||||
* @return New Large Composition Data Server model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_LCD_SRV(srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LCD_SRV, \
|
||||
NULL, NULL, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_LCD_CLI
|
||||
*
|
||||
* @brief Define a new Large Composition Data Client model.
|
||||
*
|
||||
* @note If supported, the model shall be supported by the primary element
|
||||
* and shall not be supported by any secondary elements.
|
||||
*
|
||||
* @param cli_data Pointer to a unique Large Composition Data Client model user_data.
|
||||
*
|
||||
* @return New Large Composition Data Client model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_LCD_CLI(cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LCD_CLI, \
|
||||
NULL, NULL, cli_data)
|
||||
|
||||
/** Large Composition Data Server model context */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to Large Composition Data Server model */
|
||||
} esp_ble_mesh_lcd_srv_t;
|
||||
|
||||
/** Parameters of Large Composition Data Get */
|
||||
typedef struct {
|
||||
uint8_t page; /*!< Page number of the Composition Data */
|
||||
uint16_t offset; /*!< Offset within the page */
|
||||
} esp_ble_mesh_large_comp_data_get_t;
|
||||
|
||||
/** Parameters of Models Metadata Get */
|
||||
typedef struct {
|
||||
uint8_t metadata_page; /*!< Page number of the Models Metadata */
|
||||
uint16_t offset; /*!< Offset within the page */
|
||||
} esp_ble_mesh_models_metadata_get_t;
|
||||
|
||||
/**
|
||||
* @brief Large Composition Data Client model message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_large_comp_data_get_t large_comp_data_get; /*!< For ESP_BLE_MESH_MODEL_OP_LARGE_COMP_DATA_GET */
|
||||
esp_ble_mesh_models_metadata_get_t models_metadata_get; /*!< For ESP_BLE_MESH_MODEL_OP_MODELS_METADATA_GET */
|
||||
} esp_ble_mesh_lcd_client_msg_t;
|
||||
|
||||
/** Parameters of Large Composition Data Status */
|
||||
typedef struct {
|
||||
uint8_t page; /*!< Page number of the Composition Data */
|
||||
uint16_t offset; /*!< Offset within the page */
|
||||
uint16_t total_size; /*!< Total size of the page */
|
||||
struct net_buf_simple *data; /*!< Composition Data for the identified portion of the page */
|
||||
} esp_ble_mesh_large_comp_data_status_t;
|
||||
|
||||
/** Parameters of Models Metadata Data Status */
|
||||
typedef struct {
|
||||
uint8_t metadata_page; /*!< Page number of the Models Metadata */
|
||||
uint16_t offset; /*!< Offset within the page */
|
||||
uint16_t total_size; /*!< Total size of the page */
|
||||
struct net_buf_simple *data; /*!< Models Metadata for the identified portion of the page */
|
||||
} esp_ble_mesh_models_metadata_status_t;
|
||||
|
||||
/** Result of sending Large Composition Data Client messages */
|
||||
typedef struct {
|
||||
int err_code; /*!< Result of sending a message */
|
||||
} esp_ble_mesh_lcd_client_send_cb_t;
|
||||
|
||||
/**
|
||||
* @brief Large Composition Data Client model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_large_comp_data_status_t large_comp_data_status; /*!< For ESP_BLE_MESH_MODEL_OP_LARGE_COMP_DATA_STATUS */
|
||||
esp_ble_mesh_models_metadata_status_t models_metadata_status; /*!< For ESP_BLE_MESH_MODEL_OP_MODELS_METADATA_STATUS */
|
||||
} esp_ble_mesh_lcd_client_recv_cb_t;
|
||||
|
||||
/** Large Composition Data Client model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< Client common parameters, used by all events. */
|
||||
/** Union of LCD Client callback */
|
||||
union {
|
||||
esp_ble_mesh_lcd_client_send_cb_t send; /*!< Result of sending a message */
|
||||
esp_ble_mesh_lcd_client_recv_cb_t recv; /*!< Parameters of received status message */
|
||||
};
|
||||
} esp_ble_mesh_lcd_client_cb_param_t; /*!< Large Composition Data Client model callback parameters */
|
||||
|
||||
/** This enum value is the event of Large Composition Data Client model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_LCD_CLIENT_SEND_COMP_EVT,
|
||||
ESP_BLE_MESH_LCD_CLIENT_SEND_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_LCD_CLIENT_RECV_RSP_EVT,
|
||||
ESP_BLE_MESH_LCD_CLIENT_RECV_PUB_EVT,
|
||||
ESP_BLE_MESH_LCD_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_lcd_client_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Large Composition Data Server model related context.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Large Composition Data Server model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
uint8_t dummy; /*!< Event not used currently */
|
||||
} esp_ble_mesh_lcd_server_state_change_t;
|
||||
|
||||
/**
|
||||
* @brief Large Composition Data Server model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_lcd_server_state_change_t state_change; /*!< For ESP_BLE_MESH_LCD_SERVER_STATE_CHANGE_EVT */
|
||||
} esp_ble_mesh_lcd_server_cb_value_t;
|
||||
|
||||
/** Large Composition Data Server model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
|
||||
esp_ble_mesh_lcd_server_cb_value_t value; /*!< Value of the received configuration messages */
|
||||
} esp_ble_mesh_lcd_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Large Composition Data Server model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_LCD_SERVER_STATE_CHANGE_EVT,
|
||||
ESP_BLE_MESH_LCD_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_lcd_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Large Composition Data client and server model functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Large Composition Data Client model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_lcd_client_cb_t)(esp_ble_mesh_lcd_client_cb_event_t event,
|
||||
esp_ble_mesh_lcd_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Large Composition Data Client model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_lcd_client_callback(esp_ble_mesh_lcd_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Get the value of Large Composition Data Server model state with the corresponding get message.
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] msg: Pointer to Large Composition Data Client message.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_lcd_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_lcd_client_msg_t *msg);
|
||||
|
||||
/**
|
||||
* @brief Large Composition Data Server model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_lcd_server_cb_t)(esp_ble_mesh_lcd_server_cb_event_t event,
|
||||
esp_ble_mesh_lcd_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Large Composition Data Server model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_lcd_server_callback(esp_ble_mesh_lcd_server_cb_t callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_LCD_MODEL_API_H_ */
|
||||
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_ODP_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_ODP_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BLE_MESH_MODEL_OP_OD_PRIV_PROXY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x69)
|
||||
#define ESP_BLE_MESH_MODEL_OP_OD_PRIV_PROXY_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x6A)
|
||||
#define ESP_BLE_MESH_MODEL_OP_OD_PRIV_PROXY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x6B)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_ODP_SRV
|
||||
*
|
||||
* @brief Define a new On-Demand Private Proxy Config Server model.
|
||||
*
|
||||
* @note The On-Demand Private Proxy Server model is used to represent the
|
||||
* ability to enable advertising with Private Network Identity type
|
||||
* of a node. This model extends the Mesh Private Beacon Server model.
|
||||
* When this model is present on an element, the corresponding
|
||||
* Solicitation PDU RPL Configuration Server model shall also be present.
|
||||
* The model shall be supported by a primary element and shall not be
|
||||
* supported by any secondary elements.
|
||||
*
|
||||
* @param srv_data Pointer to a unique On-Demand Private Proxy Config Server
|
||||
* model user_data.
|
||||
*
|
||||
* @return New On-Demand Private Proxy Config Server model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_ODP_SRV(srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_ODP_SRV, \
|
||||
NULL, NULL, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_ODP_CLI
|
||||
*
|
||||
* @brief Define a new On-Demand Private Proxy Config Client model.
|
||||
*
|
||||
* @note The model shall be supported by a primary element and shall not be
|
||||
* supported by any secondary elements.
|
||||
*
|
||||
* @param cli_data Pointer to a unique On-Demand Private Proxy Config Client
|
||||
* model user_data.
|
||||
*
|
||||
* @return New On-Demand Private Proxy Config Client model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_ODP_CLI(cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_ODP_CLI, \
|
||||
NULL, NULL, cli_data)
|
||||
|
||||
/** On-Demand Private Proxy Config Server model context */
|
||||
typedef struct {
|
||||
/** Pointer to On-Demand Private Proxy Config Server model */
|
||||
esp_ble_mesh_model_t *model;
|
||||
|
||||
/** Duration in seconds of the interval during which advertising
|
||||
* with Private Network Identity type is enabled after receiving
|
||||
* a Solicitation PDU or after a client disconnect.
|
||||
* Note: Binding with the Private GATT Proxy state.
|
||||
*/
|
||||
uint8_t on_demand_private_gatt_proxy;
|
||||
} esp_ble_mesh_odp_srv_t;
|
||||
|
||||
/** Parameter of On-Demand Private Proxy Set */
|
||||
typedef struct {
|
||||
uint8_t gatt_proxy; /*!< On-Demand Private GATT Proxy */
|
||||
} esp_ble_mesh_od_priv_proxy_set_t;
|
||||
|
||||
/**
|
||||
* @brief On-Demand Private Proxy Client model message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_od_priv_proxy_set_t od_priv_proxy_set; /*!< For ESP_BLE_MESH_MODEL_OP_OD_PRIV_PROXY_SET */
|
||||
} esp_ble_mesh_odp_client_msg_t;
|
||||
|
||||
/** Parameter of On-Demand Private Proxy Status */
|
||||
typedef struct {
|
||||
uint8_t gatt_proxy; /*!< On-Demand Private GATT Proxy */
|
||||
} esp_ble_mesh_od_priv_proxy_status_t;
|
||||
|
||||
/** Result of sending On-Demand Private Proxy Client messages */
|
||||
typedef struct {
|
||||
int err_code; /*!< Result of sending a message */
|
||||
} esp_ble_mesh_odp_client_send_cb_t;
|
||||
|
||||
/**
|
||||
* @brief On-Demand Private Proxy Client model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_od_priv_proxy_status_t od_priv_proxy_status; /*!< For ESP_BLE_MESH_MODEL_OP_OD_PRIV_PROXY_STATUS */
|
||||
} esp_ble_mesh_odp_client_recv_cb_t;
|
||||
|
||||
/** On-Demand Private Proxy Config Client model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< Client common parameters, used by all events */
|
||||
/** Union of ODP Client callback */
|
||||
union {
|
||||
esp_ble_mesh_odp_client_send_cb_t send; /*!< Result of sending a message */
|
||||
esp_ble_mesh_odp_client_recv_cb_t recv; /*!< Parameters of received status message */
|
||||
};
|
||||
} esp_ble_mesh_odp_client_cb_param_t; /*!< On-Demand Private Proxy Config Client model callback parameters */
|
||||
|
||||
/** This enum value is the event of On-Demand Private Proxy Config Client model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_ODP_CLIENT_SEND_COMP_EVT,
|
||||
ESP_BLE_MESH_ODP_CLIENT_SEND_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_ODP_CLIENT_RECV_RSP_EVT,
|
||||
ESP_BLE_MESH_ODP_CLIENT_RECV_PUB_EVT,
|
||||
ESP_BLE_MESH_ODP_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_odp_client_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief On-Demand Private Proxy Config Server model related context.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief On-Demand Private Proxy Config Server model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
uint8_t dummy; /*!< Event not used currently */
|
||||
} esp_ble_mesh_odp_server_state_change_t;
|
||||
|
||||
/**
|
||||
* @brief On-Demand Private Proxy Config Server model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_odp_server_state_change_t state_change; /*!< For ESP_BLE_MESH_ODP_SERVER_STATE_CHANGE_EVT */
|
||||
} esp_ble_mesh_odp_server_cb_value_t;
|
||||
|
||||
/** On-Demand Private Proxy Config Server model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
|
||||
esp_ble_mesh_odp_server_cb_value_t value; /*!< Value of the received configuration messages */
|
||||
} esp_ble_mesh_odp_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of On-Demand Private Proxy Config Server model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_ODP_SERVER_STATE_CHANGE_EVT,
|
||||
ESP_BLE_MESH_ODP_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_odp_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh On-Demand Private Proxy Config client and server model functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief On-Demand Private Proxy Config Client model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_odp_client_cb_t)(esp_ble_mesh_odp_client_cb_event_t event,
|
||||
esp_ble_mesh_odp_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh On-Demand Private Proxy Config Client model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_odp_client_callback(esp_ble_mesh_odp_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Get the value of On-Demand Private Proxy Config Server model state with the corresponding get message.
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] msg: Pointer to On-Demand Private Proxy Config Client message.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_odp_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_odp_client_msg_t *msg);
|
||||
|
||||
/**
|
||||
* @brief On-Demand Private Proxy Config Server model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_odp_server_cb_t)(esp_ble_mesh_odp_server_cb_event_t event,
|
||||
esp_ble_mesh_odp_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh On-Demand Private Proxy Config Server model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_odp_server_callback(esp_ble_mesh_odp_server_cb_t callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_ODP_MODEL_API_H_ */
|
||||
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_PRB_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_PRB_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BLE_MESH_MODEL_OP_PRIV_BEACON_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x60)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PRIV_BEACON_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x61)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PRIV_BEACON_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x62)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PRIV_GATT_PROXY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x63)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PRIV_GATT_PROXY_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x64)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PRIV_GATT_PROXY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x65)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PRIV_NODE_IDENTITY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x66)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PRIV_NODE_IDENTITY_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x67)
|
||||
#define ESP_BLE_MESH_MODEL_OP_PRIV_NODE_IDENTITY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x68)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_PRB_SRV
|
||||
*
|
||||
* @brief Define a new Private Beacon Server Model.
|
||||
*
|
||||
* @note The Private Beacon Server Model can only be included by a Primary Element.
|
||||
*
|
||||
* @param srv_data Pointer to a unique Private Beacon Server Model user_data.
|
||||
*
|
||||
* @return New Private Beacon Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_PRB_SRV(srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_PRB_SRV, \
|
||||
NULL, NULL, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_PRB_CLI
|
||||
*
|
||||
* @brief Define a new Private Beacon Client Model.
|
||||
*
|
||||
* @note The Private Beacon Client Model can only be included by a Primary Element.
|
||||
*
|
||||
* @param cli_data Pointer to a unique struct esp_ble_mesh_client_t.
|
||||
*
|
||||
* @return New Private Beacon Client Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_PRB_CLI(cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_PRB_CLI, \
|
||||
NULL, NULL, cli_data)
|
||||
|
||||
/** Private Beacon Server Model context */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to Private Beacon Server Model */
|
||||
|
||||
uint8_t private_beacon; /*!< Value of Private Beacon state */
|
||||
uint8_t random_update_interval; /*!< Value of Random Update Interval Steps state */
|
||||
uint8_t private_gatt_proxy; /*!< Value of Private GATT Proxy state */
|
||||
|
||||
struct k_delayed_work update_timer; /*!< Timer for update the random field of private beacon */
|
||||
} esp_ble_mesh_prb_srv_t;
|
||||
|
||||
/** Parameter of private Beacon Set */
|
||||
typedef struct {
|
||||
uint8_t private_beacon; /*!< New Private Beacon state */
|
||||
bool is_effect; /*!< Decide if update_interval exists */
|
||||
uint8_t update_interval; /*!< New Random Update Interval Steps state */
|
||||
} esp_ble_mesh_priv_beacon_set_t;
|
||||
|
||||
/** Parameter of Private GATT Proxy Set */
|
||||
typedef struct {
|
||||
uint8_t private_gatt_proxy; /*!< New Private GATT Proxy state */
|
||||
} esp_ble_mesh_priv_gatt_proxy_set_t;
|
||||
|
||||
/** Parameter of Private node identity Get */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< Index of the NetKey */
|
||||
} esp_ble_mesh_priv_node_id_get_t;
|
||||
|
||||
/** Parameter of Private node identity Set */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< Index of the NetKey */
|
||||
uint8_t private_node_id; /*!< New Private Node Identity state */
|
||||
} esp_ble_mesh_priv_node_id_set_t;
|
||||
|
||||
/**
|
||||
* @brief Mesh Private Beacon Client model message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_priv_beacon_set_t priv_beacon_set; /*!< ESP_BLE_MESH_MODEL_OP_PRIV_BEACON_SET. */
|
||||
esp_ble_mesh_priv_gatt_proxy_set_t priv_gatt_proxy_set; /*!< ESP_BLE_MESH_MODEL_OP_PRIV_GATT_PROXY_SET. */
|
||||
esp_ble_mesh_priv_node_id_get_t priv_node_id_get; /*!< ESP_BLE_MESH_MODEL_OP_PRIV_NODE_IDENTITY_GET. */
|
||||
esp_ble_mesh_priv_node_id_set_t priv_node_id_set; /*!< ESP_BLE_MESH_MODEL_OP_PRIV_NODE_IDENTITY_SET. */
|
||||
} esp_ble_mesh_prb_client_msg_t;
|
||||
|
||||
/** Parameter of Private Beacon Status */
|
||||
typedef struct {
|
||||
uint8_t private_beacon; /*!< Current value of the Private Beacon state */
|
||||
uint8_t update_interval; /*!< Current value of the Random Update Interval Steps state */
|
||||
} esp_ble_mesh_priv_beacon_status_cb_t;
|
||||
|
||||
/** Parameter of Private GATT Proxy Status */
|
||||
typedef struct {
|
||||
uint8_t private_gatt_proxy; /*!< Private GATT Proxy state */
|
||||
} esp_ble_mesh_priv_gatt_proxy_status_cb_t;
|
||||
|
||||
/** Parameters of Private Node Identity Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the requesting message */
|
||||
uint16_t net_idx; /*!< Index of the NetKey */
|
||||
uint8_t private_node_id; /*!< Private Node Identity state */
|
||||
} esp_ble_mesh_priv_node_identity_status_cb_t;
|
||||
|
||||
/**
|
||||
* @brief Private Beacon Client Model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_priv_beacon_status_cb_t priv_beacon_status; /*!< The private beacon status value */
|
||||
esp_ble_mesh_priv_gatt_proxy_status_cb_t priv_gatt_proxy_status; /*!< The private gatt proxy status value */
|
||||
esp_ble_mesh_priv_node_identity_status_cb_t priv_node_id_status; /*!< The private node identity status value */
|
||||
} esp_ble_mesh_prb_client_recv_cb_t;
|
||||
|
||||
/** Result of sending Bridge Configuration Client messages */
|
||||
typedef struct {
|
||||
int err_code; /*!< Result of sending a message */
|
||||
} esp_ble_mesh_prb_client_send_cb_t;
|
||||
|
||||
/** Mesh Private Beacon Client Model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */
|
||||
/** Union of Private Beacon Client callback */
|
||||
union {
|
||||
esp_ble_mesh_prb_client_send_cb_t send; /*!< Result of sending a message */
|
||||
esp_ble_mesh_prb_client_recv_cb_t recv; /*!< The private beacon message status callback values */
|
||||
};
|
||||
} esp_ble_mesh_prb_client_cb_param_t; /*!< Mesh Private Beacon Client Model callback parameters */
|
||||
|
||||
/** This enum value is the event of Private Beacon Client Model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_PRB_CLIENT_SEND_COMP_EVT,
|
||||
ESP_BLE_MESH_PRB_CLIENT_SEND_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_PRB_CLIENT_RECV_RSP_EVT,
|
||||
ESP_BLE_MESH_PRB_CLIENT_RECV_PUB_EVT,
|
||||
ESP_BLE_MESH_PRB_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_prb_client_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Mesh Private Beacon Server model related context.
|
||||
*/
|
||||
/** Parameters of Private Beacon Set. */
|
||||
typedef struct {
|
||||
uint8_t private_beacon; /*!< Private Beacon state */
|
||||
bool is_effect; /*!< Decide whether update_interval effect */
|
||||
uint8_t update_interval; /*!< Random Update Interval Steps state */
|
||||
} esp_ble_mesh_state_change_priv_beacon_set_t;
|
||||
|
||||
/** Parameters of Private GATT Proxy Set. */
|
||||
typedef struct {
|
||||
uint8_t private_gatt_proxy; /*!< Private GATT Proxy state */
|
||||
} esp_ble_mesh_state_change_priv_gatt_proxy_set_t;
|
||||
|
||||
/** Parameters of Private Node Identity Set. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< Index of the NetKey */
|
||||
uint8_t private_node_id; /*!< Private Node Identity state */
|
||||
} esp_ble_mesh_state_change_priv_node_id_set_t;
|
||||
|
||||
/**
|
||||
* @brief Mesh Private Beacon Server model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* The recv_op in ctx can be used to decide which state is changed.
|
||||
*/
|
||||
esp_ble_mesh_state_change_priv_beacon_set_t priv_beacon_set; /*!< Private Beacon Set */
|
||||
esp_ble_mesh_state_change_priv_gatt_proxy_set_t priv_gatt_proxy_set; /*!< Private GATT Proxy Set */
|
||||
esp_ble_mesh_state_change_priv_node_id_set_t priv_node_id_set; /*!< Private Node Identity Set */
|
||||
} esp_ble_mesh_prb_server_state_change_t;
|
||||
|
||||
/**
|
||||
* @brief Private Beacon Server model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_prb_server_state_change_t state_change; /*!< ESP_BLE_MESH_PRB_SERVER_STATE_CHANGE_EVT */
|
||||
} esp_ble_mesh_prb_server_cb_value_t;
|
||||
|
||||
/** Private Beacon Server model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
|
||||
esp_ble_mesh_prb_server_cb_value_t value; /*!< Value of the received private beacon messages */
|
||||
} esp_ble_mesh_prb_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Private Beacon Server model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_PRB_SERVER_STATE_CHANGE_EVT,
|
||||
ESP_BLE_MESH_PRB_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_prb_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Private Beacon Client and Server Model functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Private Beacon Client Model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_prb_client_cb_t)(esp_ble_mesh_prb_client_cb_event_t event,
|
||||
esp_ble_mesh_prb_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Private Beacon Server Model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_prb_server_cb_t)(esp_ble_mesh_prb_server_cb_event_t event,
|
||||
esp_ble_mesh_prb_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Private Beacon Client Model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_prb_client_callback(esp_ble_mesh_prb_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Private Beacon Server Model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_prb_server_callback(esp_ble_mesh_prb_server_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Get/Set the value of Private Beacon Server Model states using the corresponding messages of Private Beacon Client Model.
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] msg: Pointer to Mesh Private Beacon Client message.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_prb_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_prb_client_msg_t *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_PRB_MODEL_API_H_ */
|
||||
@@ -0,0 +1,481 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_RPR_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_RPR_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_SCAN_CAPS_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4F)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_SCAN_CAPS_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x50)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_SCAN_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x51)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_SCAN_START ESP_BLE_MESH_MODEL_OP_2(0x80, 0x52)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_SCAN_STOP ESP_BLE_MESH_MODEL_OP_2(0x80, 0x53)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_SCAN_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x54)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_SCAN_REPORT ESP_BLE_MESH_MODEL_OP_2(0x80, 0x55)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_EXT_SCAN_START ESP_BLE_MESH_MODEL_OP_2(0x80, 0x56)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_EXT_SCAN_REPORT ESP_BLE_MESH_MODEL_OP_2(0x80, 0x57)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_LINK_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x58)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_LINK_OPEN ESP_BLE_MESH_MODEL_OP_2(0x80, 0x59)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_LINK_CLOSE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x5A)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_LINK_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x5B)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_LINK_REPORT ESP_BLE_MESH_MODEL_OP_2(0x80, 0x5C)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_PDU_SEND ESP_BLE_MESH_MODEL_OP_2(0x80, 0x5D)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_PDU_OUTBOUND_REPORT ESP_BLE_MESH_MODEL_OP_2(0x80, 0x5E)
|
||||
#define ESP_BLE_MESH_MODEL_OP_RPR_PDU_REPORT ESP_BLE_MESH_MODEL_OP_2(0x80, 0x5F)
|
||||
|
||||
#define ESP_BLE_MESH_RPR_SRV_MAX_SCANNED_ITEMS_MIN 0x04
|
||||
|
||||
#define ESP_BLE_MESH_RPR_NOT_SUPPORT_ACTIVE_SCAN 0x00
|
||||
#define ESP_BLE_MESH_RPR_SUPPORT_ACTIVE_SCAN 0x01
|
||||
|
||||
#define ESP_BLE_MESH_RPR_SCAN_IDLE 0x00
|
||||
#define ESP_BLE_MESH_RPR_SCAN_MULTIPLE_DEVICE 0x01
|
||||
#define ESP_BLE_MESH_RPR_SCAN_SINGLE_DEVICE 0x02
|
||||
|
||||
#define ESP_BLE_MESH_RPR_SCAN_NOT_IN_PROGRESS 0x00
|
||||
|
||||
#define ESP_BLE_MESH_RPR_PROHIBIT_SCAN_TIMEOUT 0x00
|
||||
|
||||
#define ESP_BLE_MESH_RPR_EXT_SCAN_TIMEOUT_MIN 0x01
|
||||
#define ESP_BLE_MESH_RPR_EXT_SCAN_TIMEOUT_MAX 0x15
|
||||
|
||||
#define ESP_BLE_MESH_RPR_AD_TYPE_FILTER_CNT_MIN 0x01
|
||||
#define ESP_BLE_MESH_RPR_AD_TYPE_FILTER_CNT_MAX 0x10
|
||||
|
||||
#define ESP_BLE_MESH_RPR_LINK_OPEN_TIMEOUT_MIN 0x01
|
||||
#define ESP_BLE_MESH_RPR_LINK_OPEN_TIMEOUT_MAX 0x3C
|
||||
|
||||
/* The default value of the Timeout parameter is 10 seconds */
|
||||
#define ESP_BLE_MESH_RPR_LINK_TIMEOUT_DEFAULT 0x0A
|
||||
|
||||
#define ESP_BLE_MESH_RPR_REASON_SUCCESS 0x00
|
||||
#define ESP_BLE_MESH_RPR_REASON_FAIL 0x02
|
||||
|
||||
#define ESP_BLE_MESH_RPR_LINK_IDLE 0x00
|
||||
#define ESP_BLE_MESH_RPR_LINK_OPENING 0x01
|
||||
#define ESP_BLE_MESH_RPR_LINK_ACTIVE 0x02
|
||||
#define ESP_BLE_MESH_RPR_OUTBOUND_PACKET_TRANSFER 0x03
|
||||
#define ESP_BLE_MESH_RPR_LINK_CLOSING 0x04
|
||||
|
||||
#define ESP_BLE_MESH_RPR_STATUS_SUCCESS 0x00
|
||||
#define ESP_BLE_MESH_RPR_STATUS_SCANNING_CANNOT_START 0x01
|
||||
#define ESP_BLE_MESH_RPR_STATUS_INVALID_STATE 0x02
|
||||
#define ESP_BLE_MESH_RPR_STATUS_LIMITED_RESOURCES 0x03
|
||||
#define ESP_BLE_MESH_RPR_STATUS_LINK_CANNOT_OPEN 0x04
|
||||
#define ESP_BLE_MESH_RPR_STATUS_LINK_OPEN_FAILED 0x05
|
||||
#define ESP_BLE_MESH_RPR_STATUS_LINK_CLOSED_BY_DEVICE 0x06
|
||||
#define ESP_BLE_MESH_RPR_STATUS_LINK_CLOSED_BY_SERVER 0x07
|
||||
#define ESP_BLE_MESH_RPR_STATUS_LINK_CLOSED_BY_CLIENT 0x08
|
||||
#define ESP_BLE_MESH_RPR_STATUS_LINK_CLOSED_AS_CANNOT_RECEIVE_PDU 0x09
|
||||
#define ESP_BLE_MESH_RPR_STATUS_LINK_CLOSED_AS_CANNOT_SEND_PDU 0x0A
|
||||
#define ESP_BLE_MESH_RPR_STATUS_LINK_CLOSED_AS_CANNOT_DELIVER_PDU_REPORT 0x0B
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_RPR_SRV
|
||||
*
|
||||
* @brief Define a new Remote Provisioning Server model.
|
||||
*
|
||||
* @note If supported, the model shall be supported by a primary element
|
||||
* and may be supported by any secondary element.
|
||||
*
|
||||
* @param srv_data Pointer to a unique Remote Provisioning Server model
|
||||
* user_data.
|
||||
*
|
||||
* @return New Remote Provisioning Server model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_RPR_SRV(srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_RPR_SRV, \
|
||||
NULL, NULL, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_RPR_CLI
|
||||
*
|
||||
* @brief Define a new Remote Provisioning Client model.
|
||||
*
|
||||
* @note If supported, the model shall be supported by a primary element
|
||||
* and may be supported by any secondary element.
|
||||
*
|
||||
* @param cli_data Pointer to a unique Remote Provisioning Client model
|
||||
* user_data.
|
||||
*
|
||||
* @return New Remote Provisioning Client model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_RPR_CLI(cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_RPR_CLI, \
|
||||
NULL, NULL, cli_data)
|
||||
|
||||
/** Remote Provisioning Server model context */
|
||||
/* typedef struct {
|
||||
* void *dummy;
|
||||
* } esp_ble_mesh_rpr_srv_t;
|
||||
*/
|
||||
|
||||
/** Parameters of Remote Provisioning Scan Start */
|
||||
typedef struct {
|
||||
uint8_t scan_items_limit; /*!< Maximum number of scanned items to be reported */
|
||||
uint8_t timeout; /*!< Time limit for a scan (in seconds) */
|
||||
|
||||
bool uuid_en; /*!< Indicate if Device UUID is present */
|
||||
uint8_t uuid[16]; /*!< Device UUID (Optional) */
|
||||
} esp_ble_mesh_rpr_scan_start_t;
|
||||
|
||||
/** Parameters of Remote Provisioning Extended Scan Start */
|
||||
typedef struct {
|
||||
uint8_t ad_type_filter_count; /*!< Number of AD Types in the ADTypeFilter field */
|
||||
uint8_t ad_type_filter[16]; /*!< List of AD Types to be reported. Minimum is 1, maximum is 16 */
|
||||
|
||||
bool uuid_en; /*!< Indicate if Device UUID is present */
|
||||
uint8_t uuid[16]; /*!< Device UUID (Optional) */
|
||||
uint8_t timeout; /*!< Time limit for a scan (in seconds) (C.1) */
|
||||
} esp_ble_mesh_rpr_ext_scan_start_t;
|
||||
|
||||
/** Parameters of Remote Provisioning Link Open */
|
||||
typedef struct {
|
||||
bool uuid_en; /*!< Indicate if Device UUID is present */
|
||||
uint8_t uuid[16]; /*!< Device UUID (Optional) */
|
||||
|
||||
bool timeout_en; /*!< Indicate if Link open timeout is present */
|
||||
uint8_t timeout; /*!< Link open timeout in seconds (C.1) */
|
||||
|
||||
uint8_t nppi; /*!< Node Provisioning Protocol Interface (C.2) */
|
||||
} esp_ble_mesh_rpr_link_open_t;
|
||||
|
||||
/** Parameters of Remote Provisioning Link Close */
|
||||
typedef struct {
|
||||
uint8_t reason; /*!< Provisioning bearer link close reason code */
|
||||
} esp_ble_mesh_rpr_link_close_t;
|
||||
|
||||
/**
|
||||
* @brief Remote Provisioning Client model message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_rpr_scan_start_t scan_start; /*!< For ESP_BLE_MESH_MODEL_OP_RPR_SCAN_START */
|
||||
esp_ble_mesh_rpr_ext_scan_start_t ext_scan_start; /*!< For ESP_BLE_MESH_MODEL_OP_RPR_EXT_SCAN_START */
|
||||
esp_ble_mesh_rpr_link_open_t link_open; /*!< For ESP_BLE_MESH_MODEL_OP_RPR_LINK_OPEN */
|
||||
esp_ble_mesh_rpr_link_close_t link_close; /*!< For ESP_BLE_MESH_MODEL_OP_RPR_LINK_CLOSE */
|
||||
} esp_ble_mesh_rpr_client_msg_t;
|
||||
|
||||
/** This enum value is the action of Remote Provisioning Client model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_RPR_CLIENT_ACT_START_RPR,
|
||||
ESP_BLE_MESH_RPR_CLIENT_ACT_MAX,
|
||||
} esp_ble_mesh_rpr_client_act_type_t;
|
||||
|
||||
/** Parameters of starting remote provisioning */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer of Remote Provisioning Client */
|
||||
uint16_t rpr_srv_addr; /*!< Unicast address of Remote Provisioning Server */
|
||||
} esp_ble_mesh_rpr_client_start_rpr_t;
|
||||
|
||||
/**
|
||||
* @brief Remote Provisioning Client model action union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_rpr_client_start_rpr_t start_rpr; /*!< Start remote provisioning */
|
||||
} esp_ble_mesh_rpr_client_act_param_t;
|
||||
|
||||
/** Parameters of Remote Provisioning Scan Capabilities Status */
|
||||
typedef struct {
|
||||
uint8_t max_scan_items; /*!< The maximum number of UUIDs that can be reported during scanning */
|
||||
uint8_t active_scan; /*!< Indication if active scan is supported */
|
||||
} esp_ble_mesh_rpr_scan_caps_status_t;
|
||||
|
||||
/** Parameters of Remote Provisioning Scan Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status for the requesting message */
|
||||
uint8_t rpr_scanning; /*!< The Remote Provisioning Scan state value */
|
||||
uint8_t scan_items_limit; /*!< Maximum number of scanned items to be reported */
|
||||
uint8_t timeout; /*!< Time limit for a scan (in seconds) */
|
||||
} esp_ble_mesh_rpr_scan_status_t;
|
||||
|
||||
/** Parameters of Remote Provisioning Scan Report */
|
||||
typedef struct {
|
||||
int8_t rssi; /*!< An indication of received signal strength measured in dBm */
|
||||
uint8_t uuid[16]; /*!< Device UUID */
|
||||
uint16_t oob_info; /*!< OOB information */
|
||||
uint32_t uri_hash; /*!< URI Hash (Optional) */
|
||||
} esp_ble_mesh_rpr_scan_report_t;
|
||||
|
||||
/** Parameters of Remote Provisioning Extended Scan Report */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status for the requesting message */
|
||||
uint8_t uuid[16]; /*!< Device UUID */
|
||||
|
||||
bool oob_info_en; /*!< Indicate if OOB Information is present */
|
||||
uint16_t oob_info; /*!< OOB Information (Optional) */
|
||||
struct net_buf_simple *adv_structures; /*!< Concatenated list of AD Structures (C.1) */
|
||||
} esp_ble_mesh_rpr_ext_scan_report_t;
|
||||
|
||||
/** Parameters of Remote Provisioning Link Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status for the requesting message */
|
||||
uint8_t rpr_state; /*!< Remote Provisioning Link state */
|
||||
} esp_ble_mesh_rpr_link_status_t;
|
||||
|
||||
/** Parameters of Remote Provisioning Link Report */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status of the provisioning bearer or the NPPI */
|
||||
uint8_t rpr_state; /*!< Remote Provisioning Link state */
|
||||
bool reason_en; /*!< Indicate if Link close Reason code is present */
|
||||
uint8_t reason; /*!< Link close Reason code (Optional) */
|
||||
} esp_ble_mesh_rpr_link_report_t;
|
||||
|
||||
/**
|
||||
* @brief Remote Provisioning Client model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_rpr_scan_caps_status_t scan_caps_status; /*!< For ESP_BLE_MESH_MODEL_OP_RPR_SCAN_CAPS_STATUS */
|
||||
esp_ble_mesh_rpr_scan_status_t scan_status; /*!< For ESP_BLE_MESH_MODEL_OP_RPR_SCAN_STATUS */
|
||||
esp_ble_mesh_rpr_scan_report_t scan_report; /*!< For ESP_BLE_MESH_MODEL_OP_RPR_SCAN_REPORT */
|
||||
esp_ble_mesh_rpr_ext_scan_report_t ext_scan_report; /*!< For ESP_BLE_MESH_MODEL_OP_RPR_EXT_SCAN_REPORT */
|
||||
esp_ble_mesh_rpr_link_status_t link_status; /*!< For ESP_BLE_MESH_MODEL_OP_RPR_LINK_STATUS */
|
||||
esp_ble_mesh_rpr_link_report_t link_report; /*!< For ESP_BLE_MESH_MODEL_OP_RPR_LINK_REPORT */
|
||||
} esp_ble_mesh_rpr_client_recv_cb_t;
|
||||
|
||||
/** This enum value is the event type of the performed action */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_START_RPR_COMP_SUB_EVT,
|
||||
} esp_ble_mesh_rpr_client_act_evt_t;
|
||||
|
||||
/** Remote Provisioning Client model callback parameters */
|
||||
typedef union {
|
||||
/** Event parameters of sending messages */
|
||||
struct {
|
||||
int err_code; /*!< Result of sending a message */
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< Client common parameters */
|
||||
} send; /*!< Event parameters of sending messages */
|
||||
/** Event parameters of receiving messages */
|
||||
struct {
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< Client common parameters */
|
||||
esp_ble_mesh_rpr_client_recv_cb_t val; /*!< Parameters of received status message */
|
||||
} recv; /*!< Event parameters of receiving messages */
|
||||
/** Event parameters of performed actions */
|
||||
struct {
|
||||
esp_ble_mesh_rpr_client_act_evt_t sub_evt; /*!< Event type of the performed action */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_START_RPR_COMP_SUB_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Result of starting remote provisioning */
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer of Remote Provisioning Client */
|
||||
uint16_t rpr_srv_addr; /*!< Unicast address of Remote Provisioning Server */
|
||||
} start_rpr_comp; /*!< Event parameter of ESP_BLE_MESH_START_RPR_COMP_SUB_EVT */
|
||||
} act; /*!< Event parameters of performed actions */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_RPR_CLIENT_LINK_OPEN_EVT
|
||||
*/
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer of Remote Provisioning Client */
|
||||
uint16_t rpr_srv_addr; /*!< Unicast address of Remote Provisioning Server */
|
||||
} link_open; /*!< Event parameters of ESP_BLE_MESH_RPR_CLIENT_LINK_OPEN_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_RPR_CLIENT_LINK_CLOSE_EVT
|
||||
*/
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer of Remote Provisioning Client */
|
||||
uint16_t rpr_srv_addr; /*!< Unicast address of Remote Provisioning Server */
|
||||
uint8_t reason; /*!< Reason of closing provisioning link */
|
||||
} link_close; /*!< Event parameters of ESP_BLE_MESH_RPR_CLIENT_LINK_CLOSE_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_RPR_CLIENT_PROV_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer of Remote Provisioning Client */
|
||||
uint16_t rpr_srv_addr; /*!< Unicast address of Remote Provisioning Server */
|
||||
uint8_t nppi; /*!< NPPI Procedure */
|
||||
uint16_t index; /*!< Index of the provisioned node */
|
||||
uint8_t uuid[16]; /*!< Device UUID */
|
||||
uint16_t unicast_addr; /*!< Primary element address */
|
||||
uint8_t element_num; /*!< Element number */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
} prov; /*!< Event parameters of ESP_BLE_MESH_RPR_CLIENT_PROV_COMP_EVT */
|
||||
} esp_ble_mesh_rpr_client_cb_param_t; /*!< Remote Provisioning Client model callback parameters */
|
||||
|
||||
/** This enum value is the event of Remote Provisioning Client model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_RPR_CLIENT_SEND_COMP_EVT,
|
||||
ESP_BLE_MESH_RPR_CLIENT_SEND_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_RPR_CLIENT_RECV_RSP_EVT,
|
||||
ESP_BLE_MESH_RPR_CLIENT_RECV_PUB_EVT,
|
||||
ESP_BLE_MESH_RPR_CLIENT_ACT_COMP_EVT,
|
||||
ESP_BLE_MESH_RPR_CLIENT_LINK_OPEN_EVT,
|
||||
ESP_BLE_MESH_RPR_CLIENT_LINK_CLOSE_EVT,
|
||||
ESP_BLE_MESH_RPR_CLIENT_PROV_COMP_EVT,
|
||||
ESP_BLE_MESH_RPR_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_rpr_client_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Remote Provisioning Server model related context.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Remote Provisioning Server model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_RPR_SERVER_SCAN_START_EVT
|
||||
*/
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
uint8_t scan_items_limit; /*!< Maximum number of scanned items to be reported */
|
||||
uint8_t timeout; /*!< Time limit for a scan (in seconds) */
|
||||
uint8_t uuid[16]; /*!< Device UUID (All ZERO if not present) */
|
||||
uint16_t net_idx; /*!< NetKey Index used by Remote Provisioning Client */
|
||||
uint16_t rpr_cli_addr; /*!< Unicast address of Remote Provisioning Client */
|
||||
} scan_start;
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_RPR_SERVER_SCAN_STOP_EVT
|
||||
*/
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
uint8_t uuid[16]; /*!< Device UUID (All ZERO if not present) */
|
||||
uint16_t net_idx; /*!< NetKey Index used by Remote Provisioning Client */
|
||||
uint16_t rpr_cli_addr; /*!< Unicast address of Remote Provisioning Client */
|
||||
} scan_stop;
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_RPR_SERVER_EXT_SCAN_START_EVT
|
||||
*/
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
uint8_t ad_type_filter_count; /*!< Number of AD Types in the ADTypeFilter field */
|
||||
uint8_t *ad_type_filter; /*!< List of AD Types to be reported */
|
||||
uint8_t uuid[16]; /*!< Device UUID (All ZERO if not present) */
|
||||
uint8_t timeout; /*!< Time limit for a scan (in seconds) */
|
||||
uint8_t index; /*!< Index of the extended scan instance */
|
||||
uint16_t net_idx; /*!< NetKey Index used by Remote Provisioning Client */
|
||||
uint16_t rpr_cli_addr; /*!< Unicast address of Remote Provisioning Client */
|
||||
} ext_scan_start;
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_RPR_SERVER_EXT_SCAN_STOP_EVT
|
||||
*/
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
uint8_t uuid[16]; /*!< Device UUID (ZERO if not present)*/
|
||||
uint8_t timeout; /*!< Time limit for extended scan (in seconds) */
|
||||
uint8_t index; /*!< Index of the extended scan instance */
|
||||
uint16_t net_idx; /*!< NetKey Index used by Remote Provisioning Client */
|
||||
uint16_t rpr_cli_addr; /*!< Unicast address of Remote Provisioning Client */
|
||||
} ext_scan_stop;
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_RPR_SERVER_LINK_OPEN_EVT
|
||||
*/
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
uint8_t uuid[16]; /*!< Device UUID (ZERO if not present)*/
|
||||
uint8_t status; /*!< Status of Link Open procedure */
|
||||
uint8_t timeout; /*!< Time limit for opening a link (in seconds) */
|
||||
uint8_t nppi; /*!< Node Provisioning Protocol Interface */
|
||||
uint16_t net_idx; /*!< NetKey Index used by Remote Provisioning Client */
|
||||
uint16_t rpr_cli_addr; /*!< Unicast address of Remote Provisioning Client */
|
||||
} link_open;
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_RPR_SERVER_LINK_CLOSE_EVT
|
||||
*/
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
uint8_t uuid[16]; /*!< Device UUID (ZERO if not present)*/
|
||||
uint8_t nppi; /*!< Node Provisioning Protocol Interface */
|
||||
bool close_by_device; /*!< Indicate if the link is closed by the Unprovisioned Device */
|
||||
uint8_t reason; /*!< Provisioning bearer link close reason code */
|
||||
uint16_t net_idx; /*!< NetKey Index used by Remote Provisioning Client */
|
||||
uint16_t rpr_cli_addr; /*!< Unicast address of Remote Provisioning Client */
|
||||
} link_close;
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_RPR_SERVER_PROV_COMP_EVT. TODO: Duplicate with Link Close event?
|
||||
*/
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
uint8_t uuid[16]; /*!< Device UUID (ZERO if not present)*/
|
||||
uint8_t nppi; /*!< Provisioning bearer link close reason code */
|
||||
uint16_t net_idx; /*!< NetKey Index used by Remote Provisioning Client */
|
||||
uint16_t rpr_cli_addr; /*!< Unicast address of Remote Provisioning Client */
|
||||
} prov_comp;
|
||||
} esp_ble_mesh_rpr_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Remote Provisioning Server model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_RPR_SERVER_SCAN_START_EVT,
|
||||
ESP_BLE_MESH_RPR_SERVER_SCAN_STOP_EVT,
|
||||
ESP_BLE_MESH_RPR_SERVER_EXT_SCAN_START_EVT,
|
||||
ESP_BLE_MESH_RPR_SERVER_EXT_SCAN_STOP_EVT,
|
||||
ESP_BLE_MESH_RPR_SERVER_LINK_OPEN_EVT,
|
||||
ESP_BLE_MESH_RPR_SERVER_LINK_CLOSE_EVT,
|
||||
ESP_BLE_MESH_RPR_SERVER_PROV_COMP_EVT,
|
||||
ESP_BLE_MESH_RPR_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_rpr_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Remote Provisioning client and server model functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Remote Provisioning Client model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_rpr_client_cb_t)(esp_ble_mesh_rpr_client_cb_event_t event,
|
||||
esp_ble_mesh_rpr_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Remote Provisioning Client model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_rpr_client_callback(esp_ble_mesh_rpr_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Get the value of Remote Provisioning Server model state with the corresponding get message.
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] msg: Pointer to Remote Provisioning Client message.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_rpr_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_rpr_client_msg_t *msg);
|
||||
|
||||
/**
|
||||
* @brief Remote Provisioning Client model perform related actions, e.g. start remote provisioning.
|
||||
*
|
||||
* @param[in] type: Type of the action to be performed.
|
||||
* @param[in] param: Parameters of the action to be performed.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_rpr_client_action(esp_ble_mesh_rpr_client_act_type_t type,
|
||||
esp_ble_mesh_rpr_client_act_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Remote Provisioning Server model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_rpr_server_cb_t)(esp_ble_mesh_rpr_server_cb_event_t event,
|
||||
esp_ble_mesh_rpr_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Remote Provisioning Server model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_rpr_server_callback(esp_ble_mesh_rpr_server_cb_t callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_RPR_MODEL_API_H_ */
|
||||
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_SAR_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_SAR_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BLE_MESH_MODEL_OP_SAR_TRANSMITTER_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x6C)
|
||||
#define ESP_BLE_MESH_MODEL_OP_SAR_TRANSMITTER_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x6D)
|
||||
#define ESP_BLE_MESH_MODEL_OP_SAR_TRANSMITTER_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x6E)
|
||||
#define ESP_BLE_MESH_MODEL_OP_SAR_RECEIVER_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x6F)
|
||||
#define ESP_BLE_MESH_MODEL_OP_SAR_RECEIVER_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x70)
|
||||
#define ESP_BLE_MESH_MODEL_OP_SAR_RECEIVER_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x71)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SAR_SRV
|
||||
*
|
||||
* @brief Define a new SAR Configuration Server model.
|
||||
*
|
||||
* @note If supported, the model shall be supported by a primary element
|
||||
* and shall not be supported by any secondary elements.
|
||||
*
|
||||
* @param srv_data Pointer to a unique SAR Configuration Server model user_data.
|
||||
*
|
||||
* @return New SAR Configuration Server model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SAR_SRV(srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SAR_SRV, \
|
||||
NULL, NULL, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SAR_CLI
|
||||
*
|
||||
* @brief Define a new SAR Configuration Client model.
|
||||
*
|
||||
* @note If supported, the model shall be supported by the primary element
|
||||
* and shall not be supported by any secondary elements.
|
||||
*
|
||||
* @param cli_data Pointer to a unique SAR Configuration Client model user_data.
|
||||
*
|
||||
* @return New SAR Configuration Client model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SAR_CLI(cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SAR_CLI, \
|
||||
NULL, NULL, cli_data)
|
||||
|
||||
/** SAR Configuration Server model context */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to SAR Configuration Server model */
|
||||
} esp_ble_mesh_sar_srv_t;
|
||||
|
||||
/** Parameters of SAR Transmitter Set */
|
||||
typedef struct {
|
||||
uint8_t sar_segment_interval_step:4, /*!< SAR Segment Interval Step state value */
|
||||
sar_unicast_retrans_count:4; /*!< SAR Unicast Retransmissions Count state */
|
||||
uint8_t sar_unicast_retrans_without_progress_count:4, /*!< SAR Unicast Retransmissions Without Progress Count state */
|
||||
sar_unicast_retrans_interval_step:4; /*!< SAR Unicast Retransmissions Interval Step state */
|
||||
uint8_t sar_unicast_retrans_interval_increment:4, /*!< SAR Unicast Retransmissions Interval Increment state */
|
||||
sar_multicast_retrans_count:4; /*!< SAR Multicast Retransmissions Count state */
|
||||
uint8_t sar_multicast_retrans_interval_step:4; /*!< SAR Multicast Retransmissions Interval state */
|
||||
} esp_ble_mesh_sar_transmitter_set_t;
|
||||
|
||||
/** Parameters of SAR Receiver Set */
|
||||
typedef struct {
|
||||
uint8_t sar_segments_threshold:5, /*!< SAR Segments Threshold state */
|
||||
sar_ack_delay_increment:3; /*!< SAR Acknowledgment Delay Increment state */
|
||||
uint8_t sar_discard_timeout:4, /*!< SAR Discard Timeout state */
|
||||
sar_receiver_segment_interval_step:4; /*!< SAR Receiver Segment Interval Step state */
|
||||
uint8_t sar_ack_retrans_count:4; /*!< SAR Acknowledgment Retransmissions Count state */
|
||||
} esp_ble_mesh_sar_receiver_set_t;
|
||||
|
||||
/**
|
||||
* @brief SAR Configuration Client model message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_sar_transmitter_set_t sar_transmitter_set; /*!< For ESP_BLE_MESH_MODEL_OP_SAR_TRANSMITTER_SET */
|
||||
esp_ble_mesh_sar_receiver_set_t sar_receiver_set; /*!< For ESP_BLE_MESH_MODEL_OP_SAR_RECEIVER_SET */
|
||||
} esp_ble_mesh_sar_client_msg_t;
|
||||
|
||||
/** Parameters of SAR Transmitter Status */
|
||||
typedef struct {
|
||||
uint8_t sar_segment_interval_step:4, /*!< SAR Segment Interval Step state value */
|
||||
sar_unicast_retrans_count:4; /*!< SAR Unicast Retransmissions Count state */
|
||||
uint8_t sar_unicast_retrans_without_progress_count:4, /*!< SAR Unicast Retransmissions Without Progress Count state */
|
||||
sar_unicast_retrans_interval_step:4; /*!< SAR Unicast Retransmissions Interval Step state */
|
||||
uint8_t sar_unicast_retrans_interval_increment:4, /*!< SAR Unicast Retransmissions Interval Increment state */
|
||||
sar_multicast_retrans_count:4; /*!< SAR Multicast Retransmissions Count state */
|
||||
uint8_t sar_multicast_retrans_interval_step:4; /*!< SAR Multicast Retransmissions Interval state */
|
||||
} esp_ble_mesh_sar_transmitter_status_t;
|
||||
|
||||
/** Parameters of SAR Receiver Status */
|
||||
typedef struct {
|
||||
uint8_t sar_segments_threshold:5, /*!< SAR Segments Threshold state */
|
||||
sar_ack_delay_increment:3; /*!< SAR Acknowledgment Delay Increment state */
|
||||
uint8_t sar_discard_timeout:4, /*!< SAR Discard Timeout state */
|
||||
sar_receiver_segment_interval_step:4; /*!< SAR Receiver Segment Interval Step state */
|
||||
uint8_t sar_ack_retrans_count:4; /*!< SAR Acknowledgment Retransmissions Count state */
|
||||
} esp_ble_mesh_sar_receiver_status_t;
|
||||
|
||||
/** Result of sending SAR Configuration Client messages */
|
||||
typedef struct {
|
||||
int err_code; /*!< Result of sending a message */
|
||||
} esp_ble_mesh_sar_client_send_cb_t;
|
||||
|
||||
/**
|
||||
* @brief SAR Configuration Client model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_sar_transmitter_status_t sar_transmitter_status; /*!< For ESP_BLE_MESH_MODEL_OP_SAR_TRANSMITTER_STATUS */
|
||||
esp_ble_mesh_sar_receiver_status_t sar_receiver_status; /*!< For ESP_BLE_MESH_MODEL_OP_SAR_RECEIVE_STATUS */
|
||||
} esp_ble_mesh_sar_client_recv_cb_t;
|
||||
|
||||
/** SAR Configuration Client model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< Client common parameters, used by all events. */
|
||||
/** Union of SAR Client callback */
|
||||
union {
|
||||
esp_ble_mesh_sar_client_send_cb_t send; /*!< Result of sending a message */
|
||||
esp_ble_mesh_sar_client_recv_cb_t recv; /*!< Parameters of received status message */
|
||||
};
|
||||
} esp_ble_mesh_sar_client_cb_param_t; /*!< SAR Configuration Client model callback parameters */
|
||||
|
||||
/** This enum value is the event of SAR Configuration Client model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_SAR_CLIENT_SEND_COMP_EVT,
|
||||
ESP_BLE_MESH_SAR_CLIENT_SEND_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_SAR_CLIENT_RECV_RSP_EVT,
|
||||
ESP_BLE_MESH_SAR_CLIENT_RECV_PUB_EVT,
|
||||
ESP_BLE_MESH_SAR_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_sar_client_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief SAR Configuration Server model related context.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief SAR Configuration Server model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
uint8_t dummy; /*!< Event not used currently */
|
||||
} esp_ble_mesh_sar_server_state_change_t;
|
||||
|
||||
/**
|
||||
* @brief SAR Configuration Server model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_sar_server_state_change_t state_change; /*!< For ESP_BLE_MESH_SAR_SERVER_STATE_CHANGE_EVT */
|
||||
} esp_ble_mesh_sar_server_cb_value_t;
|
||||
|
||||
/** SAR Configuration Server model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
|
||||
esp_ble_mesh_sar_server_cb_value_t value; /*!< Value of the received configuration messages */
|
||||
} esp_ble_mesh_sar_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of SAR Configuration Server model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_SAR_SERVER_STATE_CHANGE_EVT,
|
||||
ESP_BLE_MESH_SAR_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_sar_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh SAR Configuration client and server model functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief SAR Configuration Client model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_sar_client_cb_t)(esp_ble_mesh_sar_client_cb_event_t event,
|
||||
esp_ble_mesh_sar_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh SAR Configuration Client model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_sar_client_callback(esp_ble_mesh_sar_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Get the value of SAR Configuration Server model state with the corresponding get message.
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] msg: Pointer to SAR Configuration Client message.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_sar_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_sar_client_msg_t *msg);
|
||||
|
||||
/**
|
||||
* @brief SAR Configuration Server model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_sar_server_cb_t)(esp_ble_mesh_sar_server_cb_event_t event,
|
||||
esp_ble_mesh_sar_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh SAR Configuration Server model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_sar_server_callback(esp_ble_mesh_sar_server_cb_t callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_SAR_MODEL_API_H_ */
|
||||
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_SRPL_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_SRPL_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BLE_MESH_MODEL_OP_SRPL_ITEMS_CLEAR ESP_BLE_MESH_MODEL_OP_2(0x80, 0x78)
|
||||
#define ESP_BLE_MESH_MODEL_OP_SRPL_ITEMS_CLEAR_UNACK ESP_BLE_MESH_MODEL_OP_2(0x80, 0x79)
|
||||
#define ESP_BLE_MESH_MODEL_OP_SRPL_ITEMS_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x7A)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SRPL_SRV
|
||||
*
|
||||
* @brief Define a new Solicitation PDU RPL Configuration Server model.
|
||||
*
|
||||
* @note The Solicitation PDU RPL Configuration Server model extends
|
||||
* the On-Demand Private Proxy Server model.
|
||||
* If the model is supported, the model shall be supported by a
|
||||
* primary element and shall not be supported by any secondary
|
||||
* elements.
|
||||
*
|
||||
* @param srv_data Pointer to a unique Solicitation PDU RPL Configuration Server
|
||||
* model user_data.
|
||||
*
|
||||
* @return New Solicitation PDU RPL Configuration Server model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SRPL_SRV(srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SRPL_SRV, \
|
||||
NULL, NULL, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SRPL_CLI
|
||||
*
|
||||
* @brief Define a new Solicitation PDU RPL Configuration Client model.
|
||||
*
|
||||
* @note If supported, the model shall be supported by the primary
|
||||
* element and shall not be supported by any secondary elements.
|
||||
*
|
||||
* @param cli_data Pointer to a unique Solicitation PDU RPL Configuration Client
|
||||
* model user_data.
|
||||
*
|
||||
* @return New Solicitation PDU RPL Configuration Client model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SRPL_CLI(cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SRPL_CLI, \
|
||||
NULL, NULL, cli_data)
|
||||
|
||||
/** Solicitation PDU RPL Configuration Server model context */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to Solicitation PDU RPL Configuration Server model */
|
||||
|
||||
/* This model does not define any states. */
|
||||
} esp_ble_mesh_srpl_srv_t;
|
||||
|
||||
/** Parameter of Solicitation PDU RPL Items Clear */
|
||||
typedef struct {
|
||||
esp_ble_mesh_uar_t addr_range; /*!< Unicast address range */
|
||||
} esp_ble_mesh_srpl_items_clear_t;
|
||||
|
||||
/**
|
||||
* @brief Solicitation PDU RPL Configuration Client model message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_srpl_items_clear_t srpl_items_clear; /*!< For ESP_BLE_MESH_MODEL_OP_SRPL_ITEMS_CLEAR */
|
||||
} esp_ble_mesh_srpl_client_msg_t;
|
||||
|
||||
/** Parameter of Solicitation PDU RPL Items Clear Status */
|
||||
typedef struct {
|
||||
esp_ble_mesh_uar_t addr_range; /*!< Unicast address range */
|
||||
} esp_ble_mesh_srpl_items_status_t;
|
||||
|
||||
/** Result of sending Solicitation PDU RPL Configuration Client messages */
|
||||
typedef struct {
|
||||
int err_code; /*!< Result of sending a message */
|
||||
} esp_ble_mesh_srpl_client_send_cb_t;
|
||||
|
||||
/**
|
||||
* @brief Solicitation PDU RPL Configuration Client model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_srpl_items_status_t srpl_items_status; /*!< For ESP_BLE_MESH_MODEL_OP_SRPL_ITEMS_STATUS */
|
||||
} esp_ble_mesh_srpl_client_recv_cb_t;
|
||||
|
||||
/** Solicitation PDU RPL Configuration Client model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< Client common parameters, used by all events. */
|
||||
/** Union of SRPL Client callback */
|
||||
union {
|
||||
esp_ble_mesh_srpl_client_send_cb_t send; /*!< Result of sending a message */
|
||||
esp_ble_mesh_srpl_client_recv_cb_t recv; /*!< Parameters of received status message */
|
||||
};
|
||||
} esp_ble_mesh_srpl_client_cb_param_t; /*!< Solicitation PDU RPL Configuration Client model callback parameters */
|
||||
|
||||
/** This enum value is the event of Solicitation PDU RPL Configuration Client model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_SRPL_CLIENT_SEND_COMP_EVT,
|
||||
ESP_BLE_MESH_SRPL_CLIENT_SEND_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_SRPL_CLIENT_RECV_RSP_EVT,
|
||||
ESP_BLE_MESH_SRPL_CLIENT_RECV_PUB_EVT,
|
||||
ESP_BLE_MESH_SRPL_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_srpl_client_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Solicitation PDU RPL Configuration Server model related context.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Solicitation PDU RPL Configuration Server model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
uint8_t dummy; /*!< Currently this event is not used. */
|
||||
} esp_ble_mesh_srpl_server_state_change_t;
|
||||
|
||||
/**
|
||||
* @brief Solicitation PDU RPL Configuration Server model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_srpl_server_state_change_t state_change; /*!< ESP_BLE_MESH_SRPL_SERVER_STATE_CHANGE_EVT */
|
||||
} esp_ble_mesh_srpl_server_cb_value_t;
|
||||
|
||||
/** Solicitation PDU RPL Configuration Server model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
|
||||
esp_ble_mesh_srpl_server_cb_value_t value; /*!< Value of the received configuration messages */
|
||||
} esp_ble_mesh_srpl_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Solicitation PDU RPL Configuration Server model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_SRPL_SERVER_STATE_CHANGE_EVT,
|
||||
ESP_BLE_MESH_SRPL_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_srpl_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Solicitation PDU RPL Configuration client and server model functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Solicitation PDU RPL Configuration Client model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_srpl_client_cb_t)(esp_ble_mesh_srpl_client_cb_event_t event,
|
||||
esp_ble_mesh_srpl_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Solicitation PDU RPL Configuration Client model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_srpl_client_callback(esp_ble_mesh_srpl_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Set the value of Solicitation PDU RPL Configuration Server model state with the corresponding set message.
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] msg: Pointer to Solicitation PDU RPL Configuration Client message.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_srpl_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_srpl_client_msg_t *msg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Solicitation PDU RPL Configuration Server model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_srpl_server_cb_t)(esp_ble_mesh_srpl_server_cb_event_t event,
|
||||
esp_ble_mesh_srpl_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Solicitation PDU RPL Configuration Server model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_srpl_server_callback(esp_ble_mesh_srpl_server_cb_t callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_SRPL_MODEL_API_H_ */
|
||||
@@ -0,0 +1,421 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "btc_ble_mesh_mbt_model.h"
|
||||
#include "esp_ble_mesh_mbt_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_MBT_CLI
|
||||
|
||||
extern const void *bt_mesh_get_blob_receiver(void *model, uint16_t unicast_addr);
|
||||
extern const void **bt_mesh_get_active_blob_receiver(void *model);
|
||||
extern int bt_mesh_get_transfer_progress(void *model, uint16_t unicast_addr,
|
||||
uint8_t *block_percent, uint8_t *chunk_percent);
|
||||
extern int bt_mesh_get_blob_reception_progress(void *model, uint8_t *reception_progress);
|
||||
|
||||
esp_err_t esp_ble_mesh_register_mbt_client_callback(esp_ble_mesh_mbt_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_MBT_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_retrieve_capabilities(esp_ble_mesh_retrieve_capabilities_t *input)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (input == NULL || input->model == NULL ||
|
||||
(input->unicast_addr_count && input->unicast_addr == 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_MBT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_CLIENT_RETRIEVE_CAPABILITIES;
|
||||
|
||||
memcpy(&arg.retrieve_capabilities, input, sizeof(esp_ble_mesh_retrieve_capabilities_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_client_args_t),
|
||||
btc_ble_mesh_mbt_client_arg_deep_copy,
|
||||
btc_ble_mesh_mbt_client_arg_deep_free)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_transfer_blob(esp_ble_mesh_transfer_blob_t *input)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (input == NULL || input->model == NULL ||
|
||||
(input->unicast_addr_count && input->unicast_addr == NULL) ||
|
||||
input->blob_data == 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_MBT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_CLIENT_TRANSFER_BLOB;
|
||||
|
||||
memcpy(&arg.transfer_blob, input, sizeof(esp_ble_mesh_transfer_blob_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_client_args_t),
|
||||
btc_ble_mesh_mbt_client_arg_deep_copy,
|
||||
btc_ble_mesh_mbt_client_arg_deep_free)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_send_block(esp_ble_mesh_send_block_t *input)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (input == NULL || input->model == 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_MBT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_CLIENT_SEND_BLOCK;
|
||||
|
||||
memcpy(&arg.send_block, input, sizeof(esp_ble_mesh_send_block_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_client_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_send_data(esp_ble_mesh_send_data_t *input)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (input == NULL || input->model == 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_MBT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_CLIENT_SEND_DATA;
|
||||
|
||||
memcpy(&arg.send_data, input, sizeof(esp_ble_mesh_send_data_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_client_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_determine_block_status(esp_ble_mesh_determine_block_status_t *input)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (input == NULL || input->model == 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_MBT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_CLIENT_DETERMINE_BLOCK_STATUS;
|
||||
|
||||
memcpy(&arg.determine_block_status, input, sizeof(esp_ble_mesh_determine_block_status_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_client_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_determine_transfer_status(esp_ble_mesh_determine_transfer_status_t *input)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (input == NULL || input->model == NULL ||
|
||||
(input->unicast_addr_count && input->unicast_addr == 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_MBT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_CLIENT_DETERMINE_TRANSFER_STATUS;
|
||||
|
||||
memcpy(&arg.determine_transfer_status, input, sizeof(esp_ble_mesh_determine_transfer_status_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_client_args_t),
|
||||
btc_ble_mesh_mbt_client_arg_deep_copy,
|
||||
btc_ble_mesh_mbt_client_arg_deep_free)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_cancel_transfer(esp_ble_mesh_cancel_transfer_t *input)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (input == NULL || input->model == NULL ||
|
||||
(input->unicast_addr_count && input->unicast_addr == 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_MBT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_CLIENT_CANCEL_TRANSFER;
|
||||
|
||||
memcpy(&arg.cancel_transfer, input, sizeof(esp_ble_mesh_cancel_transfer_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_client_args_t),
|
||||
btc_ble_mesh_mbt_client_arg_deep_copy,
|
||||
btc_ble_mesh_mbt_client_arg_deep_free)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
const esp_ble_mesh_blob_receiver_t *esp_ble_mesh_mbt_client_get_blob_receiver(esp_ble_mesh_model_t *model,
|
||||
uint16_t unicast_addr)
|
||||
{
|
||||
return (const esp_ble_mesh_blob_receiver_t *)bt_mesh_get_blob_receiver((struct bt_mesh_model *)model,
|
||||
unicast_addr);
|
||||
}
|
||||
|
||||
const esp_ble_mesh_blob_receiver_t **esp_ble_mesh_mbt_client_get_active_blob_receiver(esp_ble_mesh_model_t *model)
|
||||
{
|
||||
return (const esp_ble_mesh_blob_receiver_t **)bt_mesh_get_active_blob_receiver((struct bt_mesh_model *)model);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_get_transfer_progress(esp_ble_mesh_model_t *model,
|
||||
uint16_t unicast_addr,
|
||||
uint8_t *block_percent,
|
||||
uint8_t *chunk_percent)
|
||||
{
|
||||
return (bt_mesh_get_transfer_progress((struct bt_mesh_model *)model, unicast_addr,
|
||||
block_percent, chunk_percent) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_set_transfer_ttl(esp_ble_mesh_model_t *model,
|
||||
uint8_t transfer_ttl)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (model == 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_MBT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_CLIENT_SET_TRANSFER_TTL;
|
||||
|
||||
arg.set_transfer_ttl.model = model;
|
||||
arg.set_transfer_ttl.transfer_ttl = transfer_ttl;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_client_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_clear_transfer_ttl(esp_ble_mesh_model_t *model)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (model == 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_MBT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_CLIENT_CLEAR_TRANSFER_TTL;
|
||||
|
||||
arg.clear_transfer_ttl.model = model;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_client_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_set_app_idx(esp_ble_mesh_model_t *model,
|
||||
uint16_t app_idx)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (model == 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_MBT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_CLIENT_SET_APP_IDX;
|
||||
|
||||
arg.set_app_idx.model = model;
|
||||
arg.set_app_idx.app_idx = app_idx;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_client_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_clear_app_idx(esp_ble_mesh_model_t *model)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (model == 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_MBT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_CLIENT_CLEAR_APP_IDX;
|
||||
|
||||
arg.clear_app_idx.model = model;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_client_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_set_multicast_addr(esp_ble_mesh_model_t *model,
|
||||
uint16_t multicast_addr)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (model == 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_MBT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_CLIENT_SET_MULTICAST_ADDR;
|
||||
|
||||
arg.set_multicast_addr.model = model;
|
||||
arg.set_multicast_addr.multicast_addr = multicast_addr;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_client_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_client_clear_multicast_addr(esp_ble_mesh_model_t *model)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (model == 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_MBT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_CLIENT_CLEAR_MULTICAST_ADDR;
|
||||
|
||||
arg.clear_multicast_addr.model = model;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_client_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_MBT_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_MBT_SRV
|
||||
esp_err_t esp_ble_mesh_register_mbt_server_callback(esp_ble_mesh_mbt_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_MBT_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_server_initialize_blob_receive(esp_ble_mesh_initialize_blob_receive_t *input)
|
||||
{
|
||||
btc_ble_mesh_mbt_server_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (input == NULL || input->model == 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_MBT_SERVER;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_SERVER_INITIALIZE_BLOB_RECEIVE;
|
||||
|
||||
memcpy(&arg.initialize_blob_receive, input, sizeof(esp_ble_mesh_initialize_blob_receive_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_server_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_server_cancel_blob_receive(esp_ble_mesh_cancel_blob_receive_t *input)
|
||||
{
|
||||
btc_ble_mesh_mbt_server_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (input == NULL || input->model == 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_MBT_SERVER;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_SERVER_CANCEL_BLOB_RECEIVE;
|
||||
|
||||
memcpy(&arg.cancel_blob_receive, input, sizeof(esp_ble_mesh_cancel_blob_receive_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_server_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_server_set_blob_capabilities(esp_ble_mesh_set_blob_capabilities_t *input)
|
||||
{
|
||||
btc_ble_mesh_mbt_server_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (input == NULL || input->model == 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_MBT_SERVER;
|
||||
msg.act = BTC_BLE_MESH_ACT_MBT_SERVER_SET_BLOB_CAPABILITIES;
|
||||
|
||||
memcpy(&arg.set_blob_capabilities, input, sizeof(esp_ble_mesh_set_blob_capabilities_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_mbt_server_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_mbt_server_get_blob_reception_progress(esp_ble_mesh_model_t *model,
|
||||
uint8_t *reception_progress)
|
||||
{
|
||||
return (bt_mesh_get_blob_reception_progress((struct bt_mesh_model *)model,
|
||||
reception_progress) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_MBT_SRV */
|
||||
@@ -0,0 +1,693 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_MBT_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_MBT_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BLE_MESH_MODEL_OP_BLOB_TRANSFER_GET ESP_BLE_MESH_MODEL_OP_2(0x83, 0x00)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BLOB_TRANSFER_START ESP_BLE_MESH_MODEL_OP_2(0x83, 0x01)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BLOB_TRANSFER_CANCEL ESP_BLE_MESH_MODEL_OP_2(0x83, 0x02)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BLOB_TRANSFER_STATUS ESP_BLE_MESH_MODEL_OP_2(0x83, 0x03)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BLOB_BLOCK_GET ESP_BLE_MESH_MODEL_OP_2(0x83, 0x05)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BLOB_BLOCK_START ESP_BLE_MESH_MODEL_OP_2(0x83, 0x04)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BLOB_PARTIAL_BLOCK_REPORT ESP_BLE_MESH_MODEL_OP_1(0x65)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BLOB_BLOCK_STATUS ESP_BLE_MESH_MODEL_OP_1(0x67)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BLOB_CHUNK_TRANSFER ESP_BLE_MESH_MODEL_OP_1(0x66)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BLOB_INFORMATION_GET ESP_BLE_MESH_MODEL_OP_2(0x83, 0x06)
|
||||
#define ESP_BLE_MESH_MODEL_OP_BLOB_INFORMATION_STATUS ESP_BLE_MESH_MODEL_OP_2(0x83, 0x07)
|
||||
|
||||
#define ESP_BLE_MESH_BLOB_ID_SIZE 8
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_MBT_CLI
|
||||
*
|
||||
* @brief Define a new BLOB Transfer Client model.
|
||||
*
|
||||
* @note This API needs to be called for each element on which
|
||||
* the application needs to have a BLOB Transfer Client model.
|
||||
*
|
||||
* @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
|
||||
*
|
||||
* @return New BLOB Transfer Client model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_MBT_CLI(cli_pub, cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_MBT_CLI, \
|
||||
NULL, cli_pub, cli_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_MBT_SRV
|
||||
*
|
||||
* @brief Define a new BLOB Transfer Server model.
|
||||
*
|
||||
* @note This API needs to be called for each element on which
|
||||
* the application needs to have a BLOB Transfer Server model.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_blob_trans_srv_t.
|
||||
*
|
||||
* @return New BLOB Transfer Server model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_MBT_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_MBT_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** BLOB Transfer Server model context */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to BLOB Transfer Server model */
|
||||
} esp_ble_mesh_mbt_srv_t;
|
||||
|
||||
/** Parameters of BLOB receiver */
|
||||
typedef struct {
|
||||
uint16_t unicast_addr; /*!< Unicast address of the server */
|
||||
uint8_t retrieved_transfer_phase; /*!< Retrieved transfer phase of the server */
|
||||
uint8_t status:4; /*!< Status of the last operation */
|
||||
uint16_t blocks_not_received_len; /*!< Indicates the length which blocks were not received by the server. */
|
||||
uint8_t *blocks_not_received; /*!< Indicates which blocks were not received by the server. */
|
||||
uint16_t missing_chunks_len; /*!< Indicates which chunks were not received in the current block */
|
||||
uint8_t *missing_chunks; /*!< Indicates which chunks were not received by the server in the current block */
|
||||
/* The followings are the additional information contained in status messages. */
|
||||
uint8_t transfer_mode:2; /*!< BLOB transfer mode */
|
||||
uint8_t expected_blob_id[ESP_BLE_MESH_BLOB_ID_SIZE]; /*!< Expected BLOB identifier list */
|
||||
uint32_t blob_size; /*!< BLOB size in octets */
|
||||
uint8_t block_size_log; /*!< Indicates the block size */
|
||||
uint16_t transfer_mtu_size; /*!< MTU size in octets */
|
||||
bool block_status_recv; /*!< Indicate if Blob Block Status is received as a response. */
|
||||
} esp_ble_mesh_blob_receiver_t; /*!< Structure of BLOB receiver */
|
||||
|
||||
/** Parameters of BLOB Information Status */
|
||||
typedef struct {
|
||||
uint8_t min_block_size_log; /*!< Min Block Size Log */
|
||||
uint8_t max_block_size_log; /*!< Max Block Size Log */
|
||||
uint16_t max_total_chunks; /*!< Max Total Chunks */
|
||||
uint16_t max_chunk_size; /*!< Max Chunk Size */
|
||||
uint32_t max_blob_size; /*!< Max BLOB Size */
|
||||
uint16_t server_mtu_size; /*!< Server MTU size */
|
||||
uint8_t supported_transfer_mode; /*!< Supported Transfer Mode */
|
||||
} esp_ble_mesh_blob_capabilities_t; /*!< Parameters of BLOB Information Status */
|
||||
|
||||
/** Parameters of BLOB retrieve capabilities */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to BLOB Transfer Server model */
|
||||
uint8_t msg_role; /*!< Role of the device - Node/Provisioner */
|
||||
|
||||
uint16_t multicast_addr; /*!< Multicast Address state */
|
||||
uint16_t app_idx; /*!< AppKey Index state */
|
||||
uint8_t transfer_ttl; /*!< Transfer TTL state */
|
||||
uint8_t unicast_addr_count; /*!< The count of unicast address */
|
||||
uint16_t *unicast_addr; /*!< Unicast address list */
|
||||
} esp_ble_mesh_retrieve_capabilities_t; /*!< Parameters of BLOB retrieve capabilities */
|
||||
|
||||
/** Parameters of BLOB transfer */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to BLOB Transfer Server model */
|
||||
uint8_t msg_role; /*!< Role of the device - Node/Provisioner */
|
||||
|
||||
uint8_t unicast_addr_count; /*!< The count of unicast address */
|
||||
uint16_t *unicast_addr; /*!< Unicast address list */
|
||||
uint16_t multicast_addr; /*!< Multicast Address state */
|
||||
uint16_t app_idx; /*!< AppKey Index state */
|
||||
uint8_t transfer_ttl; /*!< Transfer TTL state */
|
||||
uint8_t blob_id[ESP_BLE_MESH_BLOB_ID_SIZE]; /*!< BLOB identifier list */
|
||||
uint32_t blob_size; /*!< BLOB size in octets */
|
||||
uint8_t *blob_data; /*!< BLOB data */
|
||||
uint8_t transfer_mode; /*!< BLOB transfer mode */
|
||||
uint16_t client_timeout_base; /*!< Time wait for messages from the serve */
|
||||
} esp_ble_mesh_transfer_blob_t; /*!< Parameters of BLOB transfer */
|
||||
|
||||
/** Parameters of BLOB Block Status message */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to BLOB Transfer Server model */
|
||||
uint8_t msg_role; /*!< Role of the device - Node/Provisioner */
|
||||
|
||||
uint16_t multicast_addr; /*!< Multicast Address state */
|
||||
uint16_t app_idx; /*!< AppKey Index state */
|
||||
uint8_t transfer_ttl; /*!< Transfer TTL state */
|
||||
|
||||
uint16_t block_number; /*!< Block number of the current block */
|
||||
uint16_t chunk_size; /*!< Chunk Size (in octets) for the current block */
|
||||
} esp_ble_mesh_send_block_t; /*!< BLOB Block Status message structure */
|
||||
|
||||
/** Parameters of BLOB send message */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to BLOB Transfer Server model */
|
||||
uint8_t msg_role; /*!< Role of the device - Node/Provisioner */
|
||||
|
||||
uint16_t multicast_addr; /*!< Multicast Address state */
|
||||
uint16_t app_idx; /*!< AppKey Index state */
|
||||
uint8_t transfer_ttl; /*!< Transfer TTL state */
|
||||
} esp_ble_mesh_send_data_t; /*!< Parameters of BLOB send message */
|
||||
|
||||
/** Parameters of determine Block Status message */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to BLOB Transfer Server model */
|
||||
uint8_t msg_role; /*!< Role of the device - Node/Provisioner */
|
||||
|
||||
uint16_t multicast_addr; /*!< Multicast Address state */
|
||||
uint16_t app_idx; /*!< AppKey Index state */
|
||||
uint8_t transfer_ttl; /*!< Transfer TTL state */
|
||||
} esp_ble_mesh_determine_block_status_t; /*!< Parameters of determine Block Status message */
|
||||
|
||||
/** Parameters of determine Block Status message */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to BLOB Transfer Server model */
|
||||
uint8_t msg_role; /*!< Role of the device - Node/Provisioner */
|
||||
|
||||
uint16_t multicast_addr; /*!< Multicast Address state */
|
||||
uint16_t app_idx; /*!< AppKey Index state */
|
||||
uint8_t transfer_ttl; /*!< Transfer TTL state */
|
||||
uint8_t unicast_addr_count; /*!< The count of unicast address */
|
||||
uint16_t *unicast_addr; /*!< Unicast address list */
|
||||
} esp_ble_mesh_determine_transfer_status_t; /*!< Parameters of determine Block Status message */
|
||||
|
||||
/** Parameters of cancel transfer message */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to BLOB Transfer Server model */
|
||||
uint8_t msg_role; /*!< Role of the device - Node/Provisioner */
|
||||
|
||||
uint16_t multicast_addr; /*!< Multicast Address state */
|
||||
uint16_t app_idx; /*!< AppKey Index state */
|
||||
uint8_t transfer_ttl; /*!< Transfer TTL state */
|
||||
uint8_t unicast_addr_count; /*!< The count of unicast address */
|
||||
uint16_t *unicast_addr; /*!< Unicast address list */
|
||||
|
||||
uint8_t blob_id[ESP_BLE_MESH_BLOB_ID_SIZE]; /*!< BLOB identifier list */
|
||||
} esp_ble_mesh_cancel_transfer_t; /*!< Parameters of cancel transfer message */
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client model procedure result
|
||||
*/
|
||||
#define ESP_BLE_MESH_MBT_CLIENT_RESULT_COMPLETE 0x00
|
||||
#define ESP_BLE_MESH_MBT_CLIENT_RESULT_FAIL 0x01
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client model callback values union
|
||||
*/
|
||||
typedef union {
|
||||
/** Retrieve capabilities status */
|
||||
struct {
|
||||
int error_code; /*!< Result of starting Retrieve Capabilities procedure */
|
||||
esp_ble_mesh_retrieve_capabilities_t input; /*!< Input of starting Retrieve Capabilities procedure */
|
||||
} retrieve_capabilities_status; /*!< Retrieve capabilities status */
|
||||
/** Transfer BLOB status */
|
||||
struct {
|
||||
int error_code; /*!< Result of starting Transfer BLOB procedure */
|
||||
esp_ble_mesh_transfer_blob_t input; /*!< Input of starting Transfer BLOB procedure */
|
||||
} transfer_blob_status; /*!< Transfer BLOB status */
|
||||
/** Send block status */
|
||||
struct {
|
||||
int error_code; /*!< Result of starting Send Block sub-procedure */
|
||||
esp_ble_mesh_send_block_t input; /*!< Input of starting Send Block sub-procedure */
|
||||
} send_block_status; /*!< Send block status */
|
||||
/** Send data status */
|
||||
struct {
|
||||
int error_code; /*!< Result of starting Send Data sub-procedure */
|
||||
esp_ble_mesh_send_data_t input; /*!< Input of starting Send Data sub-procedure */
|
||||
} send_data_status; /*!< Send data status */
|
||||
/** Determine block status */
|
||||
struct {
|
||||
int error_code; /*!< Result of starting Determine Block Status sub-procedure */
|
||||
esp_ble_mesh_determine_block_status_t input; /*!< Input of starting Determine Block Status sub-procedure */
|
||||
} determine_block_status_status; /*!< Determine block status */
|
||||
/** Determine transfer status */
|
||||
struct {
|
||||
int error_code; /*!< Result of starting Determine Transfer Status procedure */
|
||||
esp_ble_mesh_determine_transfer_status_t input; /*!< Input of starting Determine Transfer Status procedure */
|
||||
} determine_transfer_status_status; /*!< Determine transfer status */
|
||||
/** Cancel transfer status */
|
||||
struct {
|
||||
int error_code; /*!< Result of starting Cancel Transfer procedure */
|
||||
esp_ble_mesh_cancel_transfer_t input; /*!< Input of starting Cancel Transfer procedure */
|
||||
} cancel_transfer_status; /*!< Cancel transfer status */
|
||||
/** Retrieve capabilities complete */
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
uint8_t result; /*!< Result of Retrieve Capabilities procedure */
|
||||
} retrieve_capabilities_comp; /*!< Retrieve capabilities complete */
|
||||
/** Transfer BLOB complete */
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
uint8_t result; /*!< Result of Transfer BLOB procedure */
|
||||
} transfer_blob_comp; /*!< Transfer BLOB complete */
|
||||
/** Send block complete */
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
uint8_t result; /*!< Result of Send Block sub-procedure */
|
||||
} send_block_comp; /*!< Send block complete */
|
||||
/** Send data complete */
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
uint8_t result; /*!< Result of Send Data sub-procedure */
|
||||
} send_data_comp; /*!< Send data complete */
|
||||
/** Determine block status complete */
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
uint8_t result; /*!< Result of Determine Block Status sub-procedure */
|
||||
} determine_block_status_comp; /*!< Determine block status complete */
|
||||
/** Determine transfer status complete */
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
uint8_t result; /*!< Result of Determine Transfer Status procedure */
|
||||
} determine_transfer_status_comp; /*!< Determine transfer status complete */
|
||||
/** Cancel transfer complete */
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
uint8_t result; /*!< Result of Cancel Transfer procedure */
|
||||
} cancel_transfer_comp; /*!< Cancel transfer complete */
|
||||
/** Set transfer TTL */
|
||||
struct {
|
||||
int error_code; /*!< Result of setting Transfer TTL state */
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
uint8_t transfer_ttl; /*!< Transfer TTL state */
|
||||
} set_transfer_ttl; /*!< Set transfer TTL */
|
||||
/** Clear transfer TTL */
|
||||
struct {
|
||||
int error_code; /*!< Result of clearing Transfer TTL state */
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
} clear_transfer_ttl; /*!< Clear transfer TTL */
|
||||
/** Set application index */
|
||||
struct {
|
||||
int error_code; /*!< Result of setting AppKey Index state */
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
uint16_t app_idx; /*!< AppKey Index state */
|
||||
} set_app_idx; /*!< Set application index */
|
||||
/** Clear application index */
|
||||
struct {
|
||||
int error_code; /*!< Result of clearing AppKey Index state */
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
} clear_app_idx; /*!< Clear application index */
|
||||
/** Set multicast address */
|
||||
struct {
|
||||
int error_code; /*!< Result of setting Multicast Address state */
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
uint16_t multicast_addr; /*!< Multicast Address state */
|
||||
} set_multicast_addr; /*!< Set multicast address */
|
||||
/** Clear multicast address */
|
||||
struct {
|
||||
int error_code; /*!< Result of clearing Multicast Address state */
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
} clear_multicast_addr; /*!< Clear multicast address */
|
||||
} esp_ble_mesh_mbt_client_cb_value_t; /*!< BLOB Transfer Client model callback values union */
|
||||
|
||||
/** BLOB Transfer Client model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_mbt_client_cb_value_t value; /*!< BLOB Transfer Client model callback values */
|
||||
} esp_ble_mesh_mbt_client_cb_param_t; /*!< BLOB Transfer Client model callback parameters */
|
||||
|
||||
/**
|
||||
* This enum value is the event of BLOB Transfer Client model.
|
||||
* Note: The idea of status/complete event comes from HCI Commands.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_MBT_CLIENT_RETRIEVE_CAPABILITIES_STATUS_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_TRANSFER_BLOB_STATUS_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_SEND_BLOCK_STATUS_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_SEND_DATA_STATUS_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_DETERMINE_BLOCK_STATUS_STATUS_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_DETERMINE_TRANSFER_STATUS_STATUS_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_CANCEL_TRANSFER_STATUS_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_RETRIEVE_CAPABILITIES_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_TRANSFER_BLOB_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_SEND_BLOCK_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_SEND_DATA_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_DETERMINE_BLOCK_STATUS_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_DETERMINE_TRANSFER_STATUS_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_CANCEL_TRANSFER_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_SET_TRANSFER_TTL_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_CLEAR_TRANSFER_TTL_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_SET_APP_IDX_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_CLEAR_APP_IDX_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_SET_MULTICAST_ADDR_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_CLEAR_MULTICAST_ADDR_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_mbt_client_cb_event_t;
|
||||
|
||||
/** Parameters of initialize BLOB receive */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
|
||||
uint8_t blob_id[ESP_BLE_MESH_BLOB_ID_SIZE]; /*!< BLOB identifier list */
|
||||
uint16_t timeout; /*!< Timeout */
|
||||
uint8_t transfer_ttl; /*!< Transfer TTL state */
|
||||
} esp_ble_mesh_initialize_blob_receive_t; /*!< Structure of initialize BLOB receive */
|
||||
|
||||
/** Parameters of cancel BLOB receive */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
|
||||
uint8_t blob_id[ESP_BLE_MESH_BLOB_ID_SIZE]; /*!< BLOB identifier list */
|
||||
} esp_ble_mesh_cancel_blob_receive_t;/*!< */
|
||||
|
||||
/** Parameters of cancel BLOB receive */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the BLOB Transfer Client model */
|
||||
|
||||
esp_ble_mesh_blob_capabilities_t caps; /*!< Parameters of BLOB Information Status */
|
||||
} esp_ble_mesh_set_blob_capabilities_t;/*!< */
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Server model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
/** Initialize BLOB receive complete */
|
||||
struct {
|
||||
int error_code; /*!< Result of initializing BLOB receive */
|
||||
esp_ble_mesh_initialize_blob_receive_t input; /*!< Input of initializing BLOB receive */
|
||||
} initialize_blob_receive_comp; /*!< Initialize BLOB receive complete */
|
||||
/** Cancel BLOB receive complete */
|
||||
struct {
|
||||
int error_code; /*!< Result of canceling BLOB receive */
|
||||
esp_ble_mesh_cancel_blob_receive_t input; /*!< Input of canceling BLOB receive */
|
||||
} cancel_blob_receive_comp; /*!< Cancel BLOB receive complete */
|
||||
/** Set BLOB capabilities complete */
|
||||
struct {
|
||||
int error_code; /*!< Result of setting BLOB capabilities */
|
||||
esp_ble_mesh_set_blob_capabilities_t input; /*!< Input of setting BLOB capabilities */
|
||||
} set_blob_capabilities_comp; /*!< Set BLOB capabilities complete */
|
||||
/** BLOB transfer get */
|
||||
struct {
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< BLOB Transfer Get message context */
|
||||
} blob_transfer_get; /*!< BLOB transfer get */
|
||||
/** BLOB transfer start */
|
||||
struct {
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< BLOB Transfer Start message context */
|
||||
} blob_transfer_start; /*!< BLOB transfer start */
|
||||
/** BLOB transfer cancel */
|
||||
struct {
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< BLOB Transfer Cancel message context */
|
||||
} blob_transfer_cancel; /*!< BLOB transfer cancel */
|
||||
/** BLOB block get */
|
||||
struct {
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< BLOB Block Get message context */
|
||||
} blob_block_get; /*!< BLOB block get */
|
||||
/** BLOB block start */
|
||||
struct {
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< BLOB Block Start message context */
|
||||
} blob_block_start; /*!< BLOB block start */
|
||||
/** BLOB chunk transfer */
|
||||
struct {
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< BLOB Chunk Transfer message context */
|
||||
} blob_chunk_transfer; /*!< BLOB chunk transfer */
|
||||
/** BLOB information get */
|
||||
struct {
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< BLOB Information Get message context */
|
||||
} blob_information_get; /*!< BLOB information get */
|
||||
/** Block receive complete */
|
||||
struct {
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Information of receiving BLOB block completely */
|
||||
} block_receive_comp; /*!< Block receive complete */
|
||||
/** BLOB receive complete */
|
||||
struct {
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Information of receiving BLOB completely */
|
||||
} blob_receive_comp; /*!< BLOB receive complete */
|
||||
} esp_ble_mesh_mbt_server_cb_value_t; /*!< BLOB Transfer Server model callback value union */
|
||||
|
||||
/** BLOB Transfer Server model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_mbt_server_cb_value_t value; /*!< Value of the received blob transfer messages */
|
||||
} esp_ble_mesh_mbt_server_cb_param_t; /*!< BLOB Transfer Server model callback parameters */
|
||||
|
||||
/** This enum value is the event of BLOB Transfer Server model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_MBT_SERVER_INITIALIZE_BLOB_RECEIVE_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_SERVER_CANCEL_BLOB_RECEIVE_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_SERVER_SET_BLOB_CAPABILITIES_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_SERVER_BLOB_TRANSFER_GET_EVT,
|
||||
ESP_BLE_MESH_MBT_SERVER_BLOB_TRANSFER_START_EVT,
|
||||
ESP_BLE_MESH_MBT_SERVER_BLOB_TRANSFER_CANCEL_EVT,
|
||||
ESP_BLE_MESH_MBT_SERVER_BLOB_BLOCK_GET_EVT,
|
||||
ESP_BLE_MESH_MBT_SERVER_BLOB_BLOCK_START_EVT,
|
||||
ESP_BLE_MESH_MBT_SERVER_BLOB_CHUNK_TRANSFER_EVT,
|
||||
ESP_BLE_MESH_MBT_SERVER_BLOB_INFORMATION_GET_EVT,
|
||||
ESP_BLE_MESH_MBT_SERVER_BLOCK_RECEIVE_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_SERVER_BLOB_RECEIVE_COMP_EVT,
|
||||
ESP_BLE_MESH_MBT_SERVER_BLOB_RECEIVE_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_MBT_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_mbt_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client model callback function type
|
||||
*
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_mbt_client_cb_t)(esp_ble_mesh_mbt_client_cb_event_t event,
|
||||
esp_ble_mesh_mbt_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Server model callback function type
|
||||
*
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_mbt_server_cb_t)(esp_ble_mesh_mbt_server_cb_event_t event,
|
||||
esp_ble_mesh_mbt_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh BLOB Transfer Client model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_mbt_client_callback(esp_ble_mesh_mbt_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh BLOB Transfer Server model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_mbt_server_callback(esp_ble_mesh_mbt_server_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client starts Retrieve Capabilities procedure.
|
||||
*
|
||||
* @param[in] input: The input of Retrieve Capabilities procedure.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_retrieve_capabilities(esp_ble_mesh_retrieve_capabilities_t *input);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client starts Transfer BLOB procedure.
|
||||
*
|
||||
* @param[in] input: The input of Transfer BLOB procedure.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_transfer_blob(esp_ble_mesh_transfer_blob_t *input);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client starts Send Block sub-procedure.
|
||||
*
|
||||
* @param[in] input: The input of Send Block sub-procedure.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_send_block(esp_ble_mesh_send_block_t *input);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client starts Send Data sub-procedure.
|
||||
*
|
||||
* @param[in] input: The input of Send Data sub-procedure.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_send_data(esp_ble_mesh_send_data_t *input);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client starts Determine Block Status sub-procedure.
|
||||
*
|
||||
* @param[in] input: The input of Determine Block Status sub-procedure.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_determine_block_status(esp_ble_mesh_determine_block_status_t *input);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client starts Determine Transfer Status procedure.
|
||||
*
|
||||
* @param[in] input: The input of Determine Transfer Status procedure.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_determine_transfer_status(esp_ble_mesh_determine_transfer_status_t *input);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client starts Cancel Transfer procedure.
|
||||
*
|
||||
* @param[in] input: The input of Cancel Transfer procedure.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_cancel_transfer(esp_ble_mesh_cancel_transfer_t *input);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client gets BLOB receiver.
|
||||
*
|
||||
* @param[in] model: BLOB Transfer Client model.
|
||||
* @param[in] unicast_addr: Unicast address of the BLOB receiver.
|
||||
*
|
||||
* @return BLOB receiver on success or NULL on failure.
|
||||
*
|
||||
*/
|
||||
const esp_ble_mesh_blob_receiver_t *esp_ble_mesh_mbt_client_get_blob_receiver(esp_ble_mesh_model_t *model,
|
||||
uint16_t unicast_addr);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client gets active BLOB receiver list.
|
||||
*
|
||||
* @param[in] model: BLOB Transfer Client model.
|
||||
*
|
||||
* @return Active BLOB receiver list on success or NULL on failure.
|
||||
*
|
||||
*/
|
||||
const esp_ble_mesh_blob_receiver_t **esp_ble_mesh_mbt_client_get_active_blob_receiver(esp_ble_mesh_model_t *model);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client gets BLOB transfer progress.
|
||||
*
|
||||
* @param[in] model: BLOB Transfer Client model.
|
||||
* @param[in] unicast_addr: Unicast address of the BLOB receiver.
|
||||
* @param[in] block_percent: Block reception percent to be updated.
|
||||
* @param[in] chunk_percent: Chunk reception percent of the current block to be updated.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_get_transfer_progress(esp_ble_mesh_model_t *model,
|
||||
uint16_t unicast_addr,
|
||||
uint8_t *block_percent,
|
||||
uint8_t *chunk_percent);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client sets Transfer TTL state.
|
||||
*
|
||||
* @param[in] model: BLOB Transfer Client model.
|
||||
* @param[in] transfer_ttl: Transfer TTL state value.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_set_transfer_ttl(esp_ble_mesh_model_t *model,
|
||||
uint8_t transfer_ttl);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client clear Transfer TTL state.
|
||||
*
|
||||
* @param[in] model: BLOB Transfer Client model.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_clear_transfer_ttl(esp_ble_mesh_model_t *model);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client sets AppKey Index state.
|
||||
*
|
||||
* @param[in] model: BLOB Transfer Client model.
|
||||
* @param[in] app_idx: AppKey Index state value.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_set_app_idx(esp_ble_mesh_model_t *model,
|
||||
uint16_t app_idx);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client clear AppKey Index state.
|
||||
*
|
||||
* @param[in] model: BLOB Transfer Client model.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_clear_app_idx(esp_ble_mesh_model_t *model);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client sets Multicast Address state.
|
||||
*
|
||||
* @param[in] model: BLOB Transfer Client model.
|
||||
* @param[in] multicast_addr: Multicast Address state value.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_set_multicast_addr(esp_ble_mesh_model_t *model,
|
||||
uint16_t multicast_addr);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Client clear Multicast Address state.
|
||||
*
|
||||
* @param[in] model: BLOB Transfer Client model.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_client_clear_multicast_addr(esp_ble_mesh_model_t *model);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Server initializes BLOB receive.
|
||||
*
|
||||
* @param[in] input: The input of initializing BLOB receive.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_server_initialize_blob_receive(esp_ble_mesh_initialize_blob_receive_t *input);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Server cancels BLOB receive.
|
||||
*
|
||||
* @param[in] input: The input of cancelling BLOB receive.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_server_cancel_blob_receive(esp_ble_mesh_cancel_blob_receive_t *input);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Server sets BLOB capabilities.
|
||||
*
|
||||
* @param[in] input: The input of setting BLOB capabilities.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_server_set_blob_capabilities(esp_ble_mesh_set_blob_capabilities_t *input);
|
||||
|
||||
/**
|
||||
* @brief BLOB Transfer Server gets current BLOB reception progress.
|
||||
*
|
||||
* @param[in] model: BLOB Transfer Server model.
|
||||
* @param[in] reception_progress: Reception progress to be updated.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_mbt_server_get_blob_reception_progress(esp_ble_mesh_model_t *model,
|
||||
uint8_t *reception_progress);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_MBT_MODEL_API_H_ */
|
||||
@@ -0,0 +1,490 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_agg_model.h"
|
||||
#include "esp_ble_mesh_agg_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_AGG_CLI
|
||||
|
||||
extern int bt_mesh_agg_sequence(void *param, void *sequence);
|
||||
|
||||
/* Opcodes Aggregator Client model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_agg_client_cb_to_app(esp_ble_mesh_agg_client_cb_event_t event,
|
||||
esp_ble_mesh_agg_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_agg_client_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_AGG_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_agg_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
btc_ble_mesh_agg_client_args_t *dst = p_dest;
|
||||
btc_ble_mesh_agg_client_args_t *src = p_src;
|
||||
uint16_t length = 0;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_AGG_CLIENT_SEND:
|
||||
dst->agg_send.params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->agg_send.msg = bt_mesh_calloc(sizeof(esp_ble_mesh_agg_client_msg_t));
|
||||
if (dst->agg_send.params && dst->agg_send.msg) {
|
||||
memcpy(dst->agg_send.params, src->agg_send.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->agg_send.msg, src->agg_send.msg,
|
||||
sizeof(esp_ble_mesh_agg_client_msg_t));
|
||||
if (src->agg_send.params->opcode == ESP_BLE_MESH_MODEL_OP_AGG_SEQUENCE) {
|
||||
if (src->agg_send.msg->agg_sequence.items) {
|
||||
length = src->agg_send.msg->agg_sequence.items->len;
|
||||
dst->agg_send.msg->agg_sequence.items = bt_mesh_alloc_buf(length);
|
||||
if (!dst->agg_send.msg->agg_sequence.items) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
break;
|
||||
}
|
||||
|
||||
net_buf_simple_add_mem(dst->agg_send.msg->agg_sequence.items,
|
||||
src->agg_send.msg->agg_sequence.items->data,
|
||||
src->agg_send.msg->agg_sequence.items->len);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_agg_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_agg_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_agg_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_AGG_CLIENT_SEND:
|
||||
if (arg->agg_send.msg) {
|
||||
if (arg->agg_send.params) {
|
||||
if (arg->agg_send.params->opcode == ESP_BLE_MESH_MODEL_OP_AGG_SEQUENCE) {
|
||||
bt_mesh_free_buf(arg->agg_send.msg->agg_sequence.items);
|
||||
}
|
||||
}
|
||||
bt_mesh_free(arg->agg_send.msg);
|
||||
}
|
||||
if (arg->agg_send.params) {
|
||||
bt_mesh_free(arg->agg_send.params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_agg_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
esp_ble_mesh_agg_client_cb_param_t *p_dest_data = p_dest;
|
||||
esp_ble_mesh_agg_client_cb_param_t *p_src_data = p_src;
|
||||
uint16_t length = 0;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_AGG_CLIENT_RECV_RSP_EVT:
|
||||
case ESP_BLE_MESH_AGG_CLIENT_RECV_PUB_EVT:
|
||||
if (p_src_data->params) {
|
||||
switch (p_src_data->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_AGG_SEQUENCE:
|
||||
case ESP_BLE_MESH_MODEL_OP_AGG_STATUS:
|
||||
if (p_src_data->recv.agg_status.items) {
|
||||
length = p_src_data->recv.agg_status.items->len;
|
||||
p_dest_data->recv.agg_status.items = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->recv.agg_status.items) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
net_buf_simple_add_mem(p_dest_data->recv.agg_status.items,
|
||||
p_src_data->recv.agg_status.items->data,
|
||||
p_src_data->recv.agg_status.items->len);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_AGG_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_AGG_CLIENT_SEND_TIMEOUT_EVT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_agg_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_agg_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_agg_client_cb_param_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_AGG_CLIENT_RECV_RSP_EVT:
|
||||
case ESP_BLE_MESH_AGG_CLIENT_RECV_PUB_EVT:
|
||||
if (arg->params) {
|
||||
switch (arg->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_AGG_SEQUENCE:
|
||||
case ESP_BLE_MESH_MODEL_OP_AGG_STATUS:
|
||||
bt_mesh_free_buf(arg->recv.agg_status.items);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_AGG_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_AGG_CLIENT_SEND_TIMEOUT_EVT:
|
||||
if (arg->params) {
|
||||
bt_mesh_free(arg->params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_agg_client_cb(esp_ble_mesh_agg_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_AGG_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_AGG_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_agg_client_cb_param_t),
|
||||
btc_ble_mesh_agg_client_copy_req_data,
|
||||
btc_ble_mesh_agg_client_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_agg_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_agg_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.recv)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_AGG_CLIENT_SEND_TIMEOUT:
|
||||
act = ESP_BLE_MESH_AGG_CLIENT_SEND_TIMEOUT_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_AGG_CLIENT_RECV_RSP:
|
||||
act = ESP_BLE_MESH_AGG_CLIENT_RECV_RSP_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_AGG_CLIENT_RECV_PUB:
|
||||
act = ESP_BLE_MESH_AGG_CLIENT_RECV_PUB_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Opcodes Aggregator client event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
params.opcode = opcode;
|
||||
params.model = (esp_ble_mesh_model_t *)model;
|
||||
params.ctx.net_idx = ctx->net_idx;
|
||||
params.ctx.app_idx = ctx->app_idx;
|
||||
params.ctx.addr = ctx->addr;
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.recv, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_agg_client_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_agg_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_agg_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_AGG_CLIENT_RECV_PUB,
|
||||
model, ctx, buf->data, buf->len);
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_agg_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_agg_client_msg_t *set)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL || set == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, false);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_AGG_SEQUENCE:
|
||||
return bt_mesh_agg_sequence(¶m, &set->agg_sequence);
|
||||
default:
|
||||
BT_ERR("Invalid Opcodes Aggregator opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_agg_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_agg_client_cb_param_t cb = {0};
|
||||
btc_ble_mesh_agg_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_agg_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_AGG_CLIENT_SEND:
|
||||
cb.params = arg->agg_send.params;
|
||||
cb.send.err_code = btc_ble_mesh_agg_client_send(arg->agg_send.params,
|
||||
arg->agg_send.msg);
|
||||
btc_ble_mesh_agg_client_cb(&cb,
|
||||
ESP_BLE_MESH_AGG_CLIENT_SEND_COMP_EVT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_agg_client_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_agg_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_agg_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_agg_client_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_AGG_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_agg_client_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_agg_client_free_req_data(msg);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_AGG_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_AGG_SRV
|
||||
|
||||
/* Opcodes Aggregator Server model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_agg_server_cb_to_app(esp_ble_mesh_agg_server_cb_event_t event,
|
||||
esp_ble_mesh_agg_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_agg_server_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_AGG_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_agg_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
esp_ble_mesh_agg_server_cb_param_t *p_dest_data = p_dest;
|
||||
esp_ble_mesh_agg_server_cb_param_t *p_src_data = p_src;
|
||||
uint16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_AGG_SERVER_RECV_MSG_EVT:
|
||||
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_AGG_SEQUENCE) {
|
||||
if (p_src_data->recv.agg_sequence.items) {
|
||||
length = p_src_data->recv.agg_sequence.items->len;
|
||||
p_dest_data->recv.agg_sequence.items = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->recv.agg_sequence.items) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
|
||||
net_buf_simple_add_mem(p_dest_data->recv.agg_sequence.items,
|
||||
p_src_data->recv.agg_sequence.items->data,
|
||||
p_src_data->recv.agg_sequence.items->len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_agg_server_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_agg_server_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_agg_server_cb_param_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_AGG_SERVER_RECV_MSG_EVT:
|
||||
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_AGG_SEQUENCE) {
|
||||
bt_mesh_free_buf(arg->recv.agg_sequence.items);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_agg_server_cb(
|
||||
esp_ble_mesh_agg_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_AGG_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_AGG_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_agg_server_cb_param_t),
|
||||
btc_ble_mesh_agg_server_copy_req_data,
|
||||
btc_ble_mesh_agg_server_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_agg_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const void *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_agg_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.recv)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_AGG_SERVER_RECV_MSG:
|
||||
act = ESP_BLE_MESH_AGG_SERVER_RECV_MSG_EVT;
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.recv, val, len);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Opcodes Aggregator server event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
cb_params.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.ctx.net_idx = ctx->net_idx;
|
||||
cb_params.ctx.app_idx = ctx->app_idx;
|
||||
cb_params.ctx.addr = ctx->addr;
|
||||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
btc_ble_mesh_agg_server_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_agg_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_agg_server_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_agg_server_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_AGG_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_agg_server_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_agg_server_free_req_data(msg);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_AGG_SRV */
|
||||
@@ -0,0 +1,462 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_brc_model.h"
|
||||
#include "esp_ble_mesh_brc_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_BRC_CLI
|
||||
|
||||
extern int bt_mesh_subnet_bridge_get(void *param);
|
||||
extern int bt_mesh_subnet_bridge_set(void *param, uint8_t subnet_bridge);
|
||||
extern int bt_mesh_bridging_table_add(void *param, void *add);
|
||||
extern int bt_mesh_bridging_table_remove(void *param, void *remove);
|
||||
extern int bt_mesh_bridged_subnets_get(void *param, uint8_t bridge_filter,
|
||||
uint16_t net_idx, uint8_t bridge_start_idx);
|
||||
extern int bt_mesh_bridging_table_get(void *param,
|
||||
uint16_t bridge_net_idx_1,
|
||||
uint16_t bridge_net_idx_2,
|
||||
uint16_t bridge_start_idx);
|
||||
extern int bt_mesh_bridging_table_size_get(void *param);
|
||||
|
||||
/* Bridge Configuration Client model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_brc_client_cb_to_app(esp_ble_mesh_brc_client_cb_event_t event,
|
||||
esp_ble_mesh_brc_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_brc_client_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_BRC_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_brc_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
btc_ble_mesh_brc_client_args_t *dst = p_dest;
|
||||
btc_ble_mesh_brc_client_args_t *src = p_src;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_BRC_CLIENT_SEND:
|
||||
dst->brc_send.params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (dst->brc_send.params) {
|
||||
memcpy(dst->brc_send.params, src->brc_send.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->brc_send.msg) {
|
||||
dst->brc_send.msg = bt_mesh_calloc(sizeof(esp_ble_mesh_brc_client_msg_t));
|
||||
if (dst->brc_send.msg) {
|
||||
memcpy(dst->brc_send.msg, src->brc_send.msg,
|
||||
sizeof(esp_ble_mesh_brc_client_msg_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_brc_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_brc_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_brc_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_BRC_CLIENT_SEND:
|
||||
if (arg->brc_send.msg) {
|
||||
bt_mesh_free(arg->brc_send.msg);
|
||||
}
|
||||
if (arg->brc_send.params) {
|
||||
bt_mesh_free(arg->brc_send.params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_brc_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
esp_ble_mesh_brc_client_cb_param_t *p_dest_data = p_dest;
|
||||
esp_ble_mesh_brc_client_cb_param_t *p_src_data = p_src;
|
||||
uint16_t length = 0;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_BRC_CLIENT_RECV_RSP_EVT:
|
||||
case ESP_BLE_MESH_BRC_CLIENT_RECV_PUB_EVT:
|
||||
if (p_src_data->params) {
|
||||
switch (p_src_data->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_LIST:
|
||||
if (p_src_data->recv.bridged_subnets_list.net_idx_pair) {
|
||||
length = p_src_data->recv.bridged_subnets_list.bridged_entry_list_size * sizeof(esp_ble_mesh_bridge_net_idx_pair_entry_t);
|
||||
p_dest_data->recv.bridged_subnets_list.net_idx_pair = bt_mesh_calloc(length);
|
||||
if (!p_dest_data->recv.bridged_subnets_list.net_idx_pair) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
memcpy(p_dest_data->recv.bridged_subnets_list.net_idx_pair,
|
||||
p_src_data->recv.bridged_subnets_list.net_idx_pair, length);
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_LIST:
|
||||
if (p_src_data->recv.bridging_table_list.bridged_addr_list) {
|
||||
length = p_src_data->recv.bridging_table_list.bridged_addr_list_size * sizeof(esp_ble_mesh_bridged_addr_list_entry_t);
|
||||
p_dest_data->recv.bridging_table_list.bridged_addr_list = bt_mesh_calloc(length);
|
||||
if (!p_dest_data->recv.bridging_table_list.bridged_addr_list) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
memcpy(p_dest_data->recv.bridging_table_list.bridged_addr_list,
|
||||
p_src_data->recv.bridging_table_list.bridged_addr_list, length);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_BRC_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_BRC_CLIENT_SEND_TIMEOUT_EVT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_brc_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_brc_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_brc_client_cb_param_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_BRC_CLIENT_RECV_RSP_EVT:
|
||||
case ESP_BLE_MESH_BRC_CLIENT_RECV_PUB_EVT:
|
||||
if (arg->params) {
|
||||
switch (arg->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_LIST:
|
||||
bt_mesh_free(arg->recv.bridged_subnets_list.net_idx_pair);
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_LIST:
|
||||
bt_mesh_free(arg->recv.bridging_table_list.bridged_addr_list);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_BRC_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_BRC_CLIENT_SEND_TIMEOUT_EVT:
|
||||
if (arg->params) {
|
||||
bt_mesh_free(arg->params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_brc_client_cb(esp_ble_mesh_brc_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_BRC_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_BRC_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_brc_client_cb_param_t),
|
||||
btc_ble_mesh_brc_client_copy_req_data,
|
||||
btc_ble_mesh_brc_client_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_brc_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_brc_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.recv)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_BRC_CLIENT_RECV_RSP:
|
||||
act = ESP_BLE_MESH_BRC_CLIENT_RECV_RSP_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_BRC_CLIENT_RECV_PUB:
|
||||
act = ESP_BLE_MESH_BRC_CLIENT_RECV_PUB_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_BRC_CLIENT_SEND_TIMEOUT:
|
||||
act = ESP_BLE_MESH_BRC_CLIENT_SEND_TIMEOUT_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Bridge Config client event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
params.opcode = opcode;
|
||||
params.model = (esp_ble_mesh_model_t *)model;
|
||||
params.ctx.net_idx = ctx->net_idx;
|
||||
params.ctx.app_idx = ctx->app_idx;
|
||||
params.ctx.addr = ctx->addr;
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.recv, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_brc_client_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_brc_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_brc_client_cb_evt_to_btc(opcode,
|
||||
ESP_BLE_MESH_BRC_CLIENT_RECV_PUB_EVT,
|
||||
model, ctx, buf->data, buf->len);
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_brc_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_brc_client_msg_t *msg)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_ADD:
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_REMOVE:
|
||||
if (msg == NULL) {
|
||||
BT_ERR("Invalid Bridge Config message, opcode 0x%04x", params->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, true);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_GET:
|
||||
return bt_mesh_subnet_bridge_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_GET:
|
||||
return bt_mesh_bridged_subnets_get(¶m, msg->bridged_subnets_get.bridge_filter, msg->bridged_subnets_get.bridge_net_idx, msg->bridged_subnets_get.bridge_start_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_GET:
|
||||
return bt_mesh_bridging_table_get(¶m, msg->bridging_table_get.bridge_net_idx_1, msg->bridging_table_get.bridge_net_idx_2, msg->bridging_table_get.bridge_start_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_SIZE_GET:
|
||||
return bt_mesh_bridging_table_size_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_SET:
|
||||
return bt_mesh_subnet_bridge_set(¶m, msg->subnet_bridge_set.subnet_bridge);
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_ADD:
|
||||
return bt_mesh_bridging_table_add(¶m, &msg->bridging_table_add);
|
||||
case ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_REMOVE:
|
||||
return bt_mesh_bridging_table_remove(¶m, &msg->bridging_table_remove);
|
||||
default:
|
||||
BT_ERR("Invalid Bridge Config opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_brc_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_brc_client_cb_param_t cb = {0};
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
btc_ble_mesh_brc_client_args_t *arg = (btc_ble_mesh_brc_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_BRC_CLIENT_SEND:
|
||||
cb.params = arg->brc_send.params;
|
||||
cb.send.err_code = btc_ble_mesh_brc_client_send(arg->brc_send.params,
|
||||
arg->brc_send.msg);
|
||||
btc_ble_mesh_brc_client_cb(&cb,
|
||||
ESP_BLE_MESH_BRC_CLIENT_SEND_COMP_EVT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_brc_client_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_brc_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
esp_ble_mesh_brc_client_cb_param_t *arg = (esp_ble_mesh_brc_client_cb_param_t *)(msg->arg);
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_BRC_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_brc_client_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_brc_client_free_req_data(msg);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_BRC_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_BRC_SRV
|
||||
|
||||
/* Bridge Config Server model related functions */
|
||||
static inline void btc_ble_mesh_brc_server_cb_to_app(esp_ble_mesh_brc_server_cb_event_t event,
|
||||
esp_ble_mesh_brc_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_brc_server_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_BRC_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_brc_server_cb(esp_ble_mesh_brc_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_BRC_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_BRC_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_brc_server_cb_param_t), NULL, NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_brc_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_brc_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.value)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_BRC_SERVER_STATE_CHANGE:
|
||||
act = ESP_BLE_MESH_BRC_SERVER_STATE_CHANGE_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Bridge Config server event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
cb_params.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.ctx.net_idx = ctx->net_idx;
|
||||
cb_params.ctx.app_idx = ctx->app_idx;
|
||||
cb_params.ctx.addr = ctx->addr;
|
||||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_brc_server_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_brc_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
esp_ble_mesh_brc_server_cb_param_t *arg = (esp_ble_mesh_brc_server_cb_param_t *)(msg->arg);
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_BRC_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_brc_server_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_BRC_SRV */
|
||||
@@ -0,0 +1,711 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_df_model.h"
|
||||
#include "esp_ble_mesh_df_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_CLI
|
||||
|
||||
extern int bt_mesh_directed_control_get(void *param, uint16_t net_idx);
|
||||
extern int bt_mesh_directed_control_set(void *param, void *set);
|
||||
extern int bt_mesh_path_metric_get(void *param, uint16_t net_idx);
|
||||
extern int bt_mesh_path_metric_set(void *param, void *set);
|
||||
extern int bt_mesh_discovery_table_caps_get(void *param, uint16_t net_idx);
|
||||
extern int bt_mesh_discovery_table_caps_set(void *param, void *set);
|
||||
extern int bt_mesh_forwarding_table_add(void *param, void *add);
|
||||
extern int bt_mesh_forwarding_table_del(void *param, void *del);
|
||||
extern int bt_mesh_forwarding_table_deps_add(void *param, void *add);
|
||||
extern int bt_mesh_forwarding_table_deps_del(void *param, void *del);
|
||||
extern int bt_mesh_forwarding_table_entries_cnt_get(void *param, uint16_t net_idx);
|
||||
extern int bt_mesh_forwarding_table_entries_get(void *param, void *get);
|
||||
extern int bt_mesh_forwarding_table_deps_get(void *param, void *get);
|
||||
extern int bt_mesh_wanted_lanes_get(void *param, uint16_t net_idx);
|
||||
extern int bt_mesh_wanted_lanes_set(void *param, uint16_t net_idx, uint8_t wanted_lanes);
|
||||
extern int bt_mesh_two_way_path_get(void *param, uint16_t net_idx);
|
||||
extern int bt_mesh_two_way_path_set(void *param, uint16_t net_idx, uint8_t two_way_path);
|
||||
extern int bt_mesh_path_echo_interval_get(void *param, uint16_t net_idx);
|
||||
extern int bt_mesh_path_echo_interval_set(void *param, uint16_t net_idx,
|
||||
uint8_t unicast_echo_interval,
|
||||
uint8_t multicast_echo_interval);
|
||||
extern int bt_mesh_directed_net_transmit_get(void *param);
|
||||
extern int bt_mesh_directed_net_transmit_set(void *param, uint8_t transmit);
|
||||
extern int bt_mesh_directed_relay_retransmit_get(void *param);
|
||||
extern int bt_mesh_directed_relay_retransmit_set(void *param, uint8_t retransmit);
|
||||
extern int bt_mesh_rssi_threshold_get(void *param);
|
||||
extern int bt_mesh_rssi_threshold_set(void *param, uint8_t rssi_margin);
|
||||
extern int bt_mesh_directed_paths_get(void *param);
|
||||
extern int bt_mesh_directed_pub_policy_get(void *param, void *get);
|
||||
extern int bt_mesh_directed_pub_policy_set(void *param, void *set);
|
||||
extern int bt_mesh_path_discovery_timing_ctl_get(void *param);
|
||||
extern int bt_mesh_path_discovery_timing_ctl_set(void *param, void *set);
|
||||
extern int bt_mesh_directed_ctl_net_transmit_get(void *param);
|
||||
extern int bt_mesh_directed_ctl_net_transmit_set(void *param, uint8_t transmit);
|
||||
extern int bt_mesh_directed_ctl_relay_retransmit_get(void *param);
|
||||
extern int bt_mesh_directed_ctl_relay_retransmit_set(void *param, uint8_t retransmit);
|
||||
|
||||
/* Directed Forwarding Config Client model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_df_client_cb_to_app(esp_ble_mesh_df_client_cb_event_t event,
|
||||
esp_ble_mesh_df_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_df_client_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_DF_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_df_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
btc_ble_mesh_df_client_args_t *dst = p_dest;
|
||||
btc_ble_mesh_df_client_args_t *src = p_src;
|
||||
uint16_t length = 0;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_DF_CLIENT_GET_STATE: {
|
||||
dst->df_get.params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (dst->df_get.params) {
|
||||
memcpy(dst->df_get.params, src->df_get.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->df_get.get) {
|
||||
dst->df_get.get = bt_mesh_calloc(sizeof(esp_ble_mesh_df_client_get_t));
|
||||
if (dst->df_get.get) {
|
||||
memcpy(dst->df_get.get, src->df_get.get,
|
||||
sizeof(esp_ble_mesh_df_client_get_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_DF_CLIENT_SET_STATE: {
|
||||
dst->df_set.params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->df_set.set = bt_mesh_calloc(sizeof(esp_ble_mesh_df_client_set_t));
|
||||
if (dst->df_set.params && dst->df_set.set) {
|
||||
memcpy(dst->df_set.params, src->df_set.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->df_set.set, src->df_set.set,
|
||||
sizeof(esp_ble_mesh_df_client_set_t));
|
||||
|
||||
switch (src->df_set.params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_ADD:
|
||||
if (src->df_set.set->forwarding_table_deps_add.dep_origin_uar_list &&
|
||||
src->df_set.set->forwarding_table_deps_add.dep_origin_uar_list_size) {
|
||||
length = src->df_set.set->forwarding_table_deps_add.dep_origin_uar_list_size * sizeof(esp_ble_mesh_uar_t);
|
||||
dst->df_set.set->forwarding_table_deps_add.dep_origin_uar_list = bt_mesh_calloc(length);
|
||||
if (!dst->df_set.set->forwarding_table_deps_add.dep_origin_uar_list) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(dst->df_set.set->forwarding_table_deps_add.dep_origin_uar_list,
|
||||
src->df_set.set->forwarding_table_deps_add.dep_origin_uar_list,
|
||||
length);
|
||||
}
|
||||
if (src->df_set.set->forwarding_table_deps_add.dep_target_uar_list &&
|
||||
src->df_set.set->forwarding_table_deps_add.dep_target_uar_list_size) {
|
||||
length = src->df_set.set->forwarding_table_deps_add.dep_target_uar_list_size * sizeof(esp_ble_mesh_uar_t);
|
||||
dst->df_set.set->forwarding_table_deps_add.dep_target_uar_list = bt_mesh_calloc(length);
|
||||
if (!dst->df_set.set->forwarding_table_deps_add.dep_target_uar_list) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(dst->df_set.set->forwarding_table_deps_add.dep_target_uar_list,
|
||||
src->df_set.set->forwarding_table_deps_add.dep_target_uar_list,
|
||||
length);
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_DEL:
|
||||
if (src->df_set.set->forwarding_table_deps_del.dep_origin_list &&
|
||||
src->df_set.set->forwarding_table_deps_del.dep_origin_list_size) {
|
||||
length = src->df_set.set->forwarding_table_deps_del.dep_origin_list_size * 2;
|
||||
dst->df_set.set->forwarding_table_deps_del.dep_origin_list = bt_mesh_calloc(length);
|
||||
if (!dst->df_set.set->forwarding_table_deps_del.dep_origin_list) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(dst->df_set.set->forwarding_table_deps_del.dep_origin_list,
|
||||
src->df_set.set->forwarding_table_deps_del.dep_origin_list,
|
||||
length);
|
||||
}
|
||||
if (src->df_set.set->forwarding_table_deps_del.dep_target_list &&
|
||||
src->df_set.set->forwarding_table_deps_del.dep_target_list_size) {
|
||||
length = src->df_set.set->forwarding_table_deps_del.dep_target_list_size * 2;
|
||||
dst->df_set.set->forwarding_table_deps_del.dep_target_list = bt_mesh_calloc(length);
|
||||
if (!dst->df_set.set->forwarding_table_deps_del.dep_target_list) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(dst->df_set.set->forwarding_table_deps_del.dep_target_list,
|
||||
src->df_set.set->forwarding_table_deps_del.dep_target_list,
|
||||
length);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_df_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_df_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_df_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_DF_CLIENT_GET_STATE:
|
||||
if (arg->df_get.params) {
|
||||
bt_mesh_free(arg->df_get.params);
|
||||
}
|
||||
if (arg->df_get.get) {
|
||||
bt_mesh_free(arg->df_get.get);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_DF_CLIENT_SET_STATE:
|
||||
if (arg->df_set.set) {
|
||||
if (arg->df_set.params) {
|
||||
switch (arg->df_set.params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_ADD:
|
||||
bt_mesh_free(arg->df_set.set->forwarding_table_deps_add.dep_origin_uar_list);
|
||||
bt_mesh_free(arg->df_set.set->forwarding_table_deps_add.dep_target_uar_list);
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_DEL:
|
||||
bt_mesh_free(arg->df_set.set->forwarding_table_deps_del.dep_origin_list);
|
||||
bt_mesh_free(arg->df_set.set->forwarding_table_deps_del.dep_target_list);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
bt_mesh_free(arg->df_set.set);
|
||||
}
|
||||
if (arg->df_set.params) {
|
||||
bt_mesh_free(arg->df_set.params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_df_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
esp_ble_mesh_df_client_cb_param_t *p_dest_data = p_dest;
|
||||
esp_ble_mesh_df_client_cb_param_t *p_src_data = p_src;
|
||||
uint16_t length = 0;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_DF_CLIENT_RECV_GET_RSP_EVT:
|
||||
case ESP_BLE_MESH_DF_CLIENT_RECV_SET_RSP_EVT:
|
||||
case ESP_BLE_MESH_DF_CLIENT_RECV_PUB_EVT:
|
||||
if (p_src_data->params) {
|
||||
switch (p_src_data->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_STATUS:
|
||||
if (p_src_data->recv.forwarding_table_entries_status.entry_list) {
|
||||
length = p_src_data->recv.forwarding_table_entries_status.entry_list_size * sizeof(esp_ble_mesh_forwarding_table_entry_t);
|
||||
p_dest_data->recv.forwarding_table_entries_status.entry_list = bt_mesh_calloc(length);
|
||||
if (!p_dest_data->recv.forwarding_table_entries_status.entry_list) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->recv.forwarding_table_entries_status.entry_list,
|
||||
p_src_data->recv.forwarding_table_entries_status.entry_list,
|
||||
length);
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_GET_STATUS:
|
||||
if (p_src_data->recv.forwarding_table_deps_get_status.dep_origin_uar_list) {
|
||||
length = p_src_data->recv.forwarding_table_deps_get_status.dep_origin_uar_list_size * sizeof(esp_ble_mesh_uar_t);
|
||||
p_dest_data->recv.forwarding_table_deps_get_status.dep_origin_uar_list = bt_mesh_calloc(length);
|
||||
if (!p_dest_data->recv.forwarding_table_deps_get_status.dep_origin_uar_list) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->recv.forwarding_table_deps_get_status.dep_origin_uar_list,
|
||||
p_src_data->recv.forwarding_table_deps_get_status.dep_origin_uar_list,
|
||||
length);
|
||||
}
|
||||
if (p_src_data->recv.forwarding_table_deps_get_status.dep_target_uar_list) {
|
||||
length = p_src_data->recv.forwarding_table_deps_get_status.dep_target_uar_list_size * sizeof(esp_ble_mesh_uar_t);
|
||||
p_dest_data->recv.forwarding_table_deps_get_status.dep_target_uar_list = bt_mesh_calloc(length);
|
||||
if (!p_dest_data->recv.forwarding_table_deps_get_status.dep_target_uar_list) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->recv.forwarding_table_deps_get_status.dep_target_uar_list,
|
||||
p_src_data->recv.forwarding_table_deps_get_status.dep_target_uar_list,
|
||||
length);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_DF_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_DF_CLIENT_SEND_TIMEOUT_EVT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_df_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_df_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_df_client_cb_param_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_DF_CLIENT_RECV_GET_RSP_EVT:
|
||||
case ESP_BLE_MESH_DF_CLIENT_RECV_SET_RSP_EVT:
|
||||
case ESP_BLE_MESH_DF_CLIENT_RECV_PUB_EVT:
|
||||
if (arg->params) {
|
||||
switch (arg->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_STATUS:
|
||||
bt_mesh_free(arg->recv.forwarding_table_entries_status.entry_list);
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_GET_STATUS:
|
||||
bt_mesh_free(arg->recv.forwarding_table_deps_get_status.dep_origin_uar_list);
|
||||
bt_mesh_free(arg->recv.forwarding_table_deps_get_status.dep_target_uar_list);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_DF_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_DF_CLIENT_SEND_TIMEOUT_EVT:
|
||||
if (arg->params) {
|
||||
bt_mesh_free(arg->params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_df_client_cb(esp_ble_mesh_df_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_DF_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_DF_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_df_client_cb_param_t),
|
||||
btc_ble_mesh_df_client_copy_req_data,
|
||||
btc_ble_mesh_df_client_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_df_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_df_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.recv)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_DF_CLIENT_SEND_TIMEOUT:
|
||||
act = ESP_BLE_MESH_DF_CLIENT_SEND_TIMEOUT_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_DF_CLIENT_RECV_GET_RSP:
|
||||
act = ESP_BLE_MESH_DF_CLIENT_RECV_GET_RSP_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_DF_CLIENT_RECV_SET_RSP:
|
||||
act = ESP_BLE_MESH_DF_CLIENT_RECV_SET_RSP_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_DF_CLIENT_RECV_PUB:
|
||||
act = ESP_BLE_MESH_DF_CLIENT_RECV_PUB_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Directed Forward Config client event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
params.opcode = opcode;
|
||||
params.model = (esp_ble_mesh_model_t *)model;
|
||||
params.ctx.net_idx = ctx->net_idx;
|
||||
params.ctx.app_idx = ctx->app_idx;
|
||||
params.ctx.addr = ctx->addr;
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.recv, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_df_client_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_df_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_df_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_DF_CLIENT_RECV_PUB,
|
||||
model, ctx, buf->data, buf->len);
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_df_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_df_client_get_t *get)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_CONTROL_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_PATH_METRIC_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_DISCOVERY_TABLE_CAPS_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_CNT_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_WANTED_LANES_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_TWO_WAY_PATH_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_PATH_ECHO_INTERVAL_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_PUB_POLICY_GET:
|
||||
if (get == NULL) {
|
||||
BT_ERR("Invalid Directed Forward Config Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, true);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_CONTROL_GET:
|
||||
return bt_mesh_directed_control_get(¶m, get->directed_control_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_PATH_METRIC_GET:
|
||||
return bt_mesh_path_metric_get(¶m, get->path_metric_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_DISCOVERY_TABLE_CAPS_GET:
|
||||
return bt_mesh_discovery_table_caps_get(¶m, get->disc_table_caps_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_CNT_GET:
|
||||
return bt_mesh_forwarding_table_entries_cnt_get(¶m, get->forwarding_table_entries_cnt_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ENTRIES_GET:
|
||||
return bt_mesh_forwarding_table_entries_get(¶m, &get->forwarding_table_entries_get);
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_GET:
|
||||
return bt_mesh_forwarding_table_deps_get(¶m, &get->forwarding_table_deps_get);
|
||||
case ESP_BLE_MESH_MODEL_OP_WANTED_LANES_GET:
|
||||
return bt_mesh_wanted_lanes_get(¶m, get->wanted_lanes_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_TWO_WAY_PATH_GET:
|
||||
return bt_mesh_two_way_path_get(¶m, get->two_way_path_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_PATH_ECHO_INTERVAL_GET:
|
||||
return bt_mesh_path_echo_interval_get(¶m, get->path_echo_interval_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_NET_TRANSMIT_GET:
|
||||
return bt_mesh_directed_net_transmit_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_RELAY_RETRANSMIT_GET:
|
||||
return bt_mesh_directed_relay_retransmit_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_RSSI_THRESHOLD_GET:
|
||||
return bt_mesh_rssi_threshold_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_PATHS_GET:
|
||||
return bt_mesh_directed_paths_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_PUB_POLICY_GET:
|
||||
return bt_mesh_directed_pub_policy_get(¶m, &get->directed_pub_policy_get);
|
||||
case ESP_BLE_MESH_MODEL_OP_PATH_DISCOVERY_TIMING_CTL_GET:
|
||||
return bt_mesh_path_discovery_timing_ctl_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_NET_TRANSMIT_GET:
|
||||
return bt_mesh_directed_ctl_net_transmit_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_RELAY_RETRANSMIT_GET:
|
||||
return bt_mesh_directed_ctl_relay_retransmit_get(¶m);
|
||||
default:
|
||||
BT_ERR("Invalid Directed Forward Config Get opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_df_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_df_client_set_t *set)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL || set == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, true);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_CONTROL_SET:
|
||||
return bt_mesh_directed_control_set(¶m, &set->directed_control_set);
|
||||
case ESP_BLE_MESH_MODEL_OP_PATH_METRIC_SET:
|
||||
return bt_mesh_path_metric_set(¶m, &set->path_metric_set);
|
||||
case ESP_BLE_MESH_MODEL_OP_DISCOVERY_TABLE_CAPS_SET:
|
||||
return bt_mesh_discovery_table_caps_set(¶m, &set->disc_table_caps_set);
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_ADD:
|
||||
return bt_mesh_forwarding_table_add(¶m, &set->forwarding_table_add);
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEL:
|
||||
return bt_mesh_forwarding_table_del(¶m, &set->forwarding_table_del);
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_ADD:
|
||||
return bt_mesh_forwarding_table_deps_add(¶m, &set->forwarding_table_deps_add);
|
||||
case ESP_BLE_MESH_MODEL_OP_FORWARDING_TABLE_DEPS_DEL:
|
||||
return bt_mesh_forwarding_table_deps_del(¶m, &set->forwarding_table_deps_del);
|
||||
case ESP_BLE_MESH_MODEL_OP_WANTED_LANES_SET:
|
||||
return bt_mesh_wanted_lanes_set(¶m, set->wanted_lanes_set.net_idx,
|
||||
set->wanted_lanes_set.wanted_lanes);
|
||||
case ESP_BLE_MESH_MODEL_OP_TWO_WAY_PATH_SET:
|
||||
return bt_mesh_two_way_path_set(¶m, set->two_way_path_set.net_idx,
|
||||
set->two_way_path_set.two_way_path);
|
||||
case ESP_BLE_MESH_MODEL_OP_PATH_ECHO_INTERVAL_SET:
|
||||
return bt_mesh_path_echo_interval_set(¶m, set->path_echo_interval_set.net_idx,
|
||||
set->path_echo_interval_set.unicast_echo_interval,
|
||||
set->path_echo_interval_set.multicast_echo_interval);
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_NET_TRANSMIT_SET:
|
||||
return bt_mesh_directed_net_transmit_set(¶m, set->directed_net_transmit_set.net_transmit);
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_RELAY_RETRANSMIT_SET:
|
||||
return bt_mesh_directed_relay_retransmit_set(¶m, set->directed_relay_retransmit_set.relay_retransmit);
|
||||
case ESP_BLE_MESH_MODEL_OP_RSSI_THRESHOLD_SET:
|
||||
return bt_mesh_rssi_threshold_set(¶m, set->rssi_threshold_set.rssi_margin);
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_PUB_POLICY_SET:
|
||||
return bt_mesh_directed_pub_policy_set(¶m, &set->directed_pub_policy_set);
|
||||
case ESP_BLE_MESH_MODEL_OP_PATH_DISCOVERY_TIMING_CTL_SET:
|
||||
return bt_mesh_path_discovery_timing_ctl_set(¶m, &set->path_disc_timing_ctl_set);
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_NET_TRANSMIT_SET:
|
||||
return bt_mesh_directed_ctl_net_transmit_set(¶m, set->directed_ctl_net_transmit_set.net_transmit);
|
||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_CTL_RELAY_RETRANSMIT_SET:
|
||||
return bt_mesh_directed_ctl_relay_retransmit_set(¶m, set->directed_ctl_relay_retransmit_set.relay_retransmit);
|
||||
default:
|
||||
BT_ERR("Invalid Directed Forward Config Set opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_df_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_df_client_cb_param_t cb = {0};
|
||||
btc_ble_mesh_df_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_df_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_DF_CLIENT_GET_STATE:
|
||||
cb.params = arg->df_get.params;
|
||||
cb.send.err_code = btc_ble_mesh_df_client_get_state(arg->df_get.params,
|
||||
arg->df_get.get);
|
||||
btc_ble_mesh_df_client_cb(&cb,
|
||||
ESP_BLE_MESH_DF_CLIENT_SEND_COMP_EVT);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_DF_CLIENT_SET_STATE:
|
||||
cb.params = arg->df_set.params;
|
||||
cb.send.err_code = btc_ble_mesh_df_client_set_state(arg->df_set.params,
|
||||
arg->df_set.set);
|
||||
btc_ble_mesh_df_client_cb(&cb,
|
||||
ESP_BLE_MESH_DF_CLIENT_SEND_COMP_EVT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_df_client_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_df_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_df_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_df_client_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_DF_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_df_client_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_df_client_free_req_data(msg);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DF_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_DF_SRV
|
||||
|
||||
/* Directed Forwarding Config Server model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_df_server_cb_to_app(esp_ble_mesh_df_server_cb_event_t event,
|
||||
esp_ble_mesh_df_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_df_server_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_DF_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_df_server_cb(
|
||||
esp_ble_mesh_df_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_DF_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_DF_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_df_server_cb_param_t), NULL, NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_df_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_df_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (len > sizeof(cb_params.value)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_DF_SERVER_STATE_CHANGE:
|
||||
act = ESP_BLE_MESH_DF_SERVER_STATE_CHANGE_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_DF_SERVER_TABLE_CHANGE:
|
||||
act = ESP_BLE_MESH_DF_SERVER_TABLE_CHANGE_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Directed Forward Config server event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (model) {
|
||||
cb_params.model = (esp_ble_mesh_model_t *)model;
|
||||
}
|
||||
|
||||
if (ctx) {
|
||||
cb_params.ctx.net_idx = ctx->net_idx;
|
||||
cb_params.ctx.app_idx = ctx->app_idx;
|
||||
cb_params.ctx.addr = ctx->addr;
|
||||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
}
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_df_server_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_df_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_df_server_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_df_server_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_DF_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_df_server_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DF_SRV */
|
||||
@@ -0,0 +1,435 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_lcd_model.h"
|
||||
#include "esp_ble_mesh_lcd_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_LCD_CLI
|
||||
|
||||
extern int bt_mesh_large_comp_data_get(void *param, uint8_t page, uint16_t offset);
|
||||
extern int bt_mesh_models_metadata_get(void *param, uint8_t metadata_page, uint16_t offset);
|
||||
|
||||
/* Large Composition Data Client model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_lcd_client_cb_to_app(esp_ble_mesh_lcd_client_cb_event_t event,
|
||||
esp_ble_mesh_lcd_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_lcd_client_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_LCD_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lcd_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
btc_ble_mesh_lcd_client_args_t *dst = p_dest;
|
||||
btc_ble_mesh_lcd_client_args_t *src = p_src;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_LCD_CLIENT_SEND:
|
||||
dst->lcd_send.params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->lcd_send.msg = bt_mesh_calloc(sizeof(esp_ble_mesh_lcd_client_msg_t));
|
||||
if (dst->lcd_send.params && dst->lcd_send.msg) {
|
||||
memcpy(dst->lcd_send.params, src->lcd_send.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->lcd_send.msg, src->lcd_send.msg,
|
||||
sizeof(esp_ble_mesh_lcd_client_msg_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lcd_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_lcd_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_lcd_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_LCD_CLIENT_SEND:
|
||||
if (arg->lcd_send.msg) {
|
||||
bt_mesh_free(arg->lcd_send.msg);
|
||||
}
|
||||
if (arg->lcd_send.params) {
|
||||
bt_mesh_free(arg->lcd_send.params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_lcd_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
esp_ble_mesh_lcd_client_cb_param_t *p_dest_data = p_dest;
|
||||
esp_ble_mesh_lcd_client_cb_param_t *p_src_data = p_src;
|
||||
uint16_t length = 0;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_LCD_CLIENT_RECV_RSP_EVT:
|
||||
case ESP_BLE_MESH_LCD_CLIENT_RECV_PUB_EVT:
|
||||
if (p_src_data->params) {
|
||||
switch (p_src_data->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_LARGE_COMP_DATA_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_LARGE_COMP_DATA_STATUS:
|
||||
if (p_src_data->recv.large_comp_data_status.data) {
|
||||
length = p_src_data->recv.large_comp_data_status.data->len;
|
||||
p_dest_data->recv.large_comp_data_status.data = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->recv.large_comp_data_status.data) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
net_buf_simple_add_mem(p_dest_data->recv.large_comp_data_status.data,
|
||||
p_src_data->recv.large_comp_data_status.data->data,
|
||||
p_src_data->recv.large_comp_data_status.data->len);
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_MODELS_METADATA_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_MODELS_METADATA_STATUS:
|
||||
if (p_src_data->recv.models_metadata_status.data) {
|
||||
length = p_src_data->recv.models_metadata_status.data->len;
|
||||
p_dest_data->recv.models_metadata_status.data = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->recv.models_metadata_status.data) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
net_buf_simple_add_mem(p_dest_data->recv.models_metadata_status.data,
|
||||
p_src_data->recv.models_metadata_status.data->data,
|
||||
p_src_data->recv.models_metadata_status.data->len);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_LCD_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_LCD_CLIENT_SEND_TIMEOUT_EVT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_lcd_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_lcd_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_lcd_client_cb_param_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_LCD_CLIENT_RECV_RSP_EVT:
|
||||
case ESP_BLE_MESH_LCD_CLIENT_RECV_PUB_EVT:
|
||||
if (arg->params) {
|
||||
switch (arg->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_LARGE_COMP_DATA_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_LARGE_COMP_DATA_STATUS:
|
||||
bt_mesh_free_buf(arg->recv.large_comp_data_status.data);
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_MODELS_METADATA_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_MODELS_METADATA_STATUS:
|
||||
bt_mesh_free_buf(arg->recv.models_metadata_status.data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_LCD_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_LCD_CLIENT_SEND_TIMEOUT_EVT:
|
||||
if (arg->params) {
|
||||
bt_mesh_free(arg->params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_lcd_client_cb(esp_ble_mesh_lcd_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_LCD_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_LCD_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_lcd_client_cb_param_t),
|
||||
btc_ble_mesh_lcd_client_copy_req_data,
|
||||
btc_ble_mesh_lcd_client_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_lcd_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const void *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_lcd_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.recv)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_LCD_CLIENT_SEND_TIMEOUT:
|
||||
act = ESP_BLE_MESH_LCD_CLIENT_SEND_TIMEOUT_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_LCD_CLIENT_RECV_RSP:
|
||||
act = ESP_BLE_MESH_LCD_CLIENT_RECV_RSP_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_LCD_CLIENT_RECV_PUB:
|
||||
act = ESP_BLE_MESH_LCD_CLIENT_RECV_PUB_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Large Comp Data client event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
params.opcode = opcode;
|
||||
params.model = (esp_ble_mesh_model_t *)model;
|
||||
params.ctx.net_idx = ctx->net_idx;
|
||||
params.ctx.app_idx = ctx->app_idx;
|
||||
params.ctx.addr = ctx->addr;
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.recv, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_lcd_client_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lcd_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_lcd_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_LCD_CLIENT_RECV_PUB,
|
||||
model, ctx, buf->data, buf->len);
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_lcd_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_lcd_client_msg_t *msg)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL || msg == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, true);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_LARGE_COMP_DATA_GET:
|
||||
return bt_mesh_large_comp_data_get(¶m, msg->large_comp_data_get.page,
|
||||
msg->large_comp_data_get.offset);
|
||||
case ESP_BLE_MESH_MODEL_OP_MODELS_METADATA_GET:
|
||||
return bt_mesh_models_metadata_get(¶m, msg->models_metadata_get.metadata_page,
|
||||
msg->models_metadata_get.offset);
|
||||
default:
|
||||
BT_ERR("Invalid Large Comp Data Set opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lcd_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_lcd_client_cb_param_t cb = {0};
|
||||
btc_ble_mesh_lcd_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_lcd_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_LCD_CLIENT_SEND:
|
||||
cb.params = arg->lcd_send.params;
|
||||
cb.send.err_code = btc_ble_mesh_lcd_client_send(arg->lcd_send.params,
|
||||
arg->lcd_send.msg);
|
||||
btc_ble_mesh_lcd_client_cb(&cb, ESP_BLE_MESH_LCD_CLIENT_SEND_COMP_EVT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_lcd_client_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lcd_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_lcd_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_lcd_client_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_LCD_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_lcd_client_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_lcd_client_free_req_data(msg);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_LCD_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_LCD_SRV
|
||||
|
||||
/* Large Comp Data Server model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_lcd_server_cb_to_app(esp_ble_mesh_lcd_server_cb_event_t event,
|
||||
esp_ble_mesh_lcd_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_lcd_server_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_LCD_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_lcd_server_cb(
|
||||
esp_ble_mesh_lcd_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_LCD_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_LCD_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_lcd_server_cb_param_t), NULL, NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_lcd_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const void *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_lcd_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.value)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_LCD_SERVER_STATE_CHANGE:
|
||||
act = ESP_BLE_MESH_LCD_SERVER_STATE_CHANGE_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Large Comp Data server event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
cb_params.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.ctx.net_idx = ctx->net_idx;
|
||||
cb_params.ctx.app_idx = ctx->app_idx;
|
||||
cb_params.ctx.addr = ctx->addr;
|
||||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_lcd_server_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lcd_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_lcd_server_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_lcd_server_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_LCD_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_lcd_server_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_LCD_SRV */
|
||||
@@ -0,0 +1,600 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_mbt_model.h"
|
||||
#include "esp_ble_mesh_mbt_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_MBT_CLI
|
||||
|
||||
extern int bt_mesh_retrieve_capabilities(void *input);
|
||||
extern int bt_mesh_transfer_blob(void *input);
|
||||
extern int bt_mesh_send_block(void *input);
|
||||
extern int bt_mesh_send_data(void *input);
|
||||
extern int bt_mesh_determine_block_status(void *input);
|
||||
extern int bt_mesh_determine_transfer_status(void *input);
|
||||
extern int bt_mesh_cancel_transfer(void *input);
|
||||
extern int bt_mesh_set_transfer_ttl_state(void *model, uint8_t transfer_ttl);
|
||||
extern int bt_mesh_clear_transfer_ttl_state(void *model);
|
||||
extern int bt_mesh_set_app_idx_state(void *model, uint16_t app_idx);
|
||||
extern int bt_mesh_clear_app_idx_state(void *model);
|
||||
extern int bt_mesh_set_multicast_addr_state(void *model, uint16_t multicast_addr);
|
||||
extern int bt_mesh_clear_multicast_addr_state(void *model);
|
||||
extern int bt_mesh_initialize_blob_receive(void *input);
|
||||
extern int bt_mesh_cancel_blob_receive(void *input);
|
||||
extern int bt_mesh_set_blob_capabilities(void *model, void *input);
|
||||
|
||||
static inline void btc_ble_mesh_blob_trans_client_cb_to_app(esp_ble_mesh_mbt_client_cb_event_t event,
|
||||
esp_ble_mesh_mbt_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_mbt_client_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_mbt_client_cb_t)btc_profile_cb_get(BTC_PID_MBT_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_mbt_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t *dst = (btc_ble_mesh_mbt_client_args_t *)p_dest;
|
||||
btc_ble_mesh_mbt_client_args_t *src = (btc_ble_mesh_mbt_client_args_t *)p_src;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_RETRIEVE_CAPABILITIES:
|
||||
if (src->retrieve_capabilities.unicast_addr_count && src->retrieve_capabilities.unicast_addr) {
|
||||
dst->retrieve_capabilities.unicast_addr = bt_mesh_calloc(src->retrieve_capabilities.unicast_addr_count * 2);
|
||||
if (dst->retrieve_capabilities.unicast_addr) {
|
||||
memcpy(dst->retrieve_capabilities.unicast_addr, src->retrieve_capabilities.unicast_addr,
|
||||
src->retrieve_capabilities.unicast_addr_count * 2);
|
||||
dst->retrieve_capabilities.unicast_addr_count = src->retrieve_capabilities.unicast_addr_count;
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_TRANSFER_BLOB:
|
||||
if (src->transfer_blob.unicast_addr_count && src->transfer_blob.unicast_addr) {
|
||||
dst->transfer_blob.unicast_addr = bt_mesh_calloc(src->transfer_blob.unicast_addr_count * 2);
|
||||
if (dst->transfer_blob.unicast_addr) {
|
||||
memcpy(dst->transfer_blob.unicast_addr, src->transfer_blob.unicast_addr,
|
||||
src->transfer_blob.unicast_addr_count * 2);
|
||||
dst->transfer_blob.unicast_addr_count = src->transfer_blob.unicast_addr_count;
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_DETERMINE_TRANSFER_STATUS:
|
||||
if (src->determine_transfer_status.unicast_addr_count && src->determine_transfer_status.unicast_addr) {
|
||||
dst->determine_transfer_status.unicast_addr = bt_mesh_calloc(src->determine_transfer_status.unicast_addr_count * 2);
|
||||
if (dst->determine_transfer_status.unicast_addr) {
|
||||
memcpy(dst->determine_transfer_status.unicast_addr, src->determine_transfer_status.unicast_addr,
|
||||
src->determine_transfer_status.unicast_addr_count * 2);
|
||||
dst->determine_transfer_status.unicast_addr_count = src->determine_transfer_status.unicast_addr_count;
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_CANCEL_TRANSFER:
|
||||
if (src->cancel_transfer.unicast_addr_count && src->cancel_transfer.unicast_addr) {
|
||||
dst->cancel_transfer.unicast_addr = bt_mesh_calloc(src->cancel_transfer.unicast_addr_count * 2);
|
||||
if (dst->cancel_transfer.unicast_addr) {
|
||||
memcpy(dst->cancel_transfer.unicast_addr, src->cancel_transfer.unicast_addr,
|
||||
src->cancel_transfer.unicast_addr_count * 2);
|
||||
dst->cancel_transfer.unicast_addr_count = src->cancel_transfer.unicast_addr_count;
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_mbt_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_mbt_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_mbt_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_RETRIEVE_CAPABILITIES:
|
||||
bt_mesh_free(arg->retrieve_capabilities.unicast_addr);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_TRANSFER_BLOB:
|
||||
bt_mesh_free(arg->transfer_blob.unicast_addr);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_DETERMINE_TRANSFER_STATUS:
|
||||
bt_mesh_free(arg->determine_transfer_status.unicast_addr);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_CANCEL_TRANSFER:
|
||||
bt_mesh_free(arg->cancel_transfer.unicast_addr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_blob_trans_client_copy_req_data(btc_msg_t *msg, void *p_dst, void *p_src)
|
||||
{
|
||||
esp_ble_mesh_mbt_client_cb_param_t *dst = (esp_ble_mesh_mbt_client_cb_param_t *)p_dst;
|
||||
esp_ble_mesh_mbt_client_cb_param_t *src = (esp_ble_mesh_mbt_client_cb_param_t *)p_src;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_RETRIEVE_CAPABILITIES:
|
||||
if (src->value.retrieve_capabilities_status.input.unicast_addr_count &&
|
||||
src->value.retrieve_capabilities_status.input.unicast_addr) {
|
||||
dst->value.retrieve_capabilities_status.input.unicast_addr = bt_mesh_calloc(src->value.retrieve_capabilities_status.input.unicast_addr_count * 2);
|
||||
if (dst->value.retrieve_capabilities_status.input.unicast_addr) {
|
||||
memcpy(dst->value.retrieve_capabilities_status.input.unicast_addr, src->value.retrieve_capabilities_status.input.unicast_addr,
|
||||
src->value.retrieve_capabilities_status.input.unicast_addr_count * 2);
|
||||
dst->value.retrieve_capabilities_status.input.unicast_addr_count = src->value.retrieve_capabilities_status.input.unicast_addr_count;
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_TRANSFER_BLOB:
|
||||
if (src->value.transfer_blob_status.input.unicast_addr_count &&
|
||||
src->value.transfer_blob_status.input.unicast_addr) {
|
||||
dst->value.transfer_blob_status.input.unicast_addr = bt_mesh_calloc(src->value.transfer_blob_status.input.unicast_addr_count * 2);
|
||||
if (dst->value.transfer_blob_status.input.unicast_addr) {
|
||||
memcpy(dst->value.transfer_blob_status.input.unicast_addr, src->value.transfer_blob_status.input.unicast_addr,
|
||||
src->value.transfer_blob_status.input.unicast_addr_count * 2);
|
||||
dst->value.transfer_blob_status.input.unicast_addr_count = src->value.transfer_blob_status.input.unicast_addr_count;
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_DETERMINE_TRANSFER_STATUS:
|
||||
if (src->value.determine_transfer_status_status.input.unicast_addr_count &&
|
||||
src->value.determine_transfer_status_status.input.unicast_addr) {
|
||||
dst->value.determine_transfer_status_status.input.unicast_addr = bt_mesh_calloc(src->value.determine_transfer_status_status.input.unicast_addr_count * 2);
|
||||
if (dst->value.determine_transfer_status_status.input.unicast_addr) {
|
||||
memcpy(dst->value.determine_transfer_status_status.input.unicast_addr, src->value.determine_transfer_status_status.input.unicast_addr,
|
||||
src->value.determine_transfer_status_status.input.unicast_addr_count * 2);
|
||||
dst->value.determine_transfer_status_status.input.unicast_addr_count = src->value.determine_transfer_status_status.input.unicast_addr_count;
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_CANCEL_TRANSFER:
|
||||
if (src->value.cancel_transfer_status.input.unicast_addr_count &&
|
||||
src->value.cancel_transfer_status.input.unicast_addr) {
|
||||
dst->value.cancel_transfer_status.input.unicast_addr = bt_mesh_calloc(src->value.cancel_transfer_status.input.unicast_addr_count * 2);
|
||||
if (dst->value.cancel_transfer_status.input.unicast_addr) {
|
||||
memcpy(dst->value.cancel_transfer_status.input.unicast_addr, src->value.cancel_transfer_status.input.unicast_addr,
|
||||
src->value.cancel_transfer_status.input.unicast_addr_count * 2);
|
||||
dst->value.cancel_transfer_status.input.unicast_addr_count = src->value.cancel_transfer_status.input.unicast_addr_count;
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_blob_trans_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_mbt_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_mbt_client_cb_param_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_RETRIEVE_CAPABILITIES:
|
||||
bt_mesh_free(arg->value.retrieve_capabilities_status.input.unicast_addr);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_TRANSFER_BLOB:
|
||||
bt_mesh_free(arg->value.transfer_blob_status.input.unicast_addr);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_DETERMINE_TRANSFER_STATUS:
|
||||
bt_mesh_free(arg->value.determine_transfer_status_status.input.unicast_addr);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_CANCEL_TRANSFER:
|
||||
bt_mesh_free(arg->value.cancel_transfer_status.input.unicast_addr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_blob_trans_client_callback(esp_ble_mesh_mbt_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_MBT_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_MBT_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_mbt_client_cb_param_t),
|
||||
btc_ble_mesh_blob_trans_client_copy_req_data,
|
||||
btc_ble_mesh_blob_trans_client_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_mbt_client_cb_evt_to_btc(uint8_t event, uint8_t result,
|
||||
struct bt_mesh_model *model)
|
||||
{
|
||||
esp_ble_mesh_mbt_client_cb_param_t cb_params = {0};
|
||||
uint8_t cb_event = 0;
|
||||
|
||||
if (model == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_MBT_CLIENT_RETRIEVE_CAPABILITIES_COMP:
|
||||
cb_event = ESP_BLE_MESH_MBT_CLIENT_RETRIEVE_CAPABILITIES_COMP_EVT;
|
||||
cb_params.value.retrieve_capabilities_comp.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.value.retrieve_capabilities_comp.result = result;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_CLIENT_TRANSFER_BLOB_COMP:
|
||||
cb_event = ESP_BLE_MESH_MBT_CLIENT_TRANSFER_BLOB_COMP_EVT;
|
||||
cb_params.value.transfer_blob_comp.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.value.transfer_blob_comp.result = result;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_CLIENT_SEND_BLOCK_COMP:
|
||||
cb_event = ESP_BLE_MESH_MBT_CLIENT_SEND_BLOCK_COMP_EVT;
|
||||
cb_params.value.send_block_comp.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.value.send_block_comp.result = result;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_CLIENT_SEND_DATA_COMP:
|
||||
cb_event = ESP_BLE_MESH_MBT_CLIENT_SEND_DATA_COMP_EVT;
|
||||
cb_params.value.send_data_comp.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.value.send_data_comp.result = result;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_CLIENT_DETERMINE_BLOCK_STATUS_COMP:
|
||||
cb_event = ESP_BLE_MESH_MBT_CLIENT_DETERMINE_BLOCK_STATUS_COMP_EVT;
|
||||
cb_params.value.determine_block_status_comp.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.value.determine_block_status_comp.result = result;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_CLIENT_DETERMINE_TRANSFER_STATUS_COMP:
|
||||
cb_event = ESP_BLE_MESH_MBT_CLIENT_DETERMINE_TRANSFER_STATUS_COMP_EVT;
|
||||
cb_params.value.determine_transfer_status_comp.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.value.determine_transfer_status_comp.result = result;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_CLIENT_CANCEL_TRANSFER_COMP:
|
||||
cb_event = ESP_BLE_MESH_MBT_CLIENT_CANCEL_TRANSFER_COMP_EVT;
|
||||
cb_params.value.cancel_transfer_comp.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.value.cancel_transfer_comp.result = result;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Blob Transfer Client event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
btc_ble_mesh_blob_trans_client_callback(&cb_params, cb_event);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_mbt_client_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* TBD */
|
||||
}
|
||||
|
||||
void btc_ble_mesh_mbt_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_mbt_client_cb_param_t cb = {0};
|
||||
btc_ble_mesh_mbt_client_args_t *arg = NULL;
|
||||
uint8_t event = 0;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_mbt_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_RETRIEVE_CAPABILITIES:
|
||||
event = ESP_BLE_MESH_MBT_CLIENT_RETRIEVE_CAPABILITIES_STATUS_EVT;
|
||||
memcpy(&cb.value.retrieve_capabilities_status.input,
|
||||
&arg->retrieve_capabilities, sizeof(arg->retrieve_capabilities));
|
||||
cb.value.retrieve_capabilities_status.error_code =
|
||||
bt_mesh_retrieve_capabilities(&arg->retrieve_capabilities);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_TRANSFER_BLOB:
|
||||
event = ESP_BLE_MESH_MBT_CLIENT_TRANSFER_BLOB_STATUS_EVT;
|
||||
memcpy(&cb.value.transfer_blob_status.input, &arg->transfer_blob, sizeof(arg->transfer_blob));
|
||||
cb.value.transfer_blob_status.error_code = bt_mesh_transfer_blob(&arg->transfer_blob);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_SEND_BLOCK:
|
||||
event = ESP_BLE_MESH_MBT_CLIENT_SEND_BLOCK_STATUS_EVT;
|
||||
memcpy(&cb.value.send_block_status.input, &arg->send_block, sizeof(arg->send_block));
|
||||
cb.value.send_block_status.error_code = bt_mesh_send_block(&arg->send_block);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_SEND_DATA:
|
||||
event = ESP_BLE_MESH_MBT_CLIENT_SEND_DATA_STATUS_EVT;
|
||||
memcpy(&cb.value.send_data_status.input, &arg->send_data, sizeof(arg->send_data));
|
||||
cb.value.send_data_status.error_code = bt_mesh_send_data(&arg->send_data);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_DETERMINE_BLOCK_STATUS:
|
||||
event = ESP_BLE_MESH_MBT_CLIENT_DETERMINE_BLOCK_STATUS_STATUS_EVT;
|
||||
memcpy(&cb.value.determine_block_status_status.input,
|
||||
&arg->determine_block_status, sizeof(arg->determine_block_status));
|
||||
cb.value.determine_block_status_status.error_code =
|
||||
bt_mesh_determine_block_status(&arg->determine_block_status);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_DETERMINE_TRANSFER_STATUS:
|
||||
event = ESP_BLE_MESH_MBT_CLIENT_DETERMINE_TRANSFER_STATUS_STATUS_EVT;
|
||||
memcpy(&cb.value.determine_transfer_status_status.input,
|
||||
&arg->determine_transfer_status, sizeof(arg->determine_transfer_status));
|
||||
cb.value.determine_transfer_status_status.error_code =
|
||||
bt_mesh_determine_transfer_status(&arg->determine_transfer_status);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_CANCEL_TRANSFER:
|
||||
event = ESP_BLE_MESH_MBT_CLIENT_CANCEL_TRANSFER_STATUS_EVT;
|
||||
memcpy(&cb.value.cancel_transfer_status.input, &arg->cancel_transfer, sizeof(arg->cancel_transfer));
|
||||
cb.value.cancel_transfer_status.error_code = bt_mesh_cancel_transfer(&arg->cancel_transfer);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_SET_TRANSFER_TTL:
|
||||
event = ESP_BLE_MESH_MBT_CLIENT_SET_TRANSFER_TTL_COMP_EVT;
|
||||
cb.value.set_transfer_ttl.model = arg->set_transfer_ttl.model;
|
||||
cb.value.set_transfer_ttl.transfer_ttl = arg->set_transfer_ttl.transfer_ttl;
|
||||
cb.value.set_transfer_ttl.error_code =
|
||||
bt_mesh_set_transfer_ttl_state((struct bt_mesh_model *)arg->set_transfer_ttl.model,
|
||||
arg->set_transfer_ttl.transfer_ttl);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_CLEAR_TRANSFER_TTL:
|
||||
event = ESP_BLE_MESH_MBT_CLIENT_CLEAR_TRANSFER_TTL_COMP_EVT;
|
||||
cb.value.clear_transfer_ttl.model = arg->clear_transfer_ttl.model;
|
||||
cb.value.clear_transfer_ttl.error_code =
|
||||
bt_mesh_clear_transfer_ttl_state((struct bt_mesh_model *)arg->clear_transfer_ttl.model);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_SET_APP_IDX:
|
||||
event = ESP_BLE_MESH_MBT_CLIENT_SET_APP_IDX_COMP_EVT;
|
||||
cb.value.set_app_idx.model = arg->set_app_idx.model;
|
||||
cb.value.set_app_idx.app_idx = arg->set_app_idx.app_idx;
|
||||
cb.value.set_app_idx.error_code =
|
||||
bt_mesh_set_app_idx_state((struct bt_mesh_model *)arg->set_app_idx.model,
|
||||
arg->set_app_idx.app_idx);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_CLEAR_APP_IDX:
|
||||
event = ESP_BLE_MESH_MBT_CLIENT_CLEAR_APP_IDX_COMP_EVT;
|
||||
cb.value.clear_app_idx.model = arg->clear_app_idx.model;
|
||||
cb.value.clear_app_idx.error_code =
|
||||
bt_mesh_clear_app_idx_state((struct bt_mesh_model *)arg->clear_app_idx.model);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_SET_MULTICAST_ADDR:
|
||||
event = ESP_BLE_MESH_MBT_CLIENT_SET_MULTICAST_ADDR_COMP_EVT;
|
||||
cb.value.set_multicast_addr.model = arg->set_multicast_addr.model;
|
||||
cb.value.set_multicast_addr.multicast_addr = arg->set_multicast_addr.multicast_addr;
|
||||
cb.value.set_multicast_addr.error_code =
|
||||
bt_mesh_set_multicast_addr_state((struct bt_mesh_model *)arg->set_multicast_addr.model,
|
||||
arg->set_multicast_addr.multicast_addr);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_CLIENT_CLEAR_MULTICAST_ADDR:
|
||||
event = ESP_BLE_MESH_MBT_CLIENT_CLEAR_MULTICAST_ADDR_COMP_EVT;
|
||||
cb.value.clear_multicast_addr.model = arg->clear_multicast_addr.model;
|
||||
cb.value.clear_multicast_addr.error_code =
|
||||
bt_mesh_clear_multicast_addr_state((struct bt_mesh_model *)arg->clear_multicast_addr.model);
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown BLOB Transfer Client act %d", msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
btc_ble_mesh_blob_trans_client_callback(&cb, event);
|
||||
|
||||
btc_ble_mesh_mbt_client_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_mbt_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_mbt_client_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
param = (esp_ble_mesh_mbt_client_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_MBT_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_blob_trans_client_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_blob_trans_client_free_req_data(msg);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_MBT_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_MBT_SRV
|
||||
|
||||
static inline void btc_ble_mesh_blob_trans_server_cb_to_app(esp_ble_mesh_mbt_server_cb_event_t event,
|
||||
esp_ble_mesh_mbt_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_mbt_server_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_mbt_server_cb_t)btc_profile_cb_get(BTC_PID_MBT_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_blob_trans_server_callback(esp_ble_mesh_mbt_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_MBT_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_MBT_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_mbt_server_cb_param_t), NULL, NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_mbt_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx)
|
||||
{
|
||||
esp_ble_mesh_mbt_server_cb_param_t cb_params = {0};
|
||||
uint8_t cb_event = 0;
|
||||
|
||||
if (model == NULL || (ctx == NULL &&
|
||||
event != BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_RECEIVE_TIMEOUT)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_TRANSFER_GET:
|
||||
cb_event = ESP_BLE_MESH_MBT_SERVER_BLOB_TRANSFER_GET_EVT;
|
||||
memcpy(&cb_params.value.blob_transfer_get.ctx, ctx, sizeof(struct bt_mesh_msg_ctx));
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_TRANSFER_START:
|
||||
cb_event = ESP_BLE_MESH_MBT_SERVER_BLOB_TRANSFER_START_EVT;
|
||||
memcpy(&cb_params.value.blob_transfer_start.ctx, ctx, sizeof(struct bt_mesh_msg_ctx));
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_TRANSFER_CANCEL:
|
||||
cb_event = ESP_BLE_MESH_MBT_SERVER_BLOB_TRANSFER_CANCEL_EVT;
|
||||
memcpy(&cb_params.value.blob_transfer_cancel.ctx, ctx, sizeof(struct bt_mesh_msg_ctx));
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_BLOCK_GET:
|
||||
cb_event = ESP_BLE_MESH_MBT_SERVER_BLOB_BLOCK_GET_EVT;
|
||||
memcpy(&cb_params.value.blob_block_get.ctx, ctx, sizeof(struct bt_mesh_msg_ctx));
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_BLOCK_START:
|
||||
cb_event = ESP_BLE_MESH_MBT_SERVER_BLOB_BLOCK_START_EVT;
|
||||
memcpy(&cb_params.value.blob_block_start.ctx, ctx, sizeof(struct bt_mesh_msg_ctx));
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_CHUNK_TRANSFER:
|
||||
cb_event = ESP_BLE_MESH_MBT_SERVER_BLOB_CHUNK_TRANSFER_EVT;
|
||||
memcpy(&cb_params.value.blob_chunk_transfer.ctx, ctx, sizeof(struct bt_mesh_msg_ctx));
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_INFORMATION_GET:
|
||||
cb_event = ESP_BLE_MESH_MBT_SERVER_BLOB_INFORMATION_GET_EVT;
|
||||
memcpy(&cb_params.value.blob_information_get.ctx, ctx, sizeof(struct bt_mesh_msg_ctx));
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_SERVER_BLOCK_RECEIVE_COMP:
|
||||
cb_event = ESP_BLE_MESH_MBT_SERVER_BLOCK_RECEIVE_COMP_EVT;
|
||||
memcpy(&cb_params.value.block_receive_comp.ctx, ctx, sizeof(struct bt_mesh_msg_ctx));
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_RECEIVE_COMP:
|
||||
cb_event = ESP_BLE_MESH_MBT_SERVER_BLOB_RECEIVE_COMP_EVT;
|
||||
memcpy(&cb_params.value.blob_receive_comp.ctx, ctx, sizeof(struct bt_mesh_msg_ctx));
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_RECEIVE_TIMEOUT:
|
||||
cb_event = ESP_BLE_MESH_MBT_SERVER_BLOB_RECEIVE_TIMEOUT_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Blob Transfer server event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
btc_ble_mesh_blob_trans_server_callback(&cb_params, cb_event);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_mbt_server_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_mbt_server_cb_param_t cb = {0};
|
||||
btc_ble_mesh_mbt_server_args_t *arg = NULL;
|
||||
uint8_t event = 0;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_mbt_server_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_MBT_SERVER_INITIALIZE_BLOB_RECEIVE:
|
||||
event = ESP_BLE_MESH_MBT_SERVER_INITIALIZE_BLOB_RECEIVE_COMP_EVT;
|
||||
memcpy(&cb.value.initialize_blob_receive_comp.input,
|
||||
&arg->initialize_blob_receive, sizeof(arg->initialize_blob_receive));
|
||||
cb.value.initialize_blob_receive_comp.error_code =
|
||||
bt_mesh_initialize_blob_receive(&arg->initialize_blob_receive);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_SERVER_CANCEL_BLOB_RECEIVE:
|
||||
event = ESP_BLE_MESH_MBT_SERVER_CANCEL_BLOB_RECEIVE_COMP_EVT;
|
||||
memcpy(&cb.value.cancel_blob_receive_comp.input,
|
||||
&arg->cancel_blob_receive, sizeof(arg->cancel_blob_receive));
|
||||
cb.value.cancel_blob_receive_comp.error_code =
|
||||
bt_mesh_cancel_blob_receive(&arg->cancel_blob_receive);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_MBT_SERVER_SET_BLOB_CAPABILITIES:
|
||||
event = ESP_BLE_MESH_MBT_SERVER_SET_BLOB_CAPABILITIES_COMP_EVT;
|
||||
memcpy(&cb.value.set_blob_capabilities_comp.input,
|
||||
&arg->set_blob_capabilities, sizeof(arg->set_blob_capabilities));
|
||||
cb.value.set_blob_capabilities_comp.error_code =
|
||||
bt_mesh_set_blob_capabilities((struct bt_mesh_model *)arg->set_blob_capabilities.model,
|
||||
&arg->set_blob_capabilities.caps);
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown BLOB Transfer Server act %d", msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
btc_ble_mesh_blob_trans_server_callback(&cb, event);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_mbt_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_mbt_server_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
param = (esp_ble_mesh_mbt_server_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_MBT_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_blob_trans_server_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_MBT_SRV */
|
||||
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_odp_model.h"
|
||||
#include "esp_ble_mesh_odp_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_ODP_CLI
|
||||
|
||||
extern int bt_mesh_odp_get(void *param);
|
||||
extern int bt_mesh_odp_set(void *param, uint8_t on_demand_private_gatt_proxy);
|
||||
|
||||
/* On-Demand Private Proxy Configuration Client model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_odp_client_cb_to_app(esp_ble_mesh_odp_client_cb_event_t event,
|
||||
esp_ble_mesh_odp_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_odp_client_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_ODP_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_odp_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
btc_ble_mesh_odp_client_args_t *dst = p_dest;
|
||||
btc_ble_mesh_odp_client_args_t *src = p_src;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_ODP_CLIENT_SEND:
|
||||
dst->odp_send.params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (dst->odp_send.params) {
|
||||
memcpy(dst->odp_send.params, src->odp_send.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->odp_send.msg) {
|
||||
dst->odp_send.msg = bt_mesh_calloc(sizeof(esp_ble_mesh_odp_client_msg_t));
|
||||
if (dst->odp_send.msg) {
|
||||
memcpy(dst->odp_send.msg, src->odp_send.msg,
|
||||
sizeof(esp_ble_mesh_odp_client_msg_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_odp_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_odp_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_odp_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_ODP_CLIENT_SEND:
|
||||
if (arg->odp_send.params) {
|
||||
bt_mesh_free(arg->odp_send.params);
|
||||
}
|
||||
if (arg->odp_send.msg) {
|
||||
bt_mesh_free(arg->odp_send.msg);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_odp_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
esp_ble_mesh_odp_client_cb_param_t *p_dest_data = p_dest;
|
||||
esp_ble_mesh_odp_client_cb_param_t *p_src_data = p_src;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_odp_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_odp_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_odp_client_cb_param_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_ODP_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_ODP_CLIENT_RECV_RSP_EVT:
|
||||
case ESP_BLE_MESH_ODP_CLIENT_RECV_PUB_EVT:
|
||||
case ESP_BLE_MESH_ODP_CLIENT_SEND_TIMEOUT_EVT:
|
||||
if (arg->params) {
|
||||
bt_mesh_free(arg->params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_odp_client_cb(esp_ble_mesh_odp_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_ODP_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_ODP_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_odp_client_cb_param_t),
|
||||
btc_ble_mesh_odp_client_copy_req_data,
|
||||
btc_ble_mesh_odp_client_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_odp_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_odp_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.recv)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_ODP_CLIENT_SEND_TIMEOUT:
|
||||
act = ESP_BLE_MESH_ODP_CLIENT_SEND_TIMEOUT_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_ODP_CLIENT_RECV_RSP:
|
||||
act = ESP_BLE_MESH_ODP_CLIENT_RECV_RSP_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_ODP_CLIENT_RECV_PUB:
|
||||
act = ESP_BLE_MESH_ODP_CLIENT_RECV_PUB_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown On-Demand Private Proxy client event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
params.opcode = opcode;
|
||||
params.model = (esp_ble_mesh_model_t *)model;
|
||||
params.ctx.net_idx = ctx->net_idx;
|
||||
params.ctx.app_idx = ctx->app_idx;
|
||||
params.ctx.addr = ctx->addr;
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.recv, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_odp_client_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_odp_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_odp_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_ODP_CLIENT_RECV_PUB,
|
||||
model, ctx, buf->data, buf->len);
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_odp_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_odp_client_msg_t *msg)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (params->opcode == ESP_BLE_MESH_MODEL_OP_OD_PRIV_PROXY_SET && msg == NULL) {
|
||||
BT_ERR("Invalid On-Demand Private Proxy message, opcode 0x%04x", params->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, true);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_OD_PRIV_PROXY_GET:
|
||||
return bt_mesh_odp_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_OD_PRIV_PROXY_SET:
|
||||
return bt_mesh_odp_set(¶m, msg->od_priv_proxy_set.gatt_proxy);
|
||||
default:
|
||||
BT_ERR("Invalid On-Demand Private Proxy opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_odp_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_odp_client_cb_param_t cb = {0};
|
||||
btc_ble_mesh_odp_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_odp_client_args_t *)msg->arg;
|
||||
|
||||
if (msg->act == BTC_BLE_MESH_ACT_ODP_CLIENT_SEND) {
|
||||
cb.params = arg->odp_send.params;
|
||||
cb.send.err_code = btc_ble_mesh_odp_client_send(arg->odp_send.params,
|
||||
arg->odp_send.msg);
|
||||
btc_ble_mesh_odp_client_cb(&cb,
|
||||
ESP_BLE_MESH_ODP_CLIENT_SEND_COMP_EVT);
|
||||
}
|
||||
|
||||
btc_ble_mesh_odp_client_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_odp_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_odp_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_odp_client_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_ODP_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_odp_client_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_odp_client_free_req_data(msg);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_ODP_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_ODP_SRV
|
||||
|
||||
/* On-Demand Private Proxy Config Server model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_odp_server_cb_to_app(esp_ble_mesh_odp_server_cb_event_t event,
|
||||
esp_ble_mesh_odp_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_odp_server_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_ODP_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_odp_server_cb(esp_ble_mesh_odp_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_ODP_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_ODP_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_odp_server_cb_param_t), NULL, NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_odp_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_odp_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.value)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_ODP_SERVER_STATE_CHANGE:
|
||||
act = ESP_BLE_MESH_ODP_SERVER_STATE_CHANGE_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown On-Demand Private Proxy server event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
cb_params.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.ctx.net_idx = ctx->net_idx;
|
||||
cb_params.ctx.app_idx = ctx->app_idx;
|
||||
cb_params.ctx.addr = ctx->addr;
|
||||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_odp_server_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_odp_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_odp_server_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_odp_server_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_ODP_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_odp_server_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_ODP_SRV */
|
||||
@@ -0,0 +1,404 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_prb_model.h"
|
||||
#include "esp_ble_mesh_prb_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_PRB_CLI
|
||||
|
||||
extern int bt_mesh_private_beacon_get(void *param);
|
||||
extern int bt_mesh_private_beacon_set(void *param, void *set);
|
||||
extern int bt_mesh_private_gatt_proxy_get(void *param);
|
||||
extern int bt_mesh_private_gatt_proxy_set(void *param, uint8_t private_gatt_proxy);
|
||||
extern int bt_mesh_private_node_identity_get(void *param, uint16_t net_idx);
|
||||
extern int bt_mesh_private_node_identity_set(void *param, uint16_t net_idx,
|
||||
uint8_t private_node_id);
|
||||
|
||||
/* Private Beacon Client Model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_prb_client_cb_to_app(esp_ble_mesh_prb_client_cb_event_t event,
|
||||
esp_ble_mesh_prb_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_prb_client_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_PRB_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_prb_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
btc_ble_mesh_prb_client_args_t *dst = p_dest;
|
||||
btc_ble_mesh_prb_client_args_t *src = p_src;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_PRB_CLIENT_SEND:
|
||||
dst->prb_send.params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (dst->prb_send.params) {
|
||||
memcpy(dst->prb_send.params, src->prb_send.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->prb_send.msg) {
|
||||
dst->prb_send.msg = bt_mesh_malloc(sizeof(esp_ble_mesh_prb_client_msg_t));
|
||||
if (dst->prb_send.msg) {
|
||||
memcpy(dst->prb_send.msg, src->prb_send.msg,
|
||||
sizeof(esp_ble_mesh_prb_client_msg_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_prb_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_prb_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_prb_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_PRB_CLIENT_SEND:
|
||||
if (arg->prb_send.params) {
|
||||
bt_mesh_free(arg->prb_send.params);
|
||||
}
|
||||
if (arg->prb_send.msg) {
|
||||
bt_mesh_free(arg->prb_send.msg);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_prb_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
esp_ble_mesh_prb_client_cb_param_t *p_dest_data = p_dest;
|
||||
esp_ble_mesh_prb_client_cb_param_t *p_src_data = p_src;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_prb_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_prb_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_prb_client_cb_param_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_PRB_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_PRB_CLIENT_SEND_TIMEOUT_EVT:
|
||||
case ESP_BLE_MESH_PRB_CLIENT_RECV_RSP_EVT:
|
||||
case ESP_BLE_MESH_PRB_CLIENT_RECV_PUB_EVT:
|
||||
if (arg->params) {
|
||||
bt_mesh_free(arg->params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_prb_client_cb(esp_ble_mesh_prb_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t btc_msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_PRB_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
btc_msg.sig = BTC_SIG_API_CB;
|
||||
btc_msg.pid = BTC_PID_PRB_CLIENT;
|
||||
btc_msg.act = act;
|
||||
|
||||
btc_transfer_context(&btc_msg, cb_params, sizeof(esp_ble_mesh_prb_client_cb_param_t),
|
||||
btc_ble_mesh_prb_client_copy_req_data,
|
||||
btc_ble_mesh_prb_client_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_prb_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, uint16_t len)
|
||||
{
|
||||
esp_ble_mesh_prb_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.recv)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (evt_type) {
|
||||
case BTC_BLE_MESH_EVT_PRB_CLIENT_SEND_TIMEOUT:
|
||||
act = ESP_BLE_MESH_PRB_CLIENT_SEND_TIMEOUT_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_PRB_CLIENT_RECV_RSP:
|
||||
act = ESP_BLE_MESH_PRB_CLIENT_RECV_RSP_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_PRB_CLIENT_RECV_PUB:
|
||||
act = ESP_BLE_MESH_PRB_CLIENT_RECV_PUB_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Private Beacon client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
params.opcode = opcode;
|
||||
params.model = (esp_ble_mesh_model_t *)model;
|
||||
params.ctx.net_idx = ctx->net_idx;
|
||||
params.ctx.app_idx = ctx->app_idx;
|
||||
params.ctx.addr = ctx->addr;
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.recv, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_prb_client_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_prb_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_prb_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_PRB_CLIENT_RECV_PUB,
|
||||
model, ctx, buf->data, buf->len);
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_prb_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_prb_client_msg_t *msg)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_BEACON_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_GATT_PROXY_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_NODE_IDENTITY_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_NODE_IDENTITY_SET:
|
||||
if (msg == NULL) {
|
||||
BT_ERR("Invalid Mesh Private Beacon message, opcode 0x%04x", params->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, true);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_BEACON_GET:
|
||||
return bt_mesh_private_beacon_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_BEACON_SET:
|
||||
return bt_mesh_private_beacon_set(¶m, &msg->priv_beacon_set);
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_GATT_PROXY_GET:
|
||||
return bt_mesh_private_gatt_proxy_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_GATT_PROXY_SET:
|
||||
return bt_mesh_private_gatt_proxy_set(¶m, msg->priv_gatt_proxy_set.private_gatt_proxy);
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_NODE_IDENTITY_GET:
|
||||
return bt_mesh_private_node_identity_get(¶m, msg->priv_node_id_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_PRIV_NODE_IDENTITY_SET:
|
||||
return bt_mesh_private_node_identity_set(¶m, msg->priv_node_id_set.net_idx , msg->priv_node_id_set.private_node_id);
|
||||
default:
|
||||
BT_ERR("Invalid Private Beacon opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_prb_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_prb_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_prb_client_cb_param_t cb = {0};
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_prb_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_PRB_CLIENT_SEND:
|
||||
cb.params = arg->prb_send.params;
|
||||
cb.send.err_code = btc_ble_mesh_prb_client_send(arg->prb_send.params,
|
||||
arg->prb_send.msg);
|
||||
btc_ble_mesh_prb_client_cb(&cb,
|
||||
ESP_BLE_MESH_PRB_CLIENT_SEND_COMP_EVT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_prb_client_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_prb_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_prb_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_prb_client_cb_param_t *)(msg->arg);
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_PRB_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_prb_client_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_prb_client_free_req_data(msg);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_PRB_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_PRB_SRV
|
||||
/* Private Beacon Server Model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_prb_server_cb_to_app(esp_ble_mesh_prb_server_cb_event_t event,
|
||||
esp_ble_mesh_prb_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_prb_server_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_PRB_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_prb_server_cb(
|
||||
esp_ble_mesh_prb_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_PRB_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_PRB_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_prb_server_cb_param_t), NULL, NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_prb_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_prb_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.value)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (evt_type) {
|
||||
case BTC_BLE_MESH_EVT_PRB_SERVER_STATE_CHANGE:
|
||||
act = ESP_BLE_MESH_PRB_SERVER_STATE_CHANGE_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Private Beacon server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
cb_params.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.ctx.net_idx = ctx->net_idx;
|
||||
cb_params.ctx.app_idx = ctx->app_idx;
|
||||
cb_params.ctx.addr = ctx->addr;
|
||||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_prb_server_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_prb_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_prb_server_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_prb_server_cb_param_t *)(msg->arg);
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_PRB_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_prb_server_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_PRB_SRV */
|
||||
@@ -0,0 +1,543 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_rpr_model.h"
|
||||
#include "esp_ble_mesh_rpr_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_RPR_CLI
|
||||
|
||||
extern int bt_mesh_rpr_scan_caps_get(void *param);
|
||||
extern int bt_mesh_rpr_scan_get(void *param);
|
||||
extern int bt_mesh_rpr_scan_start(void *param, void *start);
|
||||
extern int bt_mesh_rpr_scan_stop(void *param);
|
||||
extern int bt_mesh_rpr_ext_scan_start(void *param, void *start);
|
||||
extern int bt_mesh_rpr_link_get(void *param);
|
||||
extern int bt_mesh_rpr_link_open(void *param, void *open);
|
||||
extern int bt_mesh_rpr_link_close(void *param, uint8_t reason);
|
||||
extern int bt_mesh_rpr_start_prov(void *model, uint16_t rp_srv_addr);
|
||||
|
||||
/* Remote Provisioning Client model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_rpr_client_cb_to_app(esp_ble_mesh_rpr_client_cb_event_t event,
|
||||
esp_ble_mesh_rpr_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_rpr_client_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_RPR_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_rpr_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
btc_ble_mesh_rpr_client_args_t *dst = p_dest;
|
||||
btc_ble_mesh_rpr_client_args_t *src = p_src;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_RPR_CLIENT_SEND:
|
||||
dst->rpr_send.params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->rpr_send.msg = src->rpr_send.msg ? bt_mesh_calloc(sizeof(esp_ble_mesh_rpr_client_msg_t)) : NULL;
|
||||
if (dst->rpr_send.params) {
|
||||
memcpy(dst->rpr_send.params, src->rpr_send.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (dst->rpr_send.msg) {
|
||||
memcpy(dst->rpr_send.msg, src->rpr_send.msg,
|
||||
sizeof(esp_ble_mesh_rpr_client_msg_t));
|
||||
}
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_RPR_CLIENT_ACT:
|
||||
dst->rpr_act.param = bt_mesh_calloc(sizeof(esp_ble_mesh_rpr_client_act_param_t));
|
||||
if (dst->rpr_act.param) {
|
||||
memcpy(dst->rpr_act.param, src->rpr_act.param,
|
||||
sizeof(esp_ble_mesh_rpr_client_act_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_rpr_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_rpr_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_rpr_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_RPR_CLIENT_SEND:
|
||||
if (arg->rpr_send.params) {
|
||||
bt_mesh_free(arg->rpr_send.params);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_RPR_CLIENT_ACT:
|
||||
if (arg->rpr_act.param) {
|
||||
bt_mesh_free(arg->rpr_act.param);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_rpr_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
esp_ble_mesh_rpr_client_cb_param_t *p_dest_data = p_dest;
|
||||
esp_ble_mesh_rpr_client_cb_param_t *p_src_data = p_src;
|
||||
uint16_t length = 0;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_RPR_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_RPR_CLIENT_SEND_TIMEOUT_EVT:
|
||||
if (p_src_data->send.params) {
|
||||
p_dest_data->send.params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->send.params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->send.params, p_src_data->send.params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_RPR_CLIENT_RECV_RSP_EVT:
|
||||
case ESP_BLE_MESH_RPR_CLIENT_RECV_PUB_EVT:
|
||||
if (p_src_data->recv.params) {
|
||||
p_dest_data->recv.params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->recv.params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->recv.params, p_src_data->recv.params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
|
||||
/* Remote Provisioning Extended Scan Start is an unacknowledged message,
|
||||
* so the corresponding report could only be received through the recv
|
||||
* publish event.
|
||||
*/
|
||||
if (msg->act == ESP_BLE_MESH_RPR_CLIENT_RECV_PUB_EVT &&
|
||||
p_src_data->recv.params->opcode == ESP_BLE_MESH_MODEL_OP_RPR_EXT_SCAN_REPORT) {
|
||||
if (p_src_data->recv.val.ext_scan_report.adv_structures) {
|
||||
length = p_src_data->recv.val.ext_scan_report.adv_structures->len;
|
||||
p_dest_data->recv.val.ext_scan_report.adv_structures = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->recv.val.ext_scan_report.adv_structures) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
net_buf_simple_add_mem(p_dest_data->recv.val.ext_scan_report.adv_structures,
|
||||
p_src_data->recv.val.ext_scan_report.adv_structures->data,
|
||||
p_src_data->recv.val.ext_scan_report.adv_structures->len);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_RPR_CLIENT_ACT_COMP_EVT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_rpr_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_rpr_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_rpr_client_cb_param_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_RPR_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_RPR_CLIENT_SEND_TIMEOUT_EVT:
|
||||
if (arg->send.params) {
|
||||
bt_mesh_free(arg->send.params);
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_RPR_CLIENT_RECV_RSP_EVT:
|
||||
case ESP_BLE_MESH_RPR_CLIENT_RECV_PUB_EVT:
|
||||
if (arg->recv.params &&
|
||||
msg->act == ESP_BLE_MESH_RPR_CLIENT_RECV_PUB_EVT &&
|
||||
arg->recv.params->opcode == ESP_BLE_MESH_MODEL_OP_RPR_EXT_SCAN_REPORT) {
|
||||
bt_mesh_free_buf(arg->recv.val.ext_scan_report.adv_structures);
|
||||
}
|
||||
if (arg->recv.params) {
|
||||
bt_mesh_free(arg->recv.params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_rpr_client_cb(esp_ble_mesh_rpr_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_RPR_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_RPR_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_rpr_client_cb_param_t),
|
||||
btc_ble_mesh_rpr_client_copy_req_data,
|
||||
btc_ble_mesh_rpr_client_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_rpr_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const void *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_rpr_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (model == NULL || ctx == NULL ||
|
||||
((event == BTC_BLE_MESH_EVT_RPR_CLIENT_RECV_RSP ||
|
||||
event == BTC_BLE_MESH_EVT_RPR_CLIENT_RECV_PUB) &&
|
||||
(len > sizeof(cb_params.recv.val)))) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
params.opcode = opcode;
|
||||
params.model = (esp_ble_mesh_model_t *)model;
|
||||
params.ctx.net_idx = ctx->net_idx;
|
||||
params.ctx.app_idx = ctx->app_idx;
|
||||
params.ctx.addr = ctx->addr;
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_RPR_CLIENT_SEND_TIMEOUT:
|
||||
act = ESP_BLE_MESH_RPR_CLIENT_SEND_TIMEOUT_EVT;
|
||||
cb_params.send.params = ¶ms;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_RPR_CLIENT_RECV_RSP:
|
||||
act = ESP_BLE_MESH_RPR_CLIENT_RECV_RSP_EVT;
|
||||
cb_params.recv.params = ¶ms;
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.recv.val, val, len);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_RPR_CLIENT_RECV_PUB:
|
||||
act = ESP_BLE_MESH_RPR_CLIENT_RECV_PUB_EVT;
|
||||
cb_params.recv.params = ¶ms;
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.recv.val, val, len);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Remote Provisioning client event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
btc_ble_mesh_rpr_client_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_rpr_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_rpr_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_RPR_CLIENT_RECV_PUB,
|
||||
model, ctx, buf->data, buf->len);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_rpr_client_link_close_cb(struct bt_mesh_model *model,
|
||||
uint16_t rpr_srv_addr, uint8_t reason)
|
||||
{
|
||||
esp_ble_mesh_rpr_client_cb_param_t cb_params = {0};
|
||||
|
||||
cb_params.link_close.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.link_close.rpr_srv_addr = rpr_srv_addr;
|
||||
cb_params.link_close.reason = reason;
|
||||
|
||||
btc_ble_mesh_rpr_client_cb(&cb_params, ESP_BLE_MESH_RPR_CLIENT_LINK_CLOSE_EVT);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_rpr_client_prov_comp_cb(struct bt_mesh_model *model, uint16_t rpr_srv_addr,
|
||||
uint8_t nppi, uint16_t index, uint8_t uuid[16],
|
||||
uint16_t unicast_addr, uint8_t element_num,
|
||||
uint16_t net_idx)
|
||||
{
|
||||
esp_ble_mesh_rpr_client_cb_param_t cb_params = {0};
|
||||
|
||||
cb_params.prov.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.prov.rpr_srv_addr = rpr_srv_addr;
|
||||
cb_params.prov.nppi = nppi;
|
||||
cb_params.prov.index = index;
|
||||
cb_params.prov.unicast_addr = unicast_addr;
|
||||
cb_params.prov.element_num = element_num;
|
||||
cb_params.prov.net_idx = net_idx;
|
||||
memcpy(cb_params.prov.uuid, uuid, 16);
|
||||
|
||||
btc_ble_mesh_rpr_client_cb(&cb_params, ESP_BLE_MESH_RPR_CLIENT_PROV_COMP_EVT);
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_rpr_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_rpr_client_msg_t *msg)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_SCAN_START:
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_EXT_SCAN_START:
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_LINK_OPEN:
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_LINK_CLOSE:
|
||||
if (msg == NULL) {
|
||||
BT_ERR("Invalid Remote Provisioning message opcode 0x%04x", params->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, true);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_SCAN_CAPS_GET:
|
||||
return bt_mesh_rpr_scan_caps_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_SCAN_GET:
|
||||
return bt_mesh_rpr_scan_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_SCAN_START:
|
||||
return bt_mesh_rpr_scan_start(¶m, &msg->scan_start);
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_SCAN_STOP:
|
||||
return bt_mesh_rpr_scan_stop(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_EXT_SCAN_START:
|
||||
return bt_mesh_rpr_ext_scan_start(¶m, &msg->ext_scan_start);
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_LINK_GET:
|
||||
return bt_mesh_rpr_link_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_LINK_OPEN:
|
||||
return bt_mesh_rpr_link_open(¶m, &msg->link_open);
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_LINK_CLOSE:
|
||||
return bt_mesh_rpr_link_close(¶m, msg->link_close.reason);
|
||||
case ESP_BLE_MESH_MODEL_OP_RPR_PDU_SEND:
|
||||
BT_WARN("Remote Provisioning PDU Send will be sent internally");
|
||||
return 0;
|
||||
default:
|
||||
BT_ERR("Invalid Remote Provisioning msg opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_rpr_client_act(esp_ble_mesh_rpr_client_act_type_t type,
|
||||
esp_ble_mesh_rpr_client_act_param_t *param,
|
||||
esp_ble_mesh_rpr_client_cb_param_t *cb)
|
||||
{
|
||||
if (param == NULL || cb == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case ESP_BLE_MESH_RPR_CLIENT_ACT_START_RPR:
|
||||
cb->act.sub_evt = ESP_BLE_MESH_START_RPR_COMP_SUB_EVT;
|
||||
cb->act.start_rpr_comp.model = param->start_rpr.model;
|
||||
cb->act.start_rpr_comp.rpr_srv_addr = param->start_rpr.rpr_srv_addr;
|
||||
cb->act.start_rpr_comp.err_code =
|
||||
bt_mesh_rpr_start_prov((struct bt_mesh_model *)param->start_rpr.model,
|
||||
param->start_rpr.rpr_srv_addr);
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Invalid Remote Provisioning action 0x%02x", type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_rpr_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_rpr_client_cb_param_t cb = {0};
|
||||
btc_ble_mesh_rpr_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_rpr_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_RPR_CLIENT_SEND:
|
||||
cb.send.params = arg->rpr_send.params;
|
||||
cb.send.err_code = btc_ble_mesh_rpr_client_send(arg->rpr_send.params,
|
||||
arg->rpr_send.msg);
|
||||
btc_ble_mesh_rpr_client_cb(&cb, ESP_BLE_MESH_RPR_CLIENT_SEND_COMP_EVT);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_RPR_CLIENT_ACT:
|
||||
btc_ble_mesh_rpr_client_act(arg->rpr_act.type,
|
||||
arg->rpr_act.param, &cb);
|
||||
btc_ble_mesh_rpr_client_cb(&cb, ESP_BLE_MESH_RPR_CLIENT_ACT_COMP_EVT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_rpr_client_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_rpr_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_rpr_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_rpr_client_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_RPR_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_rpr_client_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_rpr_client_free_req_data(msg);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_RPR_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_RPR_SRV
|
||||
|
||||
/* Remote Provisioning Server model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_rpr_server_cb_to_app(esp_ble_mesh_rpr_server_cb_event_t event,
|
||||
esp_ble_mesh_rpr_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_rpr_server_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_RPR_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_rpr_server_cb(esp_ble_mesh_rpr_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_RPR_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_RPR_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_rpr_server_cb_param_t), NULL, NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_rpr_server_cb_evt_to_btc(uint8_t event, const void *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_rpr_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (len > sizeof(cb_params)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_RPR_SERVER_SCAN_START:
|
||||
act = ESP_BLE_MESH_RPR_SERVER_SCAN_START_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_RPR_SERVER_SCAN_STOP:
|
||||
act = ESP_BLE_MESH_RPR_SERVER_SCAN_STOP_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_RPR_SERVER_EXT_SCAN_START:
|
||||
act = ESP_BLE_MESH_RPR_SERVER_EXT_SCAN_START_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_RPR_SERVER_EXT_SCAN_STOP:
|
||||
act = ESP_BLE_MESH_RPR_SERVER_EXT_SCAN_STOP_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_RPR_SERVER_LINK_OPEN:
|
||||
act = ESP_BLE_MESH_RPR_SERVER_LINK_OPEN_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_RPR_SERVER_LINK_CLOSE:
|
||||
act = ESP_BLE_MESH_RPR_SERVER_LINK_CLOSE_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_RPR_SERVER_PROV_COMP:
|
||||
act = ESP_BLE_MESH_RPR_SERVER_PROV_COMP_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Remote Provisioning server event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_rpr_server_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_rpr_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_rpr_server_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_rpr_server_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_RPR_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_rpr_server_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_RPR_SRV */
|
||||
@@ -0,0 +1,389 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_sar_model.h"
|
||||
#include "esp_ble_mesh_sar_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_SAR_CLI
|
||||
|
||||
extern int bt_mesh_sar_transmitter_get(void *param);
|
||||
extern int bt_mesh_sar_transmitter_set(void *param, void *set);
|
||||
extern int bt_mesh_sar_receiver_get(void *param);
|
||||
extern int bt_mesh_sar_receiver_set(void *param, void *set);
|
||||
|
||||
/* SAR Configuration Client model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_sar_client_cb_to_app(esp_ble_mesh_sar_client_cb_event_t event,
|
||||
esp_ble_mesh_sar_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_sar_client_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_SAR_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sar_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
btc_ble_mesh_sar_client_args_t *dst = p_dest;
|
||||
btc_ble_mesh_sar_client_args_t *src = p_src;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SAR_CLIENT_SEND:
|
||||
dst->sar_send.params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (dst->sar_send.params) {
|
||||
memcpy(dst->sar_send.params, src->sar_send.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->sar_send.msg) {
|
||||
dst->sar_send.msg = bt_mesh_calloc(sizeof(esp_ble_mesh_sar_client_msg_t));
|
||||
if (dst->sar_send.msg) {
|
||||
memcpy(dst->sar_send.msg, src->sar_send.msg,
|
||||
sizeof(esp_ble_mesh_sar_client_msg_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sar_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_sar_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_sar_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SAR_CLIENT_SEND:
|
||||
if (arg->sar_send.params) {
|
||||
bt_mesh_free(arg->sar_send.params);
|
||||
}
|
||||
if (arg->sar_send.msg) {
|
||||
bt_mesh_free(arg->sar_send.msg);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_sar_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
esp_ble_mesh_sar_client_cb_param_t *p_dest_data = p_dest;
|
||||
esp_ble_mesh_sar_client_cb_param_t *p_src_data = p_src;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_sar_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_sar_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_sar_client_cb_param_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_SAR_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_SAR_CLIENT_SEND_TIMEOUT_EVT:
|
||||
case ESP_BLE_MESH_SAR_CLIENT_RECV_RSP_EVT:
|
||||
case ESP_BLE_MESH_SAR_CLIENT_RECV_PUB_EVT:
|
||||
if (arg->params) {
|
||||
bt_mesh_free(arg->params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_sar_client_cb(esp_ble_mesh_sar_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_SAR_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_SAR_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sar_client_cb_param_t),
|
||||
btc_ble_mesh_sar_client_copy_req_data,
|
||||
btc_ble_mesh_sar_client_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_sar_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_sar_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.recv)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_SAR_CLIENT_SEND_TIMEOUT:
|
||||
act = ESP_BLE_MESH_SAR_CLIENT_SEND_TIMEOUT_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_SAR_CLIENT_RECV_RSP:
|
||||
act = ESP_BLE_MESH_SAR_CLIENT_RECV_RSP_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_SAR_CLIENT_RECV_PUB:
|
||||
act = ESP_BLE_MESH_SAR_CLIENT_RECV_PUB_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown SAR Config client event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
params.opcode = opcode;
|
||||
params.model = (esp_ble_mesh_model_t *)model;
|
||||
params.ctx.net_idx = ctx->net_idx;
|
||||
params.ctx.app_idx = ctx->app_idx;
|
||||
params.ctx.addr = ctx->addr;
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.recv, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_sar_client_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sar_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_sar_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_SAR_CLIENT_RECV_PUB,
|
||||
model, ctx, buf->data, buf->len);
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_sar_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_sar_client_msg_t *msg)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((params->opcode == ESP_BLE_MESH_MODEL_OP_SAR_TRANSMITTER_SET ||
|
||||
params->opcode == ESP_BLE_MESH_MODEL_OP_SAR_RECEIVER_SET) && msg == NULL) {
|
||||
BT_ERR("Invalid SAR Config message, opcode 0x%04x", params->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, true);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_SAR_TRANSMITTER_GET:
|
||||
return bt_mesh_sar_transmitter_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_SAR_TRANSMITTER_SET:
|
||||
return bt_mesh_sar_transmitter_set(¶m, &msg->sar_transmitter_set);
|
||||
case ESP_BLE_MESH_MODEL_OP_SAR_RECEIVER_GET:
|
||||
return bt_mesh_sar_receiver_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_SAR_RECEIVER_SET:
|
||||
return bt_mesh_sar_receiver_set(¶m, &msg->sar_receiver_set);
|
||||
default:
|
||||
BT_ERR("Invalid SAR Config opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sar_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_sar_client_cb_param_t cb = {0};
|
||||
btc_ble_mesh_sar_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_sar_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SAR_CLIENT_SEND:
|
||||
cb.params = arg->sar_send.params;
|
||||
cb.send.err_code = btc_ble_mesh_sar_client_send(arg->sar_send.params,
|
||||
arg->sar_send.msg);
|
||||
btc_ble_mesh_sar_client_cb(&cb, ESP_BLE_MESH_SAR_CLIENT_SEND_COMP_EVT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_sar_client_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sar_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_sar_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_sar_client_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_SAR_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_sar_client_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_sar_client_free_req_data(msg);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_SAR_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_SAR_SRV
|
||||
|
||||
/* SAR Config Server model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_sar_server_cb_to_app(esp_ble_mesh_sar_server_cb_event_t event,
|
||||
esp_ble_mesh_sar_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_sar_server_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_SAR_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_sar_server_cb(esp_ble_mesh_sar_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_SAR_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_SAR_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sar_server_cb_param_t), NULL, NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_sar_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_sar_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.value)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_SAR_SERVER_STATE_CHANGE:
|
||||
act = ESP_BLE_MESH_SAR_SERVER_STATE_CHANGE_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown SAR Config server event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
cb_params.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.ctx.net_idx = ctx->net_idx;
|
||||
cb_params.ctx.app_idx = ctx->app_idx;
|
||||
cb_params.ctx.addr = ctx->addr;
|
||||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_sar_server_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sar_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_sar_server_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_sar_server_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_SAR_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_sar_server_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_SAR_SRV */
|
||||
@@ -0,0 +1,370 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_model_common.h"
|
||||
#include "btc_ble_mesh_srpl_model.h"
|
||||
#include "esp_ble_mesh_srpl_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_SRPL_CLI
|
||||
|
||||
extern int bt_mesh_solic_pdu_rpl_items_clear(void *param, void *uar);
|
||||
|
||||
/* Solicitation PDU RPL Configuration Client model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_srpl_client_cb_to_app(esp_ble_mesh_srpl_client_cb_event_t event,
|
||||
esp_ble_mesh_srpl_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_srpl_client_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_SRPL_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_srpl_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
btc_ble_mesh_srpl_client_args_t *dst = p_dest;
|
||||
btc_ble_mesh_srpl_client_args_t *src = p_src;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SRPL_CLIENT_SEND:
|
||||
dst->srpl_send.params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->srpl_send.msg = bt_mesh_calloc(sizeof(esp_ble_mesh_srpl_client_msg_t));
|
||||
if (dst->srpl_send.params && dst->srpl_send.msg) {
|
||||
memcpy(dst->srpl_send.params, src->srpl_send.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->srpl_send.msg, src->srpl_send.msg,
|
||||
sizeof(esp_ble_mesh_srpl_client_msg_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_srpl_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_srpl_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_srpl_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SRPL_CLIENT_SEND:
|
||||
if (arg->srpl_send.msg) {
|
||||
bt_mesh_free(arg->srpl_send.msg);
|
||||
}
|
||||
if (arg->srpl_send.params) {
|
||||
bt_mesh_free(arg->srpl_send.params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_srpl_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
esp_ble_mesh_srpl_client_cb_param_t *p_dest_data = p_dest;
|
||||
esp_ble_mesh_srpl_client_cb_param_t *p_src_data = p_src;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_calloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_srpl_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_srpl_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_srpl_client_cb_param_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_SRPL_CLIENT_SEND_COMP_EVT:
|
||||
case ESP_BLE_MESH_SRPL_CLIENT_SEND_TIMEOUT_EVT:
|
||||
case ESP_BLE_MESH_SRPL_CLIENT_RECV_RSP_EVT:
|
||||
case ESP_BLE_MESH_SRPL_CLIENT_RECV_PUB_EVT:
|
||||
if (arg->params) {
|
||||
bt_mesh_free(arg->params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_srpl_client_cb(esp_ble_mesh_srpl_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_SRPL_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_SRPL_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_srpl_client_cb_param_t),
|
||||
btc_ble_mesh_srpl_client_copy_req_data,
|
||||
btc_ble_mesh_srpl_client_free_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_srpl_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_srpl_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.recv)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_SRPL_CLIENT_SEND_TIMEOUT:
|
||||
act = ESP_BLE_MESH_SRPL_CLIENT_SEND_TIMEOUT_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_SRPL_CLIENT_RECV_RSP:
|
||||
act = ESP_BLE_MESH_SRPL_CLIENT_RECV_RSP_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_SRPL_CLIENT_RECV_PUB:
|
||||
act = ESP_BLE_MESH_SRPL_CLIENT_RECV_PUB_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Solicitation PDU RPL Config client event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
params.opcode = opcode;
|
||||
params.model = (esp_ble_mesh_model_t *)model;
|
||||
params.ctx.net_idx = ctx->net_idx;
|
||||
params.ctx.app_idx = ctx->app_idx;
|
||||
params.ctx.addr = ctx->addr;
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.recv, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_srpl_client_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_srpl_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_srpl_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_SRPL_CLIENT_RECV_PUB,
|
||||
model, ctx, buf->data, buf->len);
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_srpl_client_send(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_srpl_client_msg_t *msg)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL || msg == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
btc_ble_mesh_set_client_common_param(params, ¶m, false);
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_SRPL_ITEMS_CLEAR:
|
||||
case ESP_BLE_MESH_MODEL_OP_SRPL_ITEMS_CLEAR_UNACK:
|
||||
return bt_mesh_solic_pdu_rpl_items_clear(¶m, &msg->srpl_items_clear.addr_range);
|
||||
default:
|
||||
BT_ERR("Invalid Solicitation PDU RPL Config Set opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_srpl_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_srpl_client_cb_param_t cb = {0};
|
||||
btc_ble_mesh_srpl_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_srpl_client_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SRPL_CLIENT_SEND:
|
||||
cb.params = arg->srpl_send.params;
|
||||
cb.send.err_code = btc_ble_mesh_srpl_client_send(arg->srpl_send.params,
|
||||
arg->srpl_send.msg);
|
||||
btc_ble_mesh_srpl_client_cb(&cb,
|
||||
ESP_BLE_MESH_SRPL_CLIENT_SEND_COMP_EVT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_srpl_client_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_srpl_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_srpl_client_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_srpl_client_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_SRPL_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_srpl_client_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_srpl_client_free_req_data(msg);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_SRPL_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_SRPL_SRV
|
||||
|
||||
/* Solicitation PDU RPL Config Server model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_srpl_server_cb_to_app(esp_ble_mesh_srpl_server_cb_event_t event,
|
||||
esp_ble_mesh_srpl_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_srpl_server_cb_t btc_ble_mesh_cb =
|
||||
btc_profile_cb_get(BTC_PID_SRPL_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_srpl_server_cb(esp_ble_mesh_srpl_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_SRPL_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_SRPL_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_srpl_server_cb_param_t), NULL, NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_srpl_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_srpl_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0;
|
||||
|
||||
if (!model || !ctx || len > sizeof(cb_params.value)) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case BTC_BLE_MESH_EVT_SRPL_SERVER_STATE_CHANGE:
|
||||
act = ESP_BLE_MESH_SRPL_SERVER_STATE_CHANGE_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Solicitation PDU RPL Config server event type %d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
cb_params.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.ctx.net_idx = ctx->net_idx;
|
||||
cb_params.ctx.app_idx = ctx->app_idx;
|
||||
cb_params.ctx.addr = ctx->addr;
|
||||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, len);
|
||||
}
|
||||
|
||||
btc_ble_mesh_srpl_server_cb(&cb_params, act);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_srpl_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_srpl_server_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_srpl_server_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_SRPL_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_srpl_server_cb_to_app(msg->act, arg);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_SRPL_SRV */
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BTC_BLE_MESH_AGG_MODEL_H_
|
||||
#define _BTC_BLE_MESH_AGG_MODEL_H_
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_agg_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_AGG_CLIENT_SEND,
|
||||
BTC_BLE_MESH_ACT_AGG_CLIENT_MAX,
|
||||
} btc_ble_mesh_agg_client_act_t;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
esp_ble_mesh_agg_client_msg_t *msg;
|
||||
} agg_send;
|
||||
} btc_ble_mesh_agg_client_args_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_AGG_CLIENT_SEND_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_AGG_CLIENT_RECV_RSP,
|
||||
BTC_BLE_MESH_EVT_AGG_CLIENT_RECV_PUB,
|
||||
BTC_BLE_MESH_EVT_AGG_CLIENT_MAX,
|
||||
} btc_ble_mesh_agg_client_evt_t;
|
||||
|
||||
void btc_ble_mesh_agg_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_agg_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_agg_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_agg_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_agg_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_agg_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_AGG_SERVER_RECV_MSG,
|
||||
BTC_BLE_MESH_EVT_AGG_SERVER_MAX,
|
||||
} btc_ble_mesh_agg_server_evt_t;
|
||||
|
||||
void btc_ble_mesh_agg_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void bt_mesh_agg_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const void *val, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_AGG_MODEL_H_ */
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BTC_BLE_MESH_BRC_MODEL_H_
|
||||
#define _BTC_BLE_MESH_BRC_MODEL_H_
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_brc_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_BRC_CLIENT_SEND,
|
||||
BTC_BLE_MESH_ACT_BRC_CLIENT_MAX,
|
||||
} btc_ble_mesh_brc_client_act_t;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
esp_ble_mesh_brc_client_msg_t *msg;
|
||||
} brc_send;
|
||||
} btc_ble_mesh_brc_client_args_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_BRC_CLIENT_RECV_RSP,
|
||||
BTC_BLE_MESH_EVT_BRC_CLIENT_RECV_PUB,
|
||||
BTC_BLE_MESH_EVT_BRC_CLIENT_SEND_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_BRC_CLIENT_MAX,
|
||||
} btc_ble_mesh_brc_client_evt_t;
|
||||
|
||||
void btc_ble_mesh_brc_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_brc_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_brc_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_brc_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_brc_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_brc_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_BRC_SERVER_STATE_CHANGE,
|
||||
BTC_BLE_MESH_EVT_BRC_SERVER_MAX,
|
||||
} btc_ble_mesh_brc_server_evt_t;
|
||||
|
||||
void btc_ble_mesh_brc_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void bt_mesh_brc_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_BRC_MODEL_H_ */
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BTC_BLE_MESH_DF_MODEL_H_
|
||||
#define _BTC_BLE_MESH_DF_MODEL_H_
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_df_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_DF_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_ACT_DF_CLIENT_SET_STATE,
|
||||
BTC_BLE_MESH_ACT_DF_CLIENT_MAX,
|
||||
} btc_ble_mesh_df_client_act_t;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
esp_ble_mesh_df_client_get_t *get;
|
||||
} df_get;
|
||||
struct {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
esp_ble_mesh_df_client_set_t *set;
|
||||
} df_set;
|
||||
} btc_ble_mesh_df_client_args_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_DF_CLIENT_SEND_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_DF_CLIENT_RECV_GET_RSP,
|
||||
BTC_BLE_MESH_EVT_DF_CLIENT_RECV_SET_RSP,
|
||||
BTC_BLE_MESH_EVT_DF_CLIENT_RECV_PUB,
|
||||
BTC_BLE_MESH_EVT_DF_CLIENT_MAX,
|
||||
} btc_ble_mesh_df_client_evt_t;
|
||||
|
||||
void btc_ble_mesh_df_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_df_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_df_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_df_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_df_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_df_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_DF_SERVER_STATE_CHANGE,
|
||||
BTC_BLE_MESH_EVT_DF_SERVER_TABLE_CHANGE,
|
||||
BTC_BLE_MESH_EVT_DF_SERVER_MAX,
|
||||
} btc_ble_mesh_df_server_evt_t;
|
||||
|
||||
void btc_ble_mesh_df_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void bt_mesh_df_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_DF_MODEL_H_ */
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BTC_BLE_MESH_LCD_MODEL_H_
|
||||
#define _BTC_BLE_MESH_LCD_MODEL_H_
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_lcd_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_LCD_CLIENT_SEND,
|
||||
BTC_BLE_MESH_ACT_LCD_CLIENT_MAX,
|
||||
} btc_ble_mesh_lcd_client_act_t;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
esp_ble_mesh_lcd_client_msg_t *msg;
|
||||
} lcd_send;
|
||||
} btc_ble_mesh_lcd_client_args_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_LCD_CLIENT_SEND_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_LCD_CLIENT_RECV_RSP,
|
||||
BTC_BLE_MESH_EVT_LCD_CLIENT_RECV_PUB,
|
||||
BTC_BLE_MESH_EVT_LCD_CLIENT_MAX,
|
||||
} btc_ble_mesh_lcd_client_evt_t;
|
||||
|
||||
void btc_ble_mesh_lcd_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_lcd_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_lcd_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_lcd_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_lcd_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_lcd_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const void *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_LCD_SERVER_STATE_CHANGE,
|
||||
BTC_BLE_MESH_EVT_LCD_SERVER_MAX,
|
||||
} btc_ble_mesh_lcd_server_evt_t;
|
||||
|
||||
void btc_ble_mesh_lcd_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void bt_mesh_lcd_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const void *val, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_LCD_MODEL_H_ */
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BTC_BLE_MESH_MBT_MODEL_H_
|
||||
#define _BTC_BLE_MESH_MBT_MODEL_H_
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_mbt_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_RETRIEVE_CAPABILITIES,
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_TRANSFER_BLOB,
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_SEND_BLOCK,
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_SEND_DATA,
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_DETERMINE_BLOCK_STATUS,
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_DETERMINE_TRANSFER_STATUS,
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_CANCEL_TRANSFER,
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_SET_TRANSFER_TTL,
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_CLEAR_TRANSFER_TTL,
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_SET_APP_IDX,
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_CLEAR_APP_IDX,
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_SET_MULTICAST_ADDR,
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_CLEAR_MULTICAST_ADDR,
|
||||
BTC_BLE_MESH_ACT_MBT_CLIENT_MAX,
|
||||
} btc_ble_mesh_mbt_client_act_t;
|
||||
|
||||
typedef union {
|
||||
esp_ble_mesh_retrieve_capabilities_t retrieve_capabilities;
|
||||
esp_ble_mesh_transfer_blob_t transfer_blob;
|
||||
esp_ble_mesh_send_block_t send_block;
|
||||
esp_ble_mesh_send_data_t send_data;
|
||||
esp_ble_mesh_determine_block_status_t determine_block_status;
|
||||
esp_ble_mesh_determine_transfer_status_t determine_transfer_status;
|
||||
esp_ble_mesh_cancel_transfer_t cancel_transfer;
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model;
|
||||
uint8_t transfer_ttl;
|
||||
} set_transfer_ttl;
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model;
|
||||
} clear_transfer_ttl;
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model;
|
||||
uint16_t app_idx;
|
||||
} set_app_idx;
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model;
|
||||
} clear_app_idx;
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model;
|
||||
uint16_t multicast_addr;
|
||||
} set_multicast_addr;
|
||||
struct {
|
||||
esp_ble_mesh_model_t *model;
|
||||
} clear_multicast_addr;
|
||||
} btc_ble_mesh_mbt_client_args_t;
|
||||
|
||||
#define BTC_BLE_MESH_MBT_CLIENT_RESULT_COMPLETE 0x00
|
||||
#define BTC_BLE_MESH_MBT_CLIENT_RESULT_FAIL 0x01
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_RETRIEVE_CAPABILITIES_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_TRANSFER_BLOB_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_SEND_BLOCK_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_SEND_DATA_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_DETERMINE_BLOCK_STATUS_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_DETERMINE_TRANSFER_STATUS_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_CANCEL_TRANSFER_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_SET_TRANSFER_TTL_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_CLEAR_TRANSFER_TTL_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_SET_APP_IDX_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_CLEAR_APP_IDX_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_SET_MULTICAST_ADDR_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_CLEAR_MULTICAST_ADDR_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_CLIENT_MAX,
|
||||
} btc_ble_mesh_mbt_client_evt_t;
|
||||
|
||||
void btc_ble_mesh_mbt_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_mbt_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_mbt_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_mbt_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_mbt_client_publish_callback(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_mbt_client_cb_evt_to_btc(uint8_t event, uint8_t result,
|
||||
struct bt_mesh_model *model);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_MBT_SERVER_INITIALIZE_BLOB_RECEIVE,
|
||||
BTC_BLE_MESH_ACT_MBT_SERVER_CANCEL_BLOB_RECEIVE,
|
||||
BTC_BLE_MESH_ACT_MBT_SERVER_SET_BLOB_CAPABILITIES,
|
||||
BTC_BLE_MESH_ACT_MBT_SERVER_MAX,
|
||||
} btc_ble_mesh_mbt_server_act_t;
|
||||
|
||||
typedef union {
|
||||
esp_ble_mesh_initialize_blob_receive_t initialize_blob_receive;
|
||||
esp_ble_mesh_cancel_blob_receive_t cancel_blob_receive;
|
||||
esp_ble_mesh_set_blob_capabilities_t set_blob_capabilities;
|
||||
} btc_ble_mesh_mbt_server_args_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_INITIALIZE_BLOB_RECEIVE_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_CANCEL_BLOB_RECEIVE_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_SET_BLOB_CAPABILITIES_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_TRANSFER_GET,
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_TRANSFER_START,
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_TRANSFER_CANCEL,
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_BLOCK_GET,
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_BLOCK_START,
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_CHUNK_TRANSFER,
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_INFORMATION_GET,
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_BLOCK_RECEIVE_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_RECEIVE_COMP,
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_BLOB_RECEIVE_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_MBT_SERVER_MAX,
|
||||
} btc_ble_mesh_mbt_server_evt_t;
|
||||
|
||||
void btc_ble_mesh_mbt_server_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_mbt_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void bt_mesh_mbt_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_MBT_MODEL_H_ */
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BTC_BLE_MESH_ODP_MODEL_H_
|
||||
#define _BTC_BLE_MESH_ODP_MODEL_H_
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_odp_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_ODP_CLIENT_SEND,
|
||||
BTC_BLE_MESH_ACT_ODP_CLIENT_MAX,
|
||||
} btc_ble_mesh_odp_client_act_t;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
esp_ble_mesh_odp_client_msg_t *msg;
|
||||
} odp_send;
|
||||
} btc_ble_mesh_odp_client_args_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_ODP_CLIENT_SEND_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_ODP_CLIENT_RECV_RSP,
|
||||
BTC_BLE_MESH_EVT_ODP_CLIENT_RECV_PUB,
|
||||
BTC_BLE_MESH_EVT_ODP_CLIENT_MAX,
|
||||
} btc_ble_mesh_odp_client_evt_t;
|
||||
|
||||
void btc_ble_mesh_odp_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_odp_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_odp_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_odp_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_odp_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_odp_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_ODP_SERVER_STATE_CHANGE,
|
||||
BTC_BLE_MESH_EVT_ODP_SERVER_MAX,
|
||||
} btc_ble_mesh_odp_server_evt_t;
|
||||
|
||||
void btc_ble_mesh_odp_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void bt_mesh_odp_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_ODP_MODEL_H_ */
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BTC_BLE_MESH_PRB_MODEL_H_
|
||||
#define _BTC_BLE_MESH_PRB_MODEL_H_
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_prb_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_PRB_CLIENT_SEND,
|
||||
BTC_BLE_MESH_ACT_PRB_CLIENT_MAX,
|
||||
} btc_ble_mesh_prb_client_act_t;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
esp_ble_mesh_prb_client_msg_t *msg;
|
||||
} prb_send;
|
||||
} btc_ble_mesh_prb_client_args_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_PRB_CLIENT_RECV_RSP,
|
||||
BTC_BLE_MESH_EVT_PRB_CLIENT_RECV_PUB,
|
||||
BTC_BLE_MESH_EVT_PRB_CLIENT_SEND_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_PRB_CLIENT_MAX,
|
||||
} btc_ble_mesh_prb_client_evt_t;
|
||||
|
||||
void btc_ble_mesh_prb_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_prb_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_prb_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_prb_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_prb_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_prb_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, uint16_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_PRB_SERVER_STATE_CHANGE,
|
||||
BTC_BLE_MESH_EVT_PRB_SERVER_MAX,
|
||||
} btc_ble_mesh_prb_server_evt_t;
|
||||
|
||||
void btc_ble_mesh_prb_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void bt_mesh_prb_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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_PRB_MODEL_H_ */
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BTC_BLE_MESH_RPR_MODEL_H_
|
||||
#define _BTC_BLE_MESH_RPR_MODEL_H_
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_rpr_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_RPR_CLIENT_SEND,
|
||||
BTC_BLE_MESH_ACT_RPR_CLIENT_ACT,
|
||||
BTC_BLE_MESH_ACT_RPR_CLIENT_MAX,
|
||||
} btc_ble_mesh_rpr_client_act_t;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
esp_ble_mesh_rpr_client_msg_t *msg;
|
||||
} rpr_send;
|
||||
struct {
|
||||
esp_ble_mesh_rpr_client_act_type_t type;
|
||||
esp_ble_mesh_rpr_client_act_param_t *param;
|
||||
} rpr_act;
|
||||
} btc_ble_mesh_rpr_client_args_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_RPR_CLIENT_SEND_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_RPR_CLIENT_RECV_RSP,
|
||||
BTC_BLE_MESH_EVT_RPR_CLIENT_RECV_PUB,
|
||||
BTC_BLE_MESH_EVT_RPR_CLIENT_MAX,
|
||||
} btc_ble_mesh_rpr_client_evt_t;
|
||||
|
||||
void btc_ble_mesh_rpr_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_rpr_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_rpr_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_rpr_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_rpr_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void btc_ble_mesh_rpr_client_link_close_cb(struct bt_mesh_model *model,
|
||||
uint16_t rpr_srv_addr, uint8_t reason);
|
||||
|
||||
void btc_ble_mesh_rpr_client_prov_comp_cb(struct bt_mesh_model *model, uint16_t rpr_srv_addr,
|
||||
uint8_t nppi, uint16_t index, uint8_t uuid[16],
|
||||
uint16_t unicast_addr, uint8_t element_num,
|
||||
uint16_t net_idx);
|
||||
|
||||
void bt_mesh_rpr_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const void *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_RPR_SERVER_SCAN_START,
|
||||
BTC_BLE_MESH_EVT_RPR_SERVER_SCAN_STOP,
|
||||
BTC_BLE_MESH_EVT_RPR_SERVER_EXT_SCAN_START,
|
||||
BTC_BLE_MESH_EVT_RPR_SERVER_EXT_SCAN_STOP,
|
||||
BTC_BLE_MESH_EVT_RPR_SERVER_LINK_OPEN,
|
||||
BTC_BLE_MESH_EVT_RPR_SERVER_LINK_CLOSE,
|
||||
BTC_BLE_MESH_EVT_RPR_SERVER_PROV_COMP,
|
||||
BTC_BLE_MESH_EVT_RPR_SERVER_MAX,
|
||||
} btc_ble_mesh_rpr_server_evt_t;
|
||||
|
||||
void btc_ble_mesh_rpr_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void bt_mesh_rpr_server_cb_evt_to_btc(uint8_t event, const void *val, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_RPR_MODEL_H_ */
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BTC_BLE_MESH_SAR_MODEL_H_
|
||||
#define _BTC_BLE_MESH_SAR_MODEL_H_
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_sar_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_SAR_CLIENT_SEND,
|
||||
BTC_BLE_MESH_ACT_SAR_CLIENT_MAX,
|
||||
} btc_ble_mesh_sar_client_act_t;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
esp_ble_mesh_sar_client_msg_t *msg;
|
||||
} sar_send;
|
||||
} btc_ble_mesh_sar_client_args_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_SAR_CLIENT_SEND_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_SAR_CLIENT_RECV_RSP,
|
||||
BTC_BLE_MESH_EVT_SAR_CLIENT_RECV_PUB,
|
||||
BTC_BLE_MESH_EVT_SAR_CLIENT_MAX,
|
||||
} btc_ble_mesh_sar_client_evt_t;
|
||||
|
||||
void btc_ble_mesh_sar_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_sar_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_sar_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_sar_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_sar_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_sar_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_sar_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_SAR_SERVER_STATE_CHANGE,
|
||||
BTC_BLE_MESH_EVT_SAR_SERVER_MAX,
|
||||
} btc_ble_mesh_sar_server_evt_t;
|
||||
|
||||
void bt_mesh_sar_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_SAR_MODEL_H_ */
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BTC_BLE_MESH_SRPL_MODEL_H_
|
||||
#define _BTC_BLE_MESH_SRPL_MODEL_H_
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_srpl_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_SRPL_CLIENT_SEND,
|
||||
BTC_BLE_MESH_ACT_SRPL_CLIENT_MAX,
|
||||
} btc_ble_mesh_srpl_client_act_t;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
esp_ble_mesh_srpl_client_msg_t *msg;
|
||||
} srpl_send;
|
||||
} btc_ble_mesh_srpl_client_args_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_SRPL_CLIENT_SEND_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_SRPL_CLIENT_RECV_RSP,
|
||||
BTC_BLE_MESH_EVT_SRPL_CLIENT_RECV_PUB,
|
||||
BTC_BLE_MESH_EVT_SRPL_CLIENT_MAX,
|
||||
} btc_ble_mesh_srpl_client_evt_t;
|
||||
|
||||
void btc_ble_mesh_srpl_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_srpl_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_srpl_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_srpl_client_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_srpl_client_recv_pub_cb(uint32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_srpl_client_cb_evt_to_btc(uint32_t opcode, uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_SRPL_SERVER_STATE_CHANGE,
|
||||
BTC_BLE_MESH_EVT_SRPL_SERVER_MAX,
|
||||
} btc_ble_mesh_srpl_server_evt_t;
|
||||
|
||||
void btc_ble_mesh_srpl_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void bt_mesh_srpl_server_cb_evt_to_btc(uint8_t event,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_SRPL_MODEL_H_ */
|
||||
Reference in New Issue
Block a user