ble_mesh: ble mesh btc miscellaneous modifications

This commit is contained in:
lly 2019-09-02 13:01:06 +08:00
parent 1f96bf5906
commit 624bf7e3a0
35 changed files with 1565 additions and 1492 deletions

View file

@ -114,16 +114,16 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
#endif /* #if CLASSIC_BT_INCLUDED */ #endif /* #if CLASSIC_BT_INCLUDED */
#endif #endif
#if CONFIG_BLE_MESH #if CONFIG_BLE_MESH
[BTC_PID_PROV] = {btc_mesh_prov_call_handler, btc_mesh_prov_cb_handler}, [BTC_PID_PROV] = {btc_ble_mesh_prov_call_handler, btc_ble_mesh_prov_cb_handler },
[BTC_PID_MODEL] = {btc_mesh_model_call_handler, btc_mesh_model_cb_handler}, [BTC_PID_MODEL] = {btc_ble_mesh_model_call_handler, btc_ble_mesh_model_cb_handler },
[BTC_PID_HEALTH_CLIENT] = {btc_mesh_health_client_call_handler, btc_mesh_health_client_cb_handler}, [BTC_PID_HEALTH_CLIENT] = {btc_ble_mesh_health_client_call_handler, btc_ble_mesh_health_client_cb_handler },
[BTC_PID_HEALTH_SERVER] = {btc_mesh_health_server_call_handler, btc_mesh_health_server_cb_handler}, [BTC_PID_HEALTH_SERVER] = {btc_ble_mesh_health_server_call_handler, btc_ble_mesh_health_server_cb_handler },
[BTC_PID_CFG_CLIENT] = {btc_mesh_cfg_client_call_handler, btc_mesh_cfg_client_cb_handler}, [BTC_PID_CONFIG_CLIENT] = {btc_ble_mesh_config_client_call_handler, btc_ble_mesh_config_client_cb_handler },
[BTC_PID_CFG_SERVER] = {NULL , btc_mesh_cfg_server_cb_handler}, [BTC_PID_CONFIG_SERVER] = {NULL, btc_ble_mesh_config_server_cb_handler },
[BTC_PID_GENERIC_CLIENT] = {btc_mesh_generic_client_call_handler, btc_mesh_generic_client_cb_handler}, [BTC_PID_GENERIC_CLIENT] = {btc_ble_mesh_generic_client_call_handler, btc_ble_mesh_generic_client_cb_handler },
[BTC_PID_LIGHT_CLIENT] = {btc_mesh_light_client_call_handler, btc_mesh_light_client_cb_handler}, [BTC_PID_LIGHTING_CLIENT] = {btc_ble_mesh_lighting_client_call_handler, btc_ble_mesh_lighting_client_cb_handler },
[BTC_PID_SENSOR_CLIENT] = {btc_mesh_sensor_client_call_handler, btc_mesh_sensor_client_cb_handler}, [BTC_PID_SENSOR_CLIENT] = {btc_ble_mesh_sensor_client_call_handler, btc_ble_mesh_sensor_client_cb_handler },
[BTC_PID_TIME_SCENE_CLIENT] = {btc_mesh_time_scene_client_call_handler, btc_mesh_time_scene_client_cb_handler}, [BTC_PID_TIME_SCENE_CLIENT] = {btc_ble_mesh_time_scene_client_call_handler, btc_ble_mesh_time_scene_client_cb_handler},
#endif /* #if CONFIG_BLE_MESH */ #endif /* #if CONFIG_BLE_MESH */
}; };

View file

@ -72,10 +72,10 @@ typedef enum {
BTC_PID_MODEL, BTC_PID_MODEL,
BTC_PID_HEALTH_CLIENT, BTC_PID_HEALTH_CLIENT,
BTC_PID_HEALTH_SERVER, BTC_PID_HEALTH_SERVER,
BTC_PID_CFG_CLIENT, BTC_PID_CONFIG_CLIENT,
BTC_PID_CFG_SERVER, BTC_PID_CONFIG_SERVER,
BTC_PID_GENERIC_CLIENT, BTC_PID_GENERIC_CLIENT,
BTC_PID_LIGHT_CLIENT, BTC_PID_LIGHTING_CLIENT,
BTC_PID_SENSOR_CLIENT, BTC_PID_SENSOR_CLIENT,
BTC_PID_TIME_SCENE_CLIENT, BTC_PID_TIME_SCENE_CLIENT,
#endif /* CONFIG_BLE_MESH */ #endif /* CONFIG_BLE_MESH */

View file

@ -157,7 +157,7 @@ esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model)
if (model == NULL) { if (model == NULL) {
return ESP_ERR_INVALID_ARG; return ESP_ERR_INVALID_ARG;
} }
return btc_ble_mesh_client_init(model); return btc_ble_mesh_client_model_init(model);
} }
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model, esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,

View file

@ -123,7 +123,7 @@ typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN];
#define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_SRV BLE_MESH_MODEL_ID_GEN_BATTERY_SRV #define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_SRV BLE_MESH_MODEL_ID_GEN_BATTERY_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_CLI BLE_MESH_MODEL_ID_GEN_BATTERY_CLI #define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_CLI BLE_MESH_MODEL_ID_GEN_BATTERY_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SRV BLE_MESH_MODEL_ID_GEN_LOCATION_SRV #define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SRV BLE_MESH_MODEL_ID_GEN_LOCATION_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV BLE_MESH_MODEL_ID_GEN_LOCATION_SETUPSRV #define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_CLI BLE_MESH_MODEL_ID_GEN_LOCATION_CLI #define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_CLI BLE_MESH_MODEL_ID_GEN_LOCATION_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV #define ESP_BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV #define ESP_BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV
@ -158,7 +158,7 @@ typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN];
#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV #define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_CLI BLE_MESH_MODEL_ID_LIGHT_XYL_CLI #define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_CLI BLE_MESH_MODEL_ID_LIGHT_XYL_CLI
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SRV BLE_MESH_MODEL_ID_LIGHT_LC_SRV #define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SRV BLE_MESH_MODEL_ID_LIGHT_LC_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV BLE_MESH_MODEL_ID_LIGHT_LC_SETUPSRV #define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_CLI BLE_MESH_MODEL_ID_LIGHT_LC_CLI #define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_CLI BLE_MESH_MODEL_ID_LIGHT_LC_CLI
/*!< The following opcodes will only be used in the esp_ble_mesh_config_client_get_state function. */ /*!< The following opcodes will only be used in the esp_ble_mesh_config_client_get_state function. */

View file

@ -27,20 +27,20 @@ esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_c
{ {
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_CFG_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL); return (btc_profile_cb_set(BTC_PID_CONFIG_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
} }
esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback) esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback)
{ {
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_CFG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL); return (btc_profile_cb_set(BTC_PID_CONFIG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
} }
esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params, esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_get_state_t *get_state) esp_ble_mesh_cfg_client_get_state_t *get_state)
{ {
btc_ble_mesh_cfg_client_args_t arg = {0}; btc_ble_mesh_config_client_args_t arg = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) { if (!params || !params->model || !params->ctx.addr || !get_state) {
@ -50,19 +50,19 @@ esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL; msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_CFG_CLIENT; msg.pid = BTC_PID_CONFIG_CLIENT;
msg.act = BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE; msg.act = BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE;
arg.cfg_client_get_state.params = params; arg.cfg_client_get_state.params = params;
arg.cfg_client_get_state.get_state = get_state; arg.cfg_client_get_state.get_state = get_state;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_cfg_client_args_t), btc_ble_mesh_cfg_client_arg_deep_copy) return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_config_client_args_t), btc_ble_mesh_config_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
} }
esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params, esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_set_state_t *set_state) esp_ble_mesh_cfg_client_set_state_t *set_state)
{ {
btc_ble_mesh_cfg_client_args_t arg = {0}; btc_ble_mesh_config_client_args_t arg = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) { if (!params || !params->model || !params->ctx.addr || !set_state) {
@ -72,11 +72,11 @@ esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL; msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_CFG_CLIENT; msg.pid = BTC_PID_CONFIG_CLIENT;
msg.act = BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE; msg.act = BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE;
arg.cfg_client_set_state.params = params; arg.cfg_client_set_state.params = params;
arg.cfg_client_set_state.set_state = set_state; arg.cfg_client_set_state.set_state = set_state;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_cfg_client_args_t), btc_ble_mesh_cfg_client_arg_deep_copy) return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_config_client_args_t), btc_ble_mesh_config_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
} }

View file

@ -27,13 +27,13 @@ esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_
{ {
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_LIGHT_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL); return (btc_profile_cb_set(BTC_PID_LIGHTING_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
} }
esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params, esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_light_client_get_state_t *get_state) esp_ble_mesh_light_client_get_state_t *get_state)
{ {
btc_ble_mesh_light_client_args_t arg = {0}; btc_ble_mesh_lighting_client_args_t arg = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) { if (!params || !params->model || !params->ctx.addr || !get_state) {
@ -43,19 +43,19 @@ esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL; msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_LIGHT_CLIENT; msg.pid = BTC_PID_LIGHTING_CLIENT;
msg.act = BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE; msg.act = BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE;
arg.light_client_get_state.params = params; arg.light_client_get_state.params = params;
arg.light_client_get_state.get_state = get_state; arg.light_client_get_state.get_state = get_state;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_light_client_args_t), btc_ble_mesh_light_client_arg_deep_copy) return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_lighting_client_args_t), btc_ble_mesh_lighting_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
} }
esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params, esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_light_client_set_state_t *set_state) esp_ble_mesh_light_client_set_state_t *set_state)
{ {
btc_ble_mesh_light_client_args_t arg = {0}; btc_ble_mesh_lighting_client_args_t arg = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) { if (!params || !params->model || !params->ctx.addr || !set_state) {
@ -65,12 +65,12 @@ esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL; msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_LIGHT_CLIENT; msg.pid = BTC_PID_LIGHTING_CLIENT;
msg.act = BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE; msg.act = BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE;
arg.light_client_set_state.params = params; arg.light_client_set_state.params = params;
arg.light_client_set_state.set_state = set_state; arg.light_client_set_state.set_state = set_state;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_light_client_args_t), btc_ble_mesh_light_client_arg_deep_copy) return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_lighting_client_args_t), btc_ble_mesh_lighting_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
} }

View file

@ -19,7 +19,6 @@
#ifndef _ESP_BLE_MESH_GENERIC_MODEL_API_H_ #ifndef _ESP_BLE_MESH_GENERIC_MODEL_API_H_
#define _ESP_BLE_MESH_GENERIC_MODEL_API_H_ #define _ESP_BLE_MESH_GENERIC_MODEL_API_H_
#include "generic_client.h"
#include "esp_ble_mesh_defs.h" #include "esp_ble_mesh_defs.h"
/** @def ESP_BLE_MESH_MODEL_GEN_ONOFF_CLI /** @def ESP_BLE_MESH_MODEL_GEN_ONOFF_CLI

View file

@ -19,7 +19,6 @@
#ifndef _ESP_BLE_MESH_LIGHTING_MODEL_API_H_ #ifndef _ESP_BLE_MESH_LIGHTING_MODEL_API_H_
#define _ESP_BLE_MESH_LIGHTING_MODEL_API_H_ #define _ESP_BLE_MESH_LIGHTING_MODEL_API_H_
#include "lighting_client.h"
#include "esp_ble_mesh_defs.h" #include "esp_ble_mesh_defs.h"
/** @def ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI /** @def ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI
@ -109,163 +108,163 @@
/** Parameters of Light Lightness Set */ /** Parameters of Light Lightness Set */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t lightness; /*!< Target value of light lightness actual state */ uint16_t lightness; /*!< Target value of light lightness actual state */
u8_t tid; /*!< Transaction ID */ uint8_t tid; /*!< Transaction ID */
u8_t trans_time; /*!< Time to complete state transition (optional) */ uint8_t trans_time; /*!< Time to complete state transition (optional) */
u8_t delay; /*!< Indicate message execution delay (C.1) */ uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_light_lightness_set_t; } esp_ble_mesh_light_lightness_set_t;
/** Parameters of Light Lightness Linear Set */ /** Parameters of Light Lightness Linear Set */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t lightness; /*!< Target value of light lightness linear state */ uint16_t lightness; /*!< Target value of light lightness linear state */
u8_t tid; /*!< Transaction ID */ uint8_t tid; /*!< Transaction ID */
u8_t trans_time; /*!< Time to complete state transition (optional) */ uint8_t trans_time; /*!< Time to complete state transition (optional) */
u8_t delay; /*!< Indicate message execution delay (C.1) */ uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_light_lightness_linear_set_t; } esp_ble_mesh_light_lightness_linear_set_t;
/** Parameter of Light Lightness Default Set */ /** Parameter of Light Lightness Default Set */
typedef struct { typedef struct {
u16_t lightness; /*!< The value of the Light Lightness Default state */ uint16_t lightness; /*!< The value of the Light Lightness Default state */
} esp_ble_mesh_light_lightness_default_set_t; } esp_ble_mesh_light_lightness_default_set_t;
/** Parameters of Light Lightness Range Set */ /** Parameters of Light Lightness Range Set */
typedef struct { typedef struct {
u16_t range_min; /*!< Value of range min field of light lightness range state */ uint16_t range_min; /*!< Value of range min field of light lightness range state */
u16_t range_max; /*!< Value of range max field of light lightness range state */ uint16_t range_max; /*!< Value of range max field of light lightness range state */
} esp_ble_mesh_light_lightness_range_set_t; } esp_ble_mesh_light_lightness_range_set_t;
/** Parameters of Light CTL Set */ /** Parameters of Light CTL Set */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t ctl_lightness; /*!< Target value of light ctl lightness state */ uint16_t ctl_lightness; /*!< Target value of light ctl lightness state */
u16_t ctl_temperatrue; /*!< Target value of light ctl temperature state */ uint16_t ctl_temperatrue; /*!< Target value of light ctl temperature state */
s16_t ctl_delta_uv; /*!< Target value of light ctl delta UV state */ int16_t ctl_delta_uv; /*!< Target value of light ctl delta UV state */
u8_t tid; /*!< Transaction ID */ uint8_t tid; /*!< Transaction ID */
u8_t trans_time; /*!< Time to complete state transition (optional) */ uint8_t trans_time; /*!< Time to complete state transition (optional) */
u8_t delay; /*!< Indicate message execution delay (C.1) */ uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_light_ctl_set_t; } esp_ble_mesh_light_ctl_set_t;
/** Parameters of Light CTL Temperature Set */ /** Parameters of Light CTL Temperature Set */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t ctl_temperatrue; /*!< Target value of light ctl temperature state */ uint16_t ctl_temperatrue; /*!< Target value of light ctl temperature state */
s16_t ctl_delta_uv; /*!< Target value of light ctl delta UV state */ int16_t ctl_delta_uv; /*!< Target value of light ctl delta UV state */
u8_t tid; /*!< Transaction ID */ uint8_t tid; /*!< Transaction ID */
u8_t trans_time; /*!< Time to complete state transition (optional) */ uint8_t trans_time; /*!< Time to complete state transition (optional) */
u8_t delay; /*!< Indicate message execution delay (C.1) */ uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_light_ctl_temperature_set_t; } esp_ble_mesh_light_ctl_temperature_set_t;
/** Parameters of Light CTL Temperature Range Set */ /** Parameters of Light CTL Temperature Range Set */
typedef struct { typedef struct {
u16_t range_min; /*!< Value of temperature range min field of light ctl temperature range state */ uint16_t range_min; /*!< Value of temperature range min field of light ctl temperature range state */
u16_t range_max; /*!< Value of temperature range max field of light ctl temperature range state */ uint16_t range_max; /*!< Value of temperature range max field of light ctl temperature range state */
} esp_ble_mesh_light_ctl_temperature_range_set_t; } esp_ble_mesh_light_ctl_temperature_range_set_t;
/** Parameters of Light CTL Default Set */ /** Parameters of Light CTL Default Set */
typedef struct { typedef struct {
u16_t lightness; /*!< Value of light lightness default state */ uint16_t lightness; /*!< Value of light lightness default state */
u16_t temperature; /*!< Value of light temperature default state */ uint16_t temperature; /*!< Value of light temperature default state */
s16_t delta_uv; /*!< Value of light delta UV default state */ int16_t delta_uv; /*!< Value of light delta UV default state */
} esp_ble_mesh_light_ctl_default_set_t; } esp_ble_mesh_light_ctl_default_set_t;
/** Parameters of Light HSL Set */ /** Parameters of Light HSL Set */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t hsl_lightness; /*!< Target value of light hsl lightness state */ uint16_t hsl_lightness; /*!< Target value of light hsl lightness state */
u16_t hsl_hue; /*!< Target value of light hsl hue state */ uint16_t hsl_hue; /*!< Target value of light hsl hue state */
u16_t hsl_saturation; /*!< Target value of light hsl saturation state */ uint16_t hsl_saturation; /*!< Target value of light hsl saturation state */
u8_t tid; /*!< Transaction ID */ uint8_t tid; /*!< Transaction ID */
u8_t trans_time; /*!< Time to complete state transition (optional) */ uint8_t trans_time; /*!< Time to complete state transition (optional) */
u8_t delay; /*!< Indicate message execution delay (C.1) */ uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_light_hsl_set_t; } esp_ble_mesh_light_hsl_set_t;
/** Parameters of Light HSL Hue Set */ /** Parameters of Light HSL Hue Set */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t hue; /*!< Target value of light hsl hue state */ uint16_t hue; /*!< Target value of light hsl hue state */
u8_t tid; /*!< Transaction ID */ uint8_t tid; /*!< Transaction ID */
u8_t trans_time; /*!< Time to complete state transition (optional) */ uint8_t trans_time; /*!< Time to complete state transition (optional) */
u8_t delay; /*!< Indicate message execution delay (C.1) */ uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_light_hsl_hue_set_t; } esp_ble_mesh_light_hsl_hue_set_t;
/** Parameters of Light HSL Saturation Set */ /** Parameters of Light HSL Saturation Set */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t saturation; /*!< Target value of light hsl hue state */ uint16_t saturation; /*!< Target value of light hsl hue state */
u8_t tid; /*!< Transaction ID */ uint8_t tid; /*!< Transaction ID */
u8_t trans_time; /*!< Time to complete state transition (optional) */ uint8_t trans_time; /*!< Time to complete state transition (optional) */
u8_t delay; /*!< Indicate message execution delay (C.1) */ uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_light_hsl_saturation_set_t; } esp_ble_mesh_light_hsl_saturation_set_t;
/** Parameters of Light HSL Default Set */ /** Parameters of Light HSL Default Set */
typedef struct { typedef struct {
u16_t lightness; /*!< Value of light lightness default state */ uint16_t lightness; /*!< Value of light lightness default state */
u16_t hue; /*!< Value of light hue default state */ uint16_t hue; /*!< Value of light hue default state */
u16_t saturation; /*!< Value of light saturation default state */ uint16_t saturation; /*!< Value of light saturation default state */
} esp_ble_mesh_light_hsl_default_set_t; } esp_ble_mesh_light_hsl_default_set_t;
/** Parameters of Light HSL Range Set */ /** Parameters of Light HSL Range Set */
typedef struct { typedef struct {
u16_t hue_range_min; /*!< Value of hue range min field of light hsl hue range state */ uint16_t hue_range_min; /*!< Value of hue range min field of light hsl hue range state */
u16_t hue_range_max; /*!< Value of hue range max field of light hsl hue range state */ uint16_t hue_range_max; /*!< Value of hue range max field of light hsl hue range state */
u16_t saturation_range_min; /*!< Value of saturation range min field of light hsl saturation range state */ uint16_t saturation_range_min; /*!< Value of saturation range min field of light hsl saturation range state */
u16_t saturation_range_max; /*!< Value of saturation range max field of light hsl saturation range state */ uint16_t saturation_range_max; /*!< Value of saturation range max field of light hsl saturation range state */
} esp_ble_mesh_light_hsl_range_set_t; } esp_ble_mesh_light_hsl_range_set_t;
/** Parameters of Light xyL Set */ /** Parameters of Light xyL Set */
typedef struct { typedef struct {
bool op_en; /*!< Indicate whether optional parameters included */ bool op_en; /*!< Indicate whether optional parameters included */
u16_t xyl_lightness; /*!< The target value of the Light xyL Lightness state */ uint16_t xyl_lightness; /*!< The target value of the Light xyL Lightness state */
u16_t xyl_x; /*!< The target value of the Light xyL x state */ uint16_t xyl_x; /*!< The target value of the Light xyL x state */
u16_t xyl_y; /*!< The target value of the Light xyL y state */ uint16_t xyl_y; /*!< The target value of the Light xyL y state */
u8_t tid; /*!< Transaction Identifier */ uint8_t tid; /*!< Transaction Identifier */
u8_t trans_time; /*!< Time to complete state transition (optional) */ uint8_t trans_time; /*!< Time to complete state transition (optional) */
u8_t delay; /*!< Indicate message execution delay (C.1) */ uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_light_xyl_set_t; } esp_ble_mesh_light_xyl_set_t;
/** Parameters of Light xyL Default Set */ /** Parameters of Light xyL Default Set */
typedef struct { typedef struct {
u16_t lightness; /*!< The value of the Light Lightness Default state */ uint16_t lightness; /*!< The value of the Light Lightness Default state */
u16_t xyl_x; /*!< The value of the Light xyL x Default state */ uint16_t xyl_x; /*!< The value of the Light xyL x Default state */
u16_t xyl_y; /*!< The value of the Light xyL y Default state */ uint16_t xyl_y; /*!< The value of the Light xyL y Default state */
} esp_ble_mesh_light_xyl_default_set_t; } esp_ble_mesh_light_xyl_default_set_t;
/** Parameters of Light xyL Range Set */ /** Parameters of Light xyL Range Set */
typedef struct { typedef struct {
u16_t xyl_x_range_min; /*!< The value of the xyL x Range Min field of the Light xyL x Range state */ uint16_t xyl_x_range_min; /*!< The value of the xyL x Range Min field of the Light xyL x Range state */
u16_t xyl_x_range_max; /*!< The value of the xyL x Range Max field of the Light xyL x Range state */ uint16_t xyl_x_range_max; /*!< The value of the xyL x Range Max field of the Light xyL x Range state */
u16_t xyl_y_range_min; /*!< The value of the xyL y Range Min field of the Light xyL y Range state */ uint16_t xyl_y_range_min; /*!< The value of the xyL y Range Min field of the Light xyL y Range state */
u16_t xyl_y_range_max; /*!< The value of the xyL y Range Max field of the Light xyL y Range state */ uint16_t xyl_y_range_max; /*!< The value of the xyL y Range Max field of the Light xyL y Range state */
} esp_ble_mesh_light_xyl_range_set_t; } esp_ble_mesh_light_xyl_range_set_t;
/** Parameter of Light LC Mode Set */ /** Parameter of Light LC Mode Set */
typedef struct { typedef struct {
u8_t mode; /*!< The target value of the Light LC Mode state */ uint8_t mode; /*!< The target value of the Light LC Mode state */
} esp_ble_mesh_light_lc_mode_set_t; } esp_ble_mesh_light_lc_mode_set_t;
/** Parameter of Light LC OM Set */ /** Parameter of Light LC OM Set */
typedef struct { typedef struct {
u8_t mode; /*!< The target value of the Light LC Occupancy Mode state */ uint8_t mode; /*!< The target value of the Light LC Occupancy Mode state */
} esp_ble_mesh_light_lc_om_set_t; } esp_ble_mesh_light_lc_om_set_t;
/** Parameters of Light LC Light OnOff Set */ /** Parameters of Light LC Light OnOff Set */
typedef struct { typedef struct {
bool op_en; /*!< Indicate whether optional parameters included */ bool op_en; /*!< Indicate whether optional parameters included */
u8_t light_onoff; /*!< The target value of the Light LC Light OnOff state */ uint8_t light_onoff; /*!< The target value of the Light LC Light OnOff state */
u8_t tid; /*!< Transaction Identifier */ uint8_t tid; /*!< Transaction Identifier */
u8_t trans_time; /*!< Time to complete state transition (optional) */ uint8_t trans_time; /*!< Time to complete state transition (optional) */
u8_t delay; /*!< Indicate message execution delay (C.1) */ uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_light_lc_light_onoff_set_t; } esp_ble_mesh_light_lc_light_onoff_set_t;
/** Parameter of Light LC Property Get */ /** Parameter of Light LC Property Get */
typedef struct { typedef struct {
u16_t property_id; /*!< Property ID identifying a Light LC Property */ uint16_t property_id; /*!< Property ID identifying a Light LC Property */
} esp_ble_mesh_light_lc_property_get_t; } esp_ble_mesh_light_lc_property_get_t;
/** Parameters of Light LC Property Set */ /** Parameters of Light LC Property Set */
typedef struct { typedef struct {
u16_t property_id; /*!< Property ID identifying a Light LC Property */ uint16_t property_id; /*!< Property ID identifying a Light LC Property */
struct net_buf_simple *property_value; /*!< Raw value for the Light LC Property */ struct net_buf_simple *property_value; /*!< Raw value for the Light LC Property */
} esp_ble_mesh_light_lc_property_set_t; } esp_ble_mesh_light_lc_property_set_t;
@ -309,175 +308,175 @@ typedef union {
/** Parameters of Light Lightness Status */ /** Parameters of Light Lightness Status */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t present_lightness; /*!< Current value of light lightness actual state */ uint16_t present_lightness; /*!< Current value of light lightness actual state */
u16_t target_lightness; /*!< Target value of light lightness actual state (optional) */ uint16_t target_lightness; /*!< Target value of light lightness actual state (optional) */
u8_t remain_time; /*!< Time to complete state transition (C.1) */ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
} esp_ble_mesh_light_lightness_status_cb_t; } esp_ble_mesh_light_lightness_status_cb_t;
/** Parameters of Light Lightness Linear Status */ /** Parameters of Light Lightness Linear Status */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t present_lightness; /*!< Current value of light lightness linear state */ uint16_t present_lightness; /*!< Current value of light lightness linear state */
u16_t target_lightness; /*!< Target value of light lightness linear state (optional) */ uint16_t target_lightness; /*!< Target value of light lightness linear state (optional) */
u8_t remain_time; /*!< Time to complete state transition (C.1) */ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
} esp_ble_mesh_light_lightness_linear_status_cb_t; } esp_ble_mesh_light_lightness_linear_status_cb_t;
/** Parameter of Light Lightness Last Status */ /** Parameter of Light Lightness Last Status */
typedef struct { typedef struct {
u16_t lightness; /*!< The value of the Light Lightness Last state */ uint16_t lightness; /*!< The value of the Light Lightness Last state */
} esp_ble_mesh_light_lightness_last_status_cb_t; } esp_ble_mesh_light_lightness_last_status_cb_t;
/** Parameter of Light Lightness Default Status */ /** Parameter of Light Lightness Default Status */
typedef struct { typedef struct {
u16_t lightness; /*!< The value of the Light Lightness default State */ uint16_t lightness; /*!< The value of the Light Lightness default State */
} esp_ble_mesh_light_lightness_default_status_cb_t; } esp_ble_mesh_light_lightness_default_status_cb_t;
/** Parameters of Light Lightness Range Status */ /** Parameters of Light Lightness Range Status */
typedef struct { typedef struct {
u8_t status_code; /*!< Status Code for the request message */ uint8_t status_code; /*!< Status Code for the request message */
u16_t range_min; /*!< Value of range min field of light lightness range state */ uint16_t range_min; /*!< Value of range min field of light lightness range state */
u16_t range_max; /*!< Value of range max field of light lightness range state */ uint16_t range_max; /*!< Value of range max field of light lightness range state */
} esp_ble_mesh_light_lightness_range_status_cb_t; } esp_ble_mesh_light_lightness_range_status_cb_t;
/** Parameters of Light CTL Status */ /** Parameters of Light CTL Status */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t present_ctl_lightness; /*!< Current value of light ctl lightness state */ uint16_t present_ctl_lightness; /*!< Current value of light ctl lightness state */
u16_t present_ctl_temperature; /*!< Current value of light ctl temperature state */ uint16_t present_ctl_temperature; /*!< Current value of light ctl temperature state */
u16_t target_ctl_lightness; /*!< Target value of light ctl lightness state (optional) */ uint16_t target_ctl_lightness; /*!< Target value of light ctl lightness state (optional) */
u16_t target_ctl_temperature; /*!< Target value of light ctl temperature state (C.1) */ uint16_t target_ctl_temperature; /*!< Target value of light ctl temperature state (C.1) */
u8_t remain_time; /*!< Time to complete state transition (C.1) */ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
} esp_ble_mesh_light_ctl_status_cb_t; } esp_ble_mesh_light_ctl_status_cb_t;
/** Parameters of Light CTL Temperature Status */ /** Parameters of Light CTL Temperature Status */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t present_ctl_temperature; /*!< Current value of light ctl temperature state */ uint16_t present_ctl_temperature; /*!< Current value of light ctl temperature state */
u16_t present_ctl_delta_uv; /*!< Current value of light ctl delta UV state */ uint16_t present_ctl_delta_uv; /*!< Current value of light ctl delta UV state */
u16_t target_ctl_temperature; /*!< Target value of light ctl temperature state (optional) */ uint16_t target_ctl_temperature; /*!< Target value of light ctl temperature state (optional) */
u16_t target_ctl_delta_uv; /*!< Target value of light ctl delta UV state (C.1) */ uint16_t target_ctl_delta_uv; /*!< Target value of light ctl delta UV state (C.1) */
u8_t remain_time; /*!< Time to complete state transition (C.1) */ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
} esp_ble_mesh_light_ctl_temperature_status_cb_t; } esp_ble_mesh_light_ctl_temperature_status_cb_t;
/** Parameters of Light CTL Temperature Range Status */ /** Parameters of Light CTL Temperature Range Status */
typedef struct { typedef struct {
u8_t status_code; /*!< Status code for the request message */ uint8_t status_code; /*!< Status code for the request message */
u16_t range_min; /*!< Value of temperature range min field of light ctl temperature range state */ uint16_t range_min; /*!< Value of temperature range min field of light ctl temperature range state */
u16_t range_max; /*!< Value of temperature range max field of light ctl temperature range state */ uint16_t range_max; /*!< Value of temperature range max field of light ctl temperature range state */
} esp_ble_mesh_light_ctl_temperature_range_status_cb_t; } esp_ble_mesh_light_ctl_temperature_range_status_cb_t;
/** Parameters of Light CTL Default Status */ /** Parameters of Light CTL Default Status */
typedef struct { typedef struct {
u16_t lightness; /*!< Value of light lightness default state */ uint16_t lightness; /*!< Value of light lightness default state */
u16_t temperature; /*!< Value of light temperature default state */ uint16_t temperature; /*!< Value of light temperature default state */
s16_t delta_uv; /*!< Value of light delta UV default state */ int16_t delta_uv; /*!< Value of light delta UV default state */
} esp_ble_mesh_light_ctl_default_status_cb_t; } esp_ble_mesh_light_ctl_default_status_cb_t;
/** Parameters of Light HSL Status */ /** Parameters of Light HSL Status */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t hsl_lightness; /*!< Current value of light hsl lightness state */ uint16_t hsl_lightness; /*!< Current value of light hsl lightness state */
u16_t hsl_hue; /*!< Current value of light hsl hue state */ uint16_t hsl_hue; /*!< Current value of light hsl hue state */
u16_t hsl_saturation; /*!< Current value of light hsl saturation state */ uint16_t hsl_saturation; /*!< Current value of light hsl saturation state */
u8_t remain_time; /*!< Time to complete state transition (optional) */ uint8_t remain_time; /*!< Time to complete state transition (optional) */
} esp_ble_mesh_light_hsl_status_cb_t; } esp_ble_mesh_light_hsl_status_cb_t;
/** Parameters of Light HSL Target Status */ /** Parameters of Light HSL Target Status */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t hsl_lightness_target; /*!< Target value of light hsl lightness state */ uint16_t hsl_lightness_target; /*!< Target value of light hsl lightness state */
u16_t hsl_hue_target; /*!< Target value of light hsl hue state */ uint16_t hsl_hue_target; /*!< Target value of light hsl hue state */
u16_t hsl_saturation_target; /*!< Target value of light hsl saturation state */ uint16_t hsl_saturation_target; /*!< Target value of light hsl saturation state */
u8_t remain_time; /*!< Time to complete state transition (optional) */ uint8_t remain_time; /*!< Time to complete state transition (optional) */
} esp_ble_mesh_light_hsl_target_status_cb_t; } esp_ble_mesh_light_hsl_target_status_cb_t;
/** Parameters of Light HSL Hue Status */ /** Parameters of Light HSL Hue Status */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t present_hue; /*!< Current value of light hsl hue state */ uint16_t present_hue; /*!< Current value of light hsl hue state */
u16_t target_hue; /*!< Target value of light hsl hue state (optional) */ uint16_t target_hue; /*!< Target value of light hsl hue state (optional) */
u8_t remain_time; /*!< Time to complete state transition (C.1) */ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
} esp_ble_mesh_light_hsl_hue_status_cb_t; } esp_ble_mesh_light_hsl_hue_status_cb_t;
/** Parameters of Light HSL Saturation Status */ /** Parameters of Light HSL Saturation Status */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t present_saturation; /*!< Current value of light hsl saturation state */ uint16_t present_saturation; /*!< Current value of light hsl saturation state */
u16_t target_saturation; /*!< Target value of light hsl saturation state (optional) */ uint16_t target_saturation; /*!< Target value of light hsl saturation state (optional) */
u8_t remain_time; /*!< Time to complete state transition (C.1) */ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
} esp_ble_mesh_light_hsl_saturation_status_cb_t; } esp_ble_mesh_light_hsl_saturation_status_cb_t;
/** Parameters of Light HSL Default Status */ /** Parameters of Light HSL Default Status */
typedef struct { typedef struct {
u16_t lightness; /*!< Value of light lightness default state */ uint16_t lightness; /*!< Value of light lightness default state */
u16_t hue; /*!< Value of light hue default state */ uint16_t hue; /*!< Value of light hue default state */
u16_t saturation; /*!< Value of light saturation default state */ uint16_t saturation; /*!< Value of light saturation default state */
} esp_ble_mesh_light_hsl_default_status_cb_t; } esp_ble_mesh_light_hsl_default_status_cb_t;
/** Parameters of Light HSL Range Status */ /** Parameters of Light HSL Range Status */
typedef struct { typedef struct {
u8_t status_code; /*!< Status code for the request message */ uint8_t status_code; /*!< Status code for the request message */
u16_t hue_range_min; /*!< Value of hue range min field of light hsl hue range state */ uint16_t hue_range_min; /*!< Value of hue range min field of light hsl hue range state */
u16_t hue_range_max; /*!< Value of hue range max field of light hsl hue range state */ uint16_t hue_range_max; /*!< Value of hue range max field of light hsl hue range state */
u16_t saturation_range_min; /*!< Value of saturation range min field of light hsl saturation range state */ uint16_t saturation_range_min; /*!< Value of saturation range min field of light hsl saturation range state */
u16_t saturation_range_max; /*!< Value of saturation range max field of light hsl saturation range state */ uint16_t saturation_range_max; /*!< Value of saturation range max field of light hsl saturation range state */
} esp_ble_mesh_light_hsl_range_status_cb_t; } esp_ble_mesh_light_hsl_range_status_cb_t;
/** Parameters of Light xyL Status */ /** Parameters of Light xyL Status */
typedef struct { typedef struct {
bool op_en; /*!< Indicate whether optional parameters included */ bool op_en; /*!< Indicate whether optional parameters included */
u16_t xyl_lightness; /*!< The present value of the Light xyL Lightness state */ uint16_t xyl_lightness; /*!< The present value of the Light xyL Lightness state */
u16_t xyl_x; /*!< The present value of the Light xyL x state */ uint16_t xyl_x; /*!< The present value of the Light xyL x state */
u16_t xyl_y; /*!< The present value of the Light xyL y state */ uint16_t xyl_y; /*!< The present value of the Light xyL y state */
u8_t remain_time; /*!< Time to complete state transition (optional) */ uint8_t remain_time; /*!< Time to complete state transition (optional) */
} esp_ble_mesh_light_xyl_status_cb_t; } esp_ble_mesh_light_xyl_status_cb_t;
/** Parameters of Light xyL Target Status */ /** Parameters of Light xyL Target Status */
typedef struct { typedef struct {
bool op_en; /*!< Indicate whether optional parameters included */ bool op_en; /*!< Indicate whether optional parameters included */
u16_t target_xyl_lightness; /*!< The target value of the Light xyL Lightness state */ uint16_t target_xyl_lightness; /*!< The target value of the Light xyL Lightness state */
u16_t target_xyl_x; /*!< The target value of the Light xyL x state */ uint16_t target_xyl_x; /*!< The target value of the Light xyL x state */
u16_t target_xyl_y; /*!< The target value of the Light xyL y state */ uint16_t target_xyl_y; /*!< The target value of the Light xyL y state */
u8_t remain_time; /*!< Time to complete state transition (optional) */ uint8_t remain_time; /*!< Time to complete state transition (optional) */
} esp_ble_mesh_light_xyl_target_status_cb_t; } esp_ble_mesh_light_xyl_target_status_cb_t;
/** Parameters of Light xyL Default Status */ /** Parameters of Light xyL Default Status */
typedef struct { typedef struct {
u16_t lightness; /*!< The value of the Light Lightness Default state */ uint16_t lightness; /*!< The value of the Light Lightness Default state */
u16_t xyl_x; /*!< The value of the Light xyL x Default state */ uint16_t xyl_x; /*!< The value of the Light xyL x Default state */
u16_t xyl_y; /*!< The value of the Light xyL y Default state */ uint16_t xyl_y; /*!< The value of the Light xyL y Default state */
} esp_ble_mesh_light_xyl_default_status_cb_t; } esp_ble_mesh_light_xyl_default_status_cb_t;
/** Parameters of Light xyL Range Status */ /** Parameters of Light xyL Range Status */
typedef struct { typedef struct {
u8_t status_code; /*!< Status Code for the requesting message */ uint8_t status_code; /*!< Status Code for the requesting message */
u16_t xyl_x_range_min; /*!< The value of the xyL x Range Min field of the Light xyL x Range state */ uint16_t xyl_x_range_min; /*!< The value of the xyL x Range Min field of the Light xyL x Range state */
u16_t xyl_x_range_max; /*!< The value of the xyL x Range Max field of the Light xyL x Range state */ uint16_t xyl_x_range_max; /*!< The value of the xyL x Range Max field of the Light xyL x Range state */
u16_t xyl_y_range_min; /*!< The value of the xyL y Range Min field of the Light xyL y Range state */ uint16_t xyl_y_range_min; /*!< The value of the xyL y Range Min field of the Light xyL y Range state */
u16_t xyl_y_range_max; /*!< The value of the xyL y Range Max field of the Light xyL y Range state */ uint16_t xyl_y_range_max; /*!< The value of the xyL y Range Max field of the Light xyL y Range state */
} esp_ble_mesh_light_xyl_range_status_cb_t; } esp_ble_mesh_light_xyl_range_status_cb_t;
/** Parameter of Light LC Mode Status */ /** Parameter of Light LC Mode Status */
typedef struct { typedef struct {
u8_t mode; /*!< The present value of the Light LC Mode state */ uint8_t mode; /*!< The present value of the Light LC Mode state */
} esp_ble_mesh_light_lc_mode_status_cb_t; } esp_ble_mesh_light_lc_mode_status_cb_t;
/** Parameter of Light LC OM Status */ /** Parameter of Light LC OM Status */
typedef struct { typedef struct {
u8_t mode; /*!< The present value of the Light LC Occupancy Mode state */ uint8_t mode; /*!< The present value of the Light LC Occupancy Mode state */
} esp_ble_mesh_light_lc_om_status_cb_t; } esp_ble_mesh_light_lc_om_status_cb_t;
/** Parameters of Light LC Light OnOff Status */ /** Parameters of Light LC Light OnOff Status */
typedef struct { typedef struct {
bool op_en; /*!< Indicate whether optional parameters included */ bool op_en; /*!< Indicate whether optional parameters included */
u8_t present_light_onoff; /*!< The present value of the Light LC Light OnOff state */ uint8_t present_light_onoff; /*!< The present value of the Light LC Light OnOff state */
u8_t target_light_onoff; /*!< The target value of the Light LC Light OnOff state (Optional) */ uint8_t target_light_onoff; /*!< The target value of the Light LC Light OnOff state (Optional) */
u8_t remain_time; /*!< Time to complete state transition (C.1) */ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
} esp_ble_mesh_light_lc_light_onoff_status_cb_t; } esp_ble_mesh_light_lc_light_onoff_status_cb_t;
/** Parameters of Light LC Property Status */ /** Parameters of Light LC Property Status */
typedef struct { typedef struct {
u16_t property_id; /*!< Property ID identifying a Light LC Property */ uint16_t property_id; /*!< Property ID identifying a Light LC Property */
struct net_buf_simple *property_value; /*!< Raw value for the Light LC Property */ struct net_buf_simple *property_value; /*!< Raw value for the Light LC Property */
} esp_ble_mesh_light_lc_property_status_cb_t; } esp_ble_mesh_light_lc_property_status_cb_t;
@ -571,7 +570,7 @@ esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t
* please refer to esp_ble_mesh_light_message_opcode_t in esp_ble_mesh_defs.h * please refer to esp_ble_mesh_light_message_opcode_t in esp_ble_mesh_defs.h
* *
* @param[in] params: Pointer to BLE Mesh common client parameters. * @param[in] params: Pointer to BLE Mesh common client parameters.
* @param[in] set_state: Pointer of generic set message value. * @param[in] set_state: Pointer of light set message value.
* Shall not be set to NULL. * Shall not be set to NULL.
* *
* @return ESP_OK on success or error code otherwise. * @return ESP_OK on success or error code otherwise.

View file

@ -19,7 +19,6 @@
#ifndef _ESP_BLE_MESH_SENSOR_MODEL_API_H_ #ifndef _ESP_BLE_MESH_SENSOR_MODEL_API_H_
#define _ESP_BLE_MESH_SENSOR_MODEL_API_H_ #define _ESP_BLE_MESH_SENSOR_MODEL_API_H_
#include "sensor_client.h"
#include "esp_ble_mesh_defs.h" #include "esp_ble_mesh_defs.h"
/** @def ESP_BLE_MESH_MODEL_SENSOR_CLI /** @def ESP_BLE_MESH_MODEL_SENSOR_CLI
@ -45,60 +44,60 @@
/** Parameters of Sensor Descriptor Get */ /** Parameters of Sensor Descriptor Get */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t property_id; /*!< Property ID of a sensor (optional) */ uint16_t property_id; /*!< Property ID of a sensor (optional) */
} esp_ble_mesh_sensor_descriptor_get_t; } esp_ble_mesh_sensor_descriptor_get_t;
/** Parameter of Sensor Cadence Get */ /** Parameter of Sensor Cadence Get */
typedef struct { typedef struct {
u16_t property_id; /*!< Property ID of a sensor */ uint16_t property_id; /*!< Property ID of a sensor */
} esp_ble_mesh_sensor_cadence_get_t; } esp_ble_mesh_sensor_cadence_get_t;
/** Parameters of Sensor Cadence Set */ /** Parameters of Sensor Cadence Set */
typedef struct { typedef struct {
u16_t property_id; /*!< Property ID for the sensor */ uint16_t property_id; /*!< Property ID for the sensor */
u8_t fast_cadence_period_divisor : 7, /*!< Divisor for the publish period */ uint8_t fast_cadence_period_divisor : 7, /*!< Divisor for the publish period */
status_trigger_type : 1; /*!< The unit and format of the Status Trigger Delta fields */ status_trigger_type : 1; /*!< The unit and format of the Status Trigger Delta fields */
struct net_buf_simple *status_trigger_delta_down; /*!< Delta down value that triggers a status message */ struct net_buf_simple *status_trigger_delta_down; /*!< Delta down value that triggers a status message */
struct net_buf_simple *status_trigger_delta_up; /*!< Delta up value that triggers a status message */ struct net_buf_simple *status_trigger_delta_up; /*!< Delta up value that triggers a status message */
u8_t status_min_interval; /*!< Minimum interval between two consecutive Status messages */ uint8_t status_min_interval; /*!< Minimum interval between two consecutive Status messages */
struct net_buf_simple *fast_cadence_low; /*!< Low value for the fast cadence range */ struct net_buf_simple *fast_cadence_low; /*!< Low value for the fast cadence range */
struct net_buf_simple *fast_cadence_high; /*!< Fast value for the fast cadence range */ struct net_buf_simple *fast_cadence_high; /*!< Fast value for the fast cadence range */
} esp_ble_mesh_sensor_cadence_set_t; } esp_ble_mesh_sensor_cadence_set_t;
/** Parameter of Sensor Settings Get */ /** Parameter of Sensor Settings Get */
typedef struct { typedef struct {
u16_t sensor_property_id; /*!< Property ID of a sensor */ uint16_t sensor_property_id; /*!< Property ID of a sensor */
} esp_ble_mesh_sensor_settings_get_t; } esp_ble_mesh_sensor_settings_get_t;
/** Parameters of Sensor Setting Get */ /** Parameters of Sensor Setting Get */
typedef struct { typedef struct {
u16_t sensor_property_id; /*!< Property ID of a sensor */ uint16_t sensor_property_id; /*!< Property ID of a sensor */
u16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */ uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
} esp_ble_mesh_sensor_setting_get_t; } esp_ble_mesh_sensor_setting_get_t;
/** Parameters of Sensor Setting Set */ /** Parameters of Sensor Setting Set */
typedef struct { typedef struct {
u16_t sensor_property_id; /*!< Property ID identifying a sensor */ uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
u16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */ uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */ struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */
} esp_ble_mesh_sensor_setting_set_t; } esp_ble_mesh_sensor_setting_set_t;
/** Parameters of Sensor Get */ /** Parameters of Sensor Get */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t property_id; /*!< Property ID for the sensor (optional) */ uint16_t property_id; /*!< Property ID for the sensor (optional) */
} esp_ble_mesh_sensor_get_t; } esp_ble_mesh_sensor_get_t;
/** Parameters of Sensor Column Get */ /** Parameters of Sensor Column Get */
typedef struct { typedef struct {
u16_t property_id; /*!< Property identifying a sensor */ uint16_t property_id; /*!< Property identifying a sensor */
struct net_buf_simple *raw_value_x; /*!< Raw value identifying a column */ struct net_buf_simple *raw_value_x; /*!< Raw value identifying a column */
} esp_ble_mesh_sensor_column_get_t; } esp_ble_mesh_sensor_column_get_t;
/** Parameters of Sensor Series Get */ /** Parameters of Sensor Series Get */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t property_id; /*!< Property identifying a sensor */ uint16_t property_id; /*!< Property identifying a sensor */
struct net_buf_simple *raw_value_x1; /*!< Raw value identifying a starting column (optional) */ struct net_buf_simple *raw_value_x1; /*!< Raw value identifying a starting column (optional) */
struct net_buf_simple *raw_value_x2; /*!< Raw value identifying an ending column (C.1) */ struct net_buf_simple *raw_value_x2; /*!< Raw value identifying an ending column (C.1) */
} esp_ble_mesh_sensor_series_get_t; } esp_ble_mesh_sensor_series_get_t;
@ -135,22 +134,22 @@ typedef struct {
/** Parameters of Sensor Cadence Status */ /** Parameters of Sensor Cadence Status */
typedef struct { typedef struct {
u16_t property_id; /*!< Property for the sensor */ uint16_t property_id; /*!< Property for the sensor */
struct net_buf_simple *sensor_cadence_value; /*!< Value of sensor cadence state */ struct net_buf_simple *sensor_cadence_value; /*!< Value of sensor cadence state */
} esp_ble_mesh_sensor_cadence_status_cb_t; } esp_ble_mesh_sensor_cadence_status_cb_t;
/** Parameters of Sensor Settings Status */ /** Parameters of Sensor Settings Status */
typedef struct { typedef struct {
u16_t sensor_property_id; /*!< Property ID identifying a sensor */ uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
struct net_buf_simple *sensor_setting_property_ids; /*!< A sequence of N sensor setting property IDs (optional) */ struct net_buf_simple *sensor_setting_property_ids; /*!< A sequence of N sensor setting property IDs (optional) */
} esp_ble_mesh_sensor_settings_status_cb_t; } esp_ble_mesh_sensor_settings_status_cb_t;
/** Parameters of Sensor Setting Status */ /** Parameters of Sensor Setting Status */
typedef struct { typedef struct {
bool op_en; /*!< Indicate id optional parameters are included */ bool op_en; /*!< Indicate id optional parameters are included */
u16_t sensor_property_id; /*!< Property ID identifying a sensor */ uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
u16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */ uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
u8_t sensor_setting_access; /*!< Read/Write access rights for the setting (optional) */ uint8_t sensor_setting_access; /*!< Read/Write access rights for the setting (optional) */
struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */ struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */
} esp_ble_mesh_sensor_setting_status_cb_t; } esp_ble_mesh_sensor_setting_status_cb_t;
@ -161,13 +160,13 @@ typedef struct {
/** Parameters of Sensor Column Status */ /** Parameters of Sensor Column Status */
typedef struct { typedef struct {
u16_t property_id; /*!< Property identifying a sensor and the Y axis */ uint16_t property_id; /*!< Property identifying a sensor and the Y axis */
struct net_buf_simple *sensor_column_value; /*!< Left values of sensor column status */ struct net_buf_simple *sensor_column_value; /*!< Left values of sensor column status */
} esp_ble_mesh_sensor_column_status_cb_t; } esp_ble_mesh_sensor_column_status_cb_t;
/** Parameters of Sensor Series Status */ /** Parameters of Sensor Series Status */
typedef struct { typedef struct {
u16_t property_id; /*!< Property identifying a sensor and the Y axis */ uint16_t property_id; /*!< Property identifying a sensor and the Y axis */
struct net_buf_simple *sensor_series_value; /*!< Left values of sensor series status */ struct net_buf_simple *sensor_series_value; /*!< Left values of sensor series status */
} esp_ble_mesh_sensor_series_status_cb_t; } esp_ble_mesh_sensor_series_status_cb_t;

View file

@ -19,7 +19,6 @@
#ifndef _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_ #ifndef _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_
#define _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_ #define _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_
#include "time_scene_client.h"
#include "esp_ble_mesh_defs.h" #include "esp_ble_mesh_defs.h"
/** @def ESP_BLE_MESH_MODEL_TIME_CLI /** @def ESP_BLE_MESH_MODEL_TIME_CLI
@ -76,69 +75,69 @@
/** Parameters of Time Set */ /** Parameters of Time Set */
typedef struct { typedef struct {
u8_t tai_seconds[5]; /*!< The current TAI time in seconds */ uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
u8_t sub_second; /*!< The sub-second time in units of 1/256 second */ uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */
u8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */ uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
u16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */ uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
u16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */ uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
u8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */ uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_time_set_t; } esp_ble_mesh_time_set_t;
/** Parameters of Time Zone Set */ /** Parameters of Time Zone Set */
typedef struct { typedef struct {
u8_t time_zone_offset_new; /*!< Upcoming local time zone offset */ uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
u8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */ uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
} esp_ble_mesh_time_zone_set_t; } esp_ble_mesh_time_zone_set_t;
/** Parameters of TAI-UTC Delta Set */ /** Parameters of TAI-UTC Delta Set */
typedef struct { typedef struct {
u16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */ uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
u16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */ uint16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
u8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */ uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
} esp_ble_mesh_tai_utc_delta_set_t; } esp_ble_mesh_tai_utc_delta_set_t;
/** Parameter of Time Role Set */ /** Parameter of Time Role Set */
typedef struct { typedef struct {
u8_t time_role; /*!< The Time Role for the element */ uint8_t time_role; /*!< The Time Role for the element */
} esp_ble_mesh_time_role_set_t; } esp_ble_mesh_time_role_set_t;
/** Parameter of Scene Store */ /** Parameter of Scene Store */
typedef struct { typedef struct {
u16_t scene_number; /*!< The number of scenes to be stored */ uint16_t scene_number; /*!< The number of scenes to be stored */
} esp_ble_mesh_scene_store_t; } esp_ble_mesh_scene_store_t;
/** Parameters of Scene Recall */ /** Parameters of Scene Recall */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u16_t scene_number; /*!< The number of scenes to be recalled */ uint16_t scene_number; /*!< The number of scenes to be recalled */
u8_t tid; /*!< Transaction ID */ uint8_t tid; /*!< Transaction ID */
u8_t trans_time; /*!< Time to complete state transition (optional) */ uint8_t trans_time; /*!< Time to complete state transition (optional) */
u8_t delay; /*!< Indicate message execution delay (C.1) */ uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_scene_recall_t; } esp_ble_mesh_scene_recall_t;
/** Parameter of Scene Delete */ /** Parameter of Scene Delete */
typedef struct { typedef struct {
u16_t scene_number; /*!< The number of scenes to be deleted */ uint16_t scene_number; /*!< The number of scenes to be deleted */
} esp_ble_mesh_scene_delete_t; } esp_ble_mesh_scene_delete_t;
/** Parameter of Scheduler Action Get */ /** Parameter of Scheduler Action Get */
typedef struct { typedef struct {
u8_t index; /*!< Index of the Schedule Register entry to get */ uint8_t index; /*!< Index of the Schedule Register entry to get */
} esp_ble_mesh_scheduler_act_get_t; } esp_ble_mesh_scheduler_act_get_t;
/** Parameters of Scheduler Action Set */ /** Parameters of Scheduler Action Set */
typedef struct { typedef struct {
u64_t index : 4; /*!< Index of the Schedule Register entry to set */ uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
u64_t year : 7; /*!< Scheduled year for the action */ uint64_t year : 7; /*!< Scheduled year for the action */
u64_t month : 12; /*!< Scheduled month for the action */ uint64_t month : 12; /*!< Scheduled month for the action */
u64_t day : 5; /*!< Scheduled day of the month for the action */ uint64_t day : 5; /*!< Scheduled day of the month for the action */
u64_t hour : 5; /*!< Scheduled hour for the action */ uint64_t hour : 5; /*!< Scheduled hour for the action */
u64_t minute : 6; /*!< Scheduled minute for the action */ uint64_t minute : 6; /*!< Scheduled minute for the action */
u64_t second : 6; /*!< Scheduled second for the action */ uint64_t second : 6; /*!< Scheduled second for the action */
u64_t day_of_week : 7; /*!< Schedule days of the week for the action */ uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
u64_t action : 4; /*!< Action to be performed at the scheduled time */ uint64_t action : 4; /*!< Action to be performed at the scheduled time */
u64_t trans_time : 8; /*!< Transition time for this action */ uint64_t trans_time : 8; /*!< Transition time for this action */
u16_t scene_number; /*!< Transition time for this action */ uint16_t scene_number; /*!< Transition time for this action */
} esp_ble_mesh_scheduler_act_set_t; } esp_ble_mesh_scheduler_act_set_t;
/** /**
@ -168,69 +167,69 @@ typedef union {
/** Parameters of Time Status */ /** Parameters of Time Status */
typedef struct { typedef struct {
u8_t tai_seconds[5]; /*!< The current TAI time in seconds */ uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
u8_t sub_second; /*!< The sub-second time in units of 1/256 second */ uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */
u8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */ uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
u16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */ uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
u16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */ uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
u8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */ uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_time_status_cb_t; } esp_ble_mesh_time_status_cb_t;
/** Parameters of Time Zone Status */ /** Parameters of Time Zone Status */
typedef struct { typedef struct {
u8_t time_zone_offset_curr; /*!< Current local time zone offset */ uint8_t time_zone_offset_curr; /*!< Current local time zone offset */
u8_t time_zone_offset_new; /*!< Upcoming local time zone offset */ uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
u8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */ uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
} esp_ble_mesh_time_zone_status_cb_t; } esp_ble_mesh_time_zone_status_cb_t;
/** Parameters of TAI-UTC Delta Status */ /** Parameters of TAI-UTC Delta Status */
typedef struct { typedef struct {
u16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */ uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
u16_t padding_1 : 1; /*!< Always 0b0. Other values are Prohibited. */ uint16_t padding_1 : 1; /*!< Always 0b0. Other values are Prohibited. */
u16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */ uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
u16_t padding_2 : 1; /*!< Always 0b0. Other values are Prohibited. */ uint16_t padding_2 : 1; /*!< Always 0b0. Other values are Prohibited. */
u8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */ uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
} esp_ble_mesh_tai_utc_delta_status_cb_t; } esp_ble_mesh_tai_utc_delta_status_cb_t;
/** Parameter of Time Role Status */ /** Parameter of Time Role Status */
typedef struct { typedef struct {
u8_t time_role; /*!< The Time Role for the element */ uint8_t time_role; /*!< The Time Role for the element */
} esp_ble_mesh_time_role_status_cb_t; } esp_ble_mesh_time_role_status_cb_t;
/** Parameters of Scene Status */ /** Parameters of Scene Status */
typedef struct { typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */ bool op_en; /*!< Indicate if optional parameters are included */
u8_t status_code; /*!< Status code of the last operation */ uint8_t status_code; /*!< Status code of the last operation */
u16_t current_scene; /*!< Scene Number of the current scene */ uint16_t current_scene; /*!< Scene Number of the current scene */
u16_t target_scene; /*!< Scene Number of the target scene (optional) */ uint16_t target_scene; /*!< Scene Number of the target scene (optional) */
u8_t remain_time; /*!< Time to complete state transition (C.1) */ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
} esp_ble_mesh_scene_status_cb_t; } esp_ble_mesh_scene_status_cb_t;
/** Parameters of Scene Register Status */ /** Parameters of Scene Register Status */
typedef struct { typedef struct {
u8_t status_code; /*!< Status code for the previous operation */ uint8_t status_code; /*!< Status code for the previous operation */
u16_t current_scene; /*!< Scene Number of the current scene */ uint16_t current_scene; /*!< Scene Number of the current scene */
struct net_buf_simple *scenes; /*!< A list of scenes stored within an element */ struct net_buf_simple *scenes; /*!< A list of scenes stored within an element */
} esp_ble_mesh_scene_register_status_cb_t; } esp_ble_mesh_scene_register_status_cb_t;
/** Parameter of Scheduler Status */ /** Parameter of Scheduler Status */
typedef struct { typedef struct {
u16_t schedules; /*!< Bit field indicating defined Actions in the Schedule Register */ uint16_t schedules; /*!< Bit field indicating defined Actions in the Schedule Register */
} esp_ble_mesh_scheduler_status_cb_t; } esp_ble_mesh_scheduler_status_cb_t;
/** Parameters of Scheduler Action Status */ /** Parameters of Scheduler Action Status */
typedef struct { typedef struct {
u64_t index : 4; /*!< Enumerates (selects) a Schedule Register entry */ uint64_t index : 4; /*!< Enumerates (selects) a Schedule Register entry */
u64_t year : 7; /*!< Scheduled year for the action */ uint64_t year : 7; /*!< Scheduled year for the action */
u64_t month : 12; /*!< Scheduled month for the action */ uint64_t month : 12; /*!< Scheduled month for the action */
u64_t day : 5; /*!< Scheduled day of the month for the action */ uint64_t day : 5; /*!< Scheduled day of the month for the action */
u64_t hour : 5; /*!< Scheduled hour for the action */ uint64_t hour : 5; /*!< Scheduled hour for the action */
u64_t minute : 6; /*!< Scheduled minute for the action */ uint64_t minute : 6; /*!< Scheduled minute for the action */
u64_t second : 6; /*!< Scheduled second for the action */ uint64_t second : 6; /*!< Scheduled second for the action */
u64_t day_of_week : 7; /*!< Schedule days of the week for the action */ uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
u64_t action : 4; /*!< Action to be performed at the scheduled time */ uint64_t action : 4; /*!< Action to be performed at the scheduled time */
u64_t trans_time : 8; /*!< Transition time for this action */ uint64_t trans_time : 8; /*!< Transition time for this action */
u16_t scene_number; /*!< Transition time for this action */ uint16_t scene_number; /*!< Transition time for this action */
} esp_ble_mesh_scheduler_act_status_cb_t; } esp_ble_mesh_scheduler_act_status_cb_t;
/** /**

View file

@ -27,28 +27,22 @@
extern s32_t config_msg_timeout; extern s32_t config_msg_timeout;
static inline void btc_ble_mesh_cfg_client_cb_to_app(esp_ble_mesh_cfg_client_cb_event_t event, /* Configuration Client Model related functions */
static inline void btc_ble_mesh_config_client_cb_to_app(esp_ble_mesh_cfg_client_cb_event_t event,
esp_ble_mesh_cfg_client_cb_param_t *param) esp_ble_mesh_cfg_client_cb_param_t *param)
{ {
esp_ble_mesh_cfg_client_cb_t btc_mesh_cb = (esp_ble_mesh_cfg_client_cb_t)btc_profile_cb_get(BTC_PID_CFG_CLIENT); esp_ble_mesh_cfg_client_cb_t btc_ble_mesh_cb =
if (btc_mesh_cb) { (esp_ble_mesh_cfg_client_cb_t)btc_profile_cb_get(BTC_PID_CONFIG_CLIENT);
btc_mesh_cb(event, param); if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
} }
} }
static inline void btc_ble_mesh_cfg_server_cb_to_app(esp_ble_mesh_cfg_server_cb_event_t event, void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
esp_ble_mesh_cfg_server_cb_param_t *param)
{ {
esp_ble_mesh_cfg_server_cb_t btc_mesh_cb = (esp_ble_mesh_cfg_server_cb_t)btc_profile_cb_get(BTC_PID_CFG_SERVER); btc_ble_mesh_config_client_args_t *dst = (btc_ble_mesh_config_client_args_t *)p_dest;
if (btc_mesh_cb) { btc_ble_mesh_config_client_args_t *src = (btc_ble_mesh_config_client_args_t *)p_src;
btc_mesh_cb(event, param);
}
}
void btc_ble_mesh_cfg_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{
btc_ble_mesh_cfg_client_args_t *dst = (btc_ble_mesh_cfg_client_args_t *)p_dest;
btc_ble_mesh_cfg_client_args_t *src = (btc_ble_mesh_cfg_client_args_t *)p_src;
if (!msg || !dst || !src) { if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
@ -88,11 +82,43 @@ void btc_ble_mesh_cfg_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p
} }
} }
static void btc_ble_mesh_cfg_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src) static void btc_ble_mesh_config_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_config_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_config_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE:
if (arg->cfg_client_get_state.params) {
osi_free(arg->cfg_client_get_state.params);
}
if (arg->cfg_client_get_state.get_state) {
osi_free(arg->cfg_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE:
if (arg->cfg_client_set_state.params) {
osi_free(arg->cfg_client_set_state.params);
}
if (arg->cfg_client_set_state.set_state) {
osi_free(arg->cfg_client_set_state.set_state);
}
break;
default:
break;
}
}
static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{ {
esp_ble_mesh_cfg_client_cb_param_t *p_dest_data = (esp_ble_mesh_cfg_client_cb_param_t *)p_dest; esp_ble_mesh_cfg_client_cb_param_t *p_dest_data = (esp_ble_mesh_cfg_client_cb_param_t *)p_dest;
esp_ble_mesh_cfg_client_cb_param_t *p_src_data = (esp_ble_mesh_cfg_client_cb_param_t *)p_src; esp_ble_mesh_cfg_client_cb_param_t *p_src_data = (esp_ble_mesh_cfg_client_cb_param_t *)p_src;
u32_t opcode;
u16_t length; u16_t length;
if (!msg || !p_src_data || !p_dest_data) { if (!msg || !p_src_data || !p_dest_data) {
@ -105,8 +131,7 @@ static void btc_ble_mesh_cfg_client_copy_req_data(btc_msg_t *msg, void *p_dest,
case ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT: case ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_CFG_CLIENT_PUBLISH_EVT: case ESP_BLE_MESH_CFG_CLIENT_PUBLISH_EVT:
if (p_src_data->params) { if (p_src_data->params) {
opcode = p_src_data->params->opcode; switch (p_src_data->params->opcode) {
switch (opcode) {
case OP_DEV_COMP_DATA_GET: case OP_DEV_COMP_DATA_GET:
case OP_DEV_COMP_DATA_STATUS: case OP_DEV_COMP_DATA_STATUS:
if (p_src_data->status_cb.comp_data_status.composition_data) { if (p_src_data->status_cb.comp_data_status.composition_data) {
@ -200,10 +225,9 @@ static void btc_ble_mesh_cfg_client_copy_req_data(btc_msg_t *msg, void *p_dest,
} }
} }
static void btc_ble_mesh_cfg_client_free_req_data(btc_msg_t *msg) static void btc_ble_mesh_config_client_free_req_data(btc_msg_t *msg)
{ {
esp_ble_mesh_cfg_client_cb_param_t *arg = NULL; esp_ble_mesh_cfg_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) { if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
@ -217,8 +241,7 @@ static void btc_ble_mesh_cfg_client_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT: case ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_CFG_CLIENT_PUBLISH_EVT: case ESP_BLE_MESH_CFG_CLIENT_PUBLISH_EVT:
if (arg->params) { if (arg->params) {
opcode = arg->params->opcode; switch (arg->params->opcode) {
switch (opcode) {
case OP_DEV_COMP_DATA_GET: case OP_DEV_COMP_DATA_GET:
case OP_DEV_COMP_DATA_STATUS: case OP_DEV_COMP_DATA_STATUS:
bt_mesh_free_buf(arg->status_cb.comp_data_status.composition_data); bt_mesh_free_buf(arg->status_cb.comp_data_status.composition_data);
@ -257,56 +280,21 @@ static void btc_ble_mesh_cfg_client_free_req_data(btc_msg_t *msg)
} }
} }
void btc_ble_mesh_cfg_client_arg_deep_free(btc_msg_t *msg) static void btc_ble_mesh_config_client_callback(esp_ble_mesh_cfg_client_cb_param_t *cb_params, uint8_t act)
{
btc_ble_mesh_cfg_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_cfg_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE:
if (arg->cfg_client_get_state.params) {
osi_free(arg->cfg_client_get_state.params);
}
if (arg->cfg_client_get_state.get_state) {
osi_free(arg->cfg_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE:
if (arg->cfg_client_set_state.params) {
osi_free(arg->cfg_client_set_state.params);
}
if (arg->cfg_client_set_state.set_state) {
osi_free(arg->cfg_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
static void btc_mesh_cfg_client_callback(esp_ble_mesh_cfg_client_cb_param_t *cb_params, uint8_t act)
{ {
btc_msg_t msg = {0}; btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__); LOG_DEBUG("%s", __func__);
msg.sig = BTC_SIG_API_CB; msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_CFG_CLIENT; msg.pid = BTC_PID_CONFIG_CLIENT;
msg.act = act; msg.act = act;
btc_transfer_context(&msg, cb_params, btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_cfg_client_cb_param_t), btc_ble_mesh_cfg_client_copy_req_data); sizeof(esp_ble_mesh_cfg_client_cb_param_t), btc_ble_mesh_config_client_copy_req_data);
} }
void bt_mesh_callback_config_status_to_btc(u32_t opcode, u8_t evt_type, void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len) const u8_t *val, size_t len)
@ -322,16 +310,16 @@ void bt_mesh_callback_config_status_to_btc(u32_t opcode, u8_t evt_type,
} }
switch (evt_type) { switch (evt_type) {
case 0x00: case BTC_BLE_MESH_EVT_CONFIG_CLIENT_GET_STATE:
act = ESP_BLE_MESH_CFG_CLIENT_GET_STATE_EVT; act = ESP_BLE_MESH_CFG_CLIENT_GET_STATE_EVT;
break; break;
case 0x01: case BTC_BLE_MESH_EVT_CONFIG_CLIENT_SET_STATE:
act = ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT; act = ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT;
break; break;
case 0x02: case BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH:
act = ESP_BLE_MESH_CFG_CLIENT_PUBLISH_EVT; act = ESP_BLE_MESH_CFG_CLIENT_PUBLISH_EVT;
break; break;
case 0x03: case BTC_BLE_MESH_EVT_CONFIG_CLIENT_TIMEOUT:
act = ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT; act = ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT;
break; break;
default: default:
@ -356,101 +344,32 @@ void bt_mesh_callback_config_status_to_btc(u32_t opcode, u8_t evt_type,
memcpy(&cb_params.status_cb, val, length); memcpy(&cb_params.status_cb, val, length);
} }
btc_mesh_cfg_client_callback(&cb_params, act); btc_ble_mesh_config_client_callback(&cb_params, act);
return;
} }
void btc_ble_mesh_config_client_publish_callback(u32_t opcode,
void btc_mesh_cfg_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{ {
if (!model || !ctx || !buf) { if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
return; return;
} }
bt_mesh_callback_config_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len); bt_mesh_config_client_cb_evt_to_btc(opcode,
} BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
void btc_mesh_cfg_client_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_cfg_client_cb_param_t cfg_client_cb = {0};
btc_ble_mesh_cfg_client_args_t *arg = NULL;
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return; return;
} }
arg = (btc_ble_mesh_cfg_client_args_t *)(msg->arg); static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_get_state_t *get,
switch (msg->act) { esp_ble_mesh_cfg_client_cb_param_t *cb)
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE: {
cfg_client_cb.params = arg->cfg_client_get_state.params;
role_param.model = (struct bt_mesh_model *)cfg_client_cb.params->model;
role_param.role = cfg_client_cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params,
arg->cfg_client_get_state.get_state,
&cfg_client_cb);
if (cfg_client_cb.error_code) {
btc_mesh_cfg_client_callback(&cfg_client_cb, ESP_BLE_MESH_CFG_CLIENT_GET_STATE_EVT);
}
break;
}
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE: {
cfg_client_cb.params = arg->cfg_client_set_state.params;
role_param.model = (struct bt_mesh_model *)cfg_client_cb.params->model;
role_param.role = cfg_client_cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params,
arg->cfg_client_set_state.set_state,
&cfg_client_cb);
if (cfg_client_cb.error_code) {
btc_mesh_cfg_client_callback(&cfg_client_cb, ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT);
}
break;
}
default:
break;
}
btc_ble_mesh_cfg_client_arg_deep_free(msg);
}
void btc_mesh_cfg_client_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_cfg_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_cfg_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_CFG_CLIENT_EVT_MAX) {
btc_ble_mesh_cfg_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_cfg_client_free_req_data(msg);
}
int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_get_state_t *get_state,
esp_ble_mesh_cfg_client_cb_param_t *cfg_client_cb)
{ {
struct bt_mesh_msg_ctx ctx = {0}; struct bt_mesh_msg_ctx ctx = {0};
if (!params || !cfg_client_cb) { if (!params || !cb) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
return -EINVAL; return -EINVAL;
} }
@ -465,66 +384,68 @@ int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *par
switch (params->opcode) { switch (params->opcode) {
case ESP_BLE_MESH_MODEL_OP_BEACON_GET: case ESP_BLE_MESH_MODEL_OP_BEACON_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_beacon_get(&ctx)); return (cb->error_code = bt_mesh_cfg_beacon_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET: case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_ttl_get(&ctx)); return (cb->error_code = bt_mesh_cfg_ttl_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_FRIEND_GET: case ESP_BLE_MESH_MODEL_OP_FRIEND_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_friend_get(&ctx)); return (cb->error_code = bt_mesh_cfg_friend_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET: case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_gatt_proxy_get(&ctx)); return (cb->error_code = bt_mesh_cfg_gatt_proxy_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_RELAY_GET: case ESP_BLE_MESH_MODEL_OP_RELAY_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_relay_get(&ctx)); return (cb->error_code = bt_mesh_cfg_relay_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET: case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_pub_get(&ctx, get_state->model_pub_get.element_addr, get_state->model_pub_get.model_id, bt_mesh_cfg_mod_pub_get(&ctx, get->model_pub_get.element_addr,
get_state->model_pub_get.company_id)); get->model_pub_get.model_id, get->model_pub_get.company_id));
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET: case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_hb_pub_get(&ctx)); return (cb->error_code = bt_mesh_cfg_hb_pub_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET: case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_hb_sub_get(&ctx)); return (cb->error_code = bt_mesh_cfg_hb_sub_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET: case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_comp_data_get(&ctx, get_state->comp_data_get.page)); return (cb->error_code = bt_mesh_cfg_comp_data_get(&ctx, get->comp_data_get.page));
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET: case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_sub_get(&ctx, get_state->sig_model_sub_get.element_addr, get_state->sig_model_sub_get.model_id)); bt_mesh_cfg_mod_sub_get(&ctx, get->sig_model_sub_get.element_addr,
get->sig_model_sub_get.model_id));
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET: case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_sub_get_vnd(&ctx, get_state->vnd_model_sub_get.element_addr, bt_mesh_cfg_mod_sub_get_vnd(&ctx, get->vnd_model_sub_get.element_addr,
get_state->vnd_model_sub_get.model_id, get_state->vnd_model_sub_get.company_id)); get->vnd_model_sub_get.model_id, get->vnd_model_sub_get.company_id));
case ESP_BLE_MESH_MODEL_OP_NET_KEY_GET: case ESP_BLE_MESH_MODEL_OP_NET_KEY_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_net_key_get(&ctx)); return (cb->error_code = bt_mesh_cfg_net_key_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET: case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_app_key_get(&ctx, get_state->app_key_get.net_idx)); return (cb->error_code = bt_mesh_cfg_app_key_get(&ctx, get->app_key_get.net_idx));
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET: case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_node_identity_get(&ctx, get_state->node_identity_get.net_idx)); return (cb->error_code = bt_mesh_cfg_node_identity_get(&ctx, get->node_identity_get.net_idx));
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET: case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_app_get(&ctx, get_state->sig_model_app_get.element_addr, get_state->sig_model_app_get.model_id)); bt_mesh_cfg_mod_app_get(&ctx, get->sig_model_app_get.element_addr,
get->sig_model_app_get.model_id));
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET: case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_app_get_vnd(&ctx, get_state->vnd_model_app_get.element_addr, bt_mesh_cfg_mod_app_get_vnd(&ctx, get->vnd_model_app_get.element_addr,
get_state->vnd_model_app_get.model_id, get_state->vnd_model_app_get.company_id)); get->vnd_model_app_get.model_id, get->vnd_model_app_get.company_id));
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET: case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_kr_phase_get(&ctx, get_state->kr_phase_get.net_idx)); return (cb->error_code = bt_mesh_cfg_kr_phase_get(&ctx, get->kr_phase_get.net_idx));
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET: case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_lpn_timeout_get(&ctx, get_state->lpn_pollto_get.lpn_addr)); return (cb->error_code = bt_mesh_cfg_lpn_timeout_get(&ctx, get->lpn_pollto_get.lpn_addr));
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET: case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_net_transmit_get(&ctx)); return (cb->error_code = bt_mesh_cfg_net_transmit_get(&ctx));
default: default:
BT_WARN("%s, Invalid opcode 0x%x", __func__, params->opcode); LOG_ERROR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cfg_client_cb->error_code = -EINVAL); return (cb->error_code = -EINVAL);
} }
return 0; return 0;
} }
int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params, static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_set_state_t *set_state, esp_ble_mesh_cfg_client_set_state_t *set,
esp_ble_mesh_cfg_client_cb_param_t *cfg_client_cb) esp_ble_mesh_cfg_client_cb_param_t *cb)
{ {
struct bt_mesh_msg_ctx ctx = {0}; struct bt_mesh_msg_ctx ctx = {0};
if (!params || !set_state || !cfg_client_cb) { if (!params || !set || !cb) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
return -EINVAL; return -EINVAL;
} }
@ -539,136 +460,240 @@ int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *par
switch (params->opcode) { switch (params->opcode) {
case ESP_BLE_MESH_MODEL_OP_BEACON_SET: case ESP_BLE_MESH_MODEL_OP_BEACON_SET:
return (cfg_client_cb->error_code = bt_mesh_cfg_beacon_set(&ctx, set_state->beacon_set.beacon)); return (cb->error_code = bt_mesh_cfg_beacon_set(&ctx, set->beacon_set.beacon));
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET: case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET:
return (cfg_client_cb->error_code = bt_mesh_cfg_ttl_set(&ctx, set_state->default_ttl_set.ttl)); return (cb->error_code = bt_mesh_cfg_ttl_set(&ctx, set->default_ttl_set.ttl));
case ESP_BLE_MESH_MODEL_OP_FRIEND_SET: case ESP_BLE_MESH_MODEL_OP_FRIEND_SET:
return (cfg_client_cb->error_code = bt_mesh_cfg_friend_set(&ctx, set_state->friend_set.friend_state)); return (cb->error_code = bt_mesh_cfg_friend_set(&ctx, set->friend_set.friend_state));
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET: case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET:
return (cfg_client_cb->error_code = bt_mesh_cfg_gatt_proxy_set(&ctx, set_state->gatt_proxy_set.gatt_proxy)); return (cb->error_code = bt_mesh_cfg_gatt_proxy_set(&ctx, set->gatt_proxy_set.gatt_proxy));
case ESP_BLE_MESH_MODEL_OP_RELAY_SET: case ESP_BLE_MESH_MODEL_OP_RELAY_SET:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_relay_set(&ctx, set_state->relay_set.relay, set_state->relay_set.relay_retransmit)); bt_mesh_cfg_relay_set(&ctx, set->relay_set.relay, set->relay_set.relay_retransmit));
case ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD: case ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_net_key_add(&ctx, set_state->net_key_add.net_idx, &set_state->net_key_add.net_key[0])); bt_mesh_cfg_net_key_add(&ctx, set->net_key_add.net_idx,
&set->net_key_add.net_key[0]));
case ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD: case ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_app_key_add(&ctx, set_state->app_key_add.net_idx, bt_mesh_cfg_app_key_add(&ctx, set->app_key_add.net_idx,
set_state->app_key_add.app_idx, &set_state->app_key_add.app_key[0])); set->app_key_add.app_idx, &set->app_key_add.app_key[0]));
case ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND: case ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_app_bind(&ctx, set_state->model_app_bind.element_addr, set_state->model_app_bind.model_app_idx, bt_mesh_cfg_mod_app_bind(&ctx, set->model_app_bind.element_addr,
set_state->model_app_bind.model_id, set_state->model_app_bind.company_id)); set->model_app_bind.model_app_idx, set->model_app_bind.model_id,
set->model_app_bind.company_id));
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET: { case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET: {
struct bt_mesh_cfg_mod_pub model_pub = { struct bt_mesh_cfg_mod_pub model_pub = {
.addr = set_state->model_pub_set.publish_addr, .addr = set->model_pub_set.publish_addr,
.app_idx = set_state->model_pub_set.publish_app_idx, .app_idx = set->model_pub_set.publish_app_idx,
.cred_flag = set_state->model_pub_set.cred_flag, .cred_flag = set->model_pub_set.cred_flag,
.ttl = set_state->model_pub_set.publish_ttl, .ttl = set->model_pub_set.publish_ttl,
.period = set_state->model_pub_set.publish_period, .period = set->model_pub_set.publish_period,
.transmit = set_state->model_pub_set.publish_retransmit, .transmit = set->model_pub_set.publish_retransmit,
}; };
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_pub_set(&ctx, set_state->model_pub_set.element_addr, set_state->model_pub_set.model_id, bt_mesh_cfg_mod_pub_set(&ctx, set->model_pub_set.element_addr,
set_state->model_pub_set.company_id, &model_pub)); set->model_pub_set.model_id, set->model_pub_set.company_id, &model_pub));
} }
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD: case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_sub_add(&ctx, set_state->model_sub_add.element_addr, set_state->model_sub_add.sub_addr, bt_mesh_cfg_mod_sub_add(&ctx, set->model_sub_add.element_addr,
set_state->model_sub_add.model_id, set_state->model_sub_add.company_id)); set->model_sub_add.sub_addr, set->model_sub_add.model_id,
set->model_sub_add.company_id));
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE: case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_sub_del(&ctx, set_state->model_sub_delete.element_addr, set_state->model_sub_delete.sub_addr, bt_mesh_cfg_mod_sub_del(&ctx, set->model_sub_delete.element_addr,
set_state->model_sub_delete.model_id, set_state->model_sub_delete.company_id)); set->model_sub_delete.sub_addr, set->model_sub_delete.model_id,
set->model_sub_delete.company_id));
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE: case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_sub_overwrite(&ctx, set_state->model_sub_overwrite.element_addr, set_state->model_sub_overwrite.sub_addr, bt_mesh_cfg_mod_sub_overwrite(&ctx, set->model_sub_overwrite.element_addr,
set_state->model_sub_overwrite.model_id, set_state->model_sub_overwrite.company_id)); set->model_sub_overwrite.sub_addr, set->model_sub_overwrite.model_id,
set->model_sub_overwrite.company_id));
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD: case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_sub_va_add(&ctx, set_state->model_sub_va_add.element_addr, &set_state->model_sub_va_add.label_uuid[0], bt_mesh_cfg_mod_sub_va_add(&ctx, set->model_sub_va_add.element_addr,
set_state->model_sub_va_add.model_id, set_state->model_sub_va_add.company_id)); &set->model_sub_va_add.label_uuid[0], set->model_sub_va_add.model_id,
set->model_sub_va_add.company_id));
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE: case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_sub_va_overwrite(&ctx, set_state->model_sub_va_overwrite.element_addr, &set_state->model_sub_va_overwrite.label_uuid[0], bt_mesh_cfg_mod_sub_va_overwrite(&ctx, set->model_sub_va_overwrite.element_addr,
set_state->model_sub_va_overwrite.model_id, set_state->model_sub_va_overwrite.company_id)); &set->model_sub_va_overwrite.label_uuid[0], set->model_sub_va_overwrite.model_id,
set->model_sub_va_overwrite.company_id));
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE: case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_sub_va_del(&ctx, set_state->model_sub_va_delete.element_addr, &set_state->model_sub_va_delete.label_uuid[0], bt_mesh_cfg_mod_sub_va_del(&ctx, set->model_sub_va_delete.element_addr,
set_state->model_sub_va_delete.model_id, set_state->model_sub_va_delete.company_id)); &set->model_sub_va_delete.label_uuid[0], set->model_sub_va_delete.model_id,
set->model_sub_va_delete.company_id));
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET: case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_hb_sub_set(&ctx, (struct bt_mesh_cfg_hb_sub *)&set_state->heartbeat_sub_set)); bt_mesh_cfg_hb_sub_set(&ctx,
(struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set));
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET: case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_hb_pub_set(&ctx, (const struct bt_mesh_cfg_hb_pub *)&set_state->heartbeat_pub_set)); bt_mesh_cfg_hb_pub_set(&ctx,
(const struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set));
case ESP_BLE_MESH_MODEL_OP_NODE_RESET: case ESP_BLE_MESH_MODEL_OP_NODE_RESET:
return (cfg_client_cb->error_code = bt_mesh_cfg_node_reset(&ctx)); return (cb->error_code = bt_mesh_cfg_node_reset(&ctx));
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET: { case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET: {
struct bt_mesh_cfg_mod_pub model_pub = { struct bt_mesh_cfg_mod_pub model_pub = {
.app_idx = set_state->model_pub_va_set.publish_app_idx, .app_idx = set->model_pub_va_set.publish_app_idx,
.cred_flag = set_state->model_pub_va_set.cred_flag, .cred_flag = set->model_pub_va_set.cred_flag,
.ttl = set_state->model_pub_va_set.publish_ttl, .ttl = set->model_pub_va_set.publish_ttl,
.period = set_state->model_pub_va_set.publish_period, .period = set->model_pub_va_set.publish_period,
.transmit = set_state->model_pub_va_set.publish_retransmit, .transmit = set->model_pub_va_set.publish_retransmit,
}; };
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_pub_va_set(&ctx, set_state->model_pub_va_set.element_addr, set_state->model_pub_va_set.model_id, bt_mesh_cfg_mod_pub_va_set(&ctx, set->model_pub_va_set.element_addr,
set_state->model_pub_va_set.company_id, set_state->model_pub_va_set.label_uuid, &model_pub)); set->model_pub_va_set.model_id, set->model_pub_va_set.company_id,
set->model_pub_va_set.label_uuid, &model_pub));
} }
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL: case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_sub_del_all(&ctx, set_state->model_sub_delete_all.element_addr, bt_mesh_cfg_mod_sub_del_all(&ctx, set->model_sub_delete_all.element_addr,
set_state->model_sub_delete_all.model_id, set_state->model_sub_delete_all.company_id)); set->model_sub_delete_all.model_id, set->model_sub_delete_all.company_id));
case ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE: case ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_net_key_update(&ctx, set_state->net_key_update.net_idx, set_state->net_key_update.net_key)); bt_mesh_cfg_net_key_update(&ctx, set->net_key_update.net_idx,
set->net_key_update.net_key));
case ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE: case ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_net_key_delete(&ctx, set_state->net_key_delete.net_idx)); bt_mesh_cfg_net_key_delete(&ctx, set->net_key_delete.net_idx));
case ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE: case ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_app_key_update(&ctx, set_state->app_key_update.net_idx, set_state->app_key_update.app_idx, bt_mesh_cfg_app_key_update(&ctx, set->app_key_update.net_idx,
set_state->app_key_update.app_key)); set->app_key_update.app_idx, set->app_key_update.app_key));
case ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE: case ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_app_key_delete(&ctx, set_state->app_key_delete.net_idx, set_state->app_key_delete.app_idx)); bt_mesh_cfg_app_key_delete(&ctx, set->app_key_delete.net_idx,
set->app_key_delete.app_idx));
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET: case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_node_identity_set(&ctx, set_state->node_identity_set.net_idx, set_state->node_identity_set.identity)); bt_mesh_cfg_node_identity_set(&ctx, set->node_identity_set.net_idx,
set->node_identity_set.identity));
case ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND: case ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_mod_app_unbind(&ctx, set_state->model_app_unbind.element_addr, set_state->model_app_unbind.model_app_idx, bt_mesh_cfg_mod_app_unbind(&ctx, set->model_app_unbind.element_addr,
set_state->model_app_unbind.model_id, set_state->model_app_unbind.company_id)); set->model_app_unbind.model_app_idx, set->model_app_unbind.model_id,
set->model_app_unbind.company_id));
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET: case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_kr_phase_set(&ctx, set_state->kr_phase_set.net_idx, set_state->kr_phase_set.transition)); bt_mesh_cfg_kr_phase_set(&ctx, set->kr_phase_set.net_idx,
set->kr_phase_set.transition));
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET: case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET:
return (cfg_client_cb->error_code = return (cb->error_code =
bt_mesh_cfg_net_transmit_set(&ctx, set_state->net_transmit_set.net_transmit)); bt_mesh_cfg_net_transmit_set(&ctx, set->net_transmit_set.net_transmit));
default: default:
BT_WARN("%s, Invalid opcode 0x%x", __func__, params->opcode); LOG_ERROR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cfg_client_cb->error_code = -EINVAL); return (cb->error_code = -EINVAL);
} }
return 0; return 0;
} }
static void btc_mesh_cfg_server_callback(esp_ble_mesh_cfg_server_cb_param_t *cb_params, uint8_t act) void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
{
btc_ble_mesh_config_client_args_t *arg = NULL;
esp_ble_mesh_cfg_client_cb_param_t cb = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_config_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE: {
cb.params = arg->cfg_client_get_state.params;
role_param.model = (struct bt_mesh_model *)cb.params->model;
role_param.role = cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params,
arg->cfg_client_get_state.get_state,
&cb);
if (cb.error_code) {
btc_ble_mesh_config_client_callback(&cb, ESP_BLE_MESH_CFG_CLIENT_GET_STATE_EVT);
}
break;
}
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE: {
cb.params = arg->cfg_client_set_state.params;
role_param.model = (struct bt_mesh_model *)cb.params->model;
role_param.role = cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params,
arg->cfg_client_set_state.set_state,
&cb);
if (cb.error_code) {
btc_ble_mesh_config_client_callback(&cb, ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT);
}
break;
}
default:
break;
}
btc_ble_mesh_config_client_arg_deep_free(msg);
return;
}
void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_cfg_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_cfg_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_CFG_CLIENT_EVT_MAX) {
btc_ble_mesh_config_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_config_client_free_req_data(msg);
return;
}
/* Configuration Server Model related functions */
static inline void btc_ble_mesh_config_server_cb_to_app(esp_ble_mesh_cfg_server_cb_event_t event,
esp_ble_mesh_cfg_server_cb_param_t *param)
{
esp_ble_mesh_cfg_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_cfg_server_cb_t)btc_profile_cb_get(BTC_PID_CONFIG_SERVER);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
static void btc_ble_mesh_config_server_callback(esp_ble_mesh_cfg_server_cb_param_t *cb_params, uint8_t act)
{ {
btc_msg_t msg = {0}; btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__); LOG_DEBUG("%s", __func__);
msg.sig = BTC_SIG_API_CB; msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_CFG_SERVER; msg.pid = BTC_PID_CONFIG_SERVER;
msg.act = act; msg.act = act;
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_server_cb_param_t), NULL); btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_server_cb_param_t), NULL);
} }
void bt_mesh_callback_cfg_server_event_to_btc(u8_t evt_type, struct bt_mesh_model *model, void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len) const u8_t *val, size_t len)
{ {
@ -682,7 +707,7 @@ void bt_mesh_callback_cfg_server_event_to_btc(u8_t evt_type, struct bt_mesh_mode
} }
switch (evt_type) { switch (evt_type) {
case 0x00: case BTC_BLE_MESH_EVT_CONFIG_SERVER_RECV_MSG:
act = ESP_BLE_MESH_CFG_SERVER_RECV_MSG_EVT; act = ESP_BLE_MESH_CFG_SERVER_RECV_MSG_EVT;
break; break;
default: default:
@ -703,10 +728,11 @@ void bt_mesh_callback_cfg_server_event_to_btc(u8_t evt_type, struct bt_mesh_mode
memcpy(&cb_params.status_cb, val, length); memcpy(&cb_params.status_cb, val, length);
} }
btc_mesh_cfg_server_callback(&cb_params, act); btc_ble_mesh_config_server_callback(&cb_params, act);
return;
} }
void btc_mesh_cfg_server_cb_handler(btc_msg_t *msg) void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg)
{ {
esp_ble_mesh_cfg_server_cb_param_t *param = NULL; esp_ble_mesh_cfg_server_cb_param_t *param = NULL;
@ -718,7 +744,7 @@ void btc_mesh_cfg_server_cb_handler(btc_msg_t *msg)
param = (esp_ble_mesh_cfg_server_cb_param_t *)(msg->arg); param = (esp_ble_mesh_cfg_server_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_CFG_SERVER_EVT_MAX) { if (msg->act < ESP_BLE_MESH_CFG_SERVER_EVT_MAX) {
btc_ble_mesh_cfg_server_cb_to_app(msg->act, param); btc_ble_mesh_config_server_cb_to_app(msg->act, param);
} else { } else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act); LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
} }

View file

@ -18,16 +18,19 @@
#include "btc/btc_manage.h" #include "btc/btc_manage.h"
#include "osi/allocator.h" #include "osi/allocator.h"
#include "cfg_cli.h" #include "generic_client.h"
#include "btc_ble_mesh_generic_model.h" #include "btc_ble_mesh_generic_model.h"
#include "esp_ble_mesh_generic_model_api.h" #include "esp_ble_mesh_generic_model_api.h"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_generic_client_cb_event_t event, /* Generic Client Models related functions */
static inline void btc_ble_mesh_generic_client_cb_to_app(esp_ble_mesh_generic_client_cb_event_t event,
esp_ble_mesh_generic_client_cb_param_t *param) esp_ble_mesh_generic_client_cb_param_t *param)
{ {
esp_ble_mesh_generic_client_cb_t btc_mesh_cb = (esp_ble_mesh_generic_client_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_CLIENT); esp_ble_mesh_generic_client_cb_t btc_ble_mesh_cb =
if (btc_mesh_cb) { (esp_ble_mesh_generic_client_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_CLIENT);
btc_mesh_cb(event, param); if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
} }
} }
@ -35,7 +38,6 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
{ {
btc_ble_mesh_generic_client_args_t *dst = (btc_ble_mesh_generic_client_args_t *)p_dest; btc_ble_mesh_generic_client_args_t *dst = (btc_ble_mesh_generic_client_args_t *)p_dest;
btc_ble_mesh_generic_client_args_t *src = (btc_ble_mesh_generic_client_args_t *)p_src; btc_ble_mesh_generic_client_args_t *src = (btc_ble_mesh_generic_client_args_t *)p_src;
u32_t opcode;
u16_t length; u16_t length;
if (!msg || !dst || !src) { if (!msg || !dst || !src) {
@ -66,8 +68,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
memcpy(dst->generic_client_set_state.set_state, src->generic_client_set_state.set_state, memcpy(dst->generic_client_set_state.set_state, src->generic_client_set_state.set_state,
sizeof(esp_ble_mesh_generic_client_set_state_t)); sizeof(esp_ble_mesh_generic_client_set_state_t));
opcode = src->generic_client_set_state.params->opcode; switch (src->generic_client_set_state.params->opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET: case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
if (src->generic_client_set_state.set_state->user_property_set.property_value) { if (src->generic_client_set_state.set_state->user_property_set.property_value) {
length = src->generic_client_set_state.set_state->user_property_set.property_value->len; length = src->generic_client_set_state.set_state->user_property_set.property_value->len;
@ -108,11 +109,55 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
} }
} }
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src) static void btc_ble_mesh_generic_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_generic_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_generic_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE:
if (arg->generic_client_get_state.params) {
osi_free(arg->generic_client_get_state.params);
}
if (arg->generic_client_get_state.get_state) {
osi_free(arg->generic_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE:
if (arg->generic_client_set_state.set_state) {
if (arg->generic_client_set_state.params) {
switch (arg->generic_client_set_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
bt_mesh_free_buf(arg->generic_client_set_state.set_state->user_property_set.property_value);
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
bt_mesh_free_buf(arg->generic_client_set_state.set_state->admin_property_set.property_value);
break;
default:
break;
}
}
osi_free(arg->generic_client_set_state.set_state);
}
if (arg->generic_client_set_state.params) {
osi_free(arg->generic_client_set_state.params);
}
break;
default:
break;
}
}
static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{ {
esp_ble_mesh_generic_client_cb_param_t *p_dest_data = (esp_ble_mesh_generic_client_cb_param_t *)p_dest; esp_ble_mesh_generic_client_cb_param_t *p_dest_data = (esp_ble_mesh_generic_client_cb_param_t *)p_dest;
esp_ble_mesh_generic_client_cb_param_t *p_src_data = (esp_ble_mesh_generic_client_cb_param_t *)p_src; esp_ble_mesh_generic_client_cb_param_t *p_src_data = (esp_ble_mesh_generic_client_cb_param_t *)p_src;
u32_t opcode;
u16_t length; u16_t length;
if (!msg || !p_src_data || !p_dest_data) { if (!msg || !p_src_data || !p_dest_data) {
@ -125,8 +170,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
case ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT: case ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT: case ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT:
if (p_src_data->params) { if (p_src_data->params) {
opcode = p_src_data->params->opcode; switch (p_src_data->params->opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET: case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS: case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS:
if (p_src_data->status_cb.user_properties_status.property_ids) { if (p_src_data->status_cb.user_properties_status.property_ids) {
@ -247,10 +291,9 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
} }
} }
static void btc_ble_mesh_free_req_data(btc_msg_t *msg) static void btc_ble_mesh_generic_client_free_req_data(btc_msg_t *msg)
{ {
esp_ble_mesh_generic_client_cb_param_t *arg = NULL; esp_ble_mesh_generic_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) { if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
@ -264,8 +307,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT: case ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT: case ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT:
if (arg->params) { if (arg->params) {
opcode = arg->params->opcode; switch (arg->params->opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET: case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS: case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS:
bt_mesh_free_buf(arg->status_cb.user_properties_status.property_ids); bt_mesh_free_buf(arg->status_cb.user_properties_status.property_ids);
@ -311,56 +353,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
} }
} }
void btc_ble_mesh_generic_client_arg_deep_free(btc_msg_t *msg) static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_param_t *cb_params, uint8_t act)
{
btc_ble_mesh_generic_client_args_t *arg = NULL;
u32_t opcode = 0;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_generic_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE:
if (arg->generic_client_get_state.params) {
osi_free(arg->generic_client_get_state.params);
}
if (arg->generic_client_get_state.get_state) {
osi_free(arg->generic_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE:
if (arg->generic_client_set_state.params) {
opcode = arg->generic_client_set_state.params->opcode;
osi_free(arg->generic_client_set_state.params);
}
if (arg->generic_client_set_state.set_state) {
if (opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
bt_mesh_free_buf(arg->generic_client_set_state.set_state->user_property_set.property_value);
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
bt_mesh_free_buf(arg->generic_client_set_state.set_state->admin_property_set.property_value);
break;
default:
break;
}
}
osi_free(arg->generic_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
static void btc_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_param_t *cb_params, uint8_t act)
{ {
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -371,10 +364,10 @@ static void btc_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_para
msg.act = act; msg.act = act;
btc_transfer_context(&msg, cb_params, btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_generic_client_cb_param_t), btc_ble_mesh_copy_req_data); sizeof(esp_ble_mesh_generic_client_cb_param_t), btc_ble_mesh_generic_client_copy_req_data);
} }
void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type, void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len) const u8_t *val, size_t len)
@ -390,16 +383,16 @@ void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type,
} }
switch (evt_type) { switch (evt_type) {
case 0x00: case BTC_BLE_MESH_EVT_GENERIC_CLIENT_GET_STATE:
act = ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT; act = ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT;
break; break;
case 0x01: case BTC_BLE_MESH_EVT_GENERIC_CLIENT_SET_STATE:
act = ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT; act = ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT;
break; break;
case 0x02: case BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH:
act = ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT; act = ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT;
break; break;
case 0x03: case BTC_BLE_MESH_EVT_GENERIC_CLIENT_TIMEOUT:
act = ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT; act = ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT;
break; break;
default: default:
@ -424,25 +417,30 @@ void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type,
memcpy(&cb_params.status_cb, val, length); memcpy(&cb_params.status_cb, val, length);
} }
btc_mesh_generic_client_callback(&cb_params, act); btc_ble_mesh_generic_client_callback(&cb_params, act);
return;
} }
void btc_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, void btc_ble_mesh_generic_client_publish_callback(u32_t opcode,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{ {
if (!model || !ctx || !buf) { if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
return; return;
} }
bt_mesh_callback_generic_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len); bt_mesh_generic_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
return;
} }
void btc_mesh_generic_client_call_handler(btc_msg_t *msg) void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
{ {
esp_ble_mesh_generic_client_cb_param_t generic_client_cb = {0};
esp_ble_mesh_client_common_param_t *params = NULL; esp_ble_mesh_client_common_param_t *params = NULL;
btc_ble_mesh_generic_client_args_t *arg = NULL; btc_ble_mesh_generic_client_args_t *arg = NULL;
esp_ble_mesh_generic_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0}; bt_mesh_client_common_param_t common = {0};
bt_mesh_role_param_t role_param = {0}; bt_mesh_role_param_t role_param = {0};
@ -471,15 +469,12 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
common.ctx.send_ttl = params->ctx.send_ttl; common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout; common.msg_timeout = params->msg_timeout;
generic_client_cb.params = arg->generic_client_get_state.params; cb.params = arg->generic_client_get_state.params;
generic_client_cb.error_code = cb.error_code = bt_mesh_generic_client_get_state(&common,
bt_mesh_generic_client_get_state(&common, (void *)arg->generic_client_get_state.get_state, (void *)&cb.status_cb);
(void *)arg->generic_client_get_state.get_state, if (cb.error_code) {
(void *)&generic_client_cb.status_cb);
if (generic_client_cb.error_code) {
/* If send failed, callback error_code to app layer immediately */ /* If send failed, callback error_code to app layer immediately */
btc_mesh_generic_client_callback(&generic_client_cb, btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT);
ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT);
} }
break; break;
} }
@ -500,15 +495,12 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
common.ctx.send_ttl = params->ctx.send_ttl; common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout; common.msg_timeout = params->msg_timeout;
generic_client_cb.params = arg->generic_client_set_state.params; cb.params = arg->generic_client_set_state.params;
generic_client_cb.error_code = cb.error_code = bt_mesh_generic_client_set_state(&common,
bt_mesh_generic_client_set_state(&common, (void *)arg->generic_client_set_state.set_state, (void *)&cb.status_cb);
(void *)arg->generic_client_set_state.set_state, if (cb.error_code) {
(void *)&generic_client_cb.status_cb);
if (generic_client_cb.error_code) {
/* If send failed, callback error_code to app layer immediately */ /* If send failed, callback error_code to app layer immediately */
btc_mesh_generic_client_callback(&generic_client_cb, btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT);
ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT);
} }
break; break;
} }
@ -517,9 +509,10 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
} }
btc_ble_mesh_generic_client_arg_deep_free(msg); btc_ble_mesh_generic_client_arg_deep_free(msg);
return;
} }
void btc_mesh_generic_client_cb_handler(btc_msg_t *msg) void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
{ {
esp_ble_mesh_generic_client_cb_param_t *param = NULL; esp_ble_mesh_generic_client_cb_param_t *param = NULL;
@ -531,10 +524,11 @@ void btc_mesh_generic_client_cb_handler(btc_msg_t *msg)
param = (esp_ble_mesh_generic_client_cb_param_t *)(msg->arg); param = (esp_ble_mesh_generic_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX) { if (msg->act < ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param); btc_ble_mesh_generic_client_cb_to_app(msg->act, param);
} else { } else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act); LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
} }
btc_ble_mesh_free_req_data(msg); btc_ble_mesh_generic_client_free_req_data(msg);
return;
} }

View file

@ -28,21 +28,15 @@
extern s32_t health_msg_timeout; extern s32_t health_msg_timeout;
/* Health Client Model related functions */
static inline void btc_ble_mesh_health_client_cb_to_app(esp_ble_mesh_health_client_cb_event_t event, static inline void btc_ble_mesh_health_client_cb_to_app(esp_ble_mesh_health_client_cb_event_t event,
esp_ble_mesh_health_client_cb_param_t *param) esp_ble_mesh_health_client_cb_param_t *param)
{ {
esp_ble_mesh_health_client_cb_t btc_mesh_cb = (esp_ble_mesh_health_client_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_CLIENT); esp_ble_mesh_health_client_cb_t btc_ble_mesh_cb =
if (btc_mesh_cb) { (esp_ble_mesh_health_client_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_CLIENT);
btc_mesh_cb(event, param); if (btc_ble_mesh_cb) {
} btc_ble_mesh_cb(event, param);
}
static inline void btc_ble_mesh_health_server_cb_to_app(esp_ble_mesh_health_server_cb_event_t event,
esp_ble_mesh_health_server_cb_param_t *param)
{
esp_ble_mesh_health_server_cb_t btc_mesh_cb = (esp_ble_mesh_health_server_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_SERVER);
if (btc_mesh_cb) {
btc_mesh_cb(event, param);
} }
} }
@ -120,45 +114,12 @@ static void btc_ble_mesh_health_client_arg_deep_free(btc_msg_t *msg)
default: default:
break; break;
} }
return;
}
void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_arg_deep_free(btc_msg_t *msg)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
break;
default:
break;
}
} }
static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src) static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{ {
esp_ble_mesh_health_client_cb_param_t *p_dest_data = (esp_ble_mesh_health_client_cb_param_t *)p_dest; esp_ble_mesh_health_client_cb_param_t *p_dest_data = (esp_ble_mesh_health_client_cb_param_t *)p_dest;
esp_ble_mesh_health_client_cb_param_t *p_src_data = (esp_ble_mesh_health_client_cb_param_t *)p_src; esp_ble_mesh_health_client_cb_param_t *p_src_data = (esp_ble_mesh_health_client_cb_param_t *)p_src;
u32_t opcode;
u16_t length; u16_t length;
if (!msg || !p_src_data || !p_dest_data) { if (!msg || !p_src_data || !p_dest_data) {
@ -171,8 +132,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
case ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT: case ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT: case ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT:
if (p_src_data->params) { if (p_src_data->params) {
opcode = p_src_data->params->opcode; switch (p_src_data->params->opcode) {
switch (opcode) {
case OP_HEALTH_CURRENT_STATUS: case OP_HEALTH_CURRENT_STATUS:
if (p_src_data->status_cb.current_status.fault_array) { if (p_src_data->status_cb.current_status.fault_array) {
length = p_src_data->status_cb.current_status.fault_array->len; length = p_src_data->status_cb.current_status.fault_array->len;
@ -224,7 +184,6 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg) static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
{ {
esp_ble_mesh_health_client_cb_param_t *arg = NULL; esp_ble_mesh_health_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) { if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
@ -238,8 +197,7 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT: case ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT: case ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT:
if (arg->params) { if (arg->params) {
opcode = arg->params->opcode; switch (arg->params->opcode) {
switch (opcode) {
case OP_HEALTH_CURRENT_STATUS: case OP_HEALTH_CURRENT_STATUS:
bt_mesh_free_buf(arg->status_cb.current_status.fault_array); bt_mesh_free_buf(arg->status_cb.current_status.fault_array);
break; break;
@ -263,6 +221,292 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
} }
} }
static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_HEALTH_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_health_client_cb_param_t), btc_ble_mesh_health_client_copy_req_data);
}
void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, u16_t len)
{
esp_ble_mesh_health_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_GET_STATE:
act = ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT;
break;
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_SET_STATE:
act = ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT;
break;
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH:
act = ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT;
break;
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT:
act = ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s, Unknown health client event type %d", __func__, 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;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
}
btc_ble_mesh_health_client_callback(&cb_params, act);
return;
}
void btc_ble_mesh_health_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_health_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
return;
}
static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_get_state_t *get,
esp_ble_mesh_health_client_cb_param_t *cb)
{
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = params->ctx.app_idx;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
health_msg_timeout = params->msg_timeout;
switch (params->opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
return (cb->error_code = bt_mesh_health_attention_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
return (cb->error_code = bt_mesh_health_period_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
return (cb->error_code = bt_mesh_health_fault_get(&ctx, get->fault_get.company_id));
default:
LOG_ERROR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
}
return 0;
}
static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set,
esp_ble_mesh_health_client_cb_param_t *cb)
{
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !set || !cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = params->ctx.app_idx;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
health_msg_timeout = params->msg_timeout;
switch (params->opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
return (cb->error_code =
bt_mesh_health_attention_set(&ctx, set->attention_set.attention, true));
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
return (cb->error_code =
bt_mesh_health_attention_set(&ctx, set->attention_set.attention, false));
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
return (cb->error_code =
bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, true));
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
return (cb->error_code =
bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, false));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
return (cb->error_code =
bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, true));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK:
return (cb->error_code =
bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, false));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
return (cb->error_code =
bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, true));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
return (cb->error_code =
bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, false));
default:
LOG_ERROR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
}
return 0;
}
void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
{
btc_ble_mesh_health_client_args_t *arg = NULL;
esp_ble_mesh_health_client_cb_param_t cb = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_health_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: {
cb.params = arg->health_client_get_state.params;
role_param.model = (struct bt_mesh_model *)cb.params->model;
role_param.role = cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
arg->health_client_get_state.get_state, &cb);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT);
}
break;
}
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE: {
cb.params = arg->health_client_set_state.params;
role_param.model = (struct bt_mesh_model *)cb.params->model;
role_param.role = cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
arg->health_client_set_state.set_state, &cb);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT);
}
break;
}
default:
break;
}
btc_ble_mesh_health_client_arg_deep_free(msg);
return;
}
void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_health_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_health_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX) {
btc_ble_mesh_health_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_health_client_free_req_data(msg);
return;
}
/* Health Server Model related functions */
static inline void btc_ble_mesh_health_server_cb_to_app(esp_ble_mesh_health_server_cb_event_t event,
esp_ble_mesh_health_server_cb_param_t *param)
{
esp_ble_mesh_health_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_health_server_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_SERVER);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_arg_deep_free(btc_msg_t *msg)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src) static void btc_ble_mesh_health_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{ {
if (!msg) { if (!msg) {
@ -293,21 +537,7 @@ static void btc_ble_mesh_health_server_free_req_data(btc_msg_t *msg)
} }
} }
static void btc_mesh_health_client_callback(esp_ble_mesh_health_client_cb_param_t *cb_params, uint8_t act) static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_HEALTH_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_health_client_cb_param_t), btc_ble_mesh_health_client_copy_req_data);
}
static void btc_mesh_health_server_callback(esp_ble_mesh_health_server_cb_param_t *cb_params, uint8_t act)
{ {
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -321,233 +551,7 @@ static void btc_mesh_health_server_callback(esp_ble_mesh_health_server_cb_param_
sizeof(esp_ble_mesh_health_server_cb_param_t), btc_ble_mesh_health_server_copy_req_data); sizeof(esp_ble_mesh_health_server_cb_param_t), btc_ble_mesh_health_server_copy_req_data);
} }
int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params, void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg)
esp_ble_mesh_health_client_get_state_t *get_state,
esp_ble_mesh_health_client_cb_param_t *client_cb)
{
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !client_cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = params->ctx.app_idx;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
health_msg_timeout = params->msg_timeout;
switch (params->opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
return (client_cb->error_code = bt_mesh_health_attention_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
return (client_cb->error_code = bt_mesh_health_period_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
return (client_cb->error_code = bt_mesh_health_fault_get(&ctx, get_state->fault_get.company_id));
default:
BT_WARN("%s, invalid opcode 0x%x", __func__, params->opcode);
return (client_cb->error_code = -EINVAL);
}
return 0;
}
int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set_state,
esp_ble_mesh_health_client_cb_param_t *client_cb)
{
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !set_state || !client_cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = params->ctx.app_idx;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
health_msg_timeout = params->msg_timeout;
switch (params->opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
return (client_cb->error_code =
bt_mesh_health_attention_set(&ctx, set_state->attention_set.attention, true));
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
return (client_cb->error_code =
bt_mesh_health_attention_set(&ctx, set_state->attention_set.attention, false));
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
return (client_cb->error_code =
bt_mesh_health_period_set(&ctx, set_state->period_set.fast_period_divisor, true));
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
return (client_cb->error_code =
bt_mesh_health_period_set(&ctx, set_state->period_set.fast_period_divisor, false));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
return (client_cb->error_code =
bt_mesh_health_fault_test(&ctx, set_state->fault_test.company_id, set_state->fault_test.test_id, true));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK:
return (client_cb->error_code =
bt_mesh_health_fault_test(&ctx, set_state->fault_test.company_id, set_state->fault_test.test_id, false));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
return (client_cb->error_code =
bt_mesh_health_fault_clear(&ctx, set_state->fault_clear.company_id, true));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
return (client_cb->error_code =
bt_mesh_health_fault_clear(&ctx, set_state->fault_clear.company_id, false));
default:
BT_WARN("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (client_cb->error_code = -EINVAL);
}
return 0;
}
void bt_mesh_callback_health_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, u16_t len)
{
esp_ble_mesh_health_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case 0x00:
act = ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT;
break;
case 0x01:
act = ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT;
break;
case 0x02:
act = ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT;
break;
case 0x03:
act = ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s, Unknown health client event type %d", __func__, 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;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
}
btc_mesh_health_client_callback(&cb_params, act);
}
void btc_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_callback_health_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len);
}
void btc_mesh_health_client_call_handler(btc_msg_t *msg)
{
btc_ble_mesh_health_client_args_t *arg = NULL;
esp_ble_mesh_health_client_cb_param_t health_client_cb = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_health_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: {
health_client_cb.params = arg->health_client_get_state.params;
role_param.model = (struct bt_mesh_model *)health_client_cb.params->model;
role_param.role = health_client_cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
arg->health_client_get_state.get_state,
&health_client_cb);
if (health_client_cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_mesh_health_client_callback(&health_client_cb, ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT);
}
break;
}
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE: {
health_client_cb.params = arg->health_client_set_state.params;
role_param.model = (struct bt_mesh_model *)health_client_cb.params->model;
role_param.role = health_client_cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
arg->health_client_set_state.set_state,
&health_client_cb);
if (health_client_cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_mesh_health_client_callback(&health_client_cb, ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT);
}
break;
}
default:
break;
}
btc_ble_mesh_health_client_arg_deep_free(msg);
return;
}
void btc_mesh_health_client_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_health_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_health_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX) {
btc_ble_mesh_health_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_health_client_free_req_data(msg);
}
void btc_mesh_health_server_call_handler(btc_msg_t *msg)
{ {
esp_ble_mesh_health_server_cb_param_t health_server_cb = {0}; esp_ble_mesh_health_server_cb_param_t health_server_cb = {0};
btc_ble_mesh_health_server_args_t *arg = NULL; btc_ble_mesh_health_server_args_t *arg = NULL;
@ -560,18 +564,21 @@ void btc_mesh_health_server_call_handler(btc_msg_t *msg)
arg = (btc_ble_mesh_health_server_args_t *)(msg->arg); arg = (btc_ble_mesh_health_server_args_t *)(msg->arg);
switch (msg->act) { switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE: { case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
health_server_cb.error_code = bt_mesh_fault_update((struct bt_mesh_elem *)arg->fault_update.element); health_server_cb.error_code =
btc_mesh_health_server_callback(&health_server_cb, ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT); bt_mesh_fault_update((struct bt_mesh_elem *)arg->fault_update.element);
} btc_ble_mesh_health_server_callback(
&health_server_cb, ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT);
break;
default: default:
break; break;
} }
btc_ble_mesh_health_server_arg_deep_free(msg); btc_ble_mesh_health_server_arg_deep_free(msg);
return;
} }
void btc_mesh_health_server_cb_handler(btc_msg_t *msg) void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg)
{ {
esp_ble_mesh_health_server_cb_param_t *param = NULL; esp_ble_mesh_health_server_cb_param_t *param = NULL;
@ -589,4 +596,5 @@ void btc_mesh_health_server_cb_handler(btc_msg_t *msg)
} }
btc_ble_mesh_health_server_free_req_data(msg); btc_ble_mesh_health_server_free_req_data(msg);
return;
} }

View file

@ -22,19 +22,22 @@
#include "btc_ble_mesh_lighting_model.h" #include "btc_ble_mesh_lighting_model.h"
#include "esp_ble_mesh_lighting_model_api.h" #include "esp_ble_mesh_lighting_model_api.h"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_light_client_cb_event_t event, /* Lighting Client Models related functions */
static inline void btc_ble_mesh_lighting_client_cb_to_app(esp_ble_mesh_light_client_cb_event_t event,
esp_ble_mesh_light_client_cb_param_t *param) esp_ble_mesh_light_client_cb_param_t *param)
{ {
esp_ble_mesh_light_client_cb_t btc_mesh_cb = (esp_ble_mesh_light_client_cb_t)btc_profile_cb_get(BTC_PID_LIGHT_CLIENT); esp_ble_mesh_light_client_cb_t btc_ble_mesh_cb =
if (btc_mesh_cb) { (esp_ble_mesh_light_client_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_CLIENT);
btc_mesh_cb(event, param); if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
} }
} }
void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{ {
btc_ble_mesh_light_client_args_t *dst = (btc_ble_mesh_light_client_args_t *)p_dest; btc_ble_mesh_lighting_client_args_t *dst = (btc_ble_mesh_lighting_client_args_t *)p_dest;
btc_ble_mesh_light_client_args_t *src = (btc_ble_mesh_light_client_args_t *)p_src; btc_ble_mesh_lighting_client_args_t *src = (btc_ble_mesh_lighting_client_args_t *)p_src;
if (!msg || !dst || !src) { if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
@ -42,7 +45,7 @@ void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
} }
switch (msg->act) { switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE: { case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE: {
dst->light_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t)); dst->light_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->light_client_get_state.get_state = (esp_ble_mesh_light_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_light_client_get_state_t)); dst->light_client_get_state.get_state = (esp_ble_mesh_light_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_light_client_get_state_t));
if (dst->light_client_get_state.params && dst->light_client_get_state.get_state) { if (dst->light_client_get_state.params && dst->light_client_get_state.get_state) {
@ -55,7 +58,7 @@ void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
} }
break; break;
} }
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE: { case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: {
dst->light_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t)); dst->light_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->light_client_set_state.set_state = (esp_ble_mesh_light_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_light_client_set_state_t)); dst->light_client_set_state.set_state = (esp_ble_mesh_light_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_light_client_set_state_t));
if (dst->light_client_set_state.params && dst->light_client_set_state.set_state) { if (dst->light_client_set_state.params && dst->light_client_set_state.set_state) {
@ -74,11 +77,43 @@ void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
} }
} }
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src) static void btc_ble_mesh_lighting_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_lighting_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_lighting_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE:
if (arg->light_client_get_state.params) {
osi_free(arg->light_client_get_state.params);
}
if (arg->light_client_get_state.get_state) {
osi_free(arg->light_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE:
if (arg->light_client_set_state.params) {
osi_free(arg->light_client_set_state.params);
}
if (arg->light_client_set_state.set_state) {
osi_free(arg->light_client_set_state.set_state);
}
break;
default:
break;
}
}
static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{ {
esp_ble_mesh_light_client_cb_param_t *p_dest_data = (esp_ble_mesh_light_client_cb_param_t *)p_dest; esp_ble_mesh_light_client_cb_param_t *p_dest_data = (esp_ble_mesh_light_client_cb_param_t *)p_dest;
esp_ble_mesh_light_client_cb_param_t *p_src_data = (esp_ble_mesh_light_client_cb_param_t *)p_src; esp_ble_mesh_light_client_cb_param_t *p_src_data = (esp_ble_mesh_light_client_cb_param_t *)p_src;
u32_t opcode;
u16_t length; u16_t length;
if (!msg || !p_src_data || !p_dest_data) { if (!msg || !p_src_data || !p_dest_data) {
@ -91,8 +126,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
case ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT: case ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT: case ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT:
if (p_src_data->params) { if (p_src_data->params) {
opcode = p_src_data->params->opcode; switch (p_src_data->params->opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET: case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET: case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS: case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS:
@ -127,10 +161,9 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
} }
} }
static void btc_ble_mesh_free_req_data(btc_msg_t *msg) static void btc_ble_mesh_lighting_client_free_req_data(btc_msg_t *msg)
{ {
esp_ble_mesh_light_client_cb_param_t *arg = NULL; esp_ble_mesh_light_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) { if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
@ -144,8 +177,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT: case ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT: case ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT:
if (arg->params) { if (arg->params) {
opcode = arg->params->opcode; switch (arg->params->opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET: case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET: case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS: case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS:
@ -165,56 +197,21 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
} }
} }
void btc_ble_mesh_light_client_arg_deep_free(btc_msg_t *msg) static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_param_t *cb_params, uint8_t act)
{
btc_ble_mesh_light_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_light_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE:
if (arg->light_client_get_state.params) {
osi_free(arg->light_client_get_state.params);
}
if (arg->light_client_get_state.get_state) {
osi_free(arg->light_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE:
if (arg->light_client_set_state.params) {
osi_free(arg->light_client_set_state.params);
}
if (arg->light_client_set_state.set_state) {
osi_free(arg->light_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
static void btc_mesh_light_client_callback(esp_ble_mesh_light_client_cb_param_t *cb_params, uint8_t act)
{ {
btc_msg_t msg = {0}; btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__); LOG_DEBUG("%s", __func__);
msg.sig = BTC_SIG_API_CB; msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_LIGHT_CLIENT; msg.pid = BTC_PID_LIGHTING_CLIENT;
msg.act = act; msg.act = act;
btc_transfer_context(&msg, cb_params, btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_light_client_cb_param_t), btc_ble_mesh_copy_req_data); sizeof(esp_ble_mesh_light_client_cb_param_t), btc_ble_mesh_lighting_client_copy_req_data);
} }
void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type, void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len) const u8_t *val, size_t len)
@ -230,16 +227,16 @@ void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type,
} }
switch (evt_type) { switch (evt_type) {
case 0x00: case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_GET_STATE:
act = ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT; act = ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT;
break; break;
case 0x01: case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_SET_STATE:
act = ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT; act = ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT;
break; break;
case 0x02: case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH:
act = ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT; act = ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT;
break; break;
case 0x03: case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_TIMEOUT:
act = ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT; act = ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT;
break; break;
default: default:
@ -264,25 +261,30 @@ void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type,
memcpy(&cb_params.status_cb, val, length); memcpy(&cb_params.status_cb, val, length);
} }
btc_mesh_light_client_callback(&cb_params, act); btc_ble_mesh_lighting_client_callback(&cb_params, act);
return;
} }
void btc_mesh_light_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{ {
if (!model || !ctx || !buf) { if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
return; return;
} }
bt_mesh_callback_light_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len); bt_mesh_lighting_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
return;
} }
void btc_mesh_light_client_call_handler(btc_msg_t *msg) void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
{ {
esp_ble_mesh_light_client_cb_param_t light_client_cb = {0};
esp_ble_mesh_client_common_param_t *params = NULL; esp_ble_mesh_client_common_param_t *params = NULL;
btc_ble_mesh_light_client_args_t *arg = NULL; btc_ble_mesh_lighting_client_args_t *arg = NULL;
esp_ble_mesh_light_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0}; bt_mesh_client_common_param_t common = {0};
bt_mesh_role_param_t role_param = {0}; bt_mesh_role_param_t role_param = {0};
@ -291,10 +293,10 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
return; return;
} }
arg = (btc_ble_mesh_light_client_args_t *)(msg->arg); arg = (btc_ble_mesh_lighting_client_args_t *)(msg->arg);
switch (msg->act) { switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE: { case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE: {
params = arg->light_client_get_state.params; params = arg->light_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model; role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role; role_param.role = params->msg_role;
@ -311,19 +313,16 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
common.ctx.send_ttl = params->ctx.send_ttl; common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout; common.msg_timeout = params->msg_timeout;
light_client_cb.params = arg->light_client_get_state.params; cb.params = arg->light_client_get_state.params;
light_client_cb.error_code = cb.error_code = bt_mesh_light_client_get_state(&common,
bt_mesh_light_client_get_state(&common, (void *)arg->light_client_get_state.get_state, (void *)&cb.status_cb);
(void *)arg->light_client_get_state.get_state, if (cb.error_code) {
(void *)&light_client_cb.status_cb);
if (light_client_cb.error_code) {
/* If send failed, callback error_code to app layer immediately */ /* If send failed, callback error_code to app layer immediately */
btc_mesh_light_client_callback(&light_client_cb, btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT);
ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT);
} }
break; break;
} }
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE: { case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: {
params = arg->light_client_set_state.params; params = arg->light_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model; role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role; role_param.role = params->msg_role;
@ -340,15 +339,12 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
common.ctx.send_ttl = params->ctx.send_ttl; common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout; common.msg_timeout = params->msg_timeout;
light_client_cb.params = arg->light_client_set_state.params; cb.params = arg->light_client_set_state.params;
light_client_cb.error_code = cb.error_code = bt_mesh_light_client_set_state(&common,
bt_mesh_light_client_set_state(&common, (void *)arg->light_client_set_state.set_state, (void *)&cb.status_cb);
(void *)arg->light_client_set_state.set_state, if (cb.error_code) {
(void *)&light_client_cb.status_cb);
if (light_client_cb.error_code) {
/* If send failed, callback error_code to app layer immediately */ /* If send failed, callback error_code to app layer immediately */
btc_mesh_light_client_callback(&light_client_cb, btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT);
ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT);
} }
break; break;
} }
@ -356,10 +352,11 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
break; break;
} }
btc_ble_mesh_light_client_arg_deep_free(msg); btc_ble_mesh_lighting_client_arg_deep_free(msg);
return;
} }
void btc_mesh_light_client_cb_handler(btc_msg_t *msg) void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
{ {
esp_ble_mesh_light_client_cb_param_t *param = NULL; esp_ble_mesh_light_client_cb_param_t *param = NULL;
@ -371,11 +368,12 @@ void btc_mesh_light_client_cb_handler(btc_msg_t *msg)
param = (esp_ble_mesh_light_client_cb_param_t *)(msg->arg); param = (esp_ble_mesh_light_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX) { if (msg->act < ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param); btc_ble_mesh_lighting_client_cb_to_app(msg->act, param);
} else { } else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act); LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
} }
btc_ble_mesh_free_req_data(msg); btc_ble_mesh_lighting_client_free_req_data(msg);
return;
} }

View file

@ -59,7 +59,25 @@
#include "esp_ble_mesh_provisioning_api.h" #include "esp_ble_mesh_provisioning_api.h"
#include "esp_ble_mesh_networking_api.h" #include "esp_ble_mesh_networking_api.h"
#define BLE_MESH_MAX_DATA_SIZE 379 static inline void btc_ble_mesh_prov_cb_to_app(esp_ble_mesh_prov_cb_event_t event,
esp_ble_mesh_prov_cb_param_t *param)
{
esp_ble_mesh_prov_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_prov_cb_t)btc_profile_cb_get(BTC_PID_PROV);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
static inline void btc_ble_mesh_model_cb_to_app(esp_ble_mesh_model_cb_event_t event,
esp_ble_mesh_model_cb_param_t *param)
{
esp_ble_mesh_model_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_model_cb_t)btc_profile_cb_get(BTC_PID_MODEL);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{ {
@ -97,7 +115,7 @@ void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
} }
} }
void btc_ble_mesh_prov_arg_deep_free(btc_msg_t *msg) static void btc_ble_mesh_prov_arg_deep_free(btc_msg_t *msg)
{ {
btc_ble_mesh_model_args_t *arg = NULL; btc_ble_mesh_model_args_t *arg = NULL;
@ -125,7 +143,7 @@ void btc_ble_mesh_prov_arg_deep_free(btc_msg_t *msg)
return; return;
} }
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src) static void btc_ble_mesh_model_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{ {
esp_ble_mesh_model_cb_param_t *p_dest_data = (esp_ble_mesh_model_cb_param_t *)p_dest; esp_ble_mesh_model_cb_param_t *p_dest_data = (esp_ble_mesh_model_cb_param_t *)p_dest;
esp_ble_mesh_model_cb_param_t *p_src_data = (esp_ble_mesh_model_cb_param_t *)p_src; esp_ble_mesh_model_cb_param_t *p_src_data = (esp_ble_mesh_model_cb_param_t *)p_src;
@ -201,7 +219,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
} }
} }
static void btc_ble_mesh_free_req_data(btc_msg_t *msg) static void btc_ble_mesh_model_free_req_data(btc_msg_t *msg)
{ {
esp_ble_mesh_model_cb_param_t *arg = NULL; esp_ble_mesh_model_cb_param_t *arg = NULL;
@ -248,24 +266,6 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
} }
} }
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_prov_cb_event_t event,
esp_ble_mesh_prov_cb_param_t *param)
{
esp_ble_mesh_prov_cb_t btc_mesh_cb = (esp_ble_mesh_prov_cb_t)btc_profile_cb_get(BTC_PID_PROV);
if (btc_mesh_cb) {
btc_mesh_cb(event, param);
}
}
static inline void btc_ble_mesh_model_cb_to_app(esp_ble_mesh_model_cb_event_t event,
esp_ble_mesh_model_cb_param_t *param)
{
esp_ble_mesh_model_cb_t btc_mesh_cb = (esp_ble_mesh_model_cb_t)btc_profile_cb_get(BTC_PID_MODEL);
if (btc_mesh_cb) {
btc_mesh_cb(event, param);
}
}
extern u32_t mesh_opcode; extern u32_t mesh_opcode;
static void btc_ble_mesh_server_model_op_cb(struct bt_mesh_model *model, static void btc_ble_mesh_server_model_op_cb(struct bt_mesh_model *model,
@ -286,7 +286,7 @@ static void btc_ble_mesh_server_model_op_cb(struct bt_mesh_model *model,
msg.pid = BTC_PID_MODEL; msg.pid = BTC_PID_MODEL;
msg.act = ESP_BLE_MESH_MODEL_OPERATION_EVT; msg.act = ESP_BLE_MESH_MODEL_OPERATION_EVT;
ret = btc_transfer_context(&msg, &mesh_param, ret = btc_transfer_context(&msg, &mesh_param,
sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_copy_req_data); sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_model_copy_req_data);
if (ret != BT_STATUS_SUCCESS) { if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s btc_transfer_context failed", __func__); LOG_ERROR("%s btc_transfer_context failed", __func__);
@ -341,7 +341,7 @@ static void btc_ble_mesh_client_model_op_cb(struct bt_mesh_model *model,
bt_mesh_client_free_node(&data->queue, node); bt_mesh_client_free_node(&data->queue, node);
} }
ret = btc_transfer_context(&msg, &mesh_param, ret = btc_transfer_context(&msg, &mesh_param,
sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_copy_req_data); sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_model_copy_req_data);
if (ret != BT_STATUS_SUCCESS) { if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s, btc_transfer_context failed", __func__); LOG_ERROR("%s, btc_transfer_context failed", __func__);
@ -364,7 +364,7 @@ static void btc_ble_mesh_model_send_comp_cb(esp_ble_mesh_model_t *model, esp_ble
msg.pid = BTC_PID_MODEL; msg.pid = BTC_PID_MODEL;
msg.act = ESP_BLE_MESH_MODEL_SEND_COMP_EVT; msg.act = ESP_BLE_MESH_MODEL_SEND_COMP_EVT;
ret = btc_transfer_context(&msg, &mesh_param, ret = btc_transfer_context(&msg, &mesh_param,
sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_copy_req_data); sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_model_copy_req_data);
if (ret != BT_STATUS_SUCCESS) { if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s btc_transfer_context failed", __func__); LOG_ERROR("%s btc_transfer_context failed", __func__);
@ -393,8 +393,8 @@ static void btc_ble_mesh_model_publish_comp_cb(esp_ble_mesh_model_t *model, int
return; return;
} }
#if defined(CONFIG_BLE_MESH_NODE) #if CONFIG_BLE_MESH_NODE
static void btc_oob_pub_key_cb(void) static void btc_ble_mesh_oob_pub_key_cb(void)
{ {
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -410,7 +410,7 @@ static void btc_oob_pub_key_cb(void)
return; return;
} }
static int btc_output_number_cb(bt_mesh_output_action_t act, u32_t num) static int btc_ble_mesh_output_number_cb(bt_mesh_output_action_t act, u32_t num)
{ {
esp_ble_mesh_prov_cb_param_t mesh_param = {0}; esp_ble_mesh_prov_cb_param_t mesh_param = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -434,7 +434,7 @@ static int btc_output_number_cb(bt_mesh_output_action_t act, u32_t num)
return 0; return 0;
} }
static int btc_output_string_cb(const char *str) static int btc_ble_mesh_output_string_cb(const char *str)
{ {
esp_ble_mesh_prov_cb_param_t mesh_param = {0}; esp_ble_mesh_prov_cb_param_t mesh_param = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -457,7 +457,7 @@ static int btc_output_string_cb(const char *str)
return 0; return 0;
} }
static int btc_input_cb(bt_mesh_input_action_t act, u8_t size) static int btc_ble_mesh_input_cb(bt_mesh_input_action_t act, u8_t size)
{ {
esp_ble_mesh_prov_cb_param_t mesh_param = {0}; esp_ble_mesh_prov_cb_param_t mesh_param = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -481,7 +481,7 @@ static int btc_input_cb(bt_mesh_input_action_t act, u8_t size)
return 0; return 0;
} }
static void btc_link_open_cb(bt_mesh_prov_bearer_t bearer) static void btc_ble_mesh_link_open_cb(bt_mesh_prov_bearer_t bearer)
{ {
esp_ble_mesh_prov_cb_param_t mesh_param = {0}; esp_ble_mesh_prov_cb_param_t mesh_param = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -503,7 +503,7 @@ static void btc_link_open_cb(bt_mesh_prov_bearer_t bearer)
return; return;
} }
static void btc_link_close_cb(bt_mesh_prov_bearer_t bearer) static void btc_ble_mesh_link_close_cb(bt_mesh_prov_bearer_t bearer)
{ {
esp_ble_mesh_prov_cb_param_t mesh_param = {0}; esp_ble_mesh_prov_cb_param_t mesh_param = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -525,7 +525,7 @@ static void btc_link_close_cb(bt_mesh_prov_bearer_t bearer)
return; return;
} }
static void btc_complete_cb(u16_t net_idx, u16_t addr, u8_t flags, u32_t iv_index) static void btc_ble_mesh_complete_cb(u16_t net_idx, u16_t addr, u8_t flags, u32_t iv_index)
{ {
esp_ble_mesh_prov_cb_param_t mesh_param = {0}; esp_ble_mesh_prov_cb_param_t mesh_param = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -550,7 +550,7 @@ static void btc_complete_cb(u16_t net_idx, u16_t addr, u8_t flags, u32_t iv_inde
return; return;
} }
static void btc_reset_cb(void) static void btc_ble_mesh_reset_cb(void)
{ {
btc_msg_t msg = {0}; btc_msg_t msg = {0};
bt_status_t ret; bt_status_t ret;
@ -567,9 +567,9 @@ static void btc_reset_cb(void)
} }
return; return;
} }
#endif /* defined(CONFIG_BLE_MESH_NODE) */ #endif /* CONFIG_BLE_MESH_NODE */
static void btc_prov_register_complete_cb(int err_code) static void btc_ble_mesh_prov_register_complete_cb(int err_code)
{ {
esp_ble_mesh_prov_cb_param_t mesh_param = {0}; esp_ble_mesh_prov_cb_param_t mesh_param = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -591,7 +591,7 @@ static void btc_prov_register_complete_cb(int err_code)
return; return;
} }
static void btc_client_model_timeout_cb(struct k_work *work) static void btc_ble_mesh_client_model_timeout_cb(struct k_work *work)
{ {
esp_ble_mesh_model_cb_param_t mesh_param = {0}; esp_ble_mesh_model_cb_param_t mesh_param = {0};
bt_mesh_client_user_data_t *client_param = NULL; bt_mesh_client_user_data_t *client_param = NULL;
@ -621,7 +621,7 @@ static void btc_client_model_timeout_cb(struct k_work *work)
msg.pid = BTC_PID_MODEL; msg.pid = BTC_PID_MODEL;
msg.act = ESP_BLE_MESH_CLIENT_MODEL_SEND_TIMEOUT_EVT; msg.act = ESP_BLE_MESH_CLIENT_MODEL_SEND_TIMEOUT_EVT;
ret = btc_transfer_context(&msg, &mesh_param, ret = btc_transfer_context(&msg, &mesh_param,
sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_copy_req_data); sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_model_copy_req_data);
if (ret != BT_STATUS_SUCCESS) { if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s btc_transfer_context failed", __func__); LOG_ERROR("%s btc_transfer_context failed", __func__);
@ -631,7 +631,7 @@ static void btc_client_model_timeout_cb(struct k_work *work)
return; return;
} }
static int btc_model_publish_update(struct bt_mesh_model *mod) static int btc_ble_mesh_model_publish_update(struct bt_mesh_model *mod)
{ {
esp_ble_mesh_model_cb_param_t mesh_param = {0}; esp_ble_mesh_model_cb_param_t mesh_param = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -654,7 +654,7 @@ static int btc_model_publish_update(struct bt_mesh_model *mod)
return 0; return 0;
} }
static void btc_prov_set_complete_cb(esp_ble_mesh_prov_cb_param_t *param, uint8_t act) static void btc_ble_mesh_prov_set_complete_cb(esp_ble_mesh_prov_cb_param_t *param, uint8_t act)
{ {
btc_msg_t msg = {0}; btc_msg_t msg = {0};
bt_status_t ret; bt_status_t ret;
@ -673,8 +673,9 @@ static void btc_prov_set_complete_cb(esp_ble_mesh_prov_cb_param_t *param, uint8_
return; return;
} }
#if (CONFIG_BLE_MESH_PROVISIONER) #if CONFIG_BLE_MESH_PROVISIONER
static void btc_provisioner_recv_unprov_adv_pkt_cb(const u8_t addr[6], const u8_t addr_type, static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb(
const u8_t addr[6], const u8_t addr_type,
const u8_t adv_type, const u8_t dev_uuid[16], const u8_t adv_type, const u8_t dev_uuid[16],
u16_t oob_info, bt_mesh_prov_bearer_t bearer) u16_t oob_info, bt_mesh_prov_bearer_t bearer)
{ {
@ -709,7 +710,7 @@ static void btc_provisioner_recv_unprov_adv_pkt_cb(const u8_t addr[6], const u8_
return; return;
} }
static int btc_provisioner_prov_read_oob_pub_key_cb(u8_t link_idx) static int btc_ble_mesh_provisioner_prov_read_oob_pub_key_cb(u8_t link_idx)
{ {
esp_ble_mesh_prov_cb_param_t mesh_param = {0}; esp_ble_mesh_prov_cb_param_t mesh_param = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -732,7 +733,8 @@ static int btc_provisioner_prov_read_oob_pub_key_cb(u8_t link_idx)
return 0; return 0;
} }
static int btc_provisioner_prov_input_cb(u8_t method, bt_mesh_output_action_t act, u8_t size, u8_t link_idx) static int btc_ble_mesh_provisioner_prov_input_cb(u8_t method,
bt_mesh_output_action_t act, u8_t size, u8_t link_idx)
{ {
esp_ble_mesh_prov_cb_param_t mesh_param = {0}; esp_ble_mesh_prov_cb_param_t mesh_param = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -758,7 +760,8 @@ static int btc_provisioner_prov_input_cb(u8_t method, bt_mesh_output_action_t ac
return 0; return 0;
} }
static int btc_provisioner_prov_output_cb(u8_t method, bt_mesh_input_action_t act, void *data, u8_t size, u8_t link_idx) static int btc_ble_mesh_provisioner_prov_output_cb(u8_t method,
bt_mesh_input_action_t act, void *data, u8_t size, u8_t link_idx)
{ {
esp_ble_mesh_prov_cb_param_t mesh_param = {0}; esp_ble_mesh_prov_cb_param_t mesh_param = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -789,7 +792,7 @@ static int btc_provisioner_prov_output_cb(u8_t method, bt_mesh_input_action_t ac
return 0; return 0;
} }
static void btc_provisioner_link_open_cb(bt_mesh_prov_bearer_t bearer) static void btc_ble_mesh_provisioner_link_open_cb(bt_mesh_prov_bearer_t bearer)
{ {
esp_ble_mesh_prov_cb_param_t mesh_param = {0}; esp_ble_mesh_prov_cb_param_t mesh_param = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -811,7 +814,7 @@ static void btc_provisioner_link_open_cb(bt_mesh_prov_bearer_t bearer)
return; return;
} }
static void btc_provisioner_link_close_cb(bt_mesh_prov_bearer_t bearer, u8_t reason) static void btc_ble_mesh_provisioner_link_close_cb(bt_mesh_prov_bearer_t bearer, u8_t reason)
{ {
esp_ble_mesh_prov_cb_param_t mesh_param = {0}; esp_ble_mesh_prov_cb_param_t mesh_param = {0};
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -834,7 +837,8 @@ static void btc_provisioner_link_close_cb(bt_mesh_prov_bearer_t bearer, u8_t rea
return; return;
} }
static void btc_provisioner_prov_complete_cb(int node_idx, const u8_t device_uuid[16], static void btc_ble_mesh_provisioner_prov_complete_cb(
int node_idx, const u8_t device_uuid[16],
u16_t unicast_addr, u8_t element_num, u16_t unicast_addr, u8_t element_num,
u16_t netkey_idx) u16_t netkey_idx)
{ {
@ -863,7 +867,7 @@ static void btc_provisioner_prov_complete_cb(int node_idx, const u8_t device_uui
} }
#endif /* CONFIG_BLE_MESH_PROVISIONER */ #endif /* CONFIG_BLE_MESH_PROVISIONER */
int btc_ble_mesh_client_init(esp_ble_mesh_model_t *model) int btc_ble_mesh_client_model_init(esp_ble_mesh_model_t *model)
{ {
__ASSERT(model && model->op, "%s, Invalid parameter", __func__); __ASSERT(model && model->op, "%s, Invalid parameter", __func__);
esp_ble_mesh_model_op_t *op = model->op; esp_ble_mesh_model_op_t *op = model->op;
@ -943,7 +947,7 @@ extern const struct bt_mesh_model_op time_cli_op[];
extern const struct bt_mesh_model_op scene_cli_op[]; extern const struct bt_mesh_model_op scene_cli_op[];
extern const struct bt_mesh_model_op scheduler_cli_op[]; extern const struct bt_mesh_model_op scheduler_cli_op[];
static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model) static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
{ {
esp_ble_mesh_model_op_t *op = NULL; esp_ble_mesh_model_op_t *op = NULL;
@ -968,7 +972,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_cfg_cli_op; model->op = (esp_ble_mesh_model_op_t *)bt_mesh_cfg_cli_op;
bt_mesh_config_client_t *cli = (bt_mesh_config_client_t *)model->user_data; bt_mesh_config_client_t *cli = (bt_mesh_config_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_cfg_client_publish_callback; cli->publish_status = btc_ble_mesh_config_client_publish_callback;
} }
break; break;
} }
@ -980,7 +984,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_health_cli_op; model->op = (esp_ble_mesh_model_op_t *)bt_mesh_health_cli_op;
bt_mesh_health_client_t *cli = (bt_mesh_health_client_t *)model->user_data; bt_mesh_health_client_t *cli = (bt_mesh_health_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_health_publish_callback; cli->publish_status = btc_ble_mesh_health_publish_callback;
} }
break; break;
} }
@ -988,7 +992,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)gen_onoff_cli_op); model->op = ((esp_ble_mesh_model_op_t *)gen_onoff_cli_op);
bt_mesh_gen_onoff_client_t *cli = (bt_mesh_gen_onoff_client_t *)model->user_data; bt_mesh_gen_onoff_client_t *cli = (bt_mesh_gen_onoff_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_generic_client_publish_callback; cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
} }
break; break;
} }
@ -996,7 +1000,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)gen_level_cli_op); model->op = ((esp_ble_mesh_model_op_t *)gen_level_cli_op);
bt_mesh_gen_level_client_t *cli = (bt_mesh_gen_level_client_t *)model->user_data; bt_mesh_gen_level_client_t *cli = (bt_mesh_gen_level_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_generic_client_publish_callback; cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
} }
break; break;
} }
@ -1004,7 +1008,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)gen_def_trans_time_cli_op); model->op = ((esp_ble_mesh_model_op_t *)gen_def_trans_time_cli_op);
bt_mesh_gen_def_trans_time_client_t *cli = (bt_mesh_gen_def_trans_time_client_t *)model->user_data; bt_mesh_gen_def_trans_time_client_t *cli = (bt_mesh_gen_def_trans_time_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_generic_client_publish_callback; cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
} }
break; break;
} }
@ -1012,7 +1016,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)gen_power_onoff_cli_op); model->op = ((esp_ble_mesh_model_op_t *)gen_power_onoff_cli_op);
bt_mesh_gen_power_onoff_client_t *cli = (bt_mesh_gen_power_onoff_client_t *)model->user_data; bt_mesh_gen_power_onoff_client_t *cli = (bt_mesh_gen_power_onoff_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_generic_client_publish_callback; cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
} }
break; break;
} }
@ -1020,7 +1024,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)gen_power_level_cli_op); model->op = ((esp_ble_mesh_model_op_t *)gen_power_level_cli_op);
bt_mesh_gen_power_level_client_t *cli = (bt_mesh_gen_power_level_client_t *)model->user_data; bt_mesh_gen_power_level_client_t *cli = (bt_mesh_gen_power_level_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_generic_client_publish_callback; cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
} }
break; break;
} }
@ -1028,7 +1032,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)gen_battery_cli_op); model->op = ((esp_ble_mesh_model_op_t *)gen_battery_cli_op);
bt_mesh_gen_battery_client_t *cli = (bt_mesh_gen_battery_client_t *)model->user_data; bt_mesh_gen_battery_client_t *cli = (bt_mesh_gen_battery_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_generic_client_publish_callback; cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
} }
break; break;
} }
@ -1036,7 +1040,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)gen_location_cli_op); model->op = ((esp_ble_mesh_model_op_t *)gen_location_cli_op);
bt_mesh_gen_location_client_t *cli = (bt_mesh_gen_location_client_t *)model->user_data; bt_mesh_gen_location_client_t *cli = (bt_mesh_gen_location_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_generic_client_publish_callback; cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
} }
break; break;
} }
@ -1044,7 +1048,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)gen_property_cli_op); model->op = ((esp_ble_mesh_model_op_t *)gen_property_cli_op);
bt_mesh_gen_property_client_t *cli = (bt_mesh_gen_property_client_t *)model->user_data; bt_mesh_gen_property_client_t *cli = (bt_mesh_gen_property_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_generic_client_publish_callback; cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
} }
break; break;
} }
@ -1052,7 +1056,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)light_lightness_cli_op); model->op = ((esp_ble_mesh_model_op_t *)light_lightness_cli_op);
bt_mesh_light_lightness_client_t *cli = (bt_mesh_light_lightness_client_t *)model->user_data; bt_mesh_light_lightness_client_t *cli = (bt_mesh_light_lightness_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_light_client_publish_callback; cli->publish_status = btc_ble_mesh_lighting_client_publish_callback;
} }
break; break;
} }
@ -1060,7 +1064,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)light_ctl_cli_op); model->op = ((esp_ble_mesh_model_op_t *)light_ctl_cli_op);
bt_mesh_light_ctl_client_t *cli = (bt_mesh_light_ctl_client_t *)model->user_data; bt_mesh_light_ctl_client_t *cli = (bt_mesh_light_ctl_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_light_client_publish_callback; cli->publish_status = btc_ble_mesh_lighting_client_publish_callback;
} }
break; break;
} }
@ -1068,7 +1072,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)light_hsl_cli_op); model->op = ((esp_ble_mesh_model_op_t *)light_hsl_cli_op);
bt_mesh_light_hsl_client_t *cli = (bt_mesh_light_hsl_client_t *)model->user_data; bt_mesh_light_hsl_client_t *cli = (bt_mesh_light_hsl_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_light_client_publish_callback; cli->publish_status = btc_ble_mesh_lighting_client_publish_callback;
} }
break; break;
} }
@ -1076,7 +1080,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)light_xyl_cli_op); model->op = ((esp_ble_mesh_model_op_t *)light_xyl_cli_op);
bt_mesh_light_xyl_client_t *cli = (bt_mesh_light_xyl_client_t *)model->user_data; bt_mesh_light_xyl_client_t *cli = (bt_mesh_light_xyl_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_light_client_publish_callback; cli->publish_status = btc_ble_mesh_lighting_client_publish_callback;
} }
break; break;
} }
@ -1084,7 +1088,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)light_lc_cli_op); model->op = ((esp_ble_mesh_model_op_t *)light_lc_cli_op);
bt_mesh_light_lc_client_t *cli = (bt_mesh_light_lc_client_t *)model->user_data; bt_mesh_light_lc_client_t *cli = (bt_mesh_light_lc_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_light_client_publish_callback; cli->publish_status = btc_ble_mesh_lighting_client_publish_callback;
} }
break; break;
} }
@ -1092,7 +1096,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)sensor_cli_op); model->op = ((esp_ble_mesh_model_op_t *)sensor_cli_op);
bt_mesh_sensor_client_t *cli = (bt_mesh_sensor_client_t *)model->user_data; bt_mesh_sensor_client_t *cli = (bt_mesh_sensor_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_sensor_client_publish_callback; cli->publish_status = btc_ble_mesh_sensor_client_publish_callback;
} }
break; break;
} }
@ -1100,7 +1104,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)time_cli_op); model->op = ((esp_ble_mesh_model_op_t *)time_cli_op);
bt_mesh_time_client_t *cli = (bt_mesh_time_client_t *)model->user_data; bt_mesh_time_client_t *cli = (bt_mesh_time_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_time_scene_client_publish_callback; cli->publish_status = btc_ble_mesh_time_scene_client_publish_callback;
} }
break; break;
} }
@ -1108,7 +1112,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)scene_cli_op); model->op = ((esp_ble_mesh_model_op_t *)scene_cli_op);
bt_mesh_scene_client_t *cli = (bt_mesh_scene_client_t *)model->user_data; bt_mesh_scene_client_t *cli = (bt_mesh_scene_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_time_scene_client_publish_callback; cli->publish_status = btc_ble_mesh_time_scene_client_publish_callback;
} }
break; break;
} }
@ -1116,7 +1120,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = ((esp_ble_mesh_model_op_t *)scheduler_cli_op); model->op = ((esp_ble_mesh_model_op_t *)scheduler_cli_op);
bt_mesh_scheduler_client_t *cli = (bt_mesh_scheduler_client_t *)model->user_data; bt_mesh_scheduler_client_t *cli = (bt_mesh_scheduler_client_t *)model->user_data;
if (cli != NULL) { if (cli != NULL) {
cli->publish_status = btc_mesh_time_scene_client_publish_callback; cli->publish_status = btc_ble_mesh_time_scene_client_publish_callback;
} }
break; break;
} }
@ -1128,7 +1132,7 @@ static void btc_mesh_model_op_add(esp_ble_mesh_model_t *model)
add_model_op: add_model_op:
if (model->pub) { if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_model_publish_update; model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
} }
op = model->op; op = model->op;
while (op != NULL && op->opcode != 0) { while (op != NULL && op->opcode != 0) {
@ -1138,7 +1142,7 @@ add_model_op:
return; return;
} }
void btc_mesh_prov_call_handler(btc_msg_t *msg) void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
{ {
esp_ble_mesh_prov_cb_param_t param = {0}; esp_ble_mesh_prov_cb_param_t param = {0};
btc_ble_mesh_prov_args_t *arg = NULL; btc_ble_mesh_prov_args_t *arg = NULL;
@ -1161,10 +1165,10 @@ void btc_mesh_prov_call_handler(btc_msg_t *msg)
/* The opcode of sig model should be 1 or 2 bytes. */ /* The opcode of sig model should be 1 or 2 bytes. */
if (sig_model && sig_model->op && (sig_model->op->opcode >= 0x10000)) { if (sig_model && sig_model->op && (sig_model->op->opcode >= 0x10000)) {
err_code = -EINVAL; err_code = -EINVAL;
btc_prov_register_complete_cb(err_code); btc_ble_mesh_prov_register_complete_cb(err_code);
return; return;
} }
btc_mesh_model_op_add(sig_model); btc_ble_mesh_model_op_add(sig_model);
} }
/* For vendor models */ /* For vendor models */
for (int k = 0; k < elem->vnd_model_count; k++) { for (int k = 0; k < elem->vnd_model_count; k++) {
@ -1172,36 +1176,36 @@ void btc_mesh_prov_call_handler(btc_msg_t *msg)
/* The opcode of vendor model should be 3 bytes. */ /* The opcode of vendor model should be 3 bytes. */
if (vnd_model && vnd_model->op && vnd_model->op->opcode < 0x10000) { if (vnd_model && vnd_model->op && vnd_model->op->opcode < 0x10000) {
err_code = -EINVAL; err_code = -EINVAL;
btc_prov_register_complete_cb(err_code); btc_ble_mesh_prov_register_complete_cb(err_code);
return; return;
} }
btc_mesh_model_op_add(vnd_model); btc_ble_mesh_model_op_add(vnd_model);
} }
} }
#if CONFIG_BLE_MESH_NODE #if CONFIG_BLE_MESH_NODE
arg->mesh_init.prov->oob_pub_key_cb = (esp_ble_mesh_cb_t)btc_oob_pub_key_cb; arg->mesh_init.prov->oob_pub_key_cb = (esp_ble_mesh_cb_t)btc_ble_mesh_oob_pub_key_cb;
arg->mesh_init.prov->output_num_cb = (esp_ble_mesh_cb_t)btc_output_number_cb; arg->mesh_init.prov->output_num_cb = (esp_ble_mesh_cb_t)btc_ble_mesh_output_number_cb;
arg->mesh_init.prov->output_str_cb = (esp_ble_mesh_cb_t)btc_output_string_cb; arg->mesh_init.prov->output_str_cb = (esp_ble_mesh_cb_t)btc_ble_mesh_output_string_cb;
arg->mesh_init.prov->input_cb = (esp_ble_mesh_cb_t)btc_input_cb; arg->mesh_init.prov->input_cb = (esp_ble_mesh_cb_t)btc_ble_mesh_input_cb;
arg->mesh_init.prov->link_open_cb = (esp_ble_mesh_cb_t)btc_link_open_cb; arg->mesh_init.prov->link_open_cb = (esp_ble_mesh_cb_t)btc_ble_mesh_link_open_cb;
arg->mesh_init.prov->link_close_cb = (esp_ble_mesh_cb_t)btc_link_close_cb; arg->mesh_init.prov->link_close_cb = (esp_ble_mesh_cb_t)btc_ble_mesh_link_close_cb;
arg->mesh_init.prov->complete_cb = (esp_ble_mesh_cb_t)btc_complete_cb; arg->mesh_init.prov->complete_cb = (esp_ble_mesh_cb_t)btc_ble_mesh_complete_cb;
arg->mesh_init.prov->reset_cb = (esp_ble_mesh_cb_t)btc_reset_cb; arg->mesh_init.prov->reset_cb = (esp_ble_mesh_cb_t)btc_ble_mesh_reset_cb;
#endif /* CONFIG_BLE_MESH_NODE */ #endif /* CONFIG_BLE_MESH_NODE */
#if (CONFIG_BLE_MESH_PROVISIONER) #if CONFIG_BLE_MESH_PROVISIONER
arg->mesh_init.prov->provisioner_prov_read_oob_pub_key = (esp_ble_mesh_cb_t)btc_provisioner_prov_read_oob_pub_key_cb; arg->mesh_init.prov->provisioner_prov_read_oob_pub_key = (esp_ble_mesh_cb_t)btc_ble_mesh_provisioner_prov_read_oob_pub_key_cb;
arg->mesh_init.prov->provisioner_prov_input = (esp_ble_mesh_cb_t)btc_provisioner_prov_input_cb; arg->mesh_init.prov->provisioner_prov_input = (esp_ble_mesh_cb_t)btc_ble_mesh_provisioner_prov_input_cb;
arg->mesh_init.prov->provisioner_prov_output = (esp_ble_mesh_cb_t)btc_provisioner_prov_output_cb; arg->mesh_init.prov->provisioner_prov_output = (esp_ble_mesh_cb_t)btc_ble_mesh_provisioner_prov_output_cb;
arg->mesh_init.prov->provisioner_link_open = (esp_ble_mesh_cb_t)btc_provisioner_link_open_cb; arg->mesh_init.prov->provisioner_link_open = (esp_ble_mesh_cb_t)btc_ble_mesh_provisioner_link_open_cb;
arg->mesh_init.prov->provisioner_link_close = (esp_ble_mesh_cb_t)btc_provisioner_link_close_cb; arg->mesh_init.prov->provisioner_link_close = (esp_ble_mesh_cb_t)btc_ble_mesh_provisioner_link_close_cb;
arg->mesh_init.prov->provisioner_prov_comp = (esp_ble_mesh_cb_t)btc_provisioner_prov_complete_cb; arg->mesh_init.prov->provisioner_prov_comp = (esp_ble_mesh_cb_t)btc_ble_mesh_provisioner_prov_complete_cb;
bt_mesh_prov_adv_pkt_cb_register(btc_provisioner_recv_unprov_adv_pkt_cb); bt_mesh_prov_adv_pkt_cb_register(btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb);
#endif /* CONFIG_BLE_MESH_PROVISIONER */ #endif /* CONFIG_BLE_MESH_PROVISIONER */
err_code = bt_mesh_init((struct bt_mesh_prov *)arg->mesh_init.prov, err_code = bt_mesh_init((struct bt_mesh_prov *)arg->mesh_init.prov,
(struct bt_mesh_comp *)arg->mesh_init.comp); (struct bt_mesh_comp *)arg->mesh_init.comp);
/* Give the semaphore when BLE Mesh initialization is finished. */ /* Give the semaphore when BLE Mesh initialization is finished. */
xSemaphoreGive(arg->mesh_init.semaphore); xSemaphoreGive(arg->mesh_init.semaphore);
btc_prov_register_complete_cb(err_code); btc_ble_mesh_prov_register_complete_cb(err_code);
return; return;
} }
#if CONFIG_BLE_MESH_NODE #if CONFIG_BLE_MESH_NODE
@ -1253,7 +1257,7 @@ void btc_mesh_prov_call_handler(btc_msg_t *msg)
break; break;
#endif /* CONFIG_BLE_MESH_GATT_PROXY */ #endif /* CONFIG_BLE_MESH_GATT_PROXY */
#endif /* CONFIG_BLE_MESH_NODE */ #endif /* CONFIG_BLE_MESH_NODE */
#if (CONFIG_BLE_MESH_PROVISIONER) #if CONFIG_BLE_MESH_PROVISIONER
case BTC_BLE_MESH_ACT_PROVISIONER_READ_OOB_PUB_KEY: case BTC_BLE_MESH_ACT_PROVISIONER_READ_OOB_PUB_KEY:
act = ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_COMP_EVT; act = ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_COMP_EVT;
param.provisioner_prov_read_oob_pub_key_comp.err_code = param.provisioner_prov_read_oob_pub_key_comp.err_code =
@ -1382,7 +1386,7 @@ void btc_mesh_prov_call_handler(btc_msg_t *msg)
break; break;
} }
#endif /* CONFIG_BLE_MESH_PROVISIONER */ #endif /* CONFIG_BLE_MESH_PROVISIONER */
#if (CONFIG_BLE_MESH_FAST_PROV) #if CONFIG_BLE_MESH_FAST_PROV
case BTC_BLE_MESH_ACT_SET_FAST_PROV_INFO: case BTC_BLE_MESH_ACT_SET_FAST_PROV_INFO:
act = ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT; act = ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT;
param.set_fast_prov_info_comp.status_unicast = param.set_fast_prov_info_comp.status_unicast =
@ -1402,19 +1406,38 @@ void btc_mesh_prov_call_handler(btc_msg_t *msg)
param.set_fast_prov_action_comp.status_action = param.set_fast_prov_action_comp.status_action =
bt_mesh_set_fast_prov_action(arg->set_fast_prov_action.action); bt_mesh_set_fast_prov_action(arg->set_fast_prov_action.action);
break; break;
#endif /* (CONFIG_BLE_MESH_FAST_PROV) */ #endif /* CONFIG_BLE_MESH_FAST_PROV */
default: default:
LOG_WARN("%s, Invalid msg->act %d", __func__, msg->act); LOG_WARN("%s, Invalid msg->act %d", __func__, msg->act);
return; return;
} }
btc_prov_set_complete_cb(&param, act); btc_ble_mesh_prov_set_complete_cb(&param, act);
return; return;
} }
void btc_mesh_model_call_handler(btc_msg_t *msg) void btc_ble_mesh_prov_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_prov_cb_param_t *param = NULL;
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_prov_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_PROV_EVT_MAX) {
btc_ble_mesh_prov_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
}
void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
{ {
btc_ble_mesh_model_args_t *arg = NULL; btc_ble_mesh_model_args_t *arg = NULL;
int err;
if (!msg || !msg->arg) { if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
@ -1434,7 +1457,7 @@ void btc_mesh_model_call_handler(btc_msg_t *msg)
return; return;
} }
} }
int err = bt_mesh_model_publish((struct bt_mesh_model *)arg->model_publish.model); err = bt_mesh_model_publish((struct bt_mesh_model *)arg->model_publish.model);
btc_ble_mesh_model_publish_comp_cb(arg->model_publish.model, err); btc_ble_mesh_model_publish_comp_cb(arg->model_publish.model, err);
break; break;
} }
@ -1447,7 +1470,7 @@ void btc_mesh_model_call_handler(btc_msg_t *msg)
} }
net_buf_simple_add_mem(buf, arg->model_send.data, arg->model_send.length); net_buf_simple_add_mem(buf, arg->model_send.data, arg->model_send.length);
arg->model_send.ctx->srv_send = true; arg->model_send.ctx->srv_send = true;
int err = bt_mesh_model_send((struct bt_mesh_model *)arg->model_send.model, err = bt_mesh_model_send((struct bt_mesh_model *)arg->model_send.model,
(struct bt_mesh_msg_ctx *)arg->model_send.ctx, (struct bt_mesh_msg_ctx *)arg->model_send.ctx,
buf, NULL, NULL); buf, NULL, NULL);
bt_mesh_free_buf(buf); bt_mesh_free_buf(buf);
@ -1471,10 +1494,10 @@ void btc_mesh_model_call_handler(btc_msg_t *msg)
LOG_ERROR("%s, Failed to set model role", __func__); LOG_ERROR("%s, Failed to set model role", __func__);
return; return;
} }
int err = bt_mesh_client_send_msg((struct bt_mesh_model *)arg->model_send.model, err = bt_mesh_client_send_msg((struct bt_mesh_model *)arg->model_send.model,
arg->model_send.opcode, arg->model_send.opcode,
(struct bt_mesh_msg_ctx *)arg->model_send.ctx, buf, (struct bt_mesh_msg_ctx *)arg->model_send.ctx, buf,
btc_client_model_timeout_cb, arg->model_send.msg_timeout, btc_ble_mesh_client_model_timeout_cb, arg->model_send.msg_timeout,
arg->model_send.need_rsp, NULL, NULL); arg->model_send.need_rsp, NULL, NULL);
bt_mesh_free_buf(buf); bt_mesh_free_buf(buf);
btc_ble_mesh_model_send_comp_cb(arg->model_send.model, arg->model_send.ctx, btc_ble_mesh_model_send_comp_cb(arg->model_send.model, arg->model_send.ctx,
@ -1487,9 +1510,10 @@ void btc_mesh_model_call_handler(btc_msg_t *msg)
} }
btc_ble_mesh_prov_arg_deep_free(msg); btc_ble_mesh_prov_arg_deep_free(msg);
return;
} }
void btc_mesh_model_cb_handler(btc_msg_t *msg) void btc_ble_mesh_model_cb_handler(btc_msg_t *msg)
{ {
esp_ble_mesh_model_cb_param_t *param = NULL; esp_ble_mesh_model_cb_param_t *param = NULL;
@ -1506,23 +1530,6 @@ void btc_mesh_model_cb_handler(btc_msg_t *msg)
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act); LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
} }
btc_ble_mesh_free_req_data(msg); btc_ble_mesh_model_free_req_data(msg);
}
void btc_mesh_prov_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_prov_cb_param_t *param = NULL;
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return; return;
} }
param = (esp_ble_mesh_prov_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_PROV_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
}

View file

@ -22,12 +22,15 @@
#include "btc_ble_mesh_sensor_model.h" #include "btc_ble_mesh_sensor_model.h"
#include "esp_ble_mesh_sensor_model_api.h" #include "esp_ble_mesh_sensor_model_api.h"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_sensor_client_cb_event_t event, /* Sensor Client Models related functions */
static inline void btc_ble_mesh_sensor_client_cb_to_app(esp_ble_mesh_sensor_client_cb_event_t event,
esp_ble_mesh_sensor_client_cb_param_t *param) esp_ble_mesh_sensor_client_cb_param_t *param)
{ {
esp_ble_mesh_sensor_client_cb_t btc_mesh_cb = (esp_ble_mesh_sensor_client_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_CLIENT); esp_ble_mesh_sensor_client_cb_t btc_ble_mesh_cb =
if (btc_mesh_cb) { (esp_ble_mesh_sensor_client_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_CLIENT);
btc_mesh_cb(event, param); if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
} }
} }
@ -35,7 +38,6 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
{ {
btc_ble_mesh_sensor_client_args_t *dst = (btc_ble_mesh_sensor_client_args_t *)p_dest; btc_ble_mesh_sensor_client_args_t *dst = (btc_ble_mesh_sensor_client_args_t *)p_dest;
btc_ble_mesh_sensor_client_args_t *src = (btc_ble_mesh_sensor_client_args_t *)p_src; btc_ble_mesh_sensor_client_args_t *src = (btc_ble_mesh_sensor_client_args_t *)p_src;
u32_t opcode;
u16_t length; u16_t length;
if (!msg || !dst || !src) { if (!msg || !dst || !src) {
@ -53,8 +55,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->sensor_client_get_state.get_state, src->sensor_client_get_state.get_state, memcpy(dst->sensor_client_get_state.get_state, src->sensor_client_get_state.get_state,
sizeof(esp_ble_mesh_sensor_client_get_state_t)); sizeof(esp_ble_mesh_sensor_client_get_state_t));
opcode = src->sensor_client_get_state.params->opcode; switch (src->sensor_client_get_state.params->opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET: case ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET:
if (src->sensor_client_get_state.get_state->column_get.raw_value_x) { if (src->sensor_client_get_state.get_state->column_get.raw_value_x) {
length = src->sensor_client_get_state.get_state->column_get.raw_value_x->len; length = src->sensor_client_get_state.get_state->column_get.raw_value_x->len;
@ -109,8 +110,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->sensor_client_set_state.set_state, src->sensor_client_set_state.set_state, memcpy(dst->sensor_client_set_state.set_state, src->sensor_client_set_state.set_state,
sizeof(esp_ble_mesh_sensor_client_set_state_t)); sizeof(esp_ble_mesh_sensor_client_set_state_t));
opcode = src->sensor_client_set_state.params->opcode; switch (src->sensor_client_set_state.params->opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET: case ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET:
if (src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down) { if (src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down) {
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down->len; length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down->len;
@ -184,11 +184,71 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
} }
} }
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src) void btc_ble_mesh_sensor_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_sensor_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_sensor_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE:
if (arg->sensor_client_get_state.get_state) {
if (arg->sensor_client_get_state.params) {
switch (arg->sensor_client_get_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET:
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->column_get.raw_value_x);
break;
case ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET:
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x1);
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x2);
break;
default:
break;
}
}
osi_free(arg->sensor_client_get_state.get_state);
}
if (arg->sensor_client_get_state.params) {
osi_free(arg->sensor_client_get_state.params);
}
break;
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE:
if (arg->sensor_client_set_state.set_state) {
if (arg->sensor_client_set_state.params) {
switch (arg->sensor_client_set_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET:
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_low);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_high);
break;
case ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET:
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->setting_set.sensor_setting_raw);
break;
default:
break;
}
}
osi_free(arg->sensor_client_set_state.set_state);
}
if (arg->sensor_client_set_state.params) {
osi_free(arg->sensor_client_set_state.params);
}
break;
default:
break;
}
}
static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{ {
esp_ble_mesh_sensor_client_cb_param_t *p_dest_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_dest; esp_ble_mesh_sensor_client_cb_param_t *p_dest_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_dest;
esp_ble_mesh_sensor_client_cb_param_t *p_src_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_src; esp_ble_mesh_sensor_client_cb_param_t *p_src_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_src;
u32_t opcode;
u16_t length; u16_t length;
if (!msg || !p_src_data || !p_dest_data) { if (!msg || !p_src_data || !p_dest_data) {
@ -201,8 +261,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
case ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT: case ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT: case ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT:
if (p_src_data->params) { if (p_src_data->params) {
opcode = p_src_data->params->opcode; switch (p_src_data->params->opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET: case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET:
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS: case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS:
if (p_src_data->status_cb.descriptor_status.descriptor) { if (p_src_data->status_cb.descriptor_status.descriptor) {
@ -322,10 +381,9 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
} }
} }
static void btc_ble_mesh_free_req_data(btc_msg_t *msg) static void btc_ble_mesh_sensor_client_free_req_data(btc_msg_t *msg)
{ {
esp_ble_mesh_sensor_client_cb_param_t *arg = NULL; esp_ble_mesh_sensor_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) { if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
@ -339,8 +397,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT: case ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT: case ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT:
if (arg->params) { if (arg->params) {
opcode = arg->params->opcode; switch (arg->params->opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET: case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET:
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS: case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS:
bt_mesh_free_buf(arg->status_cb.descriptor_status.descriptor); bt_mesh_free_buf(arg->status_cb.descriptor_status.descriptor);
@ -385,73 +442,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
} }
} }
void btc_ble_mesh_sensor_client_arg_deep_free(btc_msg_t *msg) static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_param_t *cb_params, uint8_t act)
{
btc_ble_mesh_sensor_client_args_t *arg = NULL;
u32_t opcode = 0;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_sensor_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE:
if (arg->sensor_client_get_state.params) {
opcode = arg->sensor_client_get_state.params->opcode;
osi_free(arg->sensor_client_get_state.params);
}
if (arg->sensor_client_get_state.get_state) {
if (opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET:
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->column_get.raw_value_x);
break;
case ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET:
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x1);
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x2);
break;
default:
break;
}
}
osi_free(arg->sensor_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE:
if (arg->sensor_client_set_state.params) {
opcode = arg->sensor_client_set_state.params->opcode;
osi_free(arg->sensor_client_set_state.params);
}
if (arg->sensor_client_set_state.set_state) {
if (opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET:
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_low);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_high);
break;
case ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET:
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->setting_set.sensor_setting_raw);
break;
default:
break;
}
}
osi_free(arg->sensor_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
static void btc_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_param_t *cb_params, uint8_t act)
{ {
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -462,10 +453,10 @@ static void btc_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_param_
msg.act = act; msg.act = act;
btc_transfer_context(&msg, cb_params, btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_sensor_client_cb_param_t), btc_ble_mesh_copy_req_data); sizeof(esp_ble_mesh_sensor_client_cb_param_t), btc_ble_mesh_sensor_client_copy_req_data);
} }
void bt_mesh_callback_sensor_status_to_btc(u32_t opcode, u8_t evt_type, void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len) const u8_t *val, size_t len)
@ -481,16 +472,16 @@ void bt_mesh_callback_sensor_status_to_btc(u32_t opcode, u8_t evt_type,
} }
switch (evt_type) { switch (evt_type) {
case 0x00: case BTC_BLE_MESH_EVT_SENSOR_CLIENT_GET_STATE:
act = ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT; act = ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT;
break; break;
case 0x01: case BTC_BLE_MESH_EVT_SENSOR_CLIENT_SET_STATE:
act = ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT; act = ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT;
break; break;
case 0x02: case BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH:
act = ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT; act = ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT;
break; break;
case 0x03: case BTC_BLE_MESH_EVT_SENSOR_CLIENT_TIMEOUT:
act = ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT; act = ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT;
break; break;
default: default:
@ -515,25 +506,30 @@ void bt_mesh_callback_sensor_status_to_btc(u32_t opcode, u8_t evt_type,
memcpy(&cb_params.status_cb, val, length); memcpy(&cb_params.status_cb, val, length);
} }
btc_mesh_sensor_client_callback(&cb_params, act); btc_ble_mesh_sensor_client_callback(&cb_params, act);
return;
} }
void btc_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{ {
if (!model || !ctx || !buf) { if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
return; return;
} }
bt_mesh_callback_sensor_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len); bt_mesh_sensor_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
return;
} }
void btc_mesh_sensor_client_call_handler(btc_msg_t *msg) void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
{ {
esp_ble_mesh_sensor_client_cb_param_t sensor_client_cb = {0};
esp_ble_mesh_client_common_param_t *params = NULL; esp_ble_mesh_client_common_param_t *params = NULL;
btc_ble_mesh_sensor_client_args_t *arg = NULL; btc_ble_mesh_sensor_client_args_t *arg = NULL;
esp_ble_mesh_sensor_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0}; bt_mesh_client_common_param_t common = {0};
bt_mesh_role_param_t role_param = {0}; bt_mesh_role_param_t role_param = {0};
@ -562,15 +558,12 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
common.ctx.send_ttl = params->ctx.send_ttl; common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout; common.msg_timeout = params->msg_timeout;
sensor_client_cb.params = arg->sensor_client_get_state.params; cb.params = arg->sensor_client_get_state.params;
sensor_client_cb.error_code = cb.error_code = bt_mesh_sensor_client_get_state(&common,
bt_mesh_sensor_client_get_state(&common, (void *)arg->sensor_client_get_state.get_state, (void *)&cb.status_cb);
(void *)arg->sensor_client_get_state.get_state, if (cb.error_code) {
(void *)&sensor_client_cb.status_cb);
if (sensor_client_cb.error_code) {
/* If send failed, callback error_code to app layer immediately */ /* If send failed, callback error_code to app layer immediately */
btc_mesh_sensor_client_callback(&sensor_client_cb, btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT);
ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT);
} }
break; break;
} }
@ -591,15 +584,12 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
common.ctx.send_ttl = params->ctx.send_ttl; common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout; common.msg_timeout = params->msg_timeout;
sensor_client_cb.params = arg->sensor_client_set_state.params; cb.params = arg->sensor_client_set_state.params;
sensor_client_cb.error_code = cb.error_code = bt_mesh_sensor_client_set_state(&common,
bt_mesh_sensor_client_set_state(&common, (void *)arg->sensor_client_set_state.set_state, (void *)&cb.status_cb);
(void *)arg->sensor_client_set_state.set_state, if (cb.error_code) {
(void *)&sensor_client_cb.status_cb);
if (sensor_client_cb.error_code) {
/* If send failed, callback error_code to app layer immediately */ /* If send failed, callback error_code to app layer immediately */
btc_mesh_sensor_client_callback(&sensor_client_cb, btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT);
ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT);
} }
break; break;
} }
@ -608,9 +598,10 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
} }
btc_ble_mesh_sensor_client_arg_deep_free(msg); btc_ble_mesh_sensor_client_arg_deep_free(msg);
return;
} }
void btc_mesh_sensor_client_cb_handler(btc_msg_t *msg) void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
{ {
esp_ble_mesh_sensor_client_cb_param_t *param = NULL; esp_ble_mesh_sensor_client_cb_param_t *param = NULL;
@ -622,11 +613,12 @@ void btc_mesh_sensor_client_cb_handler(btc_msg_t *msg)
param = (esp_ble_mesh_sensor_client_cb_param_t *)(msg->arg); param = (esp_ble_mesh_sensor_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX) { if (msg->act < ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param); btc_ble_mesh_sensor_client_cb_to_app(msg->act, param);
} else { } else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act); LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
} }
btc_ble_mesh_free_req_data(msg); btc_ble_mesh_sensor_client_free_req_data(msg);
return;
} }

View file

@ -22,12 +22,15 @@
#include "btc_ble_mesh_time_scene_model.h" #include "btc_ble_mesh_time_scene_model.h"
#include "esp_ble_mesh_time_scene_model_api.h" #include "esp_ble_mesh_time_scene_model_api.h"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_time_scene_client_cb_event_t event, /* Time and Scenes Client Models related functions */
static inline void btc_ble_mesh_time_scene_client_cb_to_app(esp_ble_mesh_time_scene_client_cb_event_t event,
esp_ble_mesh_time_scene_client_cb_param_t *param) esp_ble_mesh_time_scene_client_cb_param_t *param)
{ {
esp_ble_mesh_time_scene_client_cb_t btc_mesh_cb = (esp_ble_mesh_time_scene_client_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT); esp_ble_mesh_time_scene_client_cb_t btc_ble_mesh_cb =
if (btc_mesh_cb) { (esp_ble_mesh_time_scene_client_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT);
btc_mesh_cb(event, param); if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
} }
} }
@ -74,11 +77,43 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
} }
} }
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src) void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_time_scene_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE:
if (arg->time_scene_client_get_state.params) {
osi_free(arg->time_scene_client_get_state.params);
}
if (arg->time_scene_client_get_state.get_state) {
osi_free(arg->time_scene_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE:
if (arg->time_scene_client_set_state.params) {
osi_free(arg->time_scene_client_set_state.params);
}
if (arg->time_scene_client_set_state.set_state) {
osi_free(arg->time_scene_client_set_state.set_state);
}
break;
default:
break;
}
}
static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{ {
esp_ble_mesh_time_scene_client_cb_param_t *p_dest_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_dest; esp_ble_mesh_time_scene_client_cb_param_t *p_dest_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_dest;
esp_ble_mesh_time_scene_client_cb_param_t *p_src_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_src; esp_ble_mesh_time_scene_client_cb_param_t *p_src_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_src;
u32_t opcode;
u16_t length; u16_t length;
if (!msg || !p_src_data || !p_dest_data) { if (!msg || !p_src_data || !p_dest_data) {
@ -91,8 +126,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
case ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT: case ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT: case ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT:
if (p_src_data->params) { if (p_src_data->params) {
opcode = p_src_data->params->opcode; switch (p_src_data->params->opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_SCENE_STORE: case ESP_BLE_MESH_MODEL_OP_SCENE_STORE:
case ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET: case ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET:
case ESP_BLE_MESH_MODEL_OP_SCENE_DELETE: case ESP_BLE_MESH_MODEL_OP_SCENE_DELETE:
@ -128,10 +162,9 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
} }
} }
static void btc_ble_mesh_free_req_data(btc_msg_t *msg) static void btc_ble_mesh_time_scene_client_free_req_data(btc_msg_t *msg)
{ {
esp_ble_mesh_time_scene_client_cb_param_t *arg = NULL; esp_ble_mesh_time_scene_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) { if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
@ -145,8 +178,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT: case ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT: case ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT:
if (arg->params) { if (arg->params) {
opcode = arg->params->opcode; switch (arg->params->opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_SCENE_STORE: case ESP_BLE_MESH_MODEL_OP_SCENE_STORE:
case ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET: case ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET:
case ESP_BLE_MESH_MODEL_OP_SCENE_DELETE: case ESP_BLE_MESH_MODEL_OP_SCENE_DELETE:
@ -167,42 +199,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
} }
} }
void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg) static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_param_t *cb_params, uint8_t act)
{
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_time_scene_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE:
if (arg->time_scene_client_get_state.params) {
osi_free(arg->time_scene_client_get_state.params);
}
if (arg->time_scene_client_get_state.get_state) {
osi_free(arg->time_scene_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE:
if (arg->time_scene_client_set_state.params) {
osi_free(arg->time_scene_client_set_state.params);
}
if (arg->time_scene_client_set_state.set_state) {
osi_free(arg->time_scene_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
static void btc_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_param_t *cb_params, uint8_t act)
{ {
btc_msg_t msg = {0}; btc_msg_t msg = {0};
@ -213,10 +210,10 @@ static void btc_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_client_c
msg.act = act; msg.act = act;
btc_transfer_context(&msg, cb_params, btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_time_scene_client_cb_param_t), btc_ble_mesh_copy_req_data); sizeof(esp_ble_mesh_time_scene_client_cb_param_t), btc_ble_mesh_time_scene_client_copy_req_data);
} }
void bt_mesh_callback_time_scene_status_to_btc(u32_t opcode, u8_t evt_type, void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len) const u8_t *val, size_t len)
@ -232,16 +229,16 @@ void bt_mesh_callback_time_scene_status_to_btc(u32_t opcode, u8_t evt_type,
} }
switch (evt_type) { switch (evt_type) {
case 0x00: case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_GET_STATE:
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT; act = ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT;
break; break;
case 0x01: case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_SET_STATE:
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT; act = ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT;
break; break;
case 0x02: case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH:
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT; act = ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT;
break; break;
case 0x03: case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_TIMEOUT:
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT; act = ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT;
break; break;
default: default:
@ -266,25 +263,30 @@ void bt_mesh_callback_time_scene_status_to_btc(u32_t opcode, u8_t evt_type,
memcpy(&cb_params.status_cb, val, length); memcpy(&cb_params.status_cb, val, length);
} }
btc_mesh_time_scene_client_callback(&cb_params, act); btc_ble_mesh_time_scene_client_callback(&cb_params, act);
return;
} }
void btc_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{ {
if (!model || !ctx || !buf) { if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__); LOG_ERROR("%s, Invalid parameter", __func__);
return; return;
} }
bt_mesh_callback_time_scene_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len); bt_mesh_time_scene_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
return;
} }
void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg) void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
{ {
esp_ble_mesh_time_scene_client_cb_param_t time_scene_client_cb = {0};
btc_ble_mesh_time_scene_client_args_t *arg = NULL; btc_ble_mesh_time_scene_client_args_t *arg = NULL;
esp_ble_mesh_client_common_param_t *params = NULL; esp_ble_mesh_client_common_param_t *params = NULL;
esp_ble_mesh_time_scene_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0}; bt_mesh_client_common_param_t common = {0};
bt_mesh_role_param_t role_param = {0}; bt_mesh_role_param_t role_param = {0};
@ -313,15 +315,12 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
common.ctx.send_ttl = params->ctx.send_ttl; common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout; common.msg_timeout = params->msg_timeout;
time_scene_client_cb.params = arg->time_scene_client_get_state.params; cb.params = arg->time_scene_client_get_state.params;
time_scene_client_cb.error_code = cb.error_code = bt_mesh_time_scene_client_get_state(&common,
bt_mesh_time_scene_client_get_state(&common, (void *)arg->time_scene_client_get_state.get_state, (void *)&cb.status_cb);
(void *)arg->time_scene_client_get_state.get_state, if (cb.error_code) {
(void *)&time_scene_client_cb.status_cb);
if (time_scene_client_cb.error_code) {
/* If send failed, callback error_code to app layer immediately */ /* If send failed, callback error_code to app layer immediately */
btc_mesh_time_scene_client_callback(&time_scene_client_cb, btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT);
ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT);
} }
break; break;
} }
@ -342,15 +341,12 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
common.ctx.send_ttl = params->ctx.send_ttl; common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout; common.msg_timeout = params->msg_timeout;
time_scene_client_cb.params = arg->time_scene_client_set_state.params; cb.params = arg->time_scene_client_set_state.params;
time_scene_client_cb.error_code = cb.error_code = bt_mesh_time_scene_client_set_state(&common,
bt_mesh_time_scene_client_set_state(&common, (void *)arg->time_scene_client_set_state.set_state, (void *)&cb.status_cb);
(void *)arg->time_scene_client_set_state.set_state, if (cb.error_code) {
(void *)&time_scene_client_cb.status_cb);
if (time_scene_client_cb.error_code) {
/* If send failed, callback error_code to app layer immediately */ /* If send failed, callback error_code to app layer immediately */
btc_mesh_time_scene_client_callback(&time_scene_client_cb, btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT);
ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT);
} }
break; break;
} }
@ -359,9 +355,10 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
} }
btc_ble_mesh_time_scene_client_arg_deep_free(msg); btc_ble_mesh_time_scene_client_arg_deep_free(msg);
return;
} }
void btc_mesh_time_scene_client_cb_handler(btc_msg_t *msg) void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
{ {
esp_ble_mesh_time_scene_client_cb_param_t *param = NULL; esp_ble_mesh_time_scene_client_cb_param_t *param = NULL;
@ -373,11 +370,12 @@ void btc_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
param = (esp_ble_mesh_time_scene_client_cb_param_t *)(msg->arg); param = (esp_ble_mesh_time_scene_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX) { if (msg->act < ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param); btc_ble_mesh_time_scene_client_cb_to_app(msg->act, param);
} else { } else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act); LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
} }
btc_ble_mesh_free_req_data(msg); btc_ble_mesh_time_scene_client_free_req_data(msg);
return;
} }

View file

@ -22,42 +22,53 @@
typedef enum { typedef enum {
BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE, BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE, BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE,
} btc_ble_mesh_cfg_client_act_t; BTC_BLE_MESH_ACT_CONFIG_CLIENT_MAX,
} btc_ble_mesh_config_client_act_t;
typedef union { typedef union {
struct ble_mesh_clg_client_get_state_reg_args { struct ble_mesh_cfg_client_get_state_reg_args {
esp_ble_mesh_client_common_param_t *params; esp_ble_mesh_client_common_param_t *params;
esp_ble_mesh_cfg_client_get_state_t *get_state; esp_ble_mesh_cfg_client_get_state_t *get_state;
} cfg_client_get_state; } cfg_client_get_state;
struct ble_mesh_clg_client_set_state_reg_args { struct ble_mesh_cfg_client_set_state_reg_args {
esp_ble_mesh_client_common_param_t *params; esp_ble_mesh_client_common_param_t *params;
esp_ble_mesh_cfg_client_set_state_t *set_state; esp_ble_mesh_cfg_client_set_state_t *set_state;
} cfg_client_set_state; } cfg_client_set_state;
} btc_ble_mesh_cfg_client_args_t; } btc_ble_mesh_config_client_args_t;
void btc_mesh_cfg_client_call_handler(btc_msg_t *msg); typedef enum {
BTC_BLE_MESH_EVT_CONFIG_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_MAX,
} btc_ble_mesh_config_client_evt_t;
void btc_mesh_cfg_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_cfg_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg);
int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params, esp_ble_mesh_cfg_client_get_state_t *get_state, void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
esp_ble_mesh_cfg_client_cb_param_t *cfg_client_cb);
int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params, esp_ble_mesh_cfg_client_set_state_t *set_state, void btc_ble_mesh_config_client_publish_callback(u32_t opcode,
esp_ble_mesh_cfg_client_cb_param_t *cfg_client_cb); struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void btc_mesh_cfg_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
void bt_mesh_callback_config_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len); const u8_t *val, size_t len);
void btc_mesh_cfg_server_cb_handler(btc_msg_t *msg); void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg);
void bt_mesh_callback_cfg_server_event_to_btc(u8_t evt_type, struct bt_mesh_model *model, typedef enum {
BTC_BLE_MESH_EVT_CONFIG_SERVER_RECV_MSG,
BTC_BLE_MESH_EVT_CONFIG_SERVER_MAX,
} btc_ble_mesh_config_server_evt_t;
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len); const u8_t *val, size_t len);

View file

@ -22,6 +22,7 @@
typedef enum { typedef enum {
BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE, BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE, BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE,
BTC_BLE_MESH_ACT_GENERIC_CLIENT_MAX,
} btc_ble_mesh_generic_client_act_t; } btc_ble_mesh_generic_client_act_t;
typedef union { typedef union {
@ -35,16 +36,26 @@ typedef union {
} generic_client_set_state; } generic_client_set_state;
} btc_ble_mesh_generic_client_args_t; } btc_ble_mesh_generic_client_args_t;
void btc_mesh_generic_client_call_handler(btc_msg_t *msg); typedef enum {
BTC_BLE_MESH_EVT_GENERIC_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_MAX,
} btc_ble_mesh_generic_client_evt_t;
void btc_mesh_generic_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, void btc_ble_mesh_generic_client_publish_callback(u32_t opcode,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type, void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len); const u8_t *val, size_t len);

View file

@ -25,11 +25,6 @@ typedef enum {
BTC_BLE_MESH_ACT_HEALTH_CLIENT_MAX, BTC_BLE_MESH_ACT_HEALTH_CLIENT_MAX,
} btc_ble_mesh_health_client_act_t; } btc_ble_mesh_health_client_act_t;
typedef enum {
BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE,
BTC_BLE_MESH_ACT_HEALTH_SERVER_MAX,
} btc_ble_mesh_health_server_act_t;
typedef union { typedef union {
struct ble_mesh_health_client_get_state_reg_args { struct ble_mesh_health_client_get_state_reg_args {
esp_ble_mesh_client_common_param_t *params; esp_ble_mesh_client_common_param_t *params;
@ -41,38 +36,45 @@ typedef union {
} health_client_set_state; } health_client_set_state;
} btc_ble_mesh_health_client_args_t; } btc_ble_mesh_health_client_args_t;
typedef enum {
BTC_BLE_MESH_EVT_HEALTH_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_MAX,
} btc_ble_mesh_health_client_evt_t;
void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_health_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, u16_t len);
typedef enum {
BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE,
BTC_BLE_MESH_ACT_HEALTH_SERVER_MAX,
} btc_ble_mesh_health_server_act_t;
typedef union { typedef union {
struct ble_mesh_health_server_fault_update_args { struct ble_mesh_health_server_fault_update_args {
esp_ble_mesh_elem_t *element; esp_ble_mesh_elem_t *element;
} fault_update; } fault_update;
} btc_ble_mesh_health_server_args_t; } btc_ble_mesh_health_server_args_t;
void btc_mesh_health_client_call_handler(btc_msg_t *msg); void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg);
void btc_mesh_health_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg);
void btc_mesh_health_server_call_handler(btc_msg_t *msg);
void btc_mesh_health_server_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_get_state_t *get_state,
esp_ble_mesh_health_client_cb_param_t *client_cb);
int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set_state,
esp_ble_mesh_health_client_cb_param_t *client_cb);
void btc_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
void bt_mesh_callback_health_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, u16_t len);
#endif /* _BTC_BLE_MESH_HEALTH_MODEL_H_ */ #endif /* _BTC_BLE_MESH_HEALTH_MODEL_H_ */

View file

@ -20,9 +20,10 @@
#include "esp_ble_mesh_lighting_model_api.h" #include "esp_ble_mesh_lighting_model_api.h"
typedef enum { typedef enum {
BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE, BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE, BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE,
} btc_ble_mesh_light_client_act_t; BTC_BLE_MESH_ACT_LIGHTING_CLIENT_MAX,
} btc_ble_mesh_lighting_client_act_t;
typedef union { typedef union {
struct ble_mesh_light_client_get_state_reg_args { struct ble_mesh_light_client_get_state_reg_args {
@ -33,18 +34,28 @@ typedef union {
esp_ble_mesh_client_common_param_t *params; esp_ble_mesh_client_common_param_t *params;
esp_ble_mesh_light_client_set_state_t *set_state; esp_ble_mesh_light_client_set_state_t *set_state;
} light_client_set_state; } light_client_set_state;
} btc_ble_mesh_light_client_args_t; } btc_ble_mesh_lighting_client_args_t;
void btc_mesh_light_client_call_handler(btc_msg_t *msg); typedef enum {
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_MAX,
} btc_ble_mesh_lighting_client_evt_t;
void btc_mesh_light_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg);
void btc_mesh_light_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type, void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len); const u8_t *val, size_t len);

View file

@ -61,7 +61,7 @@ typedef enum {
typedef enum { typedef enum {
BTC_BLE_MESH_ACT_MODEL_PUBLISH, BTC_BLE_MESH_ACT_MODEL_PUBLISH,
BTC_BLE_MESH_ACT_SERVER_MODEL_SEND, BTC_BLE_MESH_ACT_SERVER_MODEL_SEND,
BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND,
} btc_ble_mesh_model_act_t; } btc_ble_mesh_model_act_t;
typedef union { typedef union {
@ -176,11 +176,9 @@ typedef union {
} model_send; } model_send;
} btc_ble_mesh_model_args_t; } btc_ble_mesh_model_args_t;
void btc_ble_mesh_prov_arg_deep_free(btc_msg_t *msg);
void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
int btc_ble_mesh_client_init(esp_ble_mesh_model_t *model); int btc_ble_mesh_client_model_init(esp_ble_mesh_model_t *model);
int32_t btc_ble_mesh_model_pub_period_get(esp_ble_mesh_model_t *mod); int32_t btc_ble_mesh_model_pub_period_get(esp_ble_mesh_model_t *mod);
@ -200,11 +198,10 @@ esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem,
const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void); const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void);
void btc_mesh_model_call_handler(btc_msg_t *msg); void btc_ble_mesh_model_call_handler(btc_msg_t *msg);
void btc_mesh_model_cb_handler(btc_msg_t *msg); void btc_ble_mesh_model_cb_handler(btc_msg_t *msg);
void btc_mesh_prov_call_handler(btc_msg_t *msg); void btc_ble_mesh_prov_call_handler(btc_msg_t *msg);
void btc_ble_mesh_prov_cb_handler(btc_msg_t *msg);
void btc_mesh_prov_cb_handler(btc_msg_t *msg);
#endif /* _BTC_BLE_MESH_PROV_H_ */ #endif /* _BTC_BLE_MESH_PROV_H_ */

View file

@ -22,6 +22,7 @@
typedef enum { typedef enum {
BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE, BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE, BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE,
BTC_BLE_MESH_ACT_SENSOR_CLIENT_MAX,
} btc_ble_mesh_sensor_client_act_t; } btc_ble_mesh_sensor_client_act_t;
typedef union { typedef union {
@ -35,16 +36,26 @@ typedef union {
} sensor_client_set_state; } sensor_client_set_state;
} btc_ble_mesh_sensor_client_args_t; } btc_ble_mesh_sensor_client_args_t;
void btc_mesh_sensor_client_call_handler(btc_msg_t *msg); typedef enum {
BTC_BLE_MESH_EVT_SENSOR_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_MAX,
} btc_ble_mesh_sensor_client_evt_t;
void btc_mesh_sensor_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_callback_sensor_status_to_btc(u32_t opcode, u8_t evt_type, void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len); const u8_t *val, size_t len);

View file

@ -22,6 +22,7 @@
typedef enum { typedef enum {
BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE, BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE, BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE,
BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_MAX,
} btc_ble_mesh_time_scene_client_act_t; } btc_ble_mesh_time_scene_client_act_t;
typedef union { typedef union {
@ -35,16 +36,26 @@ typedef union {
} time_scene_client_set_state; } time_scene_client_set_state;
} btc_ble_mesh_time_scene_client_args_t; } btc_ble_mesh_time_scene_client_args_t;
void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg); typedef enum {
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_MAX,
} btc_ble_mesh_time_scene_client_evt_t;
void btc_mesh_time_scene_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_callback_time_scene_status_to_btc(u32_t opcode, u8_t evt_type, void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len); const u8_t *val, size_t len);

View file

@ -108,8 +108,8 @@ static void timeout_handler(struct k_work *work)
return; return;
} }
bt_mesh_callback_config_status_to_btc(node->opcode, 0x03, node->ctx.model, bt_mesh_config_client_cb_evt_to_btc(node->opcode,
&node->ctx, NULL, 0); BTC_BLE_MESH_EVT_CONFIG_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0);
bt_mesh_client_free_node(&internal->queue, node); bt_mesh_client_free_node(&internal->queue, node);
@ -163,7 +163,7 @@ static void cfg_client_cancel(struct bt_mesh_model *model,
case OP_HEARTBEAT_SUB_GET: case OP_HEARTBEAT_SUB_GET:
case OP_LPN_TIMEOUT_GET: case OP_LPN_TIMEOUT_GET:
case OP_NET_TRANSMIT_GET: case OP_NET_TRANSMIT_GET:
evt_type = 0x00; evt_type = BTC_BLE_MESH_EVT_CONFIG_CLIENT_GET_STATE;
break; break;
case OP_BEACON_SET: case OP_BEACON_SET:
case OP_DEFAULT_TTL_SET: case OP_DEFAULT_TTL_SET:
@ -193,14 +193,14 @@ static void cfg_client_cancel(struct bt_mesh_model *model,
case OP_HEARTBEAT_PUB_SET: case OP_HEARTBEAT_PUB_SET:
case OP_HEARTBEAT_SUB_SET: case OP_HEARTBEAT_SUB_SET:
case OP_NET_TRANSMIT_SET: case OP_NET_TRANSMIT_SET:
evt_type = 0x01; evt_type = BTC_BLE_MESH_EVT_CONFIG_CLIENT_SET_STATE;
break; break;
default: default:
break; break;
} }
bt_mesh_callback_config_status_to_btc(node->opcode, evt_type, model, bt_mesh_config_client_cb_evt_to_btc(
ctx, (const u8_t *)status, len); node->opcode, evt_type, model, ctx, (const u8_t *)status, len);
// Don't forget to release the node at the end. // Don't forget to release the node at the end.
bt_mesh_client_free_node(&data->queue, node); bt_mesh_client_free_node(&data->queue, node);
} }

View file

@ -522,8 +522,8 @@ static void app_key_add(struct bt_mesh_model *model,
} }
#if defined(CONFIG_BLE_MESH_FAST_PROV) #if defined(CONFIG_BLE_MESH_FAST_PROV)
bt_mesh_callback_cfg_server_event_to_btc(0x0, model, ctx, bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_RECV_MSG,
(u8_t *)&key_app_idx, sizeof(u16_t)); model, ctx, (u8_t *)&key_app_idx, sizeof(u16_t));
#endif #endif
} }

View file

@ -64,8 +64,8 @@ static void timeout_handler(struct k_work *work)
return; return;
} }
bt_mesh_callback_health_status_to_btc(node->opcode, 0x03, node->ctx.model, bt_mesh_health_client_cb_evt_to_btc(node->opcode,
&node->ctx, NULL, 0); BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0);
bt_mesh_client_free_node(&internal->queue, node); bt_mesh_client_free_node(&internal->queue, node);
@ -103,20 +103,20 @@ static void health_client_cancel(struct bt_mesh_model *model,
case OP_HEALTH_FAULT_GET: case OP_HEALTH_FAULT_GET:
case OP_HEALTH_PERIOD_GET: case OP_HEALTH_PERIOD_GET:
case OP_ATTENTION_GET: case OP_ATTENTION_GET:
evt_type = 0x00; evt_type = BTC_BLE_MESH_EVT_HEALTH_CLIENT_GET_STATE;
break; break;
case OP_HEALTH_FAULT_CLEAR: case OP_HEALTH_FAULT_CLEAR:
case OP_HEALTH_FAULT_TEST: case OP_HEALTH_FAULT_TEST:
case OP_HEALTH_PERIOD_SET: case OP_HEALTH_PERIOD_SET:
case OP_ATTENTION_SET: case OP_ATTENTION_SET:
evt_type = 0x01; evt_type = BTC_BLE_MESH_EVT_HEALTH_CLIENT_SET_STATE;
break; break;
default: default:
break; break;
} }
bt_mesh_callback_health_status_to_btc(node->opcode, evt_type, model, bt_mesh_health_client_cb_evt_to_btc(
ctx, (const u8_t *)status, len); node->opcode, evt_type, model, ctx, (const u8_t *)status, len);
// Don't forget to release the node at the end. // Don't forget to release the node at the end.
bt_mesh_client_free_node(&data->queue, node); bt_mesh_client_free_node(&data->queue, node);
} }

View file

@ -88,7 +88,7 @@ struct bt_mesh_elem {
#define BLE_MESH_MODEL_ID_GEN_BATTERY_SRV 0x100c #define BLE_MESH_MODEL_ID_GEN_BATTERY_SRV 0x100c
#define BLE_MESH_MODEL_ID_GEN_BATTERY_CLI 0x100d #define BLE_MESH_MODEL_ID_GEN_BATTERY_CLI 0x100d
#define BLE_MESH_MODEL_ID_GEN_LOCATION_SRV 0x100e #define BLE_MESH_MODEL_ID_GEN_LOCATION_SRV 0x100e
#define BLE_MESH_MODEL_ID_GEN_LOCATION_SETUPSRV 0x100f #define BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV 0x100f
#define BLE_MESH_MODEL_ID_GEN_LOCATION_CLI 0x1010 #define BLE_MESH_MODEL_ID_GEN_LOCATION_CLI 0x1010
#define BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV 0x1011 #define BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV 0x1011
#define BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV 0x1012 #define BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV 0x1012
@ -123,7 +123,7 @@ struct bt_mesh_elem {
#define BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV 0x130d #define BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV 0x130d
#define BLE_MESH_MODEL_ID_LIGHT_XYL_CLI 0x130e #define BLE_MESH_MODEL_ID_LIGHT_XYL_CLI 0x130e
#define BLE_MESH_MODEL_ID_LIGHT_LC_SRV 0x130f #define BLE_MESH_MODEL_ID_LIGHT_LC_SRV 0x130f
#define BLE_MESH_MODEL_ID_LIGHT_LC_SETUPSRV 0x1310 #define BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV 0x1310
#define BLE_MESH_MODEL_ID_LIGHT_LC_CLI 0x1311 #define BLE_MESH_MODEL_ID_LIGHT_LC_CLI 0x1311
/** Message sending context. */ /** Message sending context. */

View file

@ -59,10 +59,6 @@
#if CONFIG_BLE_MESH_SETTINGS #if CONFIG_BLE_MESH_SETTINGS
#define GET_ELEMENT_IDX(x) ((u8_t)((x) >> 8))
#define GET_MODEL_IDX(x) ((u8_t)(x))
#define GET_MODEL_KEY(a, b) ((u16_t)(((u16_t)((a) << 8)) | b))
/* Tracking of what storage changes are pending for App and Net Keys. We /* Tracking of what storage changes are pending for App and Net Keys. We
* track this in a separate array here instead of within the respective * track this in a separate array here instead of within the respective
* bt_mesh_app_key and bt_mesh_subnet structs themselves, since once a key * bt_mesh_app_key and bt_mesh_subnet structs themselves, since once a key
@ -653,8 +649,8 @@ static int model_set(bool vnd, const char *name)
for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) {
u16_t model_key = net_buf_simple_pull_le16(buf); u16_t model_key = net_buf_simple_pull_le16(buf);
elem_idx = GET_ELEMENT_IDX(model_key); elem_idx = BLE_MESH_GET_ELEM_IDX(model_key);
model_idx = GET_MODEL_IDX(model_key); model_idx = BLE_MESH_GET_MODEL_IDX(model_key);
model = bt_mesh_model_get(vnd, elem_idx, model_idx); model = bt_mesh_model_get(vnd, elem_idx, model_idx);
if (!model) { if (!model) {
@ -1196,7 +1192,7 @@ static void store_pending_mod_bind(struct bt_mesh_model *model, bool vnd)
u16_t model_key; u16_t model_key;
int err; int err;
model_key = GET_MODEL_KEY(model->elem_idx, model->model_idx); model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx);
sprintf(name, "mesh/%s/%04x/b", vnd ? "v" : "s", model_key); sprintf(name, "mesh/%s/%04x/b", vnd ? "v" : "s", model_key);
@ -1226,7 +1222,7 @@ static void store_pending_mod_sub(struct bt_mesh_model *model, bool vnd)
u16_t model_key; u16_t model_key;
int err; int err;
model_key = GET_MODEL_KEY(model->elem_idx, model->model_idx); model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx);
sprintf(name, "mesh/%s/%04x/s", vnd ? "v" : "s", model_key); sprintf(name, "mesh/%s/%04x/s", vnd ? "v" : "s", model_key);
@ -1270,7 +1266,7 @@ static void store_pending_mod_pub(struct bt_mesh_model *model, bool vnd)
pub.period_div = model->pub->period_div; pub.period_div = model->pub->period_div;
pub.cred = model->pub->cred; pub.cred = model->pub->cred;
model_key = GET_MODEL_KEY(model->elem_idx, model->model_idx); model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx);
sprintf(name, "mesh/%s/%04x/p", vnd ? "v" : "s", model_key); sprintf(name, "mesh/%s/%04x/p", vnd ? "v" : "s", model_key);

View file

@ -25,6 +25,10 @@ extern "C" {
#define SETTINGS_ITEM_SIZE sizeof(u16_t) #define SETTINGS_ITEM_SIZE sizeof(u16_t)
#define BLE_MESH_GET_ELEM_IDX(x) ((u8_t)((x) >> 8))
#define BLE_MESH_GET_MODEL_IDX(x) ((u8_t)(x))
#define BLE_MESH_GET_MODEL_KEY(a, b) ((u16_t)(((u16_t)((a) << 8)) | b))
void bt_mesh_settings_foreach(void); void bt_mesh_settings_foreach(void);
int bt_mesh_save_core_settings(const char *key, const u8_t *val, size_t len); int bt_mesh_save_core_settings(const char *key, const u8_t *val, size_t len);

View file

@ -145,8 +145,8 @@ static void timeout_handler(struct k_work *work)
return; return;
} }
bt_mesh_callback_generic_status_to_btc(node->opcode, 0x03, node->ctx.model, bt_mesh_generic_client_cb_evt_to_btc(node->opcode,
&node->ctx, NULL, 0); BTC_BLE_MESH_EVT_GENERIC_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0);
bt_mesh_client_free_node(&internal->queue, node); bt_mesh_client_free_node(&internal->queue, node);
@ -558,7 +558,7 @@ static void generic_status(struct bt_mesh_model *model,
case BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_GET: case BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_GET:
case BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_GET: case BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_GET:
case BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET: case BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET:
evt = 0x00; evt = BTC_BLE_MESH_EVT_GENERIC_CLIENT_GET_STATE;
break; break;
case BLE_MESH_MODEL_OP_GEN_ONOFF_SET: case BLE_MESH_MODEL_OP_GEN_ONOFF_SET:
case BLE_MESH_MODEL_OP_GEN_LEVEL_SET: case BLE_MESH_MODEL_OP_GEN_LEVEL_SET:
@ -574,13 +574,13 @@ static void generic_status(struct bt_mesh_model *model,
case BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET: case BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
case BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET: case BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
case BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_SET: case BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_SET:
evt = 0x01; evt = BTC_BLE_MESH_EVT_GENERIC_CLIENT_SET_STATE;
break; break;
default: default:
break; break;
} }
bt_mesh_callback_generic_status_to_btc(node->opcode, evt, model, ctx, val, len); bt_mesh_generic_client_cb_evt_to_btc(node->opcode, evt, model, ctx, val, len);
// Don't forget to release the node at the end. // Don't forget to release the node at the end.
bt_mesh_client_free_node(&internal->queue, node); bt_mesh_client_free_node(&internal->queue, node);
} }
@ -781,7 +781,7 @@ static int gen_set_state(bt_mesh_client_common_param_t *common,
case BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK: { case BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK: {
struct bt_mesh_gen_delta_set *set; struct bt_mesh_gen_delta_set *set;
set = (struct bt_mesh_gen_delta_set *)value; set = (struct bt_mesh_gen_delta_set *)value;
net_buf_simple_add_le32(msg, set->level); net_buf_simple_add_le32(msg, set->delta_level);
net_buf_simple_add_u8(msg, set->tid); net_buf_simple_add_u8(msg, set->tid);
if (set->op_en) { if (set->op_en) {
net_buf_simple_add_u8(msg, set->trans_time); net_buf_simple_add_u8(msg, set->trans_time);

View file

@ -98,7 +98,7 @@ struct bt_mesh_gen_level_set {
struct bt_mesh_gen_delta_set { struct bt_mesh_gen_delta_set {
bool op_en; /* Indicate whether optional parameters included */ bool op_en; /* Indicate whether optional parameters included */
s32_t level; /* Delta change of Generic Level state */ s32_t delta_level; /* Delta change of Generic Level state */
u8_t tid; /* Transaction Identifier */ u8_t tid; /* Transaction Identifier */
u8_t trans_time; /* Time to complete state transition (optional) */ u8_t trans_time; /* Time to complete state transition (optional) */
u8_t delay; /* Indicate message execution delay (C.1) */ u8_t delay; /* Indicate message execution delay (C.1) */

View file

@ -154,8 +154,8 @@ static void timeout_handler(struct k_work *work)
return; return;
} }
bt_mesh_callback_light_status_to_btc(node->opcode, 0x03, node->ctx.model, bt_mesh_lighting_client_cb_evt_to_btc(node->opcode,
&node->ctx, NULL, 0); BTC_BLE_MESH_EVT_LIGHTING_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0);
bt_mesh_client_free_node(&internal->queue, node); bt_mesh_client_free_node(&internal->queue, node);
@ -678,7 +678,7 @@ static void light_status(struct bt_mesh_model *model,
case BLE_MESH_MODEL_OP_LIGHT_LC_OM_GET: case BLE_MESH_MODEL_OP_LIGHT_LC_OM_GET:
case BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_GET: case BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_GET:
case BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET: case BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET:
evt = 0x00; evt = BTC_BLE_MESH_EVT_LIGHTING_CLIENT_GET_STATE;
break; break;
case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET: case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET:
case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET: case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET:
@ -700,13 +700,13 @@ static void light_status(struct bt_mesh_model *model,
case BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET: case BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET:
case BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET: case BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET:
case BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET: case BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET:
evt = 0x01; evt = BTC_BLE_MESH_EVT_LIGHTING_CLIENT_SET_STATE;
break; break;
default: default:
break; break;
} }
bt_mesh_callback_light_status_to_btc(node->opcode, evt, model, ctx, val, len); bt_mesh_lighting_client_cb_evt_to_btc(node->opcode, evt, model, ctx, val, len);
// Don't forget to release the node at the end. // Don't forget to release the node at the end.
bt_mesh_client_free_node(&internal->queue, node); bt_mesh_client_free_node(&internal->queue, node);
} }

View file

@ -83,8 +83,8 @@ static void timeout_handler(struct k_work *work)
return; return;
} }
bt_mesh_callback_sensor_status_to_btc(node->opcode, 0x03, node->ctx.model, bt_mesh_sensor_client_cb_evt_to_btc(node->opcode,
&node->ctx, NULL, 0); BTC_BLE_MESH_EVT_SENSOR_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0);
bt_mesh_client_free_node(&internal->queue, node); bt_mesh_client_free_node(&internal->queue, node);
@ -274,17 +274,17 @@ static void sensor_status(struct bt_mesh_model *model,
case BLE_MESH_MODEL_OP_SENSOR_GET: case BLE_MESH_MODEL_OP_SENSOR_GET:
case BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET: case BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET:
case BLE_MESH_MODEL_OP_SENSOR_SERIES_GET: case BLE_MESH_MODEL_OP_SENSOR_SERIES_GET:
evt = 0x00; evt = BTC_BLE_MESH_EVT_SENSOR_CLIENT_GET_STATE;
break; break;
case BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET: case BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET:
case BLE_MESH_MODEL_OP_SENSOR_SETTING_SET: case BLE_MESH_MODEL_OP_SENSOR_SETTING_SET:
evt = 0x01; evt = BTC_BLE_MESH_EVT_SENSOR_CLIENT_SET_STATE;
break; break;
default: default:
break; break;
} }
bt_mesh_callback_sensor_status_to_btc(node->opcode, evt, model, ctx, val, len); bt_mesh_sensor_client_cb_evt_to_btc(node->opcode, evt, model, ctx, val, len);
// Don't forget to release the node at the end. // Don't forget to release the node at the end.
bt_mesh_client_free_node(&internal->queue, node); bt_mesh_client_free_node(&internal->queue, node);
} }

View file

@ -99,8 +99,8 @@ static void timeout_handler(struct k_work *work)
return; return;
} }
bt_mesh_callback_time_scene_status_to_btc(node->opcode, 0x03, node->ctx.model, bt_mesh_time_scene_client_cb_evt_to_btc(node->opcode,
&node->ctx, NULL, 0); BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0);
bt_mesh_client_free_node(&internal->queue, node); bt_mesh_client_free_node(&internal->queue, node);
@ -312,7 +312,7 @@ static void time_scene_status(struct bt_mesh_model *model,
case BLE_MESH_MODEL_OP_SCENE_REGISTER_GET: case BLE_MESH_MODEL_OP_SCENE_REGISTER_GET:
case BLE_MESH_MODEL_OP_SCHEDULER_GET: case BLE_MESH_MODEL_OP_SCHEDULER_GET:
case BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET: case BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET:
evt = 0x00; evt = BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_GET_STATE;
break; break;
case BLE_MESH_MODEL_OP_TIME_SET: case BLE_MESH_MODEL_OP_TIME_SET:
case BLE_MESH_MODEL_OP_TIME_ZONE_SET: case BLE_MESH_MODEL_OP_TIME_ZONE_SET:
@ -322,13 +322,13 @@ static void time_scene_status(struct bt_mesh_model *model,
case BLE_MESH_MODEL_OP_SCENE_RECALL: case BLE_MESH_MODEL_OP_SCENE_RECALL:
case BLE_MESH_MODEL_OP_SCENE_DELETE: case BLE_MESH_MODEL_OP_SCENE_DELETE:
case BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET: case BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET:
evt = 0x01; evt = BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_SET_STATE;
break; break;
default: default:
break; break;
} }
bt_mesh_callback_time_scene_status_to_btc(node->opcode, evt, model, ctx, val, len); bt_mesh_time_scene_client_cb_evt_to_btc(node->opcode, evt, model, ctx, val, len);
// Don't forget to release the node at the end. // Don't forget to release the node at the end.
bt_mesh_client_free_node(&internal->queue, node); bt_mesh_client_free_node(&internal->queue, node);
} }