ble_mesh: Miscellaneous modifications

1. Add local AppKey and NetKey update APIs
2. NULL can be input if message has no parameters
3. Fix compile warning when BT log is disabled
4. Initilize mesh stack local variables
5. Use the latest coexist functions
This commit is contained in:
lly 2020-01-10 20:14:50 +08:00 committed by baohongde
parent c4b21e9d47
commit 3b935e3fad
76 changed files with 1835 additions and 1525 deletions

View File

@ -29,7 +29,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
btc_ble_mesh_prov_args_t arg = {0};
SemaphoreHandle_t semaphore = NULL;
btc_msg_t msg = {0};
esp_err_t ret;
esp_err_t ret = ESP_OK;
if (prov == NULL || comp == NULL) {
return ESP_ERR_INVALID_ARG;
@ -44,7 +44,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
// Create a semaphore
if ((semaphore = xSemaphoreCreateCounting(1, 0)) == NULL) {
LOG_ERROR("%s, Failed to allocate memory for the semaphore", __func__);
BT_ERR("%s, Failed to allocate memory for the semaphore", __func__);
return ESP_ERR_NO_MEM;
}
@ -59,7 +59,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
if (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL) != BT_STATUS_SUCCESS) {
vSemaphoreDelete(semaphore);
LOG_ERROR("%s, BLE Mesh initialise failed", __func__);
BT_ERR("%s, BLE Mesh initialise failed", __func__);
return ESP_FAIL;
}

View File

@ -36,17 +36,17 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
uint8_t op_len = 0, mic_len = 0;
uint8_t *msg_data = NULL;
btc_msg_t msg = {0};
esp_err_t status;
esp_err_t status = ESP_OK;
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
if (ctx && ctx->addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
LOG_ERROR("%s, Invalid destination address 0x0000", __func__);
BT_ERR("%s, Invalid destination address 0x0000", __func__);
return ESP_ERR_INVALID_ARG;
}
if (device_role > ROLE_FAST_PROV) {
LOG_ERROR("%s, Invalid device role 0x%02x", __func__, device_role);
BT_ERR("%s, Invalid device role 0x%02x", __func__, device_role);
return ESP_ERR_INVALID_ARG;
}
@ -65,7 +65,7 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
if (act == BTC_BLE_MESH_ACT_MODEL_PUBLISH) {
if (op_len + length > model->pub->msg->size) {
LOG_ERROR("%s, Model publication msg size %d is too small", __func__, model->pub->msg->size);
BT_ERR("%s, Model publication msg size %d is too small", __func__, model->pub->msg->size);
return ESP_ERR_INVALID_ARG;
}
}
@ -77,7 +77,7 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
}
if (op_len + length + mic_len > MIN(ESP_BLE_MESH_SDU_MAX_LEN, ESP_BLE_MESH_TX_SDU_MAX)) {
LOG_ERROR("%s, Data length %d is too large", __func__, length);
BT_ERR("%s, Data length %d is too large", __func__, length);
return ESP_ERR_INVALID_ARG;
}
@ -128,7 +128,7 @@ esp_err_t esp_ble_mesh_register_custom_model_callback(esp_ble_mesh_model_cb_t ca
esp_err_t esp_ble_mesh_model_msg_opcode_init(uint8_t *data, uint32_t opcode)
{
uint16_t val;
uint16_t val = 0;
if (data == NULL) {
return ESP_ERR_INVALID_ARG;
@ -379,7 +379,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SET_LOCAL_APP_KEY;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_APP_KEY;
arg.add_local_app_key.net_idx = net_idx;
arg.add_local_app_key.app_idx = app_idx;
@ -392,6 +392,29 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (app_key == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_APP_KEY;
memcpy(arg.update_local_app_key.app_key, app_key, 16);
arg.update_local_app_key.net_idx = net_idx;
arg.update_local_app_key.app_idx = app_idx;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint16_t app_idx)
{
return bt_mesh_provisioner_local_app_key_get(net_idx, app_idx);
@ -446,6 +469,27 @@ esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16],
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_update_local_net_key(const uint8_t net_key[16], uint16_t net_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (net_key == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_NET_KEY;
memcpy(arg.update_local_net_key.net_key, net_key, 16);
arg.update_local_net_key.net_idx = net_idx;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx)
{
return bt_mesh_provisioner_local_net_key_get(net_idx);

View File

@ -215,9 +215,9 @@ uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name);
/**
* @brief This function is called to store the Composition Data of the node.
*
* @param[in] addr: Element address of the node
* @param[in] data: Pointer of Composition Data
* @param[in] length: Length of Composition Data
* @param[in] unicast_addr: Element address of the node
* @param[in] data: Pointer of Composition Data
* @param[in] length: Length of Composition Data
*
* @return ESP_OK on success or error code otherwise.
*
@ -269,7 +269,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16])
esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr);
/**
* @brief This function is called to set the app key for the local BLE Mesh stack.
* @brief This function is called to add a local AppKey for Provisioner.
*
* @param[in] app_key: The app key to be set for the local BLE Mesh stack.
* @param[in] net_idx: The network key index.
@ -285,6 +285,19 @@ esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr);
*/
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx);
/**
* @brief This function is used to update a local AppKey for Provisioner.
*
* @param[in] app_key: Value of the AppKey.
* @param[in] net_idx: Corresponding NetKey Index.
* @param[in] app_idx: The AppKey Index
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx);
/**
* @brief This function is called by Provisioner to get the local app key value.
*
@ -328,6 +341,17 @@ esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_
*/
esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16], uint16_t net_idx);
/**
* @brief This function is called by Provisioner to update a local network key.
*
* @param[in] net_key: Value of the NetKey.
* @param[in] net_idx: The NetKey Index.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_update_local_net_key(const uint8_t net_key[16], uint16_t net_idx);
/**
* @brief This function is called by Provisioner to get the local network key value.
*

View File

@ -761,8 +761,10 @@ typedef enum {
ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT, /*!< Provisioner input string completion event */
ESP_BLE_MESH_PROVISIONER_SET_NODE_NAME_COMP_EVT, /*!< Provisioner set node name completion event */
ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT, /*!< Provisioner add local app key completion event */
ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT, /*!< Provisioner update local app key completion event */
ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT, /*!< Provisioner bind local model with local app key completion event */
ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT, /*!< Provisioner add local network key completion event */
ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT, /*!< Provisioner update local network key completion event */
ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT, /*!< Provisioner store node composition data completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT, /*!< Provisioner delete node with uuid completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT, /*!< Provisioner delete node with unicast address completion event */
@ -1049,6 +1051,14 @@ typedef union {
int err_code; /*!< Indicate the result of adding local AppKey by the Provisioner */
uint16_t app_idx; /*!< AppKey Index */
} provisioner_add_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT
*/
struct ble_mesh_provisioner_update_local_app_key_comp_param {
int err_code; /*!< Indicate the result of updating local AppKey by the Provisioner */
uint16_t net_idx; /*!< NetKey Index */
uint16_t app_idx; /*!< AppKey Index */
} provisioner_update_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT
*/
@ -1066,6 +1076,13 @@ typedef union {
int err_code; /*!< Indicate the result of adding local NetKey by the Provisioner */
uint16_t net_idx; /*!< NetKey Index */
} provisioner_add_net_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT
*/
struct ble_mesh_provisioner_update_local_net_key_comp_param {
int err_code; /*!< Indicate the result of updating local NetKey by the Provisioner */
uint16_t net_idx; /*!< NetKey Index */
} provisioner_update_net_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT
*/

View File

@ -33,13 +33,33 @@ esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_c
return (btc_profile_cb_set(BTC_PID_CONFIG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
static bool config_client_get_need_param(esp_ble_mesh_opcode_t opcode)
{
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET:
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET:
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET:
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET:
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
return true;
default:
return false;
}
}
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)
{
btc_ble_mesh_config_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (!params || !params->model || !ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
(config_client_get_need_param(params->opcode) && !get_state)) {
return ESP_ERR_INVALID_ARG;
}
@ -61,7 +81,8 @@ esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_
btc_ble_mesh_config_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (!params || !params->model || !ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
(params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && !set_state)) {
return ESP_ERR_INVALID_ARG;
}

View File

@ -26,13 +26,27 @@ esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_cli
return (btc_profile_cb_set(BTC_PID_GENERIC_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
static bool generic_client_get_need_param(esp_ble_mesh_opcode_t opcode)
{
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET:
return true;
default:
return false;
}
}
esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_generic_client_get_state_t *get_state)
{
btc_ble_mesh_generic_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (!params || !params->model || !params->ctx.addr ||
(generic_client_get_need_param(params->opcode) && !get_state)) {
return ESP_ERR_INVALID_ARG;
}

View File

@ -39,7 +39,8 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_
btc_ble_mesh_health_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (!params || !params->model || !params->ctx.addr || (!get_state &&
params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET)) {
return ESP_ERR_INVALID_ARG;
}

View File

@ -32,7 +32,8 @@ esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t
btc_ble_mesh_lighting_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (!params || !params->model || !params->ctx.addr || (!get_state &&
params->opcode == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET)) {
return ESP_ERR_INVALID_ARG;
}

View File

@ -32,7 +32,8 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa
btc_ble_mesh_time_scene_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (!params || !params->model || !params->ctx.addr || (!get_state &&
params->opcode == ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET)) {
return ESP_ERR_INVALID_ARG;
}

View File

@ -44,39 +44,53 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
btc_ble_mesh_config_client_args_t *src = (btc_ble_mesh_config_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE: {
dst->cfg_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->cfg_client_get_state.get_state = (esp_ble_mesh_cfg_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_cfg_client_get_state_t));
if (dst->cfg_client_get_state.params && dst->cfg_client_get_state.get_state) {
if (dst->cfg_client_get_state.params) {
memcpy(dst->cfg_client_get_state.params, src->cfg_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->cfg_client_get_state.get_state, src->cfg_client_get_state.get_state,
sizeof(esp_ble_mesh_cfg_client_get_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
break;
}
if (src->cfg_client_get_state.get_state) {
dst->cfg_client_get_state.get_state = (esp_ble_mesh_cfg_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_cfg_client_get_state_t));
if (dst->cfg_client_get_state.get_state) {
memcpy(dst->cfg_client_get_state.get_state, src->cfg_client_get_state.get_state,
sizeof(esp_ble_mesh_cfg_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
}
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE: {
dst->cfg_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->cfg_client_set_state.set_state = (esp_ble_mesh_cfg_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_cfg_client_set_state_t));
if (dst->cfg_client_set_state.params && dst->cfg_client_set_state.set_state) {
if (dst->cfg_client_set_state.params) {
memcpy(dst->cfg_client_set_state.params, src->cfg_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->cfg_client_set_state.set_state, src->cfg_client_set_state.set_state,
sizeof(esp_ble_mesh_cfg_client_set_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
break;
}
if (src->cfg_client_set_state.set_state) {
dst->cfg_client_set_state.set_state = (esp_ble_mesh_cfg_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_cfg_client_set_state_t));
if (dst->cfg_client_set_state.set_state) {
memcpy(dst->cfg_client_set_state.set_state, src->cfg_client_set_state.set_state,
sizeof(esp_ble_mesh_cfg_client_set_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@ -86,7 +100,7 @@ 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__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -118,17 +132,17 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
{
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;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
@ -147,7 +161,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.comp_data_status.composition_data->len;
p_dest_data->status_cb.comp_data_status.composition_data = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.comp_data_status.composition_data) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.comp_data_status.composition_data,
@ -163,7 +177,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.model_sub_list.sub_addr->len;
p_dest_data->status_cb.model_sub_list.sub_addr = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.model_sub_list.sub_addr) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.model_sub_list.sub_addr,
@ -177,7 +191,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.netkey_list.net_idx->len;
p_dest_data->status_cb.netkey_list.net_idx = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.netkey_list.net_idx) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.netkey_list.net_idx,
@ -191,7 +205,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.appkey_list.app_idx->len;
p_dest_data->status_cb.appkey_list.app_idx = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.appkey_list.app_idx) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.appkey_list.app_idx,
@ -207,7 +221,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.model_app_list.app_idx->len;
p_dest_data->status_cb.model_app_list.app_idx = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.model_app_list.app_idx) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.model_app_list.app_idx,
@ -231,7 +245,7 @@ static void btc_ble_mesh_config_client_free_req_data(btc_msg_t *msg)
esp_ble_mesh_cfg_client_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -285,7 +299,7 @@ static void btc_ble_mesh_config_client_callback(esp_ble_mesh_cfg_client_cb_param
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_CONFIG_CLIENT)) {
@ -307,11 +321,11 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
{
esp_ble_mesh_cfg_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -329,7 +343,7 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s, Unknown config client event type %d", __func__, evt_type);
BT_ERR("%s, Unknown config client event type %d", __func__, evt_type);
return;
}
@ -360,7 +374,7 @@ void btc_ble_mesh_config_client_publish_callback(u32_t opcode,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -376,10 +390,30 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
switch (params->opcode) {
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET:
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET:
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET:
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET:
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
if (get == NULL) {
BT_ERR("%s, Invalid config client get", __func__);
return -EINVAL;
}
break;
default:
break;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = BLE_MESH_KEY_DEV;
ctx.addr = params->ctx.addr;
@ -438,7 +472,7 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET:
return (cb->error_code = bt_mesh_cfg_net_transmit_get(&ctx));
default:
LOG_ERROR("%s, Invalid opcode 0x%x", __func__, params->opcode);
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
}
@ -451,8 +485,13 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
{
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !set || !cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
if (!params || !cb) {
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
if (params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && set == NULL) {
BT_ERR("%s, Invalid config client set", __func__);
return -EINVAL;
}
@ -591,7 +630,7 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
return (cb->error_code =
bt_mesh_cfg_net_transmit_set(&ctx, set->net_transmit_set.net_transmit));
default:
LOG_ERROR("%s, Invalid opcode 0x%x", __func__, params->opcode);
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
}
@ -605,7 +644,7 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -617,7 +656,7 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
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__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params,
@ -633,7 +672,7 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
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__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params,
@ -657,7 +696,7 @@ 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__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -666,7 +705,7 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg)
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);
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_config_client_free_req_data(msg);
@ -689,7 +728,7 @@ static void btc_ble_mesh_config_server_callback(esp_ble_mesh_cfg_server_cb_param
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_CONFIG_SERVER)) {
@ -709,11 +748,11 @@ void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
const u8_t *val, size_t len)
{
esp_ble_mesh_cfg_server_cb_param_t cb_params = {0};
size_t length;
uint8_t act;
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -722,7 +761,7 @@ void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT;
break;
default:
LOG_ERROR("%s, Unknown config server event type %d", __func__, evt_type);
BT_ERR("%s, Unknown config server event type %d", __func__, evt_type);
return;
}
@ -748,7 +787,7 @@ void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_cfg_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -757,6 +796,6 @@ void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_CFG_SERVER_EVT_MAX) {
btc_ble_mesh_config_server_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
}
}

View File

@ -37,24 +37,31 @@ 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 *src = (btc_ble_mesh_generic_client_args_t *)p_src;
u16_t length;
u16_t length = 0U;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE: {
dst->generic_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->generic_client_get_state.get_state = (esp_ble_mesh_generic_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_generic_client_get_state_t));
if (dst->generic_client_get_state.params && dst->generic_client_get_state.get_state) {
if (dst->generic_client_get_state.params) {
memcpy(dst->generic_client_get_state.params, src->generic_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->generic_client_get_state.get_state, src->generic_client_get_state.get_state,
sizeof(esp_ble_mesh_generic_client_get_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
break;
}
if (src->generic_client_get_state.get_state) {
dst->generic_client_get_state.get_state = (esp_ble_mesh_generic_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_generic_client_get_state_t));
if (dst->generic_client_get_state.get_state) {
memcpy(dst->generic_client_get_state.get_state, src->generic_client_get_state.get_state,
sizeof(esp_ble_mesh_generic_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
}
@ -73,7 +80,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
length = src->generic_client_set_state.set_state->user_property_set.property_value->len;
dst->generic_client_set_state.set_state->user_property_set.property_value = bt_mesh_alloc_buf(length);
if (!dst->generic_client_set_state.set_state->user_property_set.property_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->user_property_set.property_value,
@ -86,7 +93,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
length = src->generic_client_set_state.set_state->admin_property_set.property_value->len;
dst->generic_client_set_state.set_state->admin_property_set.property_value = bt_mesh_alloc_buf(length);
if (!dst->generic_client_set_state.set_state->admin_property_set.property_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->admin_property_set.property_value,
@ -98,12 +105,12 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
break;
}
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@ -113,7 +120,7 @@ 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__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -157,17 +164,17 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
{
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;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
@ -186,7 +193,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.user_properties_status.property_ids->len;
p_dest_data->status_cb.user_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.user_properties_status.property_ids) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.user_properties_status.property_ids,
@ -201,7 +208,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.user_property_status.property_value->len;
p_dest_data->status_cb.user_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.user_property_status.property_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.user_property_status.property_value,
@ -215,7 +222,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.admin_properties_status.property_ids->len;
p_dest_data->status_cb.admin_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.admin_properties_status.property_ids) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.admin_properties_status.property_ids,
@ -230,7 +237,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.admin_property_status.property_value->len;
p_dest_data->status_cb.admin_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.admin_property_status.property_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.admin_property_status.property_value,
@ -244,7 +251,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.manufacturer_properties_status.property_ids->len;
p_dest_data->status_cb.manufacturer_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.manufacturer_properties_status.property_ids) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_properties_status.property_ids,
@ -259,7 +266,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.manufacturer_property_status.property_value->len;
p_dest_data->status_cb.manufacturer_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.manufacturer_property_status.property_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_property_status.property_value,
@ -273,7 +280,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.client_properties_status.property_ids->len;
p_dest_data->status_cb.client_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.client_properties_status.property_ids) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.client_properties_status.property_ids,
@ -297,7 +304,7 @@ static void btc_ble_mesh_generic_client_free_req_data(btc_msg_t *msg)
esp_ble_mesh_generic_client_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -358,7 +365,7 @@ static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_GENERIC_CLIENT)) {
@ -380,11 +387,11 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
{
esp_ble_mesh_generic_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -402,7 +409,7 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s, Unknown generic client event type %d", __func__, evt_type);
BT_ERR("%s, Unknown generic client event type %d", __func__, evt_type);
return;
}
@ -433,7 +440,7 @@ void btc_ble_mesh_generic_client_publish_callback(u32_t opcode,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -451,7 +458,7 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -463,7 +470,7 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
@ -489,7 +496,7 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
@ -523,7 +530,7 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_generic_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -532,7 +539,7 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX) {
btc_ble_mesh_generic_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_generic_client_free_req_data(msg);
@ -556,10 +563,10 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
{
esp_ble_mesh_generic_server_cb_param_t *p_dest_data = (esp_ble_mesh_generic_server_cb_param_t *)p_dest;
esp_ble_mesh_generic_server_cb_param_t *p_src_data = (esp_ble_mesh_generic_server_cb_param_t *)p_src;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -572,7 +579,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->value.state_change.user_property_set.value->len;
p_dest_data->value.state_change.user_property_set.value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.user_property_set.value == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.user_property_set.value,
@ -586,7 +593,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->value.state_change.admin_property_set.value->len;
p_dest_data->value.state_change.admin_property_set.value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.admin_property_set.value == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.admin_property_set.value,
@ -606,7 +613,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->value.set.user_property.property_value->len;
p_dest_data->value.set.user_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.user_property.property_value == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.user_property.property_value,
@ -620,7 +627,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->value.set.admin_property.property_value->len;
p_dest_data->value.set.admin_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.admin_property.property_value == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.admin_property.property_value,
@ -642,7 +649,7 @@ static void btc_ble_mesh_generic_server_free_req_data(btc_msg_t *msg)
esp_ble_mesh_generic_server_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -686,7 +693,7 @@ static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_GENERIC_SERVER)) {
@ -707,11 +714,11 @@ void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
const u8_t *val, size_t len)
{
esp_ble_mesh_generic_server_cb_param_t cb_params = {0};
size_t length;
uint8_t act;
size_t length = 0U;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -726,7 +733,7 @@ void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT;
break;
default:
LOG_ERROR("%s, Unknown Generic Server event type", __func__);
BT_ERR("%s, Unknown Generic Server event type", __func__);
return;
}
@ -752,7 +759,7 @@ void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_generic_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -761,7 +768,7 @@ void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_GENERIC_SERVER_EVT_MAX) {
btc_ble_mesh_generic_server_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_generic_server_free_req_data(msg);

View File

@ -43,21 +43,28 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
btc_ble_mesh_health_client_args_t *src = (btc_ble_mesh_health_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: {
dst->health_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->health_client_get_state.get_state = (esp_ble_mesh_health_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_health_client_get_state_t));
if (dst->health_client_get_state.params && dst->health_client_get_state.get_state) {
if (dst->health_client_get_state.params) {
memcpy(dst->health_client_get_state.params, src->health_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->health_client_get_state.get_state, src->health_client_get_state.get_state,
sizeof(esp_ble_mesh_health_client_get_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
break;
}
if (src->health_client_get_state.get_state) {
dst->health_client_get_state.get_state = (esp_ble_mesh_health_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_health_client_get_state_t));
if (dst->health_client_get_state.get_state) {
memcpy(dst->health_client_get_state.get_state, src->health_client_get_state.get_state,
sizeof(esp_ble_mesh_health_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
}
@ -70,12 +77,12 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->health_client_set_state.set_state, src->health_client_set_state.set_state,
sizeof(esp_ble_mesh_health_client_set_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@ -85,7 +92,7 @@ static void btc_ble_mesh_health_client_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_health_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -117,17 +124,17 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
{
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;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
@ -145,7 +152,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.current_status.fault_array->len;
p_dest_data->status_cb.current_status.fault_array = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.current_status.fault_array) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.current_status.fault_array,
@ -161,7 +168,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.fault_status.fault_array->len;
p_dest_data->status_cb.fault_status.fault_array = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.fault_status.fault_array) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.fault_status.fault_array,
@ -185,7 +192,7 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
esp_ble_mesh_health_client_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -224,7 +231,7 @@ static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_pa
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_HEALTH_CLIENT)) {
@ -246,11 +253,11 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
{
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;
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -268,7 +275,7 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s, Unknown health client event type %d", __func__, evt_type);
BT_ERR("%s, Unknown health client event type %d", __func__, evt_type);
return;
}
@ -299,7 +306,7 @@ void btc_ble_mesh_health_publish_callback(u32_t opcode,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -315,7 +322,12 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
if (params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get == NULL) {
BT_ERR("%s, Invalid health client get", __func__);
return -EINVAL;
}
@ -335,7 +347,7 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param
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);
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
}
@ -349,7 +361,7 @@ static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !set || !cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
@ -387,7 +399,7 @@ static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param
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);
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
}
@ -401,7 +413,7 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -413,7 +425,7 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
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__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
@ -429,7 +441,7 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
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__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
@ -453,7 +465,7 @@ 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__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -462,7 +474,7 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
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);
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_health_client_free_req_data(msg);
@ -484,7 +496,7 @@ static inline void btc_ble_mesh_health_server_cb_to_app(esp_ble_mesh_health_serv
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__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -499,7 +511,7 @@ void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
static void btc_ble_mesh_health_server_arg_deep_free(btc_msg_t *msg)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -514,7 +526,7 @@ static void btc_ble_mesh_health_server_arg_deep_free(btc_msg_t *msg)
static void btc_ble_mesh_health_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -529,7 +541,7 @@ static void btc_ble_mesh_health_server_copy_req_data(btc_msg_t *msg, void *p_des
static void btc_ble_mesh_health_server_free_req_data(btc_msg_t *msg)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -545,7 +557,7 @@ static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_pa
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_HEALTH_SERVER)) {
@ -566,7 +578,7 @@ void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg)
btc_ble_mesh_health_server_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -592,7 +604,7 @@ void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_health_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -601,7 +613,7 @@ void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_HEALTH_SERVER_EVT_MAX) {
btc_ble_mesh_health_server_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_health_server_free_req_data(msg);

View File

@ -39,21 +39,28 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
btc_ble_mesh_lighting_client_args_t *src = (btc_ble_mesh_lighting_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
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.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) {
memcpy(dst->light_client_get_state.params, src->light_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->light_client_get_state.get_state, src->light_client_get_state.get_state,
sizeof(esp_ble_mesh_light_client_get_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
break;
}
if (src->light_client_get_state.get_state) {
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.get_state) {
memcpy(dst->light_client_get_state.get_state, src->light_client_get_state.get_state,
sizeof(esp_ble_mesh_light_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
}
@ -66,12 +73,12 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
memcpy(dst->light_client_set_state.set_state, src->light_client_set_state.set_state,
sizeof(esp_ble_mesh_light_client_set_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@ -81,7 +88,7 @@ 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__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -113,17 +120,17 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
{
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;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
@ -143,7 +150,7 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
length = p_src_data->status_cb.lc_property_status.property_value->len;
p_dest_data->status_cb.lc_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.lc_property_status.property_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.lc_property_status.property_value,
@ -167,7 +174,7 @@ static void btc_ble_mesh_lighting_client_free_req_data(btc_msg_t *msg)
esp_ble_mesh_light_client_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -202,7 +209,7 @@ static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_p
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_LIGHTING_CLIENT)) {
@ -224,11 +231,11 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
{
esp_ble_mesh_light_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -246,7 +253,7 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s, Unknown lighting client event type", __func__);
BT_ERR("%s, Unknown lighting client event type", __func__);
return;
}
@ -277,7 +284,7 @@ void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -295,7 +302,7 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -307,7 +314,7 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
@ -333,7 +340,7 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
@ -367,7 +374,7 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_light_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -376,7 +383,7 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX) {
btc_ble_mesh_lighting_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_lighting_client_free_req_data(msg);
@ -400,10 +407,10 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
{
esp_ble_mesh_lighting_server_cb_param_t *p_dest_data = (esp_ble_mesh_lighting_server_cb_param_t *)p_dest;
esp_ble_mesh_lighting_server_cb_param_t *p_src_data = (esp_ble_mesh_lighting_server_cb_param_t *)p_src;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -415,7 +422,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
length = p_src_data->value.state_change.lc_property_set.property_value->len;
p_dest_data->value.state_change.lc_property_set.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.lc_property_set.property_value == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.lc_property_set.property_value,
@ -431,7 +438,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
length = p_src_data->value.set.lc_property.property_value->len;
p_dest_data->value.set.lc_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.lc_property.property_value == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.lc_property.property_value,
@ -446,7 +453,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
length = p_src_data->value.status.sensor_status.data->len;
p_dest_data->value.status.sensor_status.data = bt_mesh_alloc_buf(length);
if (p_dest_data->value.status.sensor_status.data == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.status.sensor_status.data,
@ -465,7 +472,7 @@ static void btc_ble_mesh_lighting_server_free_req_data(btc_msg_t *msg)
esp_ble_mesh_lighting_server_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -498,7 +505,7 @@ static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_c
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_LIGHTING_SERVER)) {
@ -519,11 +526,11 @@ void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
const u8_t *val, size_t len)
{
esp_ble_mesh_lighting_server_cb_param_t cb_params = {0};
size_t length;
uint8_t act;
size_t length = 0U;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -541,7 +548,7 @@ void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT;
break;
default:
LOG_ERROR("%s, Unknown Lighting Server event type", __func__);
BT_ERR("%s, Unknown Lighting Server event type", __func__);
return;
}
@ -567,7 +574,7 @@ void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_lighting_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -576,7 +583,7 @@ void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_LIGHTING_SERVER_EVT_MAX) {
btc_ble_mesh_lighting_server_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_lighting_server_free_req_data(msg);

View File

@ -77,42 +77,42 @@ void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
btc_ble_mesh_prov_args_t *src = (btc_ble_mesh_prov_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR:
LOG_DEBUG("%s, BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR", __func__);
BT_DBG("%s, BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR", __func__);
dst->proxy_client_add_filter_addr.addr = (uint16_t *)osi_calloc(src->proxy_client_add_filter_addr.addr_num << 1);
if (dst->proxy_client_add_filter_addr.addr) {
memcpy(dst->proxy_client_add_filter_addr.addr, src->proxy_client_add_filter_addr.addr,
src->proxy_client_add_filter_addr.addr_num << 1);
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
case BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR:
LOG_DEBUG("%s, BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR", __func__);
BT_DBG("%s, BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR", __func__);
dst->proxy_client_remove_filter_addr.addr = osi_calloc(src->proxy_client_remove_filter_addr.addr_num << 1);
if (dst->proxy_client_remove_filter_addr.addr) {
memcpy(dst->proxy_client_remove_filter_addr.addr, src->proxy_client_remove_filter_addr.addr,
src->proxy_client_remove_filter_addr.addr_num << 1);
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
case BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA:
LOG_DEBUG("%s, BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA", __func__);
BT_DBG("%s, BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA", __func__);
dst->store_node_comp_data.data = osi_calloc(src->store_node_comp_data.length);
if (dst->store_node_comp_data.data) {
memcpy(dst->store_node_comp_data.data, src->store_node_comp_data.data, src->store_node_comp_data.length);
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@ -122,7 +122,7 @@ static void btc_ble_mesh_prov_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_prov_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -155,42 +155,42 @@ void btc_ble_mesh_model_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
btc_ble_mesh_model_args_t *src = (btc_ble_mesh_model_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_SERVER_MODEL_SEND:
case BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND: {
LOG_DEBUG("%s, BTC_BLE_MESH_ACT_MODEL_SEND, src->model_send.length = %d", __func__, src->model_send.length);
BT_DBG("%s, BTC_BLE_MESH_ACT_MODEL_SEND, src->model_send.length = %d", __func__, src->model_send.length);
dst->model_send.data = src->model_send.length ? (uint8_t *)osi_malloc(src->model_send.length) : NULL;
dst->model_send.ctx = osi_malloc(sizeof(esp_ble_mesh_msg_ctx_t));
if (src->model_send.length) {
if (dst->model_send.data) {
memcpy(dst->model_send.data, src->model_send.data, src->model_send.length);
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
if (dst->model_send.ctx) {
memcpy(dst->model_send.ctx, src->model_send.ctx, sizeof(esp_ble_mesh_msg_ctx_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
case BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE:
LOG_DEBUG("%s, BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE", __func__);
BT_DBG("%s, BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE", __func__);
dst->model_update_state.value = osi_malloc(sizeof(esp_ble_mesh_server_state_value_t));
if (dst->model_update_state.value) {
memcpy(dst->model_update_state.value, src->model_update_state.value,
sizeof(esp_ble_mesh_server_state_value_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@ -200,7 +200,7 @@ static void btc_ble_mesh_model_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_model_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -234,7 +234,7 @@ static void btc_ble_mesh_model_copy_req_data(btc_msg_t *msg, void *p_dest, void
esp_ble_mesh_model_cb_param_t *p_src_data = (esp_ble_mesh_model_cb_param_t *)p_src;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -246,13 +246,13 @@ static void btc_ble_mesh_model_copy_req_data(btc_msg_t *msg, void *p_dest, void
if (p_dest_data->model_operation.ctx) {
memcpy(p_dest_data->model_operation.ctx, p_src_data->model_operation.ctx, sizeof(esp_ble_mesh_msg_ctx_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
if (p_src_data->model_operation.length) {
if (p_dest_data->model_operation.msg) {
memcpy(p_dest_data->model_operation.msg, p_src_data->model_operation.msg, p_src_data->model_operation.length);
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
}
@ -265,13 +265,13 @@ static void btc_ble_mesh_model_copy_req_data(btc_msg_t *msg, void *p_dest, void
if (p_dest_data->client_recv_publish_msg.ctx) {
memcpy(p_dest_data->client_recv_publish_msg.ctx, p_src_data->client_recv_publish_msg.ctx, sizeof(esp_ble_mesh_msg_ctx_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
if (p_src_data->client_recv_publish_msg.length) {
if (p_dest_data->client_recv_publish_msg.msg) {
memcpy(p_dest_data->client_recv_publish_msg.msg, p_src_data->client_recv_publish_msg.msg, p_src_data->client_recv_publish_msg.length);
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
}
@ -283,7 +283,7 @@ static void btc_ble_mesh_model_copy_req_data(btc_msg_t *msg, void *p_dest, void
if (p_dest_data->model_send_comp.ctx) {
memcpy(p_dest_data->model_send_comp.ctx, p_src_data->model_send_comp.ctx, sizeof(esp_ble_mesh_msg_ctx_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
@ -294,7 +294,7 @@ static void btc_ble_mesh_model_copy_req_data(btc_msg_t *msg, void *p_dest, void
if (p_dest_data->client_send_timeout.ctx) {
memcpy(p_dest_data->client_send_timeout.ctx, p_src_data->client_send_timeout.ctx, sizeof(esp_ble_mesh_msg_ctx_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
@ -309,7 +309,7 @@ static void btc_ble_mesh_model_free_req_data(btc_msg_t *msg)
esp_ble_mesh_model_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -354,9 +354,9 @@ static void btc_ble_mesh_model_free_req_data(btc_msg_t *msg)
static bt_status_t btc_ble_mesh_model_callback(esp_ble_mesh_model_cb_param_t *param, uint8_t act)
{
btc_msg_t msg = {0};
bt_status_t ret;
bt_status_t ret = BT_STATUS_SUCCESS;
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_MODEL)) {
@ -370,7 +370,7 @@ static bt_status_t btc_ble_mesh_model_callback(esp_ble_mesh_model_cb_param_t *pa
ret = btc_transfer_context(&msg, param,
sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_model_copy_req_data);
if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s, btc_transfer_context failed", __func__);
BT_ERR("%s, btc_transfer_context failed", __func__);
}
return ret;
}
@ -399,7 +399,7 @@ static void btc_ble_mesh_client_model_op_cb(struct bt_mesh_model *model,
bt_mesh_client_node_t *node = NULL;
if (!model || !model->user_data || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -483,9 +483,9 @@ static void btc_ble_mesh_model_publish_comp_cb(esp_ble_mesh_model_t *model, int
static int btc_ble_mesh_model_publish_update(struct bt_mesh_model *mod)
{
esp_ble_mesh_model_cb_param_t mesh_param = {0};
bt_status_t ret;
bt_status_t ret = BT_STATUS_SUCCESS;
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.model_publish_update.model = (esp_ble_mesh_model_t *)mod;
@ -509,9 +509,9 @@ static void btc_ble_mesh_server_model_update_state_comp_cb(esp_ble_mesh_model_t
static bt_status_t btc_ble_mesh_prov_callback(esp_ble_mesh_prov_cb_param_t *param, uint8_t act)
{
btc_msg_t msg = {0};
bt_status_t ret;
bt_status_t ret = BT_STATUS_SUCCESS;
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_PROV)) {
@ -524,7 +524,7 @@ static bt_status_t btc_ble_mesh_prov_callback(esp_ble_mesh_prov_cb_param_t *para
ret = btc_transfer_context(&msg, param, sizeof(esp_ble_mesh_prov_cb_param_t), NULL);
if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s, btc_transfer_context failed", __func__);
BT_ERR("%s, btc_transfer_context failed", __func__);
}
return ret;
}
@ -532,7 +532,7 @@ static bt_status_t btc_ble_mesh_prov_callback(esp_ble_mesh_prov_cb_param_t *para
#if CONFIG_BLE_MESH_NODE
static void btc_ble_mesh_oob_pub_key_cb(void)
{
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
btc_ble_mesh_prov_callback(NULL, ESP_BLE_MESH_NODE_PROV_OOB_PUB_KEY_EVT);
return;
@ -541,9 +541,9 @@ static void btc_ble_mesh_oob_pub_key_cb(void)
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};
bt_status_t ret;
bt_status_t ret = BT_STATUS_SUCCESS;
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.node_prov_output_num.action = (esp_ble_mesh_output_action_t)act;
mesh_param.node_prov_output_num.number = num;
@ -555,9 +555,9 @@ static int btc_ble_mesh_output_number_cb(bt_mesh_output_action_t act, u32_t num)
static int btc_ble_mesh_output_string_cb(const char *str)
{
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
bt_status_t ret;
bt_status_t ret = BT_STATUS_SUCCESS;
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
strncpy(mesh_param.node_prov_output_str.string, str, strlen(str));
@ -568,9 +568,9 @@ static int btc_ble_mesh_output_string_cb(const char *str)
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};
bt_status_t ret;
bt_status_t ret = BT_STATUS_SUCCESS;
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.node_prov_input.action = (esp_ble_mesh_input_action_t)act;
mesh_param.node_prov_input.size = size;
@ -583,7 +583,7 @@ static void btc_ble_mesh_link_open_cb(bt_mesh_prov_bearer_t bearer)
{
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.node_prov_link_open.bearer = (esp_ble_mesh_prov_bearer_t)bearer;
@ -595,7 +595,7 @@ static void btc_ble_mesh_link_close_cb(bt_mesh_prov_bearer_t bearer)
{
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.node_prov_link_close.bearer = (esp_ble_mesh_prov_bearer_t)bearer;
@ -607,7 +607,7 @@ static void btc_ble_mesh_complete_cb(u16_t net_idx, const u8_t net_key[16], u16_
{
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.node_prov_complete.net_idx = net_idx;
memcpy(mesh_param.node_prov_complete.net_key, net_key, 16);
@ -621,7 +621,7 @@ static void btc_ble_mesh_complete_cb(u16_t net_idx, const u8_t net_key[16], u16_
static void btc_ble_mesh_reset_cb(void)
{
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
btc_ble_mesh_prov_callback(NULL, ESP_BLE_MESH_NODE_PROV_RESET_EVT);
return;
@ -632,7 +632,7 @@ static void btc_ble_mesh_prov_register_complete_cb(int err_code)
{
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.prov_register_comp.err_code = err_code;
@ -642,7 +642,7 @@ static void btc_ble_mesh_prov_register_complete_cb(int err_code)
static void btc_ble_mesh_prov_set_complete_cb(esp_ble_mesh_prov_cb_param_t *param, uint8_t act)
{
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
btc_ble_mesh_prov_callback(param, act);
return;
@ -656,11 +656,11 @@ static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb(
{
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
if (addr == NULL || dev_uuid == NULL ||
(bearer != BLE_MESH_PROV_ADV && bearer != BLE_MESH_PROV_GATT)) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -679,9 +679,9 @@ static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb(
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};
bt_status_t ret;
bt_status_t ret = BT_STATUS_SUCCESS;
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.provisioner_prov_read_oob_pub_key.link_idx = link_idx;
@ -693,9 +693,9 @@ 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};
bt_status_t ret;
bt_status_t ret = BT_STATUS_SUCCESS;
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.provisioner_prov_input.method = (esp_ble_mesh_oob_method_t)method;
mesh_param.provisioner_prov_input.action = (esp_ble_mesh_output_action_t)act;
@ -710,9 +710,9 @@ 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};
bt_status_t ret;
bt_status_t ret = BT_STATUS_SUCCESS;
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.provisioner_prov_output.method = (esp_ble_mesh_oob_method_t)method;
mesh_param.provisioner_prov_output.action = (esp_ble_mesh_input_action_t)act;
@ -732,7 +732,7 @@ 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};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.provisioner_prov_link_open.bearer = (esp_ble_mesh_prov_bearer_t)bearer;
@ -744,7 +744,7 @@ static void btc_ble_mesh_provisioner_link_close_cb(bt_mesh_prov_bearer_t bearer,
{
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.provisioner_prov_link_close.bearer = (esp_ble_mesh_prov_bearer_t)bearer;
mesh_param.provisioner_prov_link_close.reason = reason;
@ -760,7 +760,7 @@ static void btc_ble_mesh_provisioner_prov_complete_cb(
{
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.provisioner_prov_complete.node_idx = node_idx;
mesh_param.provisioner_prov_complete.unicast_addr = unicast_addr;
@ -788,7 +788,7 @@ static void btc_ble_mesh_heartbeat_msg_recv_cb(u8_t hops, u16_t feature)
{
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.heartbeat_msg_recv.hops = hops;
mesh_param.heartbeat_msg_recv.feature = feature;
@ -801,9 +801,9 @@ static void btc_ble_mesh_heartbeat_msg_recv_cb(u8_t hops, u16_t feature)
static void btc_ble_mesh_lpn_cb(u16_t friend_addr, bool established)
{
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
u8_t act;
u8_t act = 0U;
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
if (established) {
mesh_param.lpn_friendship_establish.friend_addr = friend_addr;
@ -822,12 +822,12 @@ static void btc_ble_mesh_lpn_cb(u16_t friend_addr, bool established)
void btc_ble_mesh_friend_cb(bool establish, u16_t lpn_addr, u8_t reason)
{
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
u8_t act;
u8_t act = 0U;
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
if (!BLE_MESH_ADDR_IS_UNICAST(lpn_addr)) {
LOG_ERROR("%s, Not a unicast address", __func__);
BT_ERR("%s, Not a unicast address", __func__);
return;
}
@ -852,11 +852,11 @@ static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr,
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
if (!addr || !ctx || type != BLE_MESH_PROXY_ADV_NET_ID) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.proxy_client_recv_adv_pkt.addr_type = addr->type;
memcpy(mesh_param.proxy_client_recv_adv_pkt.addr, addr->val, BD_ADDR_LEN);
@ -874,11 +874,11 @@ static void btc_ble_mesh_proxy_client_connect_cb(const bt_mesh_addr_t *addr,
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
if (!addr || conn_handle >= BLE_MESH_MAX_CONN) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.proxy_client_connected.addr_type = addr->type;
memcpy(mesh_param.proxy_client_connected.addr, addr->val, BD_ADDR_LEN);
@ -895,11 +895,11 @@ static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr,
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
if (!addr || conn_handle >= BLE_MESH_MAX_CONN) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.proxy_client_disconnected.addr_type = addr->type;
memcpy(mesh_param.proxy_client_disconnected.addr, addr->val, BD_ADDR_LEN);
@ -917,11 +917,11 @@ static void btc_ble_mesh_proxy_client_filter_status_recv_cb(u8_t conn_handle,
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
if (conn_handle >= BLE_MESH_MAX_CONN) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
mesh_param.proxy_client_recv_filter_status.conn_handle = conn_handle;
mesh_param.proxy_client_recv_filter_status.server_addr = src;
@ -1068,7 +1068,7 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
esp_ble_mesh_model_op_t *op = NULL;
if (!model) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -1423,7 +1423,7 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
model->op = (esp_ble_mesh_model_op_t *)time_setup_srv_op;
if (model->pub) {
/* Time Setup Server model does not support subscribing nor publishing. */
LOG_ERROR("%s, Time Setup Server shall not support publication", __func__);
BT_ERR("%s, Time Setup Server shall not support publication", __func__);
return;
}
break;
@ -1484,10 +1484,10 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_prov_cb_param_t param = {0};
btc_ble_mesh_prov_args_t *arg = NULL;
uint8_t act;
uint8_t act = 0U;
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -1495,7 +1495,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_MESH_INIT: {
int err_code;
int err_code = 0;
for (int i = 0; i < arg->mesh_init.comp->element_count; i++) {
esp_ble_mesh_elem_t *elem = &arg->mesh_init.comp->elements[i];
/* For SIG models */
@ -1561,17 +1561,17 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
}
#if CONFIG_BLE_MESH_NODE
case BTC_BLE_MESH_ACT_PROV_ENABLE:
LOG_DEBUG("%s, BTC_BLE_MESH_ACT_PROV_ENABLE, bearers = %d", __func__, arg->node_prov_enable.bearers);
BT_DBG("%s, BTC_BLE_MESH_ACT_PROV_ENABLE, bearers = %d", __func__, arg->node_prov_enable.bearers);
act = ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT;
param.node_prov_enable_comp.err_code = bt_mesh_prov_enable(arg->node_prov_enable.bearers);
break;
case BTC_BLE_MESH_ACT_PROV_DISABLE:
LOG_DEBUG("%s, BTC_BLE_MESH_ACT_PROV_DISABLE, bearers = %d", __func__, arg->node_prov_disable.bearers);
BT_DBG("%s, BTC_BLE_MESH_ACT_PROV_DISABLE, bearers = %d", __func__, arg->node_prov_disable.bearers);
act = ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT;
param.node_prov_disable_comp.err_code = bt_mesh_prov_disable(arg->node_prov_disable.bearers);
break;
case BTC_BLE_MESH_ACT_NODE_RESET:
LOG_DEBUG("%s, BTC_BLE_MESH_ACT_NODE_RESET", __func__);
BT_DBG("%s, BTC_BLE_MESH_ACT_NODE_RESET", __func__);
bt_mesh_reset();
return;
case BTC_BLE_MESH_ACT_SET_OOB_PUB_KEY:
@ -1713,7 +1713,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
param.provisioner_set_node_name_comp.err_code =
bt_mesh_provisioner_set_node_name(arg->set_node_name.index, arg->set_node_name.name);
break;
case BTC_BLE_MESH_ACT_PROVISIONER_SET_LOCAL_APP_KEY: {
case BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_APP_KEY: {
const u8_t *app_key = NULL;
const u8_t zero[16] = {0};
if (memcmp(arg->add_local_app_key.app_key, zero, 16)) {
@ -1726,6 +1726,14 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
&arg->add_local_app_key.app_idx);
break;
}
case BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_APP_KEY:
act = ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT;
param.provisioner_update_app_key_comp.net_idx = arg->update_local_app_key.net_idx;
param.provisioner_update_app_key_comp.app_idx = arg->update_local_app_key.app_idx;
param.provisioner_update_app_key_comp.err_code =
bt_mesh_provisioner_local_app_key_update(arg->update_local_app_key.app_key,
arg->update_local_app_key.net_idx, arg->update_local_app_key.app_idx);
break;
case BTC_BLE_MESH_ACT_PROVISIONER_BIND_LOCAL_MOD_APP:
act = ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT;
param.provisioner_bind_app_key_to_model_comp.element_addr = arg->local_mod_app_bind.elem_addr;
@ -1750,6 +1758,13 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
bt_mesh_provisioner_local_net_key_add(net_key, &arg->add_local_net_key.net_idx);
break;
}
case BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_NET_KEY:
act = ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT;
param.provisioner_update_net_key_comp.net_idx = arg->update_local_net_key.net_idx;
param.provisioner_update_net_key_comp.err_code =
bt_mesh_provisioner_local_net_key_update(arg->update_local_net_key.net_key,
arg->update_local_net_key.net_idx);
break;
case BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA:
act = ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT;
param.provisioner_store_node_comp_data_comp.addr = arg->store_node_comp_data.unicast_addr;
@ -1865,7 +1880,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
}
#endif /* CONFIG_BLE_MESH_GATT_PROXY_CLIENT */
default:
LOG_WARN("%s, Invalid msg->act %d", __func__, msg->act);
BT_WARN("%s, Invalid msg->act %d", __func__, msg->act);
return;
}
@ -1883,7 +1898,7 @@ 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__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -1892,17 +1907,17 @@ void btc_ble_mesh_prov_cb_handler(btc_msg_t *msg)
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);
BT_ERR("%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;
int err;
int err = 0;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -1915,7 +1930,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
common.model = (struct bt_mesh_model *)(arg->model_publish.model);
common.role = arg->model_publish.device_role;
if (bt_mesh_set_client_model_role(&common)) {
LOG_ERROR("%s, Failed to set model role", __func__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
}
@ -1927,7 +1942,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
/* arg->model_send.length contains opcode & message, 8 is used for TransMIC */
struct net_buf_simple *buf = bt_mesh_alloc_buf(arg->model_send.length + 8);
if (!buf) {
LOG_ERROR("%s, Failed to allocate memory", __func__);
BT_ERR("%s, Failed to allocate memory", __func__);
break;
}
net_buf_simple_add_mem(buf, arg->model_send.data, arg->model_send.length);
@ -1945,7 +1960,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
/* arg->model_send.length contains opcode & message, 8 is used for TransMIC */
struct net_buf_simple *buf = bt_mesh_alloc_buf(arg->model_send.length + 8);
if (!buf) {
LOG_ERROR("%s, Failed to allocate memory", __func__);
BT_ERR("%s, Failed to allocate memory", __func__);
break;
}
net_buf_simple_add_mem(buf, arg->model_send.data, arg->model_send.length);
@ -1953,7 +1968,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
common.model = (struct bt_mesh_model *)(arg->model_send.model);
common.role = arg->model_send.device_role;
if (bt_mesh_set_client_model_role(&common)) {
LOG_ERROR("%s, Failed to set model role", __func__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
err = bt_mesh_client_send_msg((struct bt_mesh_model *)arg->model_send.model,
@ -1974,7 +1989,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
arg->model_update_state.type, err);
break;
default:
LOG_WARN("%s, Unknown msg->act %d", __func__, msg->act);
BT_WARN("%s, Unknown msg->act %d", __func__, msg->act);
break;
}
@ -1987,7 +2002,7 @@ void btc_ble_mesh_model_cb_handler(btc_msg_t *msg)
esp_ble_mesh_model_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -1996,7 +2011,7 @@ void btc_ble_mesh_model_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_MODEL_EVT_MAX) {
btc_ble_mesh_model_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_model_free_req_data(msg);

View File

@ -37,10 +37,10 @@ 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 *src = (btc_ble_mesh_sensor_client_args_t *)p_src;
u16_t length;
u16_t length = 0U;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -60,7 +60,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_get_state.get_state->column_get.raw_value_x->len;
dst->sensor_client_get_state.get_state->column_get.raw_value_x = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_get_state.get_state->column_get.raw_value_x) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->column_get.raw_value_x,
@ -73,7 +73,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_get_state.get_state->series_get.raw_value_x1->len;
dst->sensor_client_get_state.get_state->series_get.raw_value_x1 = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x1) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x1,
@ -84,7 +84,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_get_state.get_state->series_get.raw_value_x2->len;
dst->sensor_client_get_state.get_state->series_get.raw_value_x2 = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x2) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x2,
@ -96,7 +96,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
break;
}
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
@ -115,7 +115,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down->len;
dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down,
@ -126,7 +126,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up->len;
dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up,
@ -137,7 +137,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_low->len;
dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low,
@ -148,7 +148,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_high->len;
dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high,
@ -161,7 +161,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->setting_set.sensor_setting_raw->len;
dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw,
@ -173,12 +173,12 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
break;
}
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@ -188,7 +188,7 @@ 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__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -248,17 +248,17 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
{
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;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
@ -277,7 +277,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.descriptor_status.descriptor->len;
p_dest_data->status_cb.descriptor_status.descriptor = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.descriptor_status.descriptor) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.descriptor_status.descriptor,
@ -292,7 +292,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.cadence_status.sensor_cadence_value->len;
p_dest_data->status_cb.cadence_status.sensor_cadence_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.cadence_status.sensor_cadence_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.cadence_status.sensor_cadence_value,
@ -306,7 +306,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.settings_status.sensor_setting_property_ids->len;
p_dest_data->status_cb.settings_status.sensor_setting_property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.settings_status.sensor_setting_property_ids) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.settings_status.sensor_setting_property_ids,
@ -321,7 +321,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.setting_status.sensor_setting_raw->len;
p_dest_data->status_cb.setting_status.sensor_setting_raw = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.setting_status.sensor_setting_raw) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.setting_status.sensor_setting_raw,
@ -335,7 +335,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.sensor_status.marshalled_sensor_data->len;
p_dest_data->status_cb.sensor_status.marshalled_sensor_data = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.sensor_status.marshalled_sensor_data) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.sensor_status.marshalled_sensor_data,
@ -349,7 +349,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.column_status.sensor_column_value->len;
p_dest_data->status_cb.column_status.sensor_column_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.column_status.sensor_column_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.column_status.sensor_column_value,
@ -363,7 +363,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.series_status.sensor_series_value->len;
p_dest_data->status_cb.series_status.sensor_series_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.series_status.sensor_series_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.series_status.sensor_series_value,
@ -387,7 +387,7 @@ static void btc_ble_mesh_sensor_client_free_req_data(btc_msg_t *msg)
esp_ble_mesh_sensor_client_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -447,7 +447,7 @@ static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_pa
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_SENSOR_CLIENT)) {
@ -469,11 +469,11 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
{
esp_ble_mesh_sensor_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -491,7 +491,7 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s, Unknown sensor client event type %d", __func__, evt_type);
BT_ERR("%s, Unknown sensor client event type %d", __func__, evt_type);
return;
}
@ -522,7 +522,7 @@ void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -540,7 +540,7 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -552,7 +552,7 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
@ -578,7 +578,7 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
@ -612,7 +612,7 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_sensor_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -621,7 +621,7 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX) {
btc_ble_mesh_sensor_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_sensor_client_free_req_data(msg);
@ -645,10 +645,10 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
{
esp_ble_mesh_sensor_server_cb_param_t *p_dest_data = (esp_ble_mesh_sensor_server_cb_param_t *)p_dest;
esp_ble_mesh_sensor_server_cb_param_t *p_src_data = (esp_ble_mesh_sensor_server_cb_param_t *)p_src;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -660,7 +660,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->len;
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down,
@ -671,7 +671,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->len;
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up,
@ -682,7 +682,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->len;
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low,
@ -693,7 +693,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->len;
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high,
@ -706,7 +706,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_setting_set.setting_value->len;
p_dest_data->value.state_change.sensor_setting_set.setting_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_setting_set.setting_value == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_setting_set.setting_value,
@ -721,7 +721,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.get.sensor_column.raw_value_x->len;
p_dest_data->value.get.sensor_column.raw_value_x = bt_mesh_alloc_buf(length);
if (p_dest_data->value.get.sensor_column.raw_value_x == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.get.sensor_column.raw_value_x,
@ -733,7 +733,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.get.sensor_series.raw_value->len;
p_dest_data->value.get.sensor_series.raw_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.get.sensor_series.raw_value == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.get.sensor_series.raw_value,
@ -749,7 +749,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.set.sensor_cadence.cadence->len;
p_dest_data->value.set.sensor_cadence.cadence = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.sensor_cadence.cadence == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.sensor_cadence.cadence,
@ -762,7 +762,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.set.sensor_setting.setting_raw->len;
p_dest_data->value.set.sensor_setting.setting_raw = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.sensor_setting.setting_raw == NULL) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.sensor_setting.setting_raw,
@ -781,7 +781,7 @@ static void btc_ble_mesh_sensor_server_free_req_data(btc_msg_t *msg)
esp_ble_mesh_sensor_server_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -825,7 +825,7 @@ static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_pa
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_SENSOR_SERVER)) {
@ -846,11 +846,11 @@ void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
const u8_t *val, size_t len)
{
esp_ble_mesh_sensor_server_cb_param_t cb_params = {0};
size_t length;
uint8_t act;
size_t length = 0U;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -865,7 +865,7 @@ void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT;
break;
default:
LOG_ERROR("%s, Unknown Sensor Server event type", __func__);
BT_ERR("%s, Unknown Sensor Server event type", __func__);
return;
}
@ -891,7 +891,7 @@ void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_sensor_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -900,7 +900,7 @@ void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_SENSOR_SERVER_EVT_MAX) {
btc_ble_mesh_sensor_server_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_sensor_server_free_req_data(msg);

View File

@ -39,21 +39,28 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
btc_ble_mesh_time_scene_client_args_t *src = (btc_ble_mesh_time_scene_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE: {
dst->time_scene_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->time_scene_client_get_state.get_state = (esp_ble_mesh_time_scene_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_time_scene_client_get_state_t));
if (dst->time_scene_client_get_state.params && dst->time_scene_client_get_state.get_state) {
if (dst->time_scene_client_get_state.params) {
memcpy(dst->time_scene_client_get_state.params, src->time_scene_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->time_scene_client_get_state.get_state, src->time_scene_client_get_state.get_state,
sizeof(esp_ble_mesh_time_scene_client_get_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
break;
}
if (src->time_scene_client_get_state.get_state) {
dst->time_scene_client_get_state.get_state = (esp_ble_mesh_time_scene_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_time_scene_client_get_state_t));
if (dst->time_scene_client_get_state.get_state) {
memcpy(dst->time_scene_client_get_state.get_state, src->time_scene_client_get_state.get_state,
sizeof(esp_ble_mesh_time_scene_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
}
@ -66,12 +73,12 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
memcpy(dst->time_scene_client_set_state.set_state, src->time_scene_client_set_state.set_state,
sizeof(esp_ble_mesh_time_scene_client_set_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@ -81,7 +88,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -113,17 +120,17 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
{
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;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
@ -144,7 +151,7 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
length = p_src_data->status_cb.scene_register_status.scenes->len;
p_dest_data->status_cb.scene_register_status.scenes = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.scene_register_status.scenes) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.scene_register_status.scenes,
@ -168,7 +175,7 @@ static void btc_ble_mesh_time_scene_client_free_req_data(btc_msg_t *msg)
esp_ble_mesh_time_scene_client_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -204,7 +211,7 @@ static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_clie
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT)) {
@ -226,11 +233,11 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
{
esp_ble_mesh_time_scene_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -248,7 +255,7 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s, Unknown time scene client event type %d", __func__, evt_type);
BT_ERR("%s, Unknown time scene client event type %d", __func__, evt_type);
return;
}
@ -279,7 +286,7 @@ void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -297,7 +304,7 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -309,7 +316,7 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
@ -335,7 +342,7 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
@ -369,7 +376,7 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_time_scene_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -378,7 +385,7 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX) {
btc_ble_mesh_time_scene_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_time_scene_client_free_req_data(msg);
@ -402,7 +409,7 @@ static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_serv
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_TIME_SCENE_SERVER)) {
@ -423,11 +430,11 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
const u8_t *val, size_t len)
{
esp_ble_mesh_time_scene_server_cb_param_t cb_params = {0};
size_t length;
uint8_t act;
size_t length = 0U;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -445,7 +452,7 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT;
break;
default:
LOG_ERROR("%s, Unknown Time Scene Server event type", __func__);
BT_ERR("%s, Unknown Time Scene Server event type", __func__);
return;
}
@ -471,7 +478,7 @@ void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_time_scene_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -480,7 +487,7 @@ void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX) {
btc_ble_mesh_time_scene_server_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
}
return;

View File

@ -45,9 +45,11 @@ typedef enum {
BTC_BLE_MESH_ACT_PROVISIONER_SET_STATIC_OOB_VAL,
BTC_BLE_MESH_ACT_PROVISIONER_SET_PRIMARY_ELEM_ADDR,
BTC_BLE_MESH_ACT_PROVISIONER_SET_NODE_NAME,
BTC_BLE_MESH_ACT_PROVISIONER_SET_LOCAL_APP_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_APP_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_APP_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_BIND_LOCAL_MOD_APP,
BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_NET_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_NET_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA,
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_UUID,
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_ADDR,
@ -155,6 +157,11 @@ typedef union {
uint16_t net_idx;
uint16_t app_idx;
} add_local_app_key;
struct ble_mesh_provisioner_update_local_app_key_args {
uint8_t app_key[16];
uint16_t net_idx;
uint16_t app_idx;
} update_local_app_key;
struct ble_mesh_provisioner_bind_local_mod_app_args {
uint16_t elem_addr;
uint16_t model_id;
@ -165,6 +172,10 @@ typedef union {
uint8_t net_key[16];
uint16_t net_idx;
} add_local_net_key;
struct ble_mesh_provisioner_update_local_net_key_args {
uint8_t net_key[16];
uint16_t net_idx;
} update_local_net_key;
struct ble_mesh_provisioner_store_node_comp_data_args {
uint16_t unicast_addr;
uint16_t length;

View File

@ -46,12 +46,6 @@
#define MESH_TRACE_TAG "BLE_MESH"
#define LOG_ERROR(format, ... ) {if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR) esp_log_write(ESP_LOG_ERROR, "BT_LOG", LOG_FORMAT(E, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); }
#define LOG_WARN(format, ... ) {if (LOG_LOCAL_LEVEL >= ESP_LOG_WARN) esp_log_write(ESP_LOG_WARN, "BT_LOG", LOG_FORMAT(W, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); }
#define LOG_INFO(format, ... ) {if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) esp_log_write(ESP_LOG_INFO, "BT_LOG", LOG_FORMAT(I, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); }
#define LOG_DEBUG(format, ... ) {if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) esp_log_write(ESP_LOG_DEBUG, "BT_LOG", LOG_FORMAT(D, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); }
#define LOG_VERBOSE(format, ... ) {if (LOG_LOCAL_LEVEL >= ESP_LOG_VERBOSE) esp_log_write(ESP_LOG_VERBOSE, "BT_LOG", LOG_FORMAT(V, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__); }
#if (LOG_LOCAL_LEVEL >= 4)
#define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING (LOG_LOCAL_LEVEL + 1)
#else

View File

@ -161,7 +161,7 @@ static inline void mult_row_column(uint8_t *out, const uint8_t *in)
static inline void mix_columns(uint8_t *s)
{
uint8_t t[Nb * Nk];
uint8_t t[Nb * Nk] = {0};
mult_row_column(t, s);
mult_row_column(&t[Nb], s + Nb);
@ -176,7 +176,7 @@ static inline void mix_columns(uint8_t *s)
*/
static inline void shift_rows(uint8_t *s)
{
uint8_t t[Nb * Nk];
uint8_t t[Nb * Nk] = {0};
t[0] = s[0]; t[1] = s[5]; t[2] = s[10]; t[3] = s[15];
t[4] = s[4]; t[5] = s[9]; t[6] = s[14]; t[7] = s[3];
@ -187,7 +187,7 @@ static inline void shift_rows(uint8_t *s)
int tc_aes_encrypt(uint8_t *out, const uint8_t *in, const TCAesKeySched_t s)
{
uint8_t state[Nk * Nb];
uint8_t state[Nk * Nb] = {0};
unsigned int i;
if (out == (uint8_t *) 0) {
@ -363,7 +363,7 @@ int tc_cmac_update(TCCmacState_t s, const uint8_t *data, size_t data_length)
int tc_cmac_final(uint8_t *tag, TCCmacState_t s)
{
uint8_t *k;
uint8_t *k = NULL;
unsigned int i;
/* input sanity check: */

View File

@ -54,7 +54,7 @@ bt_mesh_atomic_val_t bt_mesh_atomic_get(const bt_mesh_atomic_t *target)
*/
bt_mesh_atomic_val_t bt_mesh_atomic_set(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value)
{
bt_mesh_atomic_val_t ret;
bt_mesh_atomic_val_t ret = 0;
bt_mesh_atomic_lock();
@ -81,7 +81,7 @@ bt_mesh_atomic_val_t bt_mesh_atomic_set(bt_mesh_atomic_t *target, bt_mesh_atomic
*/
bt_mesh_atomic_val_t bt_mesh_atomic_or(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value)
{
bt_mesh_atomic_val_t ret;
bt_mesh_atomic_val_t ret = 0;
bt_mesh_atomic_lock();
@ -108,7 +108,7 @@ bt_mesh_atomic_val_t bt_mesh_atomic_or(bt_mesh_atomic_t *target, bt_mesh_atomic_
*/
bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value)
{
bt_mesh_atomic_val_t ret;
bt_mesh_atomic_val_t ret = 0;
bt_mesh_atomic_lock();
@ -133,7 +133,7 @@ bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, bt_mesh_atomic
*/
bt_mesh_atomic_val_t bt_mesh_atomic_dec(bt_mesh_atomic_t *target)
{
bt_mesh_atomic_val_t ret;
bt_mesh_atomic_val_t ret = 0;
bt_mesh_atomic_lock();
@ -158,7 +158,7 @@ bt_mesh_atomic_val_t bt_mesh_atomic_dec(bt_mesh_atomic_t *target)
*/
bt_mesh_atomic_val_t bt_mesh_atomic_inc(bt_mesh_atomic_t *target)
{
bt_mesh_atomic_val_t ret;
bt_mesh_atomic_val_t ret = 0;
bt_mesh_atomic_lock();

View File

@ -21,7 +21,7 @@ int net_buf_id(struct net_buf *buf)
static inline struct net_buf *pool_get_uninit(struct net_buf_pool *pool,
u16_t uninit_count)
{
struct net_buf *buf;
struct net_buf *buf = NULL;
buf = &pool->__bufs[pool->buf_count - uninit_count];
@ -58,7 +58,7 @@ void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem,
u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val)
{
u8_t *u8;
u8_t *u8 = NULL;
NET_BUF_SIMPLE_DBG("buf %p val 0x%02x", buf, val);
@ -160,7 +160,7 @@ void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len)
u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf)
{
u8_t val;
u8_t val = 0U;
val = buf->data[0];
net_buf_simple_pull(buf, 1);
@ -170,7 +170,7 @@ u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf)
u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf)
{
u16_t val;
u16_t val = 0U;
val = UNALIGNED_GET((u16_t *)buf->data);
net_buf_simple_pull(buf, sizeof(val));
@ -180,7 +180,7 @@ u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf)
u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf)
{
u16_t val;
u16_t val = 0U;
val = UNALIGNED_GET((u16_t *)buf->data);
net_buf_simple_pull(buf, sizeof(val));
@ -190,7 +190,7 @@ u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf)
u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf)
{
u32_t val;
u32_t val = 0U;
val = UNALIGNED_GET((u32_t *)buf->data);
net_buf_simple_pull(buf, sizeof(val));
@ -200,7 +200,7 @@ u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf)
u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf)
{
u32_t val;
u32_t val = 0U;
val = UNALIGNED_GET((u32_t *)buf->data);
net_buf_simple_pull(buf, sizeof(val));
@ -237,7 +237,7 @@ void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve)
void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf)
{
struct net_buf *tail;
struct net_buf *tail = NULL;
NET_BUF_ASSERT(list);
NET_BUF_ASSERT(buf);
@ -253,7 +253,7 @@ void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf)
struct net_buf *net_buf_slist_get(sys_slist_t *list)
{
struct net_buf *buf, *frag;
struct net_buf *buf = NULL, *frag = NULL;
NET_BUF_ASSERT(list);
@ -303,7 +303,7 @@ void net_buf_unref(struct net_buf *buf)
while (buf) {
struct net_buf *frags = buf->frags;
struct net_buf_pool *pool;
struct net_buf_pool *pool = NULL;
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
if (!buf->ref) {
@ -498,7 +498,7 @@ struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag)
#endif
{
struct net_buf *next_frag;
struct net_buf *next_frag = NULL;
NET_BUF_ASSERT(frag);
@ -524,9 +524,9 @@ struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag)
size_t net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src,
size_t offset, size_t len)
{
struct net_buf *frag;
size_t to_copy;
size_t copied;
struct net_buf *frag = NULL;
size_t to_copy = 0U;
size_t copied = 0U;
len = MIN(len, dst_len);
@ -566,7 +566,7 @@ size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
net_buf_allocator_cb allocate_cb, void *user_data)
{
struct net_buf *frag = net_buf_frag_last(buf);
size_t added_len = 0;
size_t added_len = 0U;
const u8_t *value8 = value;
do {

View File

@ -40,64 +40,64 @@ static const struct {
const u16_t id;
int (*const init)(struct bt_mesh_model *model, bool primary);
} model_init[] = {
{ BLE_MESH_MODEL_ID_CFG_SRV, bt_mesh_cfg_srv_init },
{ BLE_MESH_MODEL_ID_HEALTH_SRV, bt_mesh_health_srv_init },
{ BLE_MESH_MODEL_ID_CFG_SRV, bt_mesh_cfg_srv_init },
{ BLE_MESH_MODEL_ID_HEALTH_SRV, bt_mesh_health_srv_init },
#if defined(CONFIG_BLE_MESH_CFG_CLI)
{ BLE_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_init },
{ BLE_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_HEALTH_CLI)
{ BLE_MESH_MODEL_ID_HEALTH_CLI, bt_mesh_health_cli_init },
{ BLE_MESH_MODEL_ID_HEALTH_CLI, bt_mesh_health_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
{ BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, bt_mesh_gen_onoff_cli_init },
{ BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, bt_mesh_gen_onoff_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_LEVEL_CLI)
{ BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, bt_mesh_gen_level_cli_init },
{ BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, bt_mesh_gen_level_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI)
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, bt_mesh_gen_def_trans_time_cli_init },
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, bt_mesh_gen_def_trans_time_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI)
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, bt_mesh_gen_pwr_onoff_cli_init },
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, bt_mesh_gen_pwr_onoff_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI)
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, bt_mesh_gen_pwr_level_cli_init },
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, bt_mesh_gen_pwr_level_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_BATTERY_CLI)
{ BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, bt_mesh_gen_battery_cli_init },
{ BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, bt_mesh_gen_battery_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_LOCATION_CLI)
{ BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, bt_mesh_gen_location_cli_init },
{ BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, bt_mesh_gen_location_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI)
{ BLE_MESH_MODEL_ID_GEN_PROP_CLI, bt_mesh_gen_property_cli_init },
{ BLE_MESH_MODEL_ID_GEN_PROP_CLI, bt_mesh_gen_property_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_SENSOR_CLI)
{ BLE_MESH_MODEL_ID_SENSOR_CLI, bt_mesh_sensor_cli_init },
{ BLE_MESH_MODEL_ID_SENSOR_CLI, bt_mesh_sensor_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_TIME_CLI)
{ BLE_MESH_MODEL_ID_TIME_CLI, bt_mesh_time_cli_init },
{ BLE_MESH_MODEL_ID_TIME_CLI, bt_mesh_time_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_SCENE_CLI)
{ BLE_MESH_MODEL_ID_SCENE_CLI, bt_mesh_scene_cli_init },
{ BLE_MESH_MODEL_ID_SCENE_CLI, bt_mesh_scene_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_SCHEDULER_CLI)
{ BLE_MESH_MODEL_ID_SCHEDULER_CLI, bt_mesh_scheduler_cli_init },
{ BLE_MESH_MODEL_ID_SCHEDULER_CLI, bt_mesh_scheduler_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, bt_mesh_light_lightness_cli_init },
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, bt_mesh_light_lightness_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_CTL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, bt_mesh_light_ctl_cli_init },
{ BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, bt_mesh_light_ctl_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_HSL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, bt_mesh_light_hsl_cli_init },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, bt_mesh_light_hsl_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_XYL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, bt_mesh_light_xyl_cli_init },
{ BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, bt_mesh_light_xyl_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_LC_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_LC_CLI, bt_mesh_light_lc_cli_init },
{ BLE_MESH_MODEL_ID_LIGHT_LC_CLI, bt_mesh_light_lc_cli_init },
#endif
{ BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, bt_mesh_gen_onoff_srv_init },
{ BLE_MESH_MODEL_ID_GEN_LEVEL_SRV, bt_mesh_gen_level_srv_init },
@ -302,7 +302,7 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod)
static s32_t next_period(struct bt_mesh_model *mod)
{
struct bt_mesh_model_pub *pub = mod->pub;
u32_t elapsed, period;
u32_t elapsed = 0U, period = 0U;
if (!pub) {
BT_ERR("%s, Model has no publication support", __func__);
@ -330,7 +330,7 @@ static s32_t next_period(struct bt_mesh_model *mod)
static void publish_sent(int err, void *user_data)
{
struct bt_mesh_model *mod = user_data;
s32_t delay;
s32_t delay = 0;
BT_DBG("err %d", err);
@ -394,7 +394,7 @@ static int publish_retransmit(struct bt_mesh_model *mod)
.xmit = bt_mesh_net_transmit_get(),
.friend_cred = pub->cred,
};
int err;
int err = 0;
key = bt_mesh_app_key_find(pub->key);
if (!key) {
@ -428,8 +428,8 @@ static void mod_publish(struct k_work *work)
struct bt_mesh_model_pub *pub = CONTAINER_OF(work,
struct bt_mesh_model_pub,
timer.work);
s32_t period_ms;
int err;
s32_t period_ms = 0;
int err = 0;
BT_DBG("%s", __func__);
@ -481,7 +481,7 @@ struct bt_mesh_elem *bt_mesh_model_elem(struct bt_mesh_model *mod)
struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
{
struct bt_mesh_elem *elem;
struct bt_mesh_elem *elem = NULL;
if (!dev_comp) {
BT_ERR("%s, dev_comp is not initialized", __func__);
@ -550,7 +550,7 @@ static void mod_init(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
static void mod_deinit(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
bool vnd, bool primary, void *user_data)
{
size_t i;
int i;
mod->elem = NULL;
@ -559,7 +559,7 @@ static void mod_deinit(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
k_delayed_work_free(&mod->pub->timer);
}
for (i = 0U; i < ARRAY_SIZE(mod->keys); i++) {
for (i = 0; i < ARRAY_SIZE(mod->keys); i++) {
mod->keys[i] = BLE_MESH_KEY_UNUSED;
}
@ -654,8 +654,8 @@ u16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, u16_t addr)
static struct bt_mesh_model *bt_mesh_elem_find_group(struct bt_mesh_elem *elem,
u16_t group_addr)
{
struct bt_mesh_model *model;
u16_t *match;
struct bt_mesh_model *model = NULL;
u16_t *match = NULL;
int i;
for (i = 0; i < elem->model_count; i++) {
@ -681,7 +681,7 @@ static struct bt_mesh_model *bt_mesh_elem_find_group(struct bt_mesh_elem *elem,
struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr)
{
u16_t index;
u16_t index = 0U;
if (BLE_MESH_ADDR_IS_UNICAST(addr)) {
index = (addr - dev_comp->elem[0].addr);
@ -726,9 +726,9 @@ static const struct bt_mesh_model_op *find_op(struct bt_mesh_model *models,
u16_t app_idx, u32_t opcode,
struct bt_mesh_model **model)
{
u8_t i;
int i;
for (i = 0U; i < model_count; i++) {
for (i = 0; i < model_count; i++) {
const struct bt_mesh_model_op *op;
*model = &models[i];
@ -808,10 +808,10 @@ bool bt_mesh_fixed_group_match(u16_t addr)
void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
{
struct bt_mesh_model *models, *model;
const struct bt_mesh_model_op *op;
u32_t opcode;
u8_t count;
struct bt_mesh_model *models = NULL, *model = NULL;
const struct bt_mesh_model_op *op = NULL;
u32_t opcode = 0U;
u8_t count = 0U;
int i;
BT_INFO("app_idx 0x%04x src 0x%04x dst 0x%04x", rx->ctx.app_idx,
@ -936,7 +936,7 @@ static int model_send(struct bt_mesh_model *model,
struct net_buf_simple *msg,
const struct bt_mesh_send_cb *cb, void *cb_data)
{
u8_t role;
u8_t role = 0U;
role = bt_mesh_get_device_role(model, tx->ctx->srv_send);
if (role == ROLE_NVAL) {
@ -977,7 +977,7 @@ int bt_mesh_model_send(struct bt_mesh_model *model,
const struct bt_mesh_send_cb *cb, void *cb_data)
{
struct bt_mesh_subnet *sub = NULL;
u8_t role;
u8_t role = 0U;
role = bt_mesh_get_device_role(model, ctx->srv_send);
if (role == ROLE_NVAL) {
@ -1016,7 +1016,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
.src = bt_mesh_model_elem(model)->addr,
.xmit = bt_mesh_net_transmit_get(),
};
int err;
int err = 0;
BT_DBG("%s", __func__);
@ -1088,9 +1088,9 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
u16_t company, u16_t id)
{
u8_t i;
int i;
for (i = 0U; i < elem->vnd_model_count; i++) {
for (i = 0; i < elem->vnd_model_count; i++) {
if (elem->vnd_models[i].vnd.company == company &&
elem->vnd_models[i].vnd.id == id) {
return &elem->vnd_models[i];
@ -1103,9 +1103,9 @@ struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem,
u16_t id)
{
u8_t i;
int i;
for (i = 0U; i < elem->model_count; i++) {
for (i = 0; i < elem->model_count; i++) {
if (elem->models[i].id == id) {
return &elem->models[i];
}
@ -1168,7 +1168,7 @@ struct bt_mesh_app_key *bt_mesh_tx_appkey_get(u8_t role, u16_t app_idx)
/* APIs used by messages decryption in network layer & upper transport layer */
size_t bt_mesh_rx_netkey_size(void)
{
size_t size = 0;
size_t size = 0U;
#if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER
if (bt_mesh_is_provisioned()) {
@ -1221,7 +1221,7 @@ struct bt_mesh_subnet *bt_mesh_rx_netkey_get(size_t index)
size_t bt_mesh_rx_devkey_size(void)
{
size_t size = 0;
size_t size = 0U;
#if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER
if (bt_mesh_is_provisioned()) {
@ -1274,7 +1274,7 @@ const u8_t *bt_mesh_rx_devkey_get(size_t index, u16_t src)
size_t bt_mesh_rx_appkey_size(void)
{
size_t size = 0;
size_t size = 0U;
#if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER
if (bt_mesh_is_provisioned()) {

View File

@ -20,6 +20,7 @@
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_ADV)
#include "mesh.h"
#include "mesh_hci.h"
#include "adv.h"
#include "beacon.h"
#include "prov.h"
@ -120,9 +121,9 @@ static inline int adv_send(struct net_buf *buf)
const struct bt_mesh_send_cb *cb = BLE_MESH_ADV(buf)->cb;
void *cb_data = BLE_MESH_ADV(buf)->cb_data;
struct bt_mesh_adv_param param = {0};
u16_t duration, adv_int;
u16_t duration = 0U, adv_int = 0U;
struct bt_mesh_adv_data ad = {0};
int err;
int err = 0;
#if 0
adv_int = MAX(adv_int_min,
@ -175,10 +176,10 @@ static inline int adv_send(struct net_buf *buf)
static void adv_thread(void *p)
{
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
QueueSetMemberHandle_t handle;
QueueSetMemberHandle_t handle = NULL;
#endif
bt_mesh_msg_t msg = {0};
struct net_buf **buf;
struct net_buf **buf = NULL;
buf = (struct net_buf **)(&msg.arg);
@ -214,7 +215,7 @@ static void adv_thread(void *p)
}
} else {
while (!(*buf)) {
s32_t timeout;
s32_t timeout = 0;
BT_DBG("Mesh Proxy Advertising start");
timeout = bt_mesh_proxy_adv_start();
BT_DBG("Mesh Proxy Advertising up to %d ms", timeout);
@ -281,8 +282,8 @@ struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
enum bt_mesh_adv_type type,
u8_t xmit, s32_t timeout)
{
struct bt_mesh_adv *adv;
struct net_buf *buf;
struct bt_mesh_adv *adv = NULL;
struct net_buf *buf = NULL;
if (bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_SUSPENDED)) {
BT_WARN("Refusing to allocate buffer while suspended");
@ -310,14 +311,14 @@ struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
void bt_mesh_unref_buf_from_pool(struct net_buf_pool *pool)
{
size_t i;
int i;
if (pool == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
for (i = 0U; i < pool->buf_count; i++) {
for (i = 0; i < pool->buf_count; i++) {
struct net_buf *buf = &pool->__bufs[i];
if (buf->ref > 1U) {
buf->ref = 1U;
@ -359,7 +360,7 @@ void bt_mesh_adv_buf_ref_debug(const char *func, struct net_buf *buf,
static void bt_mesh_unref_buf(bt_mesh_msg_t *msg)
{
struct net_buf *buf;
struct net_buf *buf = NULL;
if (msg->arg) {
buf = (struct net_buf *)msg->arg;
@ -415,7 +416,7 @@ void bt_mesh_adv_update(void)
static bool ignore_relay_packet(u32_t timestamp)
{
u32_t now = k_uptime_get_32();
u32_t interval;
u32_t interval = 0U;
if (now >= timestamp) {
interval = now - timestamp;
@ -440,7 +441,7 @@ struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, u8_t xmit,
static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
{
QueueSetMemberHandle_t handle;
QueueSetMemberHandle_t handle = NULL;
bt_mesh_msg_t old_msg = {0};
BT_DBG("%s", __func__);
@ -513,7 +514,7 @@ const bt_mesh_addr_t *bt_mesh_pba_get_addr(void)
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
static bool bt_mesh_is_adv_flags_valid(struct net_buf_simple *buf)
{
u8_t flags;
u8_t flags = 0U;
if (buf->len != 1U) {
BT_DBG("%s, Unexpected flags length", __func__);
@ -525,6 +526,7 @@ static bool bt_mesh_is_adv_flags_valid(struct net_buf_simple *buf)
BT_DBG("Received adv pkt with flags: 0x%02x", flags);
/* Flags context will not be checked curently */
((void) flags);
return true;
}
@ -564,7 +566,7 @@ static bool bt_mesh_is_adv_srv_uuid_valid(struct net_buf_simple *buf, u16_t *uui
static void bt_mesh_adv_srv_data_recv(struct net_buf_simple *buf, const bt_mesh_addr_t *addr, u16_t uuid, s8_t rssi)
{
u16_t type;
u16_t type = 0U;
if (!buf || !addr) {
BT_ERR("%s, Invalid parameter", __func__);
@ -614,7 +616,7 @@ static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi,
{
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
u16_t uuid = 0x0;
u16_t uuid = 0U;
#endif
if (adv_type != BLE_MESH_ADV_NONCONN_IND && adv_type != BLE_MESH_ADV_IND) {
@ -744,7 +746,7 @@ void bt_mesh_adv_deinit(void)
int bt_mesh_scan_enable(void)
{
int err;
int err = 0;
struct bt_mesh_scan_param scan_param = {
.type = BLE_MESH_SCAN_PASSIVE,
@ -770,7 +772,7 @@ int bt_mesh_scan_enable(void)
int bt_mesh_scan_disable(void)
{
int err;
int err = 0;
BT_DBG("%s", __func__);

View File

@ -48,8 +48,8 @@ static struct k_delayed_work beacon_timer;
static struct bt_mesh_subnet *cache_check(u8_t data[21])
{
size_t subnet_size;
int i;
size_t subnet_size = 0U;
int i = 0;
subnet_size = bt_mesh_rx_netkey_size();
@ -86,7 +86,7 @@ void bt_mesh_beacon_create(struct bt_mesh_subnet *sub,
struct net_buf_simple *buf)
{
u8_t flags = bt_mesh_net_flags(sub);
struct bt_mesh_subnet_keys *keys;
struct bt_mesh_subnet_keys *keys = NULL;
net_buf_simple_add_u8(buf, BEACON_TYPE_SECURE);
@ -122,8 +122,8 @@ static int secure_beacon_send(void)
.end = beacon_complete,
};
u32_t now = k_uptime_get_32();
size_t subnet_size;
int i;
size_t subnet_size = 0U;
int i = 0;
BT_DBG("%s", __func__);
@ -176,10 +176,10 @@ static int secure_beacon_send(void)
static int unprovisioned_beacon_send(void)
{
#if defined(CONFIG_BLE_MESH_PB_ADV)
const struct bt_mesh_prov *prov;
const struct bt_mesh_prov *prov = NULL;
u8_t uri_hash[16] = { 0 };
struct net_buf *buf;
u16_t oob_info;
struct net_buf *buf = NULL;
u16_t oob_info = 0U;
BT_DBG("%s", __func__);
@ -240,8 +240,8 @@ static int unprovisioned_beacon_send(void)
static void update_beacon_observation(void)
{
static bool first_half;
size_t subnet_size;
int i;
size_t subnet_size = 0U;
int i = 0;
/* Observation period is 20 seconds, whereas the beacon timer
* runs every 10 seconds. We process what's happened during the
@ -313,11 +313,11 @@ static void beacon_send(struct k_work *work)
static void secure_beacon_recv(struct net_buf_simple *buf)
{
u8_t *data, *net_id, *auth;
struct bt_mesh_subnet *sub;
u32_t iv_index;
bool new_key, kr_change, iv_change;
u8_t flags;
u8_t *data = NULL, *net_id = NULL, *auth = NULL;
struct bt_mesh_subnet *sub = NULL;
u32_t iv_index = 0U;
bool new_key = false, kr_change = false, iv_change = false;
u8_t flags = 0U;
if (buf->len < 21) {
BT_ERR("%s, Too short secure beacon (len %u)", __func__, buf->len);
@ -394,7 +394,7 @@ update_stats:
void bt_mesh_beacon_recv(struct net_buf_simple *buf, s8_t rssi)
{
u8_t type;
u8_t type = 0U;
BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len));
@ -444,8 +444,8 @@ void bt_mesh_beacon_ivu_initiator(bool enable)
void bt_mesh_beacon_enable(void)
{
size_t subnet_size;
int i;
size_t subnet_size = 0U;
int i = 0;
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_node() &&
!bt_mesh_is_provisioned()) {

View File

@ -139,8 +139,8 @@ void bt_mesh_hci_init(void)
static void bt_mesh_scan_results_change_2_bta(tBTM_INQ_RESULTS *p_inq, u8_t *p_eir,
tBTA_DM_SEARCH_CBACK *p_scan_cback)
{
tBTM_INQ_INFO *p_inq_info;
tBTA_DM_SEARCH result;
tBTM_INQ_INFO *p_inq_info = NULL;
tBTA_DM_SEARCH result = {0};
bdcpy(result.inq_res.bd_addr, p_inq->remote_bd_addr);
result.inq_res.rssi = p_inq->rssi;
@ -293,8 +293,8 @@ static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window, u8_t filt
static void bt_mesh_scan_result_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
{
bt_mesh_addr_t addr = {0};
UINT8 adv_type;
UINT8 rssi;
u8_t adv_type = 0U;
s8_t rssi = 0;
BT_DBG("%s, event = %d", __func__, event);
@ -329,13 +329,13 @@ int bt_le_adv_start(const struct bt_mesh_adv_param *param,
const struct bt_mesh_adv_data *ad, size_t ad_len,
const struct bt_mesh_adv_data *sd, size_t sd_len)
{
tBTA_START_ADV_CMPL_CBACK *p_start_adv_cb;
tBTM_BLE_ADV_CHNL_MAP channel_map;
tBLE_ADDR_TYPE addr_type_own;
tBTA_START_ADV_CMPL_CBACK *p_start_adv_cb = NULL;
tBTM_BLE_ADV_CHNL_MAP channel_map = 0U;
tBLE_ADDR_TYPE addr_type_own = 0U;
tBLE_BD_ADDR p_dir_bda = {0};
tBTM_BLE_AFP adv_fil_pol;
UINT8 adv_type;
int err;
tBTM_BLE_AFP adv_fil_pol = 0U;
u8_t adv_type = 0U;
int err = 0;
#if BLE_MESH_DEV
if (bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_ADVERTISING)) {
@ -421,7 +421,7 @@ int bt_le_adv_stop(void)
int bt_le_scan_start(const struct bt_mesh_scan_param *param, bt_mesh_scan_cb_t cb)
{
int err;
int err = 0;
#if BLE_MESH_DEV
if (bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) {
@ -482,7 +482,7 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
case BTA_GATTS_READ_EVT: {
struct bt_mesh_gatt_attr *attr = bt_mesh_gatts_find_attr_by_handle(p_data->req_data.p_data->read_req.handle);
u8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->req_data.conn_id);
tBTA_GATTS_RSP rsp;
tBTA_GATTS_RSP rsp = {0};
u8_t buf[100] = {0};
u16_t len = 0;
@ -679,7 +679,7 @@ ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn, const struct bt_mesh_
void *buf, u16_t buf_len, u16_t offset,
const void *value, u16_t value_len)
{
u16_t len;
u16_t len = 0U;
if (offset > value_len) {
return BLE_MESH_GATT_ERR(BLE_MESH_ATT_ERR_INVALID_OFFSET);
@ -707,7 +707,7 @@ ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn,
struct bt_mesh_gatt_attr *incl = attr->user_data;
struct bt_mesh_uuid *uuid = incl->user_data;
struct gatts_incl pdu = {0};
u8_t value_len;
u8_t value_len = 0U;
/* First attr points to the start handle */
pdu.start_handle = sys_cpu_to_le16(incl->handle);
@ -757,7 +757,7 @@ ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn,
struct bt_mesh_gatt_char *chrc = attr->user_data;
const struct bt_mesh_gatt_attr *next = NULL;
struct gatts_chrc pdu = {0};
u8_t value_len;
u8_t value_len = 0U;
pdu.properties = chrc->properties;
/* BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part G] page 534:
@ -809,8 +809,8 @@ static void bta_uuid_to_bt_mesh_uuid(tBT_UUID *bta_uuid, const struct bt_mesh_uu
static int gatts_register(struct bt_mesh_gatt_service *svc)
{
struct bt_mesh_gatt_service *last;
u16_t handle;
struct bt_mesh_gatt_service *last = NULL;
u16_t handle = 0U;
if (sys_slist_is_empty(&bt_mesh_gatts_db)) {
handle = 0;
@ -821,6 +821,8 @@ static int gatts_register(struct bt_mesh_gatt_service *svc)
handle = last->attrs[last->attr_count - 1].handle;
BT_DBG("%s, handle = %d", __func__, handle);
((void) handle);
populate:
sys_slist_append(&bt_mesh_gatts_db, &svc->node);
return 0;
@ -1063,10 +1065,10 @@ void bt_mesh_gattc_conn_cb_deregister(void)
u8_t bt_mesh_gattc_get_free_conn_count(void)
{
u8_t count = 0;
u8_t i;
u8_t count = 0U;
int i;
for (i = 0U; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
if (bt_mesh_gattc_info[i].conn.handle == 0xFFFF &&
bt_mesh_gattc_info[i].service_uuid == 0x0000) {
++count;
@ -1078,9 +1080,9 @@ u8_t bt_mesh_gattc_get_free_conn_count(void)
u16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn)
{
u8_t i;
int i;
for (i = 0U; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
if (conn == &bt_mesh_gattc_info[i].conn) {
return bt_mesh_gattc_info[i].service_uuid;
}
@ -1172,7 +1174,7 @@ void bt_mesh_gattc_exchange_mtu(u8_t index)
* ATT_MTU >= 69 for Mesh GATT Prov Service
* ATT_NTU >= 33 for Mesh GATT Proxy Service
*/
u16_t conn_id;
u16_t conn_id = 0U;
conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gattc_if, bt_mesh_gattc_info[index].conn.handle);
@ -1195,7 +1197,7 @@ u16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn)
int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr,
const void *data, u16_t len)
{
u16_t conn_id;
u16_t conn_id = 0U;
int i;
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
@ -1222,7 +1224,7 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn)
* when proxy_disconnected callback comes, the proxy server
* information and prov_link information should be cleared.
*/
u16_t conn_id;
u16_t conn_id = 0U;
int i;
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
@ -1247,7 +1249,7 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn)
static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
{
struct bt_mesh_conn *conn = NULL;
u16_t handle = 0;
u16_t handle = 0U;
ssize_t len = 0;
int i = 0;
@ -1332,8 +1334,8 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
u16_t notify_en = BLE_MESH_GATT_CCC_NOTIFY;
btgatt_db_element_t *result = NULL;
tBT_UUID char_uuid = {0};
tBTA_GATT_STATUS status;
tBTA_GATT_UNFMT write;
tBTA_GATT_STATUS status = 0U;
tBTA_GATT_UNFMT write = {0};
int count = 0;
int num = 0;
@ -1824,7 +1826,7 @@ int bt_mesh_dh_key_gen(const u8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const u
static void ecb_encrypt(u8_t const *const key_le, u8_t const *const clear_text_le,
u8_t *const cipher_text_le, u8_t *const cipher_text_be)
{
struct bt_mesh_ecb_param ecb;
struct bt_mesh_ecb_param ecb = {0};
mbedtls_aes_context aes_ctx = {0};
aes_ctx.key_bytes = 16;
@ -1846,7 +1848,7 @@ static void ecb_encrypt(u8_t const *const key_le, u8_t const *const clear_text_l
static void ecb_encrypt_be(u8_t const *const key_be, u8_t const *const clear_text_be,
u8_t *const cipher_text_be)
{
struct bt_mesh_ecb_param ecb;
struct bt_mesh_ecb_param ecb = {0};
mbedtls_aes_context aes_ctx = {0};
aes_ctx.key_bytes = 16;
@ -1869,8 +1871,8 @@ int bt_mesh_encrypt_le(const u8_t key[16], const u8_t plaintext[16],
BT_DBG("enc_data %s", bt_hex(enc_data, 16));
return 0;
#else /* CONFIG_MBEDTLS_HARDWARE_AES */
struct tc_aes_key_sched_struct s;
u8_t tmp[16];
struct tc_aes_key_sched_struct s = {0};
u8_t tmp[16] = {0};
BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16));
@ -1906,7 +1908,7 @@ int bt_mesh_encrypt_be(const u8_t key[16], const u8_t plaintext[16],
return 0;
#else /* CONFIG_MBEDTLS_HARDWARE_AES */
struct tc_aes_key_sched_struct s;
struct tc_aes_key_sched_struct s = {0};
BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16));

View File

@ -116,7 +116,7 @@ static void timeout_handler(struct k_work *work)
struct k_delayed_work *timer = NULL;
bt_mesh_client_node_t *node = NULL;
struct bt_mesh_msg_ctx ctx = {0};
u32_t opcode;
u32_t opcode = 0U;
BT_WARN("Receive configuration status message timeout");
@ -289,7 +289,7 @@ static void state_status_u8(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u8_t status = 0;
u8_t status = 0U;
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
@ -349,7 +349,7 @@ static void net_key_status(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_cfg_netkey_status status = {0};
u16_t app_idx;
u16_t app_idx = 0U;
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
@ -695,7 +695,7 @@ const struct bt_mesh_model_op bt_mesh_cfg_cli_op[] = {
int bt_mesh_cfg_comp_data_get(struct bt_mesh_msg_ctx *ctx, u8_t page)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_DEV_COMP_DATA_GET, 1);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -717,7 +717,7 @@ int bt_mesh_cfg_comp_data_get(struct bt_mesh_msg_ctx *ctx, u8_t page)
static int get_state_u8(struct bt_mesh_msg_ctx *ctx, u32_t op)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 0);
int err;
int err = 0;
bt_mesh_model_msg_init(&msg, op);
@ -733,7 +733,7 @@ static int get_state_u8(struct bt_mesh_msg_ctx *ctx, u32_t op)
static int set_state_u8(struct bt_mesh_msg_ctx *ctx, u32_t op, u8_t new_val)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 1);
int err;
int err = 0;
bt_mesh_model_msg_init(&msg, op);
net_buf_simple_add_u8(&msg, new_val);
@ -814,7 +814,7 @@ int bt_mesh_cfg_gatt_proxy_set(struct bt_mesh_msg_ctx *ctx, u8_t val)
int bt_mesh_cfg_relay_get(struct bt_mesh_msg_ctx *ctx)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_RELAY_GET, 0);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -836,7 +836,7 @@ int bt_mesh_cfg_relay_set(struct bt_mesh_msg_ctx *ctx, u8_t new_relay,
u8_t new_transmit)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_RELAY_SET, 2);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -860,7 +860,7 @@ int bt_mesh_cfg_net_key_add(struct bt_mesh_msg_ctx *ctx, u16_t key_net_idx,
const u8_t net_key[16])
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_ADD, 18);
int err;
int err = 0;
if (!ctx || !ctx->addr || !net_key) {
return -EINVAL;
@ -884,7 +884,7 @@ int bt_mesh_cfg_app_key_add(struct bt_mesh_msg_ctx *ctx, u16_t key_net_idx,
u16_t key_app_idx, const u8_t app_key[16])
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_ADD, 19);
int err;
int err = 0;
if (!ctx || !ctx->addr || !app_key) {
return -EINVAL;
@ -908,7 +908,7 @@ int bt_mesh_cfg_mod_app_bind(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
u16_t mod_app_idx, u16_t mod_id, u16_t cid)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_BIND, 8);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -936,7 +936,7 @@ static int mod_sub(u32_t op, struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
u16_t sub_addr, u16_t mod_id, u16_t cid)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 8);
int err;
int err = 0;
bt_mesh_model_msg_init(&msg, op);
net_buf_simple_add_le16(&msg, elem_addr);
@ -986,7 +986,7 @@ static int mod_sub_va(u32_t op, struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
const u8_t label[16], u16_t mod_id, u16_t cid)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 22);
int err;
int err = 0;
BT_DBG("net_idx 0x%04x addr 0x%04x elem_addr 0x%04x label %s",
ctx->net_idx, ctx->addr, elem_addr, label);
@ -1040,7 +1040,7 @@ int bt_mesh_cfg_mod_pub_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
u16_t mod_id, u16_t cid)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_GET, 6);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -1068,7 +1068,7 @@ int bt_mesh_cfg_mod_pub_set(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
struct bt_mesh_cfg_mod_pub *pub)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_SET, 13);
int err;
int err = 0;
if (!ctx || !ctx->addr || !pub) {
return -EINVAL;
@ -1100,7 +1100,7 @@ int bt_mesh_cfg_hb_sub_set(struct bt_mesh_msg_ctx *ctx,
struct bt_mesh_cfg_hb_sub *sub)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_SUB_SET, 5);
int err;
int err = 0;
if (!ctx || !ctx->addr || !sub) {
return -EINVAL;
@ -1124,7 +1124,7 @@ int bt_mesh_cfg_hb_sub_set(struct bt_mesh_msg_ctx *ctx,
int bt_mesh_cfg_hb_sub_get(struct bt_mesh_msg_ctx *ctx)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_SUB_GET, 0);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -1146,7 +1146,7 @@ int bt_mesh_cfg_hb_pub_set(struct bt_mesh_msg_ctx *ctx,
const struct bt_mesh_cfg_hb_pub *pub)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_PUB_SET, 9);
int err;
int err = 0;
if (!ctx || !ctx->addr || !pub) {
return -EINVAL;
@ -1173,7 +1173,7 @@ int bt_mesh_cfg_hb_pub_set(struct bt_mesh_msg_ctx *ctx,
int bt_mesh_cfg_hb_pub_get(struct bt_mesh_msg_ctx *ctx)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_PUB_GET, 0);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -1194,7 +1194,7 @@ int bt_mesh_cfg_hb_pub_get(struct bt_mesh_msg_ctx *ctx)
int bt_mesh_cfg_node_reset(struct bt_mesh_msg_ctx *ctx)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_RESET, 0);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -1217,7 +1217,7 @@ int bt_mesh_cfg_mod_pub_va_set(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
struct bt_mesh_cfg_mod_pub *pub)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_VA_SET, 27);
int err;
int err = 0;
if (!ctx || !ctx->addr || !label || !pub) {
return -EINVAL;
@ -1249,7 +1249,7 @@ int bt_mesh_cfg_mod_sub_del_all(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
u16_t mod_id, u16_t cid)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_SUB_DEL_ALL, 6);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -1276,7 +1276,7 @@ static int mod_sub_get(u32_t op, struct bt_mesh_msg_ctx *ctx,
u16_t elem_addr, u16_t mod_id, u16_t cid)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 6);
int err;
int err = 0;
bt_mesh_model_msg_init(&msg, op);
net_buf_simple_add_le16(&msg, elem_addr);
@ -1315,7 +1315,7 @@ int bt_mesh_cfg_net_key_update(struct bt_mesh_msg_ctx *ctx, u16_t net_idx,
const u8_t net_key[16])
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_UPDATE, 18);
int err;
int err = 0;
if (!ctx || !ctx->addr || !net_key) {
return -EINVAL;
@ -1338,7 +1338,7 @@ int bt_mesh_cfg_net_key_update(struct bt_mesh_msg_ctx *ctx, u16_t net_idx,
int bt_mesh_cfg_net_key_delete(struct bt_mesh_msg_ctx *ctx, u16_t net_idx)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_DEL, 2);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -1360,7 +1360,7 @@ int bt_mesh_cfg_net_key_delete(struct bt_mesh_msg_ctx *ctx, u16_t net_idx)
int bt_mesh_cfg_net_key_get(struct bt_mesh_msg_ctx *ctx)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_GET, 0);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -1382,7 +1382,7 @@ int bt_mesh_cfg_app_key_update(struct bt_mesh_msg_ctx *ctx, u16_t net_idx,
u16_t app_idx, const u8_t app_key[16])
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_UPDATE, 19);
int err;
int err = 0;
if (!ctx || !ctx->addr || !app_key) {
return -EINVAL;
@ -1405,7 +1405,7 @@ int bt_mesh_cfg_app_key_update(struct bt_mesh_msg_ctx *ctx, u16_t net_idx,
int bt_mesh_cfg_app_key_delete(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u16_t app_idx)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_DEL, 3);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -1427,7 +1427,7 @@ int bt_mesh_cfg_app_key_delete(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u16_t
int bt_mesh_cfg_app_key_get(struct bt_mesh_msg_ctx *ctx, u16_t net_idx)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_GET, 2);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -1450,7 +1450,7 @@ static int node_identity_op(u32_t op, struct bt_mesh_msg_ctx *ctx,
u16_t net_idx, u8_t identity)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 3);
int err;
int err = 0;
bt_mesh_model_msg_init(&msg, op);
net_buf_simple_add_le16(&msg, net_idx);
@ -1487,7 +1487,7 @@ int bt_mesh_cfg_mod_app_unbind(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
u16_t app_idx, u16_t mod_id, u16_t cid)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_UNBIND, 8);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -1515,7 +1515,7 @@ static int mod_app_get(u32_t op, struct bt_mesh_msg_ctx *ctx,
u16_t elem_addr, u16_t mod_id, u16_t cid)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 6);
int err;
int err = 0;
bt_mesh_model_msg_init(&msg, op);
net_buf_simple_add_le16(&msg, elem_addr);
@ -1554,7 +1554,7 @@ static int kr_phase_op(u32_t op, struct bt_mesh_msg_ctx *ctx,
u16_t net_idx, u8_t transition)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 3);
int err;
int err = 0;
bt_mesh_model_msg_init(&msg, op);
net_buf_simple_add_le16(&msg, net_idx);
@ -1590,7 +1590,7 @@ int bt_mesh_cfg_kr_phase_set(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u8_t tr
int bt_mesh_cfg_lpn_timeout_get(struct bt_mesh_msg_ctx *ctx, u16_t lpn_addr)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_LPN_TIMEOUT_GET, 2);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;

View File

@ -45,7 +45,7 @@ static struct label labels[CONFIG_BLE_MESH_LABEL_COUNT];
static int comp_add_elem(struct net_buf_simple *buf, struct bt_mesh_elem *elem,
bool primary)
{
struct bt_mesh_model *mod;
struct bt_mesh_model *mod = NULL;
int i;
if (net_buf_simple_tailroom(buf) <
@ -76,7 +76,7 @@ static int comp_add_elem(struct net_buf_simple *buf, struct bt_mesh_elem *elem,
static int comp_get_page_0(struct net_buf_simple *buf)
{
u16_t feat = 0U;
const struct bt_mesh_comp *comp;
const struct bt_mesh_comp *comp = NULL;
int i;
comp = bt_mesh_comp_get();
@ -120,7 +120,7 @@ static void dev_comp_data_get(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct net_buf_simple *sdu = NULL;
u8_t page;
u8_t page = 0U;
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
@ -159,7 +159,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem,
struct net_buf_simple *buf, bool *vnd)
{
if (buf->len < 4) {
u16_t id;
u16_t id = 0U;
id = net_buf_simple_pull_le16(buf);
@ -169,7 +169,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem,
return bt_mesh_model_find(elem, id);
} else {
u16_t company, id;
u16_t company = 0U, id = 0U;
company = net_buf_simple_pull_le16(buf);
id = net_buf_simple_pull_le16(buf);
@ -350,9 +350,9 @@ struct bt_mesh_app_key *bt_mesh_app_key_alloc(u16_t app_idx)
static u8_t app_key_set(u16_t net_idx, u16_t app_idx, const u8_t val[16],
bool update)
{
struct bt_mesh_app_keys *keys;
struct bt_mesh_app_key *key;
struct bt_mesh_subnet *sub;
struct bt_mesh_app_keys *keys = NULL;
struct bt_mesh_app_key *key = NULL;
struct bt_mesh_subnet *sub = NULL;
BT_DBG("net_idx 0x%04x app_idx %04x update %u val %s",
net_idx, app_idx, update, bt_hex(val, 16));
@ -441,8 +441,8 @@ static void app_key_add(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4);
u16_t key_net_idx, key_app_idx;
u8_t status;
u16_t key_net_idx = 0U, key_app_idx = 0U;
u8_t status = 0U;
key_idx_unpack(buf, &key_net_idx, &key_app_idx);
@ -476,8 +476,8 @@ static void app_key_update(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4);
u16_t key_net_idx, key_app_idx;
u8_t status;
u16_t key_net_idx = 0U, key_app_idx = 0U;
u8_t status = 0U;
key_idx_unpack(buf, &key_net_idx, &key_app_idx);
@ -539,9 +539,9 @@ static void app_key_del(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4);
u16_t key_net_idx, key_app_idx;
struct bt_mesh_app_key *key;
u8_t status;
u16_t key_net_idx = 0U, key_app_idx = 0U;
struct bt_mesh_app_key *key = NULL;
u8_t status = 0U;
key_idx_unpack(buf, &key_net_idx, &key_app_idx);
@ -598,8 +598,8 @@ static void app_key_get(struct bt_mesh_model *model,
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_LIST,
3 + IDX_LEN(CONFIG_BLE_MESH_APP_KEY_COUNT));
u16_t get_idx, i, prev;
u8_t status;
u16_t get_idx = 0U, i = 0U, prev = 0U;
u8_t status = 0U;
get_idx = net_buf_simple_pull_le16(buf);
if (get_idx > 0xfff) {
@ -1017,11 +1017,11 @@ static void mod_pub_get(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u16_t elem_addr, pub_addr = 0U;
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u8_t *mod_id, status;
bool vnd;
u16_t elem_addr = 0U, pub_addr = 0U;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u8_t *mod_id = NULL, status = 0U;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -1064,12 +1064,12 @@ static void mod_pub_set(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u8_t retransmit, status, pub_ttl, pub_period, cred_flag;
u16_t elem_addr, pub_addr, pub_app_idx;
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u8_t *mod_id;
bool vnd;
u8_t retransmit = 0U, status = 0U, pub_ttl = 0U, pub_period = 0U, cred_flag = 0U;
u16_t elem_addr = 0U, pub_addr = 0U, pub_app_idx = 0U;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u8_t *mod_id = NULL;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -1183,7 +1183,7 @@ static struct label *va_find(const u8_t *label_uuid,
static u8_t va_add(u8_t *label_uuid, u16_t *addr)
{
struct label *update, *free_slot = NULL;
struct label *update = NULL, *free_slot = NULL;
update = va_find(label_uuid, &free_slot);
if (update) {
@ -1210,7 +1210,7 @@ static u8_t va_add(u8_t *label_uuid, u16_t *addr)
static u8_t va_del(u8_t *label_uuid, u16_t *addr)
{
struct label *update;
struct label *update = NULL;
update = va_find(label_uuid, NULL);
if (update) {
@ -1233,8 +1233,8 @@ static u8_t va_del(u8_t *label_uuid, u16_t *addr)
static size_t mod_sub_list_clear(struct bt_mesh_model *mod)
{
u8_t *label_uuid;
size_t clear_count;
u8_t *label_uuid = NULL;
size_t clear_count = 0U;
int i;
/* Unref stored labels related to this model */
@ -1267,13 +1267,13 @@ static void mod_pub_va_set(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u8_t retransmit, status, pub_ttl, pub_period, cred_flag;
u16_t elem_addr, pub_addr, pub_app_idx;
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u8_t *label_uuid;
u8_t *mod_id;
bool vnd;
u8_t retransmit = 0U, status = 0U, pub_ttl = 0U, pub_period = 0U, cred_flag = 0U;
u16_t elem_addr = 0U, pub_addr = 0U, pub_app_idx = 0U;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u8_t *label_uuid = NULL;
u8_t *mod_id = NULL;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -1331,7 +1331,7 @@ send_status:
#else
static size_t mod_sub_list_clear(struct bt_mesh_model *mod)
{
size_t clear_count;
size_t clear_count = 0U;
int i;
/* Unref stored labels related to this model */
@ -1349,11 +1349,11 @@ static void mod_pub_va_set(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u8_t *mod_id, status;
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u16_t elem_addr, pub_addr = 0U;
bool vnd;
u8_t *mod_id = NULL, status = 0U;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u16_t elem_addr = 0U, pub_addr = 0U;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -1425,12 +1425,12 @@ static void mod_sub_add(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u16_t elem_addr, sub_addr;
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u8_t *mod_id;
u8_t status;
bool vnd;
u16_t elem_addr = 0U, sub_addr = 0U;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u8_t *mod_id = NULL;
u8_t status = 0U;
bool vnd = false;
int i;
elem_addr = net_buf_simple_pull_le16(buf);
@ -1511,13 +1511,13 @@ static void mod_sub_del(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u16_t elem_addr, sub_addr;
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u8_t *mod_id;
u16_t *match;
u8_t status;
bool vnd;
u16_t elem_addr = 0U, sub_addr = 0U;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u8_t *mod_id = NULL;
u16_t *match = NULL;
u8_t status = 0U;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -1587,12 +1587,12 @@ static void mod_sub_overwrite(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u16_t elem_addr, sub_addr;
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u8_t *mod_id;
u8_t status;
bool vnd;
u16_t elem_addr = 0U, sub_addr = 0U;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u8_t *mod_id = NULL;
u8_t status = 0U;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -1656,12 +1656,12 @@ static void mod_sub_del_all(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u16_t elem_addr;
u8_t *mod_id;
u8_t status;
bool vnd;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u16_t elem_addr = 0U;
u8_t *mod_id = NULL;
u8_t status = 0U;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -1710,9 +1710,9 @@ static void mod_sub_get(struct bt_mesh_model *model,
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_SUB_LIST,
5 + CONFIG_BLE_MESH_MODEL_GROUP_COUNT * 2);
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u16_t addr, id;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u16_t addr = 0U, id = 0U;
int i;
addr = net_buf_simple_pull_le16(buf);
@ -1766,9 +1766,9 @@ static void mod_sub_get_vnd(struct bt_mesh_model *model,
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_SUB_LIST_VND,
7 + CONFIG_BLE_MESH_MODEL_GROUP_COUNT * 2);
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u16_t company, addr, id;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u16_t company = 0U, addr = 0U, id = 0U;
int i;
addr = net_buf_simple_pull_le16(buf);
@ -1825,13 +1825,13 @@ static void mod_sub_va_add(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u16_t elem_addr, sub_addr;
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u8_t *label_uuid;
u8_t *mod_id;
u8_t status;
bool vnd;
u16_t elem_addr = 0U, sub_addr = 0U;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u8_t *label_uuid = NULL;
u8_t *mod_id = NULL;
u8_t status = 0U;
bool vnd = false;
int i;
elem_addr = net_buf_simple_pull_le16(buf);
@ -1902,14 +1902,14 @@ static void mod_sub_va_del(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u16_t elem_addr, sub_addr;
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u8_t *label_uuid;
u8_t *mod_id;
u16_t *match;
u8_t status;
bool vnd;
u16_t elem_addr = 0U, sub_addr = 0U;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u8_t *label_uuid = NULL;
u8_t *mod_id = NULL;
u16_t *match = NULL;
u8_t status = 0U;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -1970,13 +1970,13 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u16_t elem_addr, sub_addr = BLE_MESH_ADDR_UNASSIGNED;
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u8_t *label_uuid;
u8_t *mod_id;
u8_t status;
bool vnd;
u16_t elem_addr = 0U, sub_addr = BLE_MESH_ADDR_UNASSIGNED;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u8_t *label_uuid = NULL;
u8_t *mod_id = NULL;
u8_t status = 0U;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -2036,12 +2036,12 @@ static void mod_sub_va_add(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u16_t elem_addr;
u8_t *mod_id;
u8_t status;
bool vnd;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u16_t elem_addr = 0U;
u8_t *mod_id = NULL;
u8_t status = 0U;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -2078,11 +2078,11 @@ static void mod_sub_va_del(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
struct bt_mesh_elem *elem;
u16_t elem_addr;
u8_t *mod_id;
u8_t status;
bool vnd;
struct bt_mesh_elem *elem = NULL;
u16_t elem_addr = 0U;
u8_t *mod_id = NULL;
u8_t status = 0U;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -2117,11 +2117,11 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
struct bt_mesh_elem *elem;
u16_t elem_addr;
u8_t *mod_id;
u8_t status;
bool vnd;
struct bt_mesh_elem *elem = NULL;
u16_t elem_addr = 0U;
u8_t *mod_id = NULL;
u8_t status = 0U;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -2173,9 +2173,9 @@ static void net_key_add(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
struct bt_mesh_subnet *sub;
u16_t idx;
int err;
struct bt_mesh_subnet *sub = NULL;
u16_t idx = 0U;
int err = 0;
idx = net_buf_simple_pull_le16(buf);
if (idx > 0xfff) {
@ -2205,7 +2205,7 @@ static void net_key_add(struct bt_mesh_model *model,
/* Check for already existing subnet */
if (sub->net_idx == idx) {
u8_t status;
u8_t status = 0U;
if (memcmp(buf->data, sub->keys[0].net, 16)) {
status = STATUS_IDX_ALREADY_STORED;
@ -2254,9 +2254,9 @@ static void net_key_update(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
struct bt_mesh_subnet *sub;
u16_t idx;
int err;
struct bt_mesh_subnet *sub = NULL;
u16_t idx = 0U;
int err = 0;
idx = net_buf_simple_pull_le16(buf);
if (idx > 0xfff) {
@ -2341,9 +2341,9 @@ static void net_key_del(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
struct bt_mesh_subnet *sub;
u16_t del_idx;
u8_t status;
struct bt_mesh_subnet *sub = NULL;
u16_t del_idx = 0U;
u8_t status = 0U;
del_idx = net_buf_simple_pull_le16(buf);
if (del_idx > 0xfff) {
@ -2390,7 +2390,7 @@ static void net_key_get(struct bt_mesh_model *model,
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_LIST,
IDX_LEN(CONFIG_BLE_MESH_SUBNET_COUNT));
u16_t prev, i;
u16_t prev = 0U, i = 0U;
bt_mesh_model_msg_init(&msg, OP_NET_KEY_LIST);
@ -2425,9 +2425,9 @@ static void node_identity_get(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_IDENTITY_STATUS, 4);
struct bt_mesh_subnet *sub;
u8_t node_id;
u16_t idx;
struct bt_mesh_subnet *sub = NULL;
u8_t node_id = 0U;
u16_t idx = 0U;
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
@ -2463,9 +2463,9 @@ static void node_identity_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_IDENTITY_STATUS, 4);
struct bt_mesh_subnet *sub;
u8_t node_id;
u16_t idx;
struct bt_mesh_subnet *sub = NULL;
u8_t node_id = 0U;
u16_t idx = 0U;
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
@ -2537,11 +2537,11 @@ static void mod_app_bind(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_STATUS, 9);
u16_t elem_addr, key_app_idx;
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u8_t *mod_id, status;
bool vnd;
u16_t elem_addr = 0U, key_app_idx = 0U;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u8_t *mod_id = NULL, status = 0U;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -2600,11 +2600,11 @@ static void mod_app_unbind(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_STATUS, 9);
u16_t elem_addr, key_app_idx;
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u8_t *mod_id, status;
bool vnd;
u16_t elem_addr = 0U, key_app_idx = 0U;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u8_t *mod_id = NULL, status = 0U;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -2662,11 +2662,11 @@ static void mod_app_get(struct bt_mesh_model *model,
9 + KEY_LIST_LEN),
BLE_MESH_MODEL_BUF_LEN(OP_SIG_MOD_APP_LIST,
9 + KEY_LIST_LEN)));
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u8_t *mod_id, status;
u16_t elem_addr;
bool vnd;
struct bt_mesh_model *mod = NULL;
struct bt_mesh_elem *elem = NULL;
u8_t *mod_id = NULL, status = 0U;
u16_t elem_addr = 0U;
bool vnd = false;
elem_addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
@ -2826,9 +2826,9 @@ static void lpn_timeout_get(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_LPN_TIMEOUT_STATUS, 5);
struct bt_mesh_friend *frnd;
u16_t lpn_addr;
s32_t timeout;
struct bt_mesh_friend *frnd = NULL;
u16_t lpn_addr = 0U;
s32_t timeout = 0;
lpn_addr = net_buf_simple_pull_le16(buf);
@ -2886,8 +2886,8 @@ static void send_krp_status(struct bt_mesh_model *model,
static void krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
struct bt_mesh_subnet *sub;
u16_t idx;
struct bt_mesh_subnet *sub = NULL;
u16_t idx = 0U;
idx = net_buf_simple_pull_le16(buf);
if (idx > 0xfff) {
@ -2909,9 +2909,9 @@ static void krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
struct bt_mesh_subnet *sub;
u8_t phase;
u16_t idx;
struct bt_mesh_subnet *sub = NULL;
u8_t phase = 0U;
u16_t idx = 0U;
idx = net_buf_simple_pull_le16(buf);
phase = net_buf_simple_pull_u8(buf);
@ -3056,8 +3056,8 @@ static void heartbeat_pub_set(struct bt_mesh_model *model,
{
struct hb_pub_param *param = (void *)buf->data;
struct bt_mesh_cfg_srv *cfg = model->user_data;
u16_t dst, feat, idx;
u8_t status;
u16_t dst = 0U, feat = 0U, idx = 0U;
u8_t status = 0U;
BT_DBG("src 0x%04x", ctx->addr);
@ -3153,8 +3153,8 @@ static void hb_sub_send_status(struct bt_mesh_model *model,
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_SUB_STATUS, 9);
struct bt_mesh_cfg_srv *cfg = model->user_data;
u16_t period;
s64_t uptime;
u16_t period = 0U;
s64_t uptime = 0;
BT_DBG("src 0x%04x status 0x%02x", ctx->addr, status);
@ -3194,9 +3194,9 @@ static void heartbeat_sub_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_cfg_srv *cfg = model->user_data;
u16_t sub_src, sub_dst;
u8_t sub_period;
s32_t period_ms;
u16_t sub_src = 0U, sub_dst = 0U;
u8_t sub_period = 0U;
s32_t period_ms = 0;
BT_DBG("src 0x%04x", ctx->addr);
@ -3328,8 +3328,8 @@ static void hb_publish(struct k_work *work)
struct bt_mesh_cfg_srv *cfg = CONTAINER_OF(work,
struct bt_mesh_cfg_srv,
hb_pub.timer.work);
struct bt_mesh_subnet *sub;
u16_t period_ms;
struct bt_mesh_subnet *sub = NULL;
u16_t period_ms = 0U;
BT_DBG("hb_pub.count: %u", cfg->hb_pub.count);
@ -3436,7 +3436,7 @@ int bt_mesh_cfg_srv_deinit(struct bt_mesh_model *model, bool primary)
static void mod_reset(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
bool vnd, bool primary, void *user_data)
{
size_t clear_count;
size_t clear_count = 0U;
/* Clear model state that isn't otherwise cleared. E.g. AppKey
* binding and model publication is cleared as a consequence

View File

@ -23,8 +23,8 @@
int bt_mesh_aes_cmac(const u8_t key[16], struct bt_mesh_sg *sg,
size_t sg_len, u8_t mac[16])
{
struct tc_aes_key_sched_struct sched;
struct tc_cmac_struct state;
struct tc_aes_key_sched_struct sched = {0};
struct tc_cmac_struct state = {0};
if (tc_cmac_setup(&state, key, &sched) == TC_CRYPTO_FAIL) {
return -EIO;
@ -47,7 +47,7 @@ int bt_mesh_aes_cmac(const u8_t key[16], struct bt_mesh_sg *sg,
int bt_mesh_k1(const u8_t *ikm, size_t ikm_len, const u8_t salt[16],
const char *info, u8_t okm[16])
{
int err;
int err = 0;
err = bt_mesh_aes_cmac_one(salt, ikm, ikm_len, okm);
if (err < 0) {
@ -60,12 +60,12 @@ int bt_mesh_k1(const u8_t *ikm, size_t ikm_len, const u8_t salt[16],
int bt_mesh_k2(const u8_t n[16], const u8_t *p, size_t p_len,
u8_t net_id[1], u8_t enc_key[16], u8_t priv_key[16])
{
struct bt_mesh_sg sg[3];
u8_t salt[16];
u8_t out[16];
u8_t t[16];
u8_t pad;
int err;
struct bt_mesh_sg sg[3] = {0};
u8_t salt[16] = {0};
u8_t out[16] = {0};
u8_t t[16] = {0};
u8_t pad = 0U;
int err = 0;
BT_DBG("n %s", bt_hex(n, 16));
BT_DBG("p %s", bt_hex(p, p_len));
@ -125,9 +125,9 @@ int bt_mesh_k2(const u8_t n[16], const u8_t *p, size_t p_len,
int bt_mesh_k3(const u8_t n[16], u8_t out[8])
{
u8_t id64[] = { 'i', 'd', '6', '4', 0x01 };
u8_t tmp[16];
u8_t t[16];
int err;
u8_t tmp[16] = {0};
u8_t t[16] = {0};
int err = 0;
err = bt_mesh_s1("smk3", tmp);
if (err) {
@ -152,9 +152,9 @@ int bt_mesh_k3(const u8_t n[16], u8_t out[8])
int bt_mesh_k4(const u8_t n[16], u8_t out[1])
{
u8_t id6[] = { 'i', 'd', '6', 0x01 };
u8_t tmp[16];
u8_t t[16];
int err;
u8_t tmp[16] = {0};
u8_t t[16] = {0};
int err = 0;
err = bt_mesh_s1("smk4", tmp);
if (err) {
@ -179,8 +179,8 @@ int bt_mesh_k4(const u8_t n[16], u8_t out[1])
int bt_mesh_id128(const u8_t n[16], const char *s, u8_t out[16])
{
const char *id128 = "id128\x01";
u8_t salt[16];
int err;
u8_t salt[16] = {0};
int err = 0;
err = bt_mesh_s1(s, salt);
if (err) {
@ -195,10 +195,11 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
const u8_t *aad, size_t aad_len,
u8_t *out_msg, size_t mic_size)
{
u8_t msg[16], pmsg[16], cmic[16], cmsg[16], Xn[16], mic[16];
u16_t last_blk, blk_cnt;
size_t i, j;
int err;
u8_t msg[16] = {0}, pmsg[16] = {0}, cmic[16] = {0},
cmsg[16] = {0}, Xn[16] = {0}, mic[16] = {0};
u16_t last_blk = 0U, blk_cnt = 0U;
size_t i = 0U, j = 0U;
int err = 0;
if (msg_len < 1 || aad_len >= 0xff00) {
return -EINVAL;
@ -353,10 +354,11 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
const u8_t *aad, size_t aad_len,
u8_t *out_msg, size_t mic_size)
{
u8_t pmsg[16], cmic[16], cmsg[16], mic[16], Xn[16];
u16_t blk_cnt, last_blk;
size_t i, j;
int err;
u8_t pmsg[16] = {0}, cmic[16] = {0}, cmsg[16] = {0},
mic[16] = {0}, Xn[16] = {0};
u16_t blk_cnt = 0U, last_blk = 0U;
size_t i = 0U, j = 0U;
int err = 0;
BT_DBG("key %s", bt_hex(key, 16));
BT_DBG("nonce %s", bt_hex(nonce, 13));
@ -566,8 +568,8 @@ int bt_mesh_net_obfuscate(u8_t *pdu, u32_t iv_index,
const u8_t privacy_key[16])
{
u8_t priv_rand[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, };
u8_t tmp[16];
int err, i;
u8_t tmp[16] = {0};
int err = 0, i;
BT_DBG("IVIndex %u, PrivacyKey %s", iv_index, bt_hex(privacy_key, 16));
@ -592,8 +594,8 @@ int bt_mesh_net_encrypt(const u8_t key[16], struct net_buf_simple *buf,
u32_t iv_index, bool proxy)
{
u8_t mic_len = NET_MIC_LEN(buf->data);
u8_t nonce[13];
int err;
u8_t nonce[13] = {0};
int err = 0;
BT_DBG("IVIndex %u EncKey %s mic_len %u", iv_index, bt_hex(key, 16),
mic_len);
@ -624,7 +626,7 @@ int bt_mesh_net_decrypt(const u8_t key[16], struct net_buf_simple *buf,
u32_t iv_index, bool proxy)
{
u8_t mic_len = NET_MIC_LEN(buf->data);
u8_t nonce[13];
u8_t nonce[13] = {0};
BT_DBG("PDU (%u bytes) %s", buf->len, bt_hex(buf->data, buf->len));
BT_DBG("iv_index %u, key %s mic_len %u", iv_index, bt_hex(key, 16),
@ -670,8 +672,8 @@ int bt_mesh_app_encrypt(const u8_t key[16], bool dev_key, u8_t aszmic,
struct net_buf_simple *buf, const u8_t *ad,
u16_t src, u16_t dst, u32_t seq_num, u32_t iv_index)
{
u8_t nonce[13];
int err;
u8_t nonce[13] = {0};
int err = 0;
BT_DBG("AppKey %s", bt_hex(key, 16));
BT_DBG("dev_key %u src 0x%04x dst 0x%04x", dev_key, src, dst);
@ -697,8 +699,8 @@ int bt_mesh_app_decrypt(const u8_t key[16], bool dev_key, u8_t aszmic,
const u8_t *ad, u16_t src, u16_t dst, u32_t seq_num,
u32_t iv_index)
{
u8_t nonce[13];
int err;
u8_t nonce[13] = {0};
int err = 0;
BT_DBG("EncData (len %u) %s", buf->len, bt_hex(buf->data, buf->len));
@ -787,9 +789,9 @@ bool bt_mesh_fcs_check(struct net_buf_simple *buf, u8_t received_fcs)
int bt_mesh_virtual_addr(const u8_t virtual_label[16], u16_t *addr)
{
u8_t salt[16];
u8_t tmp[16];
int err;
u8_t salt[16] = {0};
u8_t tmp[16] = {0};
int err = 0;
err = bt_mesh_s1("vtad", salt);
if (err) {
@ -849,8 +851,8 @@ int bt_mesh_beacon_auth(const u8_t beacon_key[16], u8_t flags,
const u8_t net_id[8], u32_t iv_index,
u8_t auth[8])
{
u8_t msg[13], tmp[16];
int err;
u8_t msg[13] = {0}, tmp[16] = {0};
int err = 0;
BT_DBG("BeaconKey %s", bt_hex(beacon_key, 16));
BT_DBG("NetId %s", bt_hex(net_id, 8));

View File

@ -128,7 +128,7 @@ struct bt_mesh_friend *bt_mesh_friend_find(u16_t net_idx, u16_t lpn_addr,
static void purge_buffers(sys_slist_t *list)
{
while (!sys_slist_is_empty(list)) {
struct net_buf *buf;
struct net_buf *buf = NULL;
buf = (void *)sys_slist_get_not_empty(list);
@ -241,15 +241,15 @@ void bt_mesh_friend_sec_update(u16_t net_idx)
int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
{
struct bt_mesh_ctl_friend_clear *msg = (void *)buf->data;
struct bt_mesh_friend *frnd;
u16_t lpn_addr, lpn_counter;
struct bt_mesh_friend *frnd = NULL;
u16_t lpn_addr = 0U, lpn_counter = 0U;
struct bt_mesh_net_tx tx = {
.sub = rx->sub,
.ctx = &rx->ctx,
.src = bt_mesh_primary_addr(),
.xmit = bt_mesh_net_transmit_get(),
};
struct bt_mesh_ctl_friend_clear_confirm cfm;
struct bt_mesh_ctl_friend_clear_confirm cfm = {0};
if (buf->len < sizeof(*msg)) {
BT_WARN("%s, Too short Friend Clear", __func__);
@ -322,7 +322,7 @@ static struct net_buf *create_friend_pdu(struct bt_mesh_friend *frnd,
struct friend_pdu_info *info,
struct net_buf_simple *sdu)
{
struct net_buf *buf;
struct net_buf *buf = NULL;
buf = bt_mesh_adv_create_from_pool(&friend_buf_pool, adv_alloc,
BLE_MESH_ADV_DATA,
@ -363,8 +363,8 @@ static int unseg_app_sdu_unpack(struct bt_mesh_friend *frnd,
struct unseg_app_sdu_meta *meta)
{
u16_t app_idx = FRIEND_ADV(buf)->app_idx;
u8_t role;
int err;
u8_t role = 0U;
int err = 0;
meta->subnet = friend_subnet_get(frnd->net_idx);
if (!meta->subnet) {
@ -401,7 +401,7 @@ static int unseg_app_sdu_decrypt(struct bt_mesh_friend *frnd,
struct net_buf *buf,
const struct unseg_app_sdu_meta *meta)
{
struct net_buf_simple sdu;
struct net_buf_simple sdu = {0};
net_buf_simple_clone(&buf->b, &sdu);
net_buf_simple_pull(&sdu, 10);
@ -417,7 +417,7 @@ static int unseg_app_sdu_encrypt(struct bt_mesh_friend *frnd,
struct net_buf *buf,
const struct unseg_app_sdu_meta *meta)
{
struct net_buf_simple sdu;
struct net_buf_simple sdu = {0};
net_buf_simple_clone(&buf->b, &sdu);
net_buf_simple_pull(&sdu, 10);
@ -432,8 +432,8 @@ static int unseg_app_sdu_encrypt(struct bt_mesh_friend *frnd,
static int unseg_app_sdu_prepare(struct bt_mesh_friend *frnd,
struct net_buf *buf)
{
struct unseg_app_sdu_meta meta;
int err;
struct unseg_app_sdu_meta meta = {0};
int err = 0;
if (FRIEND_ADV(buf)->app_idx == BLE_MESH_KEY_UNUSED) {
return 0;
@ -469,11 +469,11 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct net_buf *buf,
bool master_cred)
{
struct bt_mesh_subnet *sub = friend_subnet_get(frnd->net_idx);
const u8_t *enc, *priv;
u32_t iv_index;
u16_t src;
u8_t nid;
int err;
const u8_t *enc = NULL, *priv = NULL;
u32_t iv_index = 0U;
u16_t src = 0U;
u8_t nid = 0U;
int err = 0;
if (!sub) {
BT_ERR("Invalid subnet to encrypt friend pdu");
@ -533,7 +533,7 @@ static struct net_buf *encode_friend_ctl(struct bt_mesh_friend *frnd,
u8_t ctl_op,
struct net_buf_simple *sdu)
{
struct friend_pdu_info info;
struct friend_pdu_info info = {0};
BT_DBG("LPN 0x%04x", frnd->lpn);
@ -554,7 +554,7 @@ static struct net_buf *encode_friend_ctl(struct bt_mesh_friend *frnd,
static struct net_buf *encode_update(struct bt_mesh_friend *frnd, u8_t md)
{
struct bt_mesh_ctl_friend_update *upd;
struct bt_mesh_ctl_friend_update *upd = NULL;
NET_BUF_SIMPLE_DEFINE(sdu, 1 + sizeof(*upd));
struct bt_mesh_subnet *sub = friend_subnet_get(frnd->net_idx);
@ -574,9 +574,9 @@ static struct net_buf *encode_update(struct bt_mesh_friend *frnd, u8_t md)
static void enqueue_sub_cfm(struct bt_mesh_friend *frnd, u8_t xact)
{
struct bt_mesh_ctl_friend_sub_confirm *cfm;
struct bt_mesh_ctl_friend_sub_confirm *cfm = NULL;
NET_BUF_SIMPLE_DEFINE(sdu, 1 + sizeof(*cfm));
struct net_buf *buf;
struct net_buf *buf = NULL;
BT_DBG("lpn 0x%04x xact 0x%02x", frnd->lpn, xact);
@ -614,8 +614,8 @@ static void friend_recv_delay(struct bt_mesh_friend *frnd)
int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf)
{
struct bt_mesh_friend *frnd;
u8_t xact;
struct bt_mesh_friend *frnd = NULL;
u8_t xact = 0U;
if (buf->len < BLE_MESH_FRIEND_SUB_MIN_LEN) {
BT_WARN("%s, Too short Friend Subscription Add", __func__);
@ -649,8 +649,8 @@ int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx,
int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf)
{
struct bt_mesh_friend *frnd;
u8_t xact;
struct bt_mesh_friend *frnd = NULL;
u8_t xact = 0U;
if (buf->len < BLE_MESH_FRIEND_SUB_MIN_LEN) {
BT_WARN("%s, Too short Friend Subscription Remove", __func__);
@ -689,7 +689,7 @@ static void enqueue_buf(struct bt_mesh_friend *frnd, struct net_buf *buf)
static void enqueue_update(struct bt_mesh_friend *frnd, u8_t md)
{
struct net_buf *buf;
struct net_buf *buf = NULL;
buf = encode_update(frnd, md);
if (!buf) {
@ -704,7 +704,7 @@ static void enqueue_update(struct bt_mesh_friend *frnd, u8_t md)
int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
{
struct bt_mesh_ctl_friend_poll *msg = (void *)buf->data;
struct bt_mesh_friend *frnd;
struct bt_mesh_friend *frnd = NULL;
if (buf->len < sizeof(*msg)) {
BT_WARN("%s, Too short Friend Poll", __func__);
@ -821,7 +821,7 @@ static void clear_timeout(struct k_work *work)
{
struct bt_mesh_friend *frnd = CONTAINER_OF(work, struct bt_mesh_friend,
clear.timer.work);
u32_t duration;
u32_t duration = 0U;
BT_DBG("LPN 0x%04x (old) Friend 0x%04x", frnd->lpn, frnd->clear.frnd);
@ -849,8 +849,8 @@ int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf)
{
struct bt_mesh_ctl_friend_clear_confirm *msg = (void *)buf->data;
struct bt_mesh_friend *frnd;
u16_t lpn_addr, lpn_counter;
struct bt_mesh_friend *frnd = NULL;
u16_t lpn_addr = 0U, lpn_counter = 0U;
BT_DBG("%s", __func__);
@ -887,9 +887,9 @@ int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx,
static void enqueue_offer(struct bt_mesh_friend *frnd, s8_t rssi)
{
struct bt_mesh_ctl_friend_offer *off;
struct bt_mesh_ctl_friend_offer *off = NULL;
NET_BUF_SIMPLE_DEFINE(sdu, 1 + sizeof(*off));
struct net_buf *buf;
struct net_buf *buf = NULL;
BT_DBG("%s", __func__);
@ -935,7 +935,7 @@ static s32_t offer_delay(struct bt_mesh_friend *frnd, s8_t rssi, u8_t crit)
* want to avoid floating-point arithmetic.
*/
static const u8_t fact[] = { 10, 15, 20, 25 };
s32_t delay;
s32_t delay = 0;
BT_INFO("ReceiveWindowFactor %u ReceiveWindow %u RSSIFactor %u RSSI %d",
fact[RECV_WIN_FACT(crit)], RECV_WIN,
@ -959,7 +959,7 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
{
struct bt_mesh_ctl_friend_req *msg = (void *)buf->data;
struct bt_mesh_friend *frnd = NULL;
u32_t poll_to;
u32_t poll_to = 0U;
int i;
if (buf->len < sizeof(*msg)) {
@ -1062,9 +1062,9 @@ init_friend:
static bool is_seg(struct bt_mesh_friend_seg *seg, u16_t src, u16_t seq_zero)
{
struct net_buf *buf = (void *)sys_slist_peek_head(&seg->queue);
struct net_buf_simple_state state;
u16_t buf_seq_zero;
u16_t buf_src;
struct net_buf_simple_state state = {0};
u16_t buf_seq_zero = 0U;
u16_t buf_src = 0U;
if (!buf) {
return false;
@ -1111,7 +1111,7 @@ static void enqueue_friend_pdu(struct bt_mesh_friend *frnd,
u16_t src, u8_t seg_count,
struct net_buf *buf)
{
struct bt_mesh_friend_seg *seg;
struct bt_mesh_friend_seg *seg = NULL;
BT_DBG("type %u", type);
@ -1267,11 +1267,11 @@ int bt_mesh_friend_init(void)
int bt_mesh_friend_deinit(void)
{
size_t i;
int i;
bt_mesh_friend_clear_net_idx(BLE_MESH_KEY_ANY);
for (i = 0U; i < ARRAY_SIZE(bt_mesh.frnd); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) {
struct bt_mesh_friend *frnd = &bt_mesh.frnd[i];
frnd->net_idx = BLE_MESH_KEY_UNUSED;
@ -1288,7 +1288,7 @@ int bt_mesh_friend_deinit(void)
static bool is_segack(struct net_buf *buf, u64_t *seqauth, u16_t src)
{
struct net_buf_simple_state state;
struct net_buf_simple_state state = {0};
bool found = false;
if (buf->len != 16) {
@ -1325,7 +1325,7 @@ end:
static void friend_purge_old_ack(struct bt_mesh_friend *frnd, u64_t *seq_auth,
u16_t src)
{
sys_snode_t *cur, *prev = NULL;
sys_snode_t *cur = NULL, *prev = NULL;
BT_DBG("SeqAuth %llx src 0x%04x", *seq_auth, src);
@ -1353,8 +1353,8 @@ static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd,
u64_t *seq_auth, u8_t seg_count,
struct net_buf_simple *sbuf)
{
struct friend_pdu_info info;
struct net_buf *buf;
struct friend_pdu_info info = {0};
struct net_buf *buf = NULL;
/* Because of network loopback, tx packets will also be passed into
* this rx function. These packets have already been added to the
@ -1405,8 +1405,8 @@ static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd,
u64_t *seq_auth, u8_t seg_count,
struct net_buf_simple *sbuf)
{
struct friend_pdu_info info;
struct net_buf *buf;
struct friend_pdu_info info = {0};
struct net_buf *buf = NULL;
BT_DBG("LPN 0x%04x", frnd->lpn);
@ -1559,8 +1559,8 @@ bool bt_mesh_friend_queue_has_space(u16_t net_idx, u16_t src, u16_t dst,
static bool friend_queue_prepare_space(struct bt_mesh_friend *frnd, u16_t addr,
u64_t *seq_auth, u8_t seg_count)
{
bool pending_segments;
u8_t avail_space;
bool pending_segments = false;
u8_t avail_space = 0U;
if (!friend_queue_has_space(frnd, addr, seq_auth, seg_count)) {
return false;
@ -1697,7 +1697,7 @@ void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src,
void bt_mesh_friend_remove_lpn(u16_t lpn_addr)
{
struct bt_mesh_friend *frnd;
struct bt_mesh_friend *frnd = NULL;
frnd = bt_mesh_friend_find(BLE_MESH_KEY_ANY, lpn_addr, false, false);
if (frnd) {

View File

@ -69,7 +69,7 @@ static void timeout_handler(struct k_work *work)
struct k_delayed_work *timer = NULL;
bt_mesh_client_node_t *node = NULL;
struct bt_mesh_msg_ctx ctx = {0};
u32_t opcode;
u32_t opcode = 0U;
BT_WARN("Receive health status message timeout");
@ -182,8 +182,8 @@ static void health_current_status(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
bt_mesh_client_node_t *node = NULL;
u8_t test_id;
u16_t cid;
u8_t test_id = 0U;
u16_t cid = 0U;
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
@ -199,13 +199,16 @@ static void health_current_status(struct bt_mesh_model *model,
BT_DBG("Test ID 0x%02x Company ID 0x%04x Fault Count %u",
test_id, cid, buf->len);
((void) test_id);
((void) cid);
}
static void health_period_status(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u8_t status = 0;
u8_t status = 0U;
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
@ -220,7 +223,7 @@ static void health_attention_status(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u8_t status = 0;
u8_t status = 0U;
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
@ -242,7 +245,7 @@ const struct bt_mesh_model_op bt_mesh_health_cli_op[] = {
int bt_mesh_health_attention_get(struct bt_mesh_msg_ctx *ctx)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_ATTENTION_GET, 0);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -264,8 +267,8 @@ int bt_mesh_health_attention_set(struct bt_mesh_msg_ctx *ctx,
u8_t attention, bool need_ack)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_ATTENTION_SET, 1);
u32_t opcode;
int err;
u32_t opcode = 0U;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -292,7 +295,7 @@ int bt_mesh_health_attention_set(struct bt_mesh_msg_ctx *ctx,
int bt_mesh_health_period_get(struct bt_mesh_msg_ctx *ctx)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_PERIOD_GET, 0);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -314,8 +317,8 @@ int bt_mesh_health_period_set(struct bt_mesh_msg_ctx *ctx,
u8_t divisor, bool need_ack)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_PERIOD_SET, 1);
u32_t opcode;
int err;
u32_t opcode = 0U;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -343,8 +346,8 @@ int bt_mesh_health_fault_test(struct bt_mesh_msg_ctx *ctx,
u16_t cid, u8_t test_id, bool need_ack)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_TEST, 3);
u32_t opcode;
int err;
u32_t opcode = 0U;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -373,8 +376,8 @@ int bt_mesh_health_fault_clear(struct bt_mesh_msg_ctx *ctx,
u16_t cid, bool need_ack)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_CLEAR, 2);
u32_t opcode;
int err;
u32_t opcode = 0U;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;
@ -401,7 +404,7 @@ int bt_mesh_health_fault_clear(struct bt_mesh_msg_ctx *ctx,
int bt_mesh_health_fault_get(struct bt_mesh_msg_ctx *ctx, u16_t cid)
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_GET, 2);
int err;
int err = 0;
if (!ctx || !ctx->addr) {
return -EINVAL;

View File

@ -39,8 +39,8 @@ struct bt_mesh_health_srv *health_srv;
static u8_t health_get_curr_fault_count(struct bt_mesh_model *model)
{
struct bt_mesh_health_srv *srv = model->user_data;
u8_t count = 0;
size_t i;
u8_t count = 0U;
size_t i = 0U;
for (i = 0U; i < ARRAY_SIZE(srv->test.curr_faults); i++) {
if (srv->test.curr_faults[i] != HEALTH_NO_FAULT) {
@ -56,8 +56,8 @@ static void health_get_fault_value(struct bt_mesh_model *model,
bool current)
{
struct bt_mesh_health_srv *srv = model->user_data;
size_t array_size;
size_t i;
size_t array_size = 0U;
size_t i = 0U;
array_size = current ? ARRAY_SIZE(srv->test.curr_faults) : ARRAY_SIZE(srv->test.reg_faults);
@ -76,9 +76,9 @@ static void health_get_fault_value(struct bt_mesh_model *model,
static bool health_is_test_id_exist(struct bt_mesh_model *model, u8_t test_id)
{
struct bt_mesh_health_srv *srv = model->user_data;
u8_t i;
int i;
for (i = 0U; i < srv->test.id_count; i++) {
for (i = 0; i < srv->test.id_count; i++) {
if (srv->test.test_ids[i] == test_id) {
return true;
}
@ -92,7 +92,7 @@ static int health_send_fault_status(struct bt_mesh_model *model,
{
struct bt_mesh_health_srv *srv = model->user_data;
struct net_buf_simple *msg = NULL;
int err;
int err = 0;
msg = bt_mesh_alloc_buf(4 + ARRAY_SIZE(srv->test.reg_faults) + 4);
if (!msg) {
@ -125,7 +125,7 @@ static void health_fault_get(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_health_srv *srv = model->user_data;
u16_t company_id;
u16_t company_id = 0U;
if (!srv) {
BT_ERR("%s, No Health Server context provided", __func__);
@ -148,7 +148,7 @@ static void health_fault_clear(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_health_srv *srv = model->user_data;
u16_t company_id;
u16_t company_id = 0U;
if (!srv) {
BT_ERR("%s, No Health Server context provided", __func__);
@ -179,8 +179,8 @@ static void health_fault_test(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_health_srv *srv = model->user_data;
u16_t company_id;
u8_t test_id;
u16_t company_id = 0U;
u8_t test_id = 0U;
BT_DBG("%s", __func__);
@ -219,7 +219,7 @@ static void send_attention_status(struct bt_mesh_model *model,
{
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_ATTENTION_STATUS, 1);
struct bt_mesh_health_srv *srv = model->user_data;
u8_t time;
u8_t time = 0U;
if (!srv) {
BT_ERR("%s, No Health Server context provided", __func__);
@ -250,7 +250,7 @@ static void health_set_attention(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u8_t time;
u8_t time = 0U;
time = net_buf_simple_pull_u8(buf);
@ -298,7 +298,7 @@ static void health_set_period(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
u8_t period;
u8_t period = 0U;
period = net_buf_simple_pull_u8(buf);
if (period > 15) {
@ -365,7 +365,7 @@ static size_t health_get_current(struct bt_mesh_model *model,
static int health_pub_update(struct bt_mesh_model *model)
{
struct bt_mesh_model_pub *pub = model->pub;
size_t count;
size_t count = 0U;
BT_DBG("%s", __func__);
@ -386,7 +386,7 @@ static int health_pub_update(struct bt_mesh_model *model)
int bt_mesh_fault_update(struct bt_mesh_elem *elem)
{
struct bt_mesh_model *model;
struct bt_mesh_model *model = NULL;
model = bt_mesh_model_find(elem, BLE_MESH_MODEL_ID_HEALTH_SRV);
if (!model) {
@ -512,7 +512,7 @@ int bt_mesh_health_srv_deinit(struct bt_mesh_model *model, bool primary)
void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)
{
struct bt_mesh_health_srv *srv;
struct bt_mesh_health_srv *srv = NULL;
if (!model) {
srv = health_srv;

View File

@ -71,6 +71,7 @@
static void (*lpn_cb)(u16_t friend_addr, bool established);
#if !CONFIG_BLE_MESH_NO_LOG
static const char *state2str(int state)
{
switch (state) {
@ -98,6 +99,7 @@ static const char *state2str(int state)
return "(unknown)";
}
}
#endif
static inline void lpn_set_state(int state)
{
@ -388,7 +390,7 @@ static int send_friend_poll(void)
};
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
u8_t fsn = lpn->fsn;
int err;
int err = 0;
BT_DBG("lpn->sent_req 0x%02x", lpn->sent_req);
@ -507,9 +509,9 @@ int bt_mesh_lpn_friend_offer(struct bt_mesh_net_rx *rx,
struct bt_mesh_ctl_friend_offer *msg = (void *)buf->data;
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
struct bt_mesh_subnet *sub = rx->sub;
struct friend_cred *cred;
u16_t frnd_counter;
int err;
struct friend_cred *cred = NULL;
u16_t frnd_counter = 0U;
int err = 0;
if (buf->len < sizeof(*msg)) {
BT_WARN("Too short Friend Offer");
@ -570,7 +572,7 @@ int bt_mesh_lpn_friend_clear_cfm(struct bt_mesh_net_rx *rx,
{
struct bt_mesh_ctl_friend_clear_confirm *msg = (void *)buf->data;
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
u16_t addr, counter;
u16_t addr = 0U, counter = 0U;
if (buf->len < sizeof(*msg)) {
BT_WARN("Too short Friend Clear Confirm");
@ -672,8 +674,8 @@ static bool sub_update(u8_t op)
.xmit = POLL_XMIT,
.friend_cred = true,
};
struct bt_mesh_ctl_friend_sub req;
size_t i, g;
struct bt_mesh_ctl_friend_sub req = {0};
size_t i = 0U, g = 0U;
BT_DBG("op 0x%02x sent_req 0x%02x", op, lpn->sent_req);
@ -681,7 +683,7 @@ static bool sub_update(u8_t op)
return false;
}
for (i = 0, g = 0; i < ARRAY_SIZE(lpn->groups); i++) {
for (i = 0U, g = 0U; i < ARRAY_SIZE(lpn->groups); i++) {
if (lpn->groups[i] == BLE_MESH_ADDR_UNASSIGNED) {
continue;
}
@ -709,7 +711,7 @@ static bool sub_update(u8_t op)
}
}
if (g == 0) {
if (g == 0U) {
group_zero(lpn->pending);
return false;
}
@ -957,7 +959,7 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx,
struct bt_mesh_ctl_friend_update *msg = (void *)buf->data;
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
struct bt_mesh_subnet *sub = rx->sub;
u32_t iv_index;
u32_t iv_index = 0U;
if (buf->len < sizeof(*msg)) {
BT_WARN("Too short Friend Update");

View File

@ -36,8 +36,8 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
u8_t flags, u32_t iv_index, u16_t addr,
const u8_t dev_key[16])
{
bool pb_gatt_enabled;
int err;
bool pb_gatt_enabled = false;
int err = 0;
BT_INFO("Primary Element: 0x%04x", addr);
BT_INFO("net_idx 0x%04x flags 0x%02x iv_index 0x%04x",
@ -235,7 +235,7 @@ static void model_suspend(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
int bt_mesh_suspend(void)
{
int err;
int err = 0;
if (!bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_VALID)) {
return -EINVAL;
@ -277,7 +277,7 @@ static void model_resume(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
int bt_mesh_resume(void)
{
int err;
int err = 0;
if (!bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_VALID)) {
return -EINVAL;
@ -306,7 +306,7 @@ int bt_mesh_resume(void)
int bt_mesh_init(const struct bt_mesh_prov *prov,
const struct bt_mesh_comp *comp)
{
int err;
int err = 0;
bt_mesh_k_init();
@ -378,7 +378,7 @@ int bt_mesh_init(const struct bt_mesh_prov *prov,
int bt_mesh_deinit(void)
{
int err;
int err = 0;
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) {
if (IS_ENABLED(CONFIG_BLE_MESH_PB_ADV)) {
@ -513,7 +513,7 @@ int bt_mesh_provisioner_net_start(bt_mesh_prov_bearer_t bearers)
int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers)
{
int err;
int err = 0;
if (bt_mesh_is_provisioner_en()) {
BT_WARN("%s, Already", __func__);
@ -543,7 +543,7 @@ int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers)
int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers)
{
bt_mesh_prov_bearer_t enable;
bt_mesh_prov_bearer_t enable = 0U;
if (!bt_mesh_is_provisioner_en()) {
BT_WARN("%s, Already", __func__);

View File

@ -89,7 +89,7 @@ static int dup_cache_next;
static bool check_dup(struct net_buf_simple *data)
{
const u8_t *tail = net_buf_simple_tail(data);
u32_t val;
u32_t val = 0U;
int i;
val = sys_get_be32(tail - 4) ^ sys_get_be32(tail - 8);
@ -108,7 +108,7 @@ static bool check_dup(struct net_buf_simple *data)
static u64_t msg_hash(struct bt_mesh_net_rx *rx, struct net_buf_simple *pdu)
{
u32_t hash1, hash2;
u32_t hash1 = 0U, hash2 = 0U;
/* Three least significant bytes of IVI + first byte of SEQ */
hash1 = (BLE_MESH_NET_IVI_RX(rx) << 8) | pdu->data[2];
@ -123,9 +123,9 @@ static bool msg_cache_match(struct bt_mesh_net_rx *rx,
struct net_buf_simple *pdu)
{
u64_t hash = msg_hash(rx, pdu);
u16_t i;
int i;
for (i = 0U; i < ARRAY_SIZE(msg_cache); i++) {
for (i = 0; i < ARRAY_SIZE(msg_cache); i++) {
if (msg_cache[i] == hash) {
return true;
}
@ -142,9 +142,10 @@ static bool msg_cache_match(struct bt_mesh_net_rx *rx,
#if CONFIG_BLE_MESH_PROVISIONER
void bt_mesh_msg_cache_clear(u16_t unicast_addr, u8_t elem_num)
{
u16_t src, i;
u16_t src = 0U;
int i;
for (i = 0U; i < ARRAY_SIZE(msg_cache); i++) {
for (i = 0; i < ARRAY_SIZE(msg_cache); i++) {
src = (((u8_t)(msg_cache[i] >> 16)) << 8) | (u8_t)(msg_cache[i] >> 24);
if (src >= unicast_addr && src < unicast_addr + elem_num) {
memset(&msg_cache[i], 0x0, sizeof(msg_cache[i]));
@ -174,8 +175,8 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys,
const u8_t key[16])
{
u8_t p[] = { 0 };
u8_t nid;
int err;
u8_t nid = 0U;
int err = 0;
err = bt_mesh_k2(key, p, sizeof(p), &nid, keys->enc, keys->privacy);
if (err) {
@ -223,9 +224,9 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys,
defined(CONFIG_BLE_MESH_FRIEND))
int friend_cred_set(struct friend_cred *cred, u8_t idx, const u8_t net_key[16])
{
u16_t lpn_addr, frnd_addr;
int err;
u8_t p[9];
u16_t lpn_addr = 0U, frnd_addr = 0U;
int err = 0;
u8_t p[9] = {0};
#if defined(CONFIG_BLE_MESH_LOW_POWER)
if (cred->addr == bt_mesh.lpn.frnd) {
@ -281,7 +282,7 @@ void friend_cred_refresh(u16_t net_idx)
int friend_cred_update(struct bt_mesh_subnet *sub)
{
int err, i;
int err = 0, i;
BT_DBG("net_idx 0x%04x", sub->net_idx);
@ -305,8 +306,8 @@ int friend_cred_update(struct bt_mesh_subnet *sub)
struct friend_cred *friend_cred_create(struct bt_mesh_subnet *sub, u16_t addr,
u16_t lpn_counter, u16_t frnd_counter)
{
struct friend_cred *cred;
int i, err;
struct friend_cred *cred = NULL;
int i, err = 0;
BT_DBG("net_idx 0x%04x addr 0x%04x", sub->net_idx, addr);
@ -432,7 +433,7 @@ u8_t bt_mesh_net_flags(struct bt_mesh_subnet *sub)
int bt_mesh_net_beacon_update(struct bt_mesh_subnet *sub)
{
u8_t flags = bt_mesh_net_flags(sub);
struct bt_mesh_subnet_keys *keys;
struct bt_mesh_subnet_keys *keys = NULL;
if (sub->kr_flag) {
BT_DBG("NetIndex %u Using new key", sub->net_idx);
@ -451,8 +452,8 @@ int bt_mesh_net_beacon_update(struct bt_mesh_subnet *sub)
int bt_mesh_net_create(u16_t idx, u8_t flags, const u8_t key[16],
u32_t iv_index)
{
struct bt_mesh_subnet *sub;
int err;
struct bt_mesh_subnet *sub = NULL;
int err = 0;
BT_DBG("idx %u flags 0x%02x iv_index %u", idx, flags, iv_index);
@ -762,10 +763,10 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf,
bool new_key, const struct bt_mesh_send_cb *cb,
void *cb_data)
{
const u8_t *enc, *priv;
u32_t seq;
u16_t dst;
int err;
const u8_t *enc = NULL, *priv = NULL;
u32_t seq = 0U;
u16_t dst = 0U;
int err = 0;
BT_DBG("net_idx 0x%04x new_key %u len %u", sub->net_idx, new_key,
buf->len);
@ -818,7 +819,7 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf,
static void bt_mesh_net_local(struct k_work *work)
{
struct net_buf *buf;
struct net_buf *buf = NULL;
while ((buf = net_buf_slist_get(&bt_mesh.local_queue))) {
BT_DBG("len %u: %s", buf->len, bt_hex(buf->data, buf->len));
@ -831,11 +832,11 @@ int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct net_buf_simple *buf,
bool proxy)
{
const bool ctl = (tx->ctx->app_idx == BLE_MESH_KEY_UNUSED);
u32_t seq_val;
u8_t nid;
const u8_t *enc, *priv;
u8_t *seq;
int err;
u32_t seq_val = 0U;
u8_t nid = 0U;
const u8_t *enc = NULL, *priv = NULL;
u8_t *seq = NULL;
int err = 0;
if (ctl && net_buf_simple_tailroom(buf) < 8) {
BT_ERR("%s, Insufficient MIC space for CTL PDU", __func__);
@ -894,7 +895,7 @@ int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct net_buf_simple *buf,
int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf,
const struct bt_mesh_send_cb *cb, void *cb_data)
{
int err;
int err = 0;
BT_DBG("src 0x%04x dst 0x%04x len %u headroom %u tailroom %u",
tx->src, tx->ctx->addr, buf->len, net_buf_headroom(buf),
@ -975,7 +976,7 @@ static bool auth_match(struct bt_mesh_subnet_keys *keys,
const u8_t net_id[8], u8_t flags,
u32_t iv_index, const u8_t auth[8])
{
u8_t net_auth[8];
u8_t net_auth[8] = {0};
if (memcmp(net_id, keys->net_id, 8)) {
return false;
@ -997,7 +998,7 @@ struct bt_mesh_subnet *bt_mesh_subnet_find(const u8_t net_id[8], u8_t flags,
u32_t iv_index, const u8_t auth[8],
bool *new_key)
{
size_t subnet_size;
size_t subnet_size = 0U;
int i;
subnet_size = bt_mesh_rx_netkey_size();
@ -1110,7 +1111,7 @@ static bool net_find_and_decrypt(const u8_t *data, size_t data_len,
struct net_buf_simple *buf)
{
struct bt_mesh_subnet *sub = NULL;
size_t array_size = 0;
size_t array_size = 0U;
int i;
BT_DBG("%s", __func__);
@ -1184,9 +1185,9 @@ static bool relay_to_adv(enum bt_mesh_net_if net_if)
static void bt_mesh_net_relay(struct net_buf_simple *sbuf,
struct bt_mesh_net_rx *rx)
{
const u8_t *enc, *priv;
struct net_buf *buf;
u8_t nid, transmit;
const u8_t *enc = NULL, *priv = NULL;
struct net_buf *buf = NULL;
u8_t nid = 0U, transmit = 0U;
if (rx->net_if == BLE_MESH_NET_IF_LOCAL) {
/* Locally originated PDUs with TTL=1 will only be delivered
@ -1398,7 +1399,7 @@ void bt_mesh_net_recv(struct net_buf_simple *data, s8_t rssi,
{
NET_BUF_SIMPLE_DEFINE(buf, 29);
struct bt_mesh_net_rx rx = { .ctx.recv_rssi = rssi };
struct net_buf_simple_state state;
struct net_buf_simple_state state = {0};
BT_DBG("rssi %d net_if %u", rssi, net_if);

View File

@ -335,7 +335,7 @@ static void reset_adv_link(void)
static struct net_buf *adv_buf_create(void)
{
struct net_buf *buf;
struct net_buf *buf = NULL;
buf = bt_mesh_adv_create(BLE_MESH_ADV_PROV, PROV_XMIT, BUF_TIMEOUT);
if (!buf) {
@ -359,8 +359,8 @@ static void gen_prov_ack_send(u8_t xact_id)
static const struct bt_mesh_send_cb cb = {
.start = ack_complete,
};
const struct bt_mesh_send_cb *complete;
struct net_buf *buf;
const struct bt_mesh_send_cb *complete = NULL;
struct net_buf *buf = NULL;
BT_DBG("xact_id %u", xact_id);
@ -412,7 +412,7 @@ static void send_reliable(void)
static int bearer_ctl_send(u8_t op, void *data, u8_t data_len)
{
struct net_buf *buf;
struct net_buf *buf = NULL;
BT_DBG("op 0x%02x data_len %u", op, data_len);
@ -458,9 +458,9 @@ static inline u8_t next_transaction_id(void)
static int prov_send_adv(struct net_buf_simple *msg)
{
struct net_buf *start, *buf;
u8_t seg_len, seg_id;
u8_t xact_id;
struct net_buf *start = NULL, *buf = NULL;
u8_t seg_len = 0U, seg_id = 0U;
u8_t xact_id = 0U;
s32_t timeout = PROTOCOL_TIMEOUT;
BT_DBG("%s, len %u: %s", __func__, msg->len, bt_hex(msg->data, msg->len));
@ -642,7 +642,7 @@ static void prov_invite(const u8_t *data)
static void prov_capabilities(const u8_t *data)
{
u16_t algorithms, output_action, input_action;
u16_t algorithms = 0U, output_action = 0U, input_action = 0U;
BT_DBG("Elements: %u", data[0]);
@ -660,6 +660,10 @@ static void prov_capabilities(const u8_t *data)
input_action = sys_get_be16(&data[9]);
BT_DBG("Input OOB Action: 0x%04x", input_action);
((void) algorithms);
((void) output_action);
((void) input_action);
}
static bt_mesh_output_action_t output_action(u8_t action)
@ -698,8 +702,8 @@ static bt_mesh_input_action_t input_action(u8_t action)
static int prov_auth(u8_t method, u8_t action, u8_t size)
{
bt_mesh_output_action_t output;
bt_mesh_input_action_t input;
bt_mesh_output_action_t output = 0U;
bt_mesh_input_action_t input = 0U;
switch (method) {
case AUTH_METHOD_NO_OOB:
@ -735,8 +739,8 @@ static int prov_auth(u8_t method, u8_t action, u8_t size)
}
if (output == BLE_MESH_DISPLAY_STRING) {
unsigned char str[9];
u8_t i;
unsigned char str[9] = {'\0'};
u8_t i = 0U;
bt_mesh_rand(str, size);
@ -760,7 +764,7 @@ static int prov_auth(u8_t method, u8_t action, u8_t size)
u32_t div[8] = { 10, 100, 1000, 10000, 100000,
1000000, 10000000, 100000000
};
u32_t num;
u32_t num = 0U;
bt_mesh_rand(&num, sizeof(num));
num %= div[size - 1];
@ -973,7 +977,7 @@ static void prov_dh_key_cb(const u8_t key[32], const u8_t idx)
static void send_pub_key(void)
{
PROV_BUF(buf, 65);
const u8_t *key;
const u8_t *key = NULL;
/* Copy remote key in little-endian for bt_mesh_dh_key_gen().
* X and Y halves are swapped independently. Use response
@ -1123,7 +1127,7 @@ static void prov_confirm(const u8_t *data)
static void prov_random(const u8_t *data)
{
PROV_BUF(rnd, 17);
u8_t conf_verify[16];
u8_t conf_verify[16] = {0};
BT_DBG("Remote Random: %s", bt_hex(data, 16));
@ -1173,16 +1177,16 @@ static inline bool is_pb_gatt(void)
static void prov_data(const u8_t *data)
{
PROV_BUF(msg, 1);
u8_t session_key[16];
u8_t nonce[13];
u8_t dev_key[16];
u8_t pdu[25];
u8_t flags;
u32_t iv_index;
u16_t addr;
u16_t net_idx;
int err;
bool identity_enable;
u8_t session_key[16] = {0};
u8_t nonce[13] = {0};
u8_t dev_key[16] = {0};
u8_t pdu[25] = {0};
u8_t flags = 0U;
u32_t iv_index = 0U;
u16_t addr = 0U;
u16_t net_idx = 0U;
int err = 0;
bool identity_enable = false;
BT_DBG("%s", __func__);
@ -1491,7 +1495,7 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf)
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
return;
} else if (seg == link.rx.last_seg) {
u8_t expect_len;
u8_t expect_len = 0U;
expect_len = (link.rx.buf->len - 20U -
((link.rx.last_seg - 1) * 23U));
@ -1607,7 +1611,7 @@ static void gen_prov_recv(struct prov_rx *rx, struct net_buf_simple *buf)
void bt_mesh_pb_adv_recv(struct net_buf_simple *buf)
{
struct prov_rx rx;
struct prov_rx rx = {0};
if (!bt_prov_active() && bt_mesh_is_provisioned()) {
BT_DBG("Ignoring provisioning PDU - already provisioned");
@ -1637,7 +1641,7 @@ void bt_mesh_pb_adv_recv(struct net_buf_simple *buf)
#if defined(CONFIG_BLE_MESH_PB_GATT)
int bt_mesh_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf)
{
u8_t type;
u8_t type = 0U;
BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len));

View File

@ -173,9 +173,9 @@ done:
int bt_mesh_provisioner_deinit(void)
{
size_t i;
int i;
for (i = 0U; i < CONFIG_BLE_MESH_PROVISIONER_SUBNET_COUNT; i++) {
for (i = 0; i < CONFIG_BLE_MESH_PROVISIONER_SUBNET_COUNT; i++) {
if (bt_mesh.p_sub[i]) {
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
bt_mesh_clear_p_subnet(bt_mesh.p_sub[i]);
@ -185,7 +185,7 @@ int bt_mesh_provisioner_deinit(void)
}
}
for (i = 0U; i < CONFIG_BLE_MESH_PROVISIONER_APP_KEY_COUNT; i++) {
for (i = 0; i < CONFIG_BLE_MESH_PROVISIONER_APP_KEY_COUNT; i++) {
if (bt_mesh.p_app_keys[i]) {
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
bt_mesh_clear_p_app_key(bt_mesh.p_app_keys[i]);
@ -202,7 +202,7 @@ int bt_mesh_provisioner_deinit(void)
bt_mesh_clear_p_app_idx();
}
for (i = 0U; i < CONFIG_BLE_MESH_MAX_STORED_NODES; i++) {
for (i = 0; i < CONFIG_BLE_MESH_MAX_STORED_NODES; i++) {
provisioner_remove_node(i);
}
@ -219,8 +219,8 @@ bool bt_mesh_provisioner_check_is_addr_dup(u16_t addr, u8_t elem_num, bool comp_
const struct bt_mesh_comp *comp = NULL;
struct bt_mesh_node *node = NULL;
u16_t primary_addr = BLE_MESH_ADDR_UNASSIGNED;
u16_t comp_addr;
size_t i;
u16_t comp_addr = BLE_MESH_ADDR_UNASSIGNED;
int i;
if (comp_with_own) {
comp = bt_mesh_comp_get();
@ -237,7 +237,7 @@ bool bt_mesh_provisioner_check_is_addr_dup(u16_t addr, u8_t elem_num, bool comp_
}
for (comp_addr = addr; comp_addr < addr + elem_num; comp_addr++) {
for (i = 0U; i < ARRAY_SIZE(mesh_nodes); i++) {
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
node = mesh_nodes[i];
if (node && comp_addr >= node->unicast_addr &&
comp_addr < node->unicast_addr + node->element_num) {
@ -288,8 +288,8 @@ u16_t bt_mesh_provisioner_get_all_node_count(void)
static int provisioner_store_node(struct bt_mesh_node *node, bool prov, bool store, u16_t *index)
{
u16_t min, max;
size_t i;
u16_t min = 0U, max = 0U;
size_t i = 0U;
bt_mesh_provisioner_lock();
@ -389,8 +389,8 @@ static int provisioner_remove_node(u16_t index)
{
struct bt_mesh_node *node = NULL;
struct bt_mesh_rpl *rpl = NULL;
bool is_prov;
size_t i;
bool is_prov = false;
int i;
BT_DBG("%s, reset node %d", __func__, index);
@ -407,7 +407,7 @@ static int provisioner_remove_node(u16_t index)
bt_mesh_msg_cache_clear(node->unicast_addr, node->element_num);
/* Reset corresponding rpl when removing the node */
for (i = 0U; i < ARRAY_SIZE(bt_mesh.rpl); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.rpl); i++) {
rpl = &bt_mesh.rpl[i];
if (rpl->src >= node->unicast_addr &&
rpl->src < node->unicast_addr + node->element_num) {
@ -443,7 +443,7 @@ static int provisioner_remove_node(u16_t index)
static struct bt_mesh_node *provisioner_find_node_with_uuid(const u8_t uuid[16], u16_t *index)
{
size_t i;
int i;
BT_DBG("%s", __func__);
@ -454,7 +454,7 @@ static struct bt_mesh_node *provisioner_find_node_with_uuid(const u8_t uuid[16],
bt_mesh_provisioner_lock();
for (i = 0U; i < ARRAY_SIZE(mesh_nodes); i++) {
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
if (mesh_nodes[i] && !memcmp(mesh_nodes[i]->dev_uuid, uuid, 16)) {
if (index) {
*index = i;
@ -471,7 +471,7 @@ static struct bt_mesh_node *provisioner_find_node_with_uuid(const u8_t uuid[16],
bool bt_mesh_provisioner_find_node_with_uuid(const u8_t uuid[16], bool reset)
{
struct bt_mesh_node *node = NULL;
u16_t index;
u16_t index = 0U;
node = provisioner_find_node_with_uuid(uuid, &index);
if (!node) {
@ -486,9 +486,9 @@ bool bt_mesh_provisioner_find_node_with_uuid(const u8_t uuid[16], bool reset)
bool bt_mesh_provisioner_find_node_with_addr(const bt_mesh_addr_t *addr, bool reset)
{
size_t i;
int i;
for (i = 0U; i < ARRAY_SIZE(mesh_nodes); i++) {
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
if (mesh_nodes[i]) {
if (!memcmp(mesh_nodes[i]->addr, addr->val, BLE_MESH_ADDR_LEN) &&
mesh_nodes[i]->addr_type == addr->type) {
@ -506,11 +506,11 @@ bool bt_mesh_provisioner_find_node_with_addr(const bt_mesh_addr_t *addr, bool re
int bt_mesh_provisioner_remove_node(const u8_t uuid[16])
{
struct bt_mesh_node *node = NULL;
u16_t index;
size_t i;
u16_t index = 0U;
int i;
if (uuid == NULL) {
for (i = 0U; i < ARRAY_SIZE(mesh_nodes); i++) {
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
if (mesh_nodes[i]) {
provisioner_remove_node(i);
}
@ -531,7 +531,7 @@ int bt_mesh_provisioner_remove_node(const u8_t uuid[16])
static struct bt_mesh_node *provisioner_find_node_with_addr(u16_t addr, u16_t *index)
{
struct bt_mesh_node *node = NULL;
size_t i;
int i;
BT_DBG("%s", __func__);
@ -542,7 +542,7 @@ static struct bt_mesh_node *provisioner_find_node_with_addr(u16_t addr, u16_t *i
bt_mesh_provisioner_lock();
for (i = 0U; i < ARRAY_SIZE(mesh_nodes); i++) {
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
node = mesh_nodes[i];
if (node && addr >= node->unicast_addr &&
addr < (node->unicast_addr + node->element_num)) {
@ -617,7 +617,7 @@ struct bt_mesh_node *bt_mesh_provisioner_get_node_with_addr(u16_t unicast_addr)
int bt_mesh_provisioner_delete_node_with_uuid(const u8_t uuid[16])
{
struct bt_mesh_node *node = NULL;
u16_t index;
u16_t index = 0U;
node = provisioner_find_node_with_uuid(uuid, &index);
if (!node) {
@ -632,7 +632,7 @@ int bt_mesh_provisioner_delete_node_with_uuid(const u8_t uuid[16])
int bt_mesh_provisioner_delete_node_with_addr(u16_t unicast_addr)
{
struct bt_mesh_node *node = NULL;
u16_t index;
u16_t index = 0U;
node = provisioner_find_node_with_addr(unicast_addr, &index);
if (!node) {
@ -663,8 +663,8 @@ static int provisioner_check_node_index(u16_t index)
int bt_mesh_provisioner_set_node_name(u16_t index, const char *name)
{
size_t length, name_len;
size_t i;
size_t length = 0U, name_len = 0U;
int i;
BT_DBG("%s", __func__);
@ -681,7 +681,7 @@ int bt_mesh_provisioner_set_node_name(u16_t index, const char *name)
BT_DBG("name len is %d, name is %s", strlen(name), name);
length = (strlen(name) <= BLE_MESH_NODE_NAME_SIZE) ? strlen(name) : BLE_MESH_NODE_NAME_SIZE;
for (i = 0U; i < ARRAY_SIZE(mesh_nodes); i++) {
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
if (mesh_nodes[i]) {
name_len = strlen(mesh_nodes[i]->name);
if (length != name_len) {
@ -719,8 +719,8 @@ const char *bt_mesh_provisioner_get_node_name(u16_t index)
u16_t bt_mesh_provisioner_get_node_index(const char *name)
{
size_t length, name_len;
size_t i;
size_t length = 0U, name_len = 0U;
int i;
BT_DBG("%s", __func__);
@ -730,7 +730,7 @@ u16_t bt_mesh_provisioner_get_node_index(const char *name)
}
length = (strlen(name) <= BLE_MESH_NODE_NAME_SIZE) ? strlen(name) : BLE_MESH_NODE_NAME_SIZE;
for (i = 0U; i < ARRAY_SIZE(mesh_nodes); i++) {
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
if (mesh_nodes[i]) {
name_len = strlen(mesh_nodes[i]->name);
if (length != name_len) {
@ -784,11 +784,11 @@ int bt_mesh_provisioner_store_node_comp_data(u16_t addr, const u8_t *data, u16_t
const u8_t *bt_mesh_provisioner_net_key_get(u16_t net_idx)
{
struct bt_mesh_subnet *sub = NULL;
size_t i;
int i;
BT_DBG("%s", __func__);
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
sub = bt_mesh.p_sub[i];
if (sub && sub->net_idx == net_idx) {
if (sub->kr_flag) {
@ -805,7 +805,7 @@ const u8_t *bt_mesh_provisioner_net_key_get(u16_t net_idx)
struct bt_mesh_subnet *bt_mesh_provisioner_subnet_get(u16_t net_idx)
{
struct bt_mesh_subnet *sub = NULL;
size_t i;
int i;
BT_DBG("%s", __func__);
@ -813,7 +813,7 @@ struct bt_mesh_subnet *bt_mesh_provisioner_subnet_get(u16_t net_idx)
return bt_mesh.p_sub[0];
}
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
sub = bt_mesh.p_sub[i];
if (sub && sub->net_idx == net_idx) {
return sub;
@ -826,7 +826,7 @@ struct bt_mesh_subnet *bt_mesh_provisioner_subnet_get(u16_t net_idx)
bool bt_mesh_provisioner_check_msg_dst(u16_t dst)
{
struct bt_mesh_node *node = NULL;
size_t i;
int i;
BT_DBG("%s", __func__);
@ -834,7 +834,7 @@ bool bt_mesh_provisioner_check_msg_dst(u16_t dst)
return true;
}
for (i = 0U; i < ARRAY_SIZE(mesh_nodes); i++) {
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
node = mesh_nodes[i];
if (node && dst >= node->unicast_addr &&
dst < node->unicast_addr + node->element_num) {
@ -852,7 +852,7 @@ const u8_t *bt_mesh_provisioner_dev_key_get(u16_t dst)
* element which uses the primary unicast address.
*/
struct bt_mesh_node *node = NULL;
size_t i;
int i;
BT_DBG("%s", __func__);
@ -861,7 +861,7 @@ const u8_t *bt_mesh_provisioner_dev_key_get(u16_t dst)
return NULL;
}
for (i = 0U; i < ARRAY_SIZE(mesh_nodes); i++) {
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
node = mesh_nodes[i];
if (node && node->unicast_addr == dst) {
return node->dev_key;
@ -874,11 +874,11 @@ const u8_t *bt_mesh_provisioner_dev_key_get(u16_t dst)
struct bt_mesh_app_key *bt_mesh_provisioner_app_key_find(u16_t app_idx)
{
struct bt_mesh_app_key *key = NULL;
size_t i;
int i;
BT_DBG("%s", __func__);
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
key = bt_mesh.p_app_keys[i];
if (key && key->net_idx != BLE_MESH_KEY_UNUSED &&
key->app_idx == app_idx) {
@ -892,14 +892,14 @@ struct bt_mesh_app_key *bt_mesh_provisioner_app_key_find(u16_t app_idx)
static int provisioner_check_app_key(const u8_t app_key[16], u16_t *app_idx)
{
struct bt_mesh_app_key *key = NULL;
size_t i;
int i;
if (!app_key) {
return 0;
}
/* Check if app_key is already existed */
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
key = bt_mesh.p_app_keys[i];
if (key && (!memcmp(key->keys[0].val, app_key, 16) ||
!memcmp(key->keys[1].val, app_key, 16))) {
@ -914,11 +914,11 @@ static int provisioner_check_app_key(const u8_t app_key[16], u16_t *app_idx)
static int provisioner_check_app_idx(u16_t app_idx, bool exist)
{
struct bt_mesh_app_key *key = NULL;
size_t i;
int i;
if (exist) {
/* Check if app_idx is already existed */
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
key = bt_mesh.p_app_keys[i];
if (key && (key->app_idx == app_idx)) {
return -EEXIST;
@ -940,9 +940,9 @@ static int provisioner_check_app_idx(u16_t app_idx, bool exist)
static int provisioner_check_app_key_full(void)
{
size_t i;
int i;
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
if (!bt_mesh.p_app_keys[i]) {
return i;
}
@ -954,14 +954,14 @@ static int provisioner_check_app_key_full(void)
static int provisioner_check_net_key(const u8_t net_key[16], u16_t *net_idx)
{
struct bt_mesh_subnet *sub = NULL;
size_t i;
int i;
if (!net_key) {
return 0;
}
/* Check if net_key is already existed */
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
sub = bt_mesh.p_sub[i];
if (sub && (!memcmp(sub->keys[0].net, net_key, 16) ||
!memcmp(sub->keys[1].net, net_key, 16))) {
@ -976,11 +976,11 @@ static int provisioner_check_net_key(const u8_t net_key[16], u16_t *net_idx)
static int provisioner_check_net_idx(u16_t net_idx, bool exist)
{
struct bt_mesh_subnet *sub = NULL;
size_t i;
int i;
if (exist) {
/* Check if net_idx is already existed */
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
sub = bt_mesh.p_sub[i];
if (sub && (sub->net_idx == net_idx)) {
return -EEXIST;
@ -1002,9 +1002,9 @@ static int provisioner_check_net_idx(u16_t net_idx, bool exist)
static int provisioner_check_net_key_full(void)
{
size_t i;
int i;
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
if (!bt_mesh.p_sub[i]) {
return i;
}
@ -1108,10 +1108,53 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx,
return 0;
}
int bt_mesh_provisioner_local_app_key_update(const u8_t app_key[16], u16_t net_idx, u16_t app_idx)
{
struct bt_mesh_app_keys *keys = NULL;
struct bt_mesh_app_key *key = NULL;
if (app_key == NULL) {
BT_ERR("%s, Invalid AppKey", __func__);
return -EINVAL;
}
BT_INFO("AppKey %s, net_idx 0x%03x, app_idx 0x%03x", bt_hex(app_key, 16), net_idx, app_idx);
/* Check if the net_idx exists */
if (provisioner_check_net_idx(net_idx, false)) {
BT_ERR("%s, NetKey Index 0x%03x not exist", __func__, net_idx);
return -ENODEV;
}
key = bt_mesh_provisioner_app_key_find(app_idx);
if (key == NULL) {
BT_ERR("%s, AppKey 0x%03x not exist", __func__, app_idx);
return -ENODEV;
}
keys = &key->keys[0];
if (bt_mesh_app_id(app_key, &keys->id)) {
BT_ERR("%s, Failed to generate AID", __func__);
return -EIO;
}
memset(keys->val, 0, 16);
memcpy(keys->val, app_key, 16);
key->updated = false;
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
bt_mesh_store_p_app_idx();
bt_mesh_store_p_app_key(key);
}
return 0;
}
const u8_t *bt_mesh_provisioner_local_app_key_get(u16_t net_idx, u16_t app_idx)
{
struct bt_mesh_app_key *key = NULL;
size_t i;
int i;
BT_DBG("%s", __func__);
@ -1125,7 +1168,7 @@ const u8_t *bt_mesh_provisioner_local_app_key_get(u16_t net_idx, u16_t app_idx)
return NULL;
}
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
key = bt_mesh.p_app_keys[i];
if (key && key->net_idx == net_idx &&
key->app_idx == app_idx) {
@ -1170,11 +1213,11 @@ static void model_pub_clear(struct bt_mesh_model *model)
static void model_unbind(struct bt_mesh_model *model, u16_t app_idx)
{
size_t i;
int i;
BT_DBG("model %p key_idx 0x%03x", model, app_idx);
for (i = 0U; i < ARRAY_SIZE(model->keys); i++) {
for (i = 0; i < ARRAY_SIZE(model->keys); i++) {
if (model->keys[i] != app_idx) {
continue;
}
@ -1200,7 +1243,7 @@ static void _model_unbind(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
int bt_mesh_provisioner_local_app_key_delete(u16_t net_idx, u16_t app_idx)
{
struct bt_mesh_app_key *key = NULL;
size_t i;
int i;
BT_DBG("%s", __func__);
@ -1214,7 +1257,7 @@ int bt_mesh_provisioner_local_app_key_delete(u16_t net_idx, u16_t app_idx)
return -ENODEV;
}
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
key = bt_mesh.p_app_keys[i];
if (key && key->net_idx == net_idx &&
key->app_idx == app_idx) {
@ -1322,10 +1365,54 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx
return 0;
}
int bt_mesh_provisioner_local_net_key_update(const u8_t net_key[16], u16_t net_idx)
{
struct bt_mesh_subnet *sub = NULL;
int err = 0;
if (net_key == NULL) {
BT_ERR("%s, Invalid NetKey", __func__);
return -EINVAL;
}
BT_INFO("NetKey %s, net_idx 0x%03x", bt_hex(net_key, 16), net_idx);
sub = bt_mesh_provisioner_subnet_get(net_idx);
if (sub == NULL) {
BT_ERR("%s, NetKey 0x%03x not exist", __func__, net_idx);
return -ENODEV;
}
err = bt_mesh_net_keys_create(&sub->keys[0], net_key);
if (err) {
BT_ERR("%s, Failed to generate NID", __func__);
return -EIO;
}
memset(sub->keys[0].net, 0, 16);
memcpy(sub->keys[0].net, net_key, 16);
sub->kr_phase = BLE_MESH_KR_NORMAL;
sub->kr_flag = false;
sub->node_id = BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED;
err = bt_mesh_net_beacon_update(sub);
if (err) {
BT_ERR("%s, Failed to update secure beacon", __func__);
return -EIO;
}
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
bt_mesh_store_p_subnet(sub);
}
return 0;
}
const u8_t *bt_mesh_provisioner_local_net_key_get(u16_t net_idx)
{
struct bt_mesh_subnet *sub = NULL;
size_t i;
int i;
BT_DBG("%s", __func__);
@ -1334,7 +1421,7 @@ const u8_t *bt_mesh_provisioner_local_net_key_get(u16_t net_idx)
return NULL;
}
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
sub = bt_mesh.p_sub[i];
if (sub && sub->net_idx == net_idx) {
if (sub->kr_flag) {
@ -1350,7 +1437,7 @@ const u8_t *bt_mesh_provisioner_local_net_key_get(u16_t net_idx)
int bt_mesh_provisioner_local_net_key_delete(u16_t net_idx)
{
struct bt_mesh_subnet *sub = NULL;
u16_t i, j;
int i, j;
BT_DBG("%s", __func__);
@ -1359,11 +1446,11 @@ int bt_mesh_provisioner_local_net_key_delete(u16_t net_idx)
return -ENODEV;
}
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
sub = bt_mesh.p_sub[i];
if (sub && sub->net_idx == net_idx) {
/* Delete any app keys bound to this NetKey index */
for (j = 0U; j < ARRAY_SIZE(bt_mesh.p_app_keys); j++) {
for (j = 0; j < ARRAY_SIZE(bt_mesh.p_app_keys); j++) {
struct bt_mesh_app_key *key = bt_mesh.p_app_keys[j];
if (key->net_idx == sub->net_idx) {
bt_mesh_provisioner_local_app_key_delete(key->net_idx, key->app_idx);
@ -1389,7 +1476,7 @@ int bt_mesh_provisioner_bind_local_model_app_idx(u16_t elem_addr, u16_t mod_id,
{
struct bt_mesh_model *model = NULL;
struct bt_mesh_elem *elem = NULL;
size_t i;
int i;
elem = bt_mesh_elem_find(elem_addr);
if (!elem) {
@ -1412,14 +1499,14 @@ int bt_mesh_provisioner_bind_local_model_app_idx(u16_t elem_addr, u16_t mod_id,
return -ENODEV;
}
for (i = 0U; i < ARRAY_SIZE(model->keys); i++) {
for (i = 0; i < ARRAY_SIZE(model->keys); i++) {
if (model->keys[i] == app_idx) {
BT_WARN("AppKey 0x%03x is already bound to model", app_idx);
return 0;
}
}
for (i = 0U; i < ARRAY_SIZE(model->keys); i++) {
for (i = 0; i < ARRAY_SIZE(model->keys); i++) {
if (model->keys[i] == BLE_MESH_KEY_UNUSED) {
model->keys[i] = app_idx;
@ -1439,7 +1526,7 @@ int bt_mesh_print_local_composition_data(void)
const struct bt_mesh_comp *comp = NULL;
struct bt_mesh_model *model = NULL;
struct bt_mesh_elem *elem = NULL;
size_t i, j;
int i, j;
comp = bt_mesh_comp_get();
if (!comp) {
@ -1450,21 +1537,23 @@ int bt_mesh_print_local_composition_data(void)
BT_INFO("************************************************");
BT_INFO("* cid: 0x%04x pid: 0x%04x vid: 0x%04x *", comp->cid, comp->pid, comp->vid);
BT_INFO("* Element Number: 0x%02x *", comp->elem_count);
for (i = 0U; i < comp->elem_count; i++) {
for (i = 0; i < comp->elem_count; i++) {
elem = &comp->elem[i];
BT_INFO("* Element %d: 0x%04x *", i, elem->addr);
BT_INFO("* Loc: 0x%04x NumS: 0x%02x NumV: 0x%02x *", elem->loc, elem->model_count, elem->vnd_model_count);
for (j = 0U; j < elem->model_count; j++) {
for (j = 0; j < elem->model_count; j++) {
model = &elem->models[j];
BT_INFO("* sig_model %d: id - 0x%04x *", j, model->id);
}
for (j = 0U; j < elem->vnd_model_count; j++) {
for (j = 0; j < elem->vnd_model_count; j++) {
model = &elem->vnd_models[j];
BT_INFO("* vnd_model %d: id - 0x%04x, cid - 0x%04x *", j, model->vnd.id, model->vnd.company);
}
}
BT_INFO("************************************************");
((void) model);
return 0;
}
@ -1477,7 +1566,7 @@ int bt_mesh_print_local_composition_data(void)
const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst)
{
struct bt_mesh_node *node = NULL;
size_t i;
int i;
BT_DBG("%s", __func__);
@ -1490,7 +1579,7 @@ const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst)
return bt_mesh.dev_key;
}
for (i = 0U; i < ARRAY_SIZE(mesh_nodes); i++) {
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
node = mesh_nodes[i];
if (node && node->unicast_addr == dst) {
return node->dev_key;
@ -1503,18 +1592,18 @@ const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst)
struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(u16_t net_idx)
{
struct bt_mesh_subnet *sub = NULL;
size_t i;
int i;
BT_DBG("%s", __func__);
for (i = 0U; i < ARRAY_SIZE(bt_mesh.sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
sub = &bt_mesh.sub[i];
if (sub->net_idx == net_idx) {
return sub;
}
}
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
sub = bt_mesh.p_sub[i];
if (sub && sub->net_idx == net_idx) {
return sub;
@ -1527,11 +1616,11 @@ struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(u16_t net_idx)
struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(u16_t app_idx)
{
struct bt_mesh_app_key *key = NULL;
size_t i;
int i;
BT_DBG("%s", __func__);
for (i = 0U; i < ARRAY_SIZE(bt_mesh.app_keys); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.app_keys); i++) {
key = &bt_mesh.app_keys[i];
if (key->net_idx != BLE_MESH_KEY_UNUSED &&
key->app_idx == app_idx) {
@ -1539,7 +1628,7 @@ struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(u16_t app_idx)
}
}
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
key = bt_mesh.p_app_keys[i];
if (key && key->net_idx != BLE_MESH_KEY_UNUSED &&
key->app_idx == app_idx) {
@ -1569,8 +1658,8 @@ u8_t bt_mesh_set_fast_prov_net_idx(u16_t net_idx)
u8_t bt_mesh_add_fast_prov_net_key(const u8_t net_key[16])
{
const u8_t *keys = NULL;
u16_t net_idx;
int err;
u16_t net_idx = 0U;
int err = 0;
net_idx = bt_mesh_provisioner_get_fast_prov_net_idx();
bt_mesh.p_net_idx_next = net_idx;

View File

@ -101,12 +101,16 @@ struct bt_mesh_app_key *bt_mesh_provisioner_app_key_find(u16_t app_idx);
int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx, u16_t *app_idx);
int bt_mesh_provisioner_local_app_key_update(const u8_t app_key[16], u16_t net_idx, u16_t app_idx);
const u8_t *bt_mesh_provisioner_local_app_key_get(u16_t net_idx, u16_t app_idx);
int bt_mesh_provisioner_local_app_key_delete(u16_t net_idx, u16_t app_idx);
int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx);
int bt_mesh_provisioner_local_net_key_update(const u8_t net_key[16], u16_t net_idx);
const u8_t *bt_mesh_provisioner_local_net_key_get(u16_t net_idx);
int bt_mesh_provisioner_local_net_key_delete(u16_t net_idx);

View File

@ -472,7 +472,7 @@ static inline void provisioner_pbg_count_inc(void)
#if defined(CONFIG_BLE_MESH_PB_GATT)
void bt_mesh_provisioner_clear_link_info(const u8_t addr[6])
{
u8_t i;
int i;
if (!addr) {
BT_ERR("%s, Invalid parameter", __func__);
@ -517,7 +517,7 @@ static int provisioner_dev_find(const bt_mesh_addr_t *addr, const u8_t uuid[16],
bool uuid_match = false;
bool addr_match = false;
u8_t zero[16] = {0};
u16_t i = 0, j = 0;
u16_t i = 0U, j = 0U;
int comp = 0;
if (addr) {
@ -574,7 +574,7 @@ static int provisioner_dev_find(const bt_mesh_addr_t *addr, const u8_t uuid[16],
static bool is_unprov_dev_being_provision(const u8_t uuid[16])
{
u16_t i;
int i;
#if defined(CONFIG_BLE_MESH_FAST_PROV)
/**
@ -590,7 +590,7 @@ static bool is_unprov_dev_being_provision(const u8_t uuid[16])
}
#endif
for (i = 0U; i < BLE_MESH_PROV_SAME_TIME; i++) {
for (i = 0; i < BLE_MESH_PROV_SAME_TIME; i++) {
#if defined(CONFIG_BLE_MESH_PB_ADV) && defined(CONFIG_BLE_MESH_PB_GATT)
if (link[i].linking || link[i].connecting ||
bt_mesh_atomic_test_bit(link[i].flags, LINK_ACTIVE)) {
@ -676,8 +676,8 @@ static int provisioner_start_prov_pb_adv(const u8_t uuid[16], const bt_mesh_addr
u16_t oob_info, u16_t assign_addr)
{
u8_t zero[6] = {0};
int addr_cmp;
u8_t i;
int addr_cmp = 0;
int i;
if (!uuid || !addr) {
BT_ERR("%s, Invalid parameter", __func__);
@ -702,7 +702,7 @@ static int provisioner_start_prov_pb_adv(const u8_t uuid[16], const bt_mesh_addr
addr_cmp = memcmp(addr->val, zero, BLE_MESH_ADDR_LEN);
for (i = 0U; i < CONFIG_BLE_MESH_PBA_SAME_TIME; i++) {
for (i = 0; i < CONFIG_BLE_MESH_PBA_SAME_TIME; i++) {
if (!bt_mesh_atomic_test_bit(link[i].flags, LINK_ACTIVE) && !link[i].linking) {
memcpy(link[i].uuid, uuid, 16);
link[i].oob_info = oob_info;
@ -734,8 +734,8 @@ static int provisioner_start_prov_pb_gatt(const u8_t uuid[16], const bt_mesh_add
u16_t oob_info, u16_t assign_addr)
{
u8_t zero[6] = {0};
int addr_cmp;
u8_t i;
int addr_cmp = 0;
int i;
if (!uuid || !addr) {
BT_ERR("%s, Invalid parameter", __func__);
@ -802,8 +802,8 @@ int bt_mesh_provisioner_add_unprov_dev(struct bt_mesh_unprov_dev_add *add_dev, u
u8_t zero[16] = {0};
int addr_cmp = 0;
int uuid_cmp = 0;
u16_t i;
int err;
u16_t i = 0U;
int err = 0;
if (!add_dev) {
BT_ERR("%s, Invalid parameter", __func__);
@ -943,7 +943,7 @@ int bt_mesh_provisioner_prov_device_with_addr(const u8_t uuid[16], const u8_t ad
u16_t oob_info, u16_t unicast_addr)
{
bt_mesh_addr_t dev_addr = {0};
int err;
int err = 0;
if (uuid == NULL) {
BT_ERR("%s, NULL device uuid", __func__);
@ -1033,8 +1033,8 @@ int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev)
bool uuid_match = false;
int addr_cmp = 0;
int uuid_cmp = 0;
u16_t i;
int err;
u16_t i = 0U;
int err = 0;
if (!del_dev) {
BT_ERR("%s, Invalid parameter", __func__);
@ -1207,7 +1207,7 @@ bt_mesh_prov_bearer_t bt_mesh_provisioner_get_prov_bearer(void)
int bt_mesh_provisioner_set_static_oob_value(const u8_t *value, u8_t length)
{
size_t i;
int i;
if (value == NULL || length == 0U || length > 16U) {
BT_ERR("%s, Invalid parameter", __func__);
@ -1215,7 +1215,7 @@ int bt_mesh_provisioner_set_static_oob_value(const u8_t *value, u8_t length)
}
/* Make sure Static OOB is not being used. */
for (i = 0U; i < BLE_MESH_PROV_SAME_TIME; i++) {
for (i = 0; i < BLE_MESH_PROV_SAME_TIME; i++) {
if (link[i].auth_method == AUTH_METHOD_STATIC) {
BT_ERR("%s, Static OOB is being used", __func__);
return -EINVAL;
@ -1381,11 +1381,11 @@ static struct bt_mesh_send_cb buf_sent_cb = {
static void free_segments(const u8_t idx)
{
u8_t i;
int i;
bt_mesh_pb_buf_lock();
for (i = 0U; i < ARRAY_SIZE(link[idx].tx.buf); i++) {
for (i = 0; i < ARRAY_SIZE(link[idx].tx.buf); i++) {
struct net_buf *buf = link[idx].tx.buf[i];
if (!buf) {
@ -1450,7 +1450,7 @@ static void reset_link(const u8_t idx, u8_t reason)
static struct net_buf *adv_buf_create(void)
{
struct net_buf *buf;
struct net_buf *buf = NULL;
buf = bt_mesh_adv_create(BLE_MESH_ADV_PROV, PROV_XMIT, BUF_TIMEOUT);
if (!buf) {
@ -1475,8 +1475,8 @@ static void gen_prov_ack_send(const u8_t idx, u8_t xact_id)
static const struct bt_mesh_send_cb cb = {
.start = ack_complete,
};
const struct bt_mesh_send_cb *complete;
struct net_buf *buf;
const struct bt_mesh_send_cb *complete = NULL;
struct net_buf *buf = NULL;
BT_DBG("xact_id %u", xact_id);
@ -1513,11 +1513,11 @@ static void gen_prov_ack_send(const u8_t idx, u8_t xact_id)
static void send_reliable(const u8_t idx)
{
u8_t i;
int i;
link[idx].tx.start = k_uptime_get();
for (i = 0U; i < ARRAY_SIZE(link[idx].tx.buf); i++) {
for (i = 0; i < ARRAY_SIZE(link[idx].tx.buf); i++) {
struct net_buf *buf = link[idx].tx.buf[i];
if (!buf) {
@ -1534,7 +1534,7 @@ static void send_reliable(const u8_t idx)
static int bearer_ctl_send(const u8_t idx, u8_t op, void *data, u8_t data_len)
{
struct net_buf *buf;
struct net_buf *buf = NULL;
BT_DBG("op 0x%02x data_len %u", op, data_len);
@ -1571,14 +1571,14 @@ static int bearer_ctl_send(const u8_t idx, u8_t op, void *data, u8_t data_len)
static void send_link_open(const u8_t idx)
{
u8_t j;
int j;
/** Generate link ID, and may need to check if this id is
* currently being used, which may will not happen ever.
*/
bt_mesh_rand(&link[idx].link_id, sizeof(u32_t));
while (1) {
for (j = 0U; j < CONFIG_BLE_MESH_PBA_SAME_TIME; j++) {
for (j = 0; j < CONFIG_BLE_MESH_PBA_SAME_TIME; j++) {
if (bt_mesh_atomic_test_bit(link[j].flags, LINK_ACTIVE) || link[j].linking) {
if (link[idx].link_id == link[j].link_id) {
bt_mesh_rand(&link[idx].link_id, sizeof(u32_t));
@ -1640,9 +1640,9 @@ static inline u8_t next_transaction_id(const u8_t idx)
static int prov_send_adv(const u8_t idx, struct net_buf_simple *msg)
{
struct net_buf *start, *buf;
u8_t seg_len, seg_id;
u8_t xact_id;
struct net_buf *start = NULL, *buf = NULL;
u8_t seg_len = 0U, seg_id = 0U;
u8_t xact_id = 0U;
s32_t timeout = PROVISION_TIMEOUT;
BT_DBG("%s, len %u: %s", __func__, msg->len, bt_hex(msg->data, msg->len));
@ -1717,7 +1717,7 @@ static int prov_send_adv(const u8_t idx, struct net_buf_simple *msg)
#if defined(CONFIG_BLE_MESH_PB_GATT)
static int prov_send_gatt(const u8_t idx, struct net_buf_simple *msg)
{
int err;
int err = 0;
if (!link[idx].conn) {
return -ENOTCONN;
@ -1802,10 +1802,10 @@ static void send_invite(const u8_t idx)
static void prov_capabilities(const u8_t idx, const u8_t *data)
{
PROV_BUF(buf, 6);
u16_t algorithms, output_action, input_action;
u8_t element_num, pub_key_oob, static_oob,
output_size, input_size;
u8_t auth_method, auth_action, auth_size;
u16_t algorithms = 0U, output_action = 0U, input_action = 0U;
u8_t element_num = 0U, pub_key_oob = 0U, static_oob = 0U,
output_size = 0U, input_size = 0U;
u8_t auth_method = 0U, auth_action = 0U, auth_size = 0U;
element_num = data[0];
BT_INFO("Elements: 0x%02x", element_num);
@ -1995,8 +1995,8 @@ static bt_mesh_input_action_t input_action(u8_t action)
static int prov_auth(const u8_t idx, u8_t method, u8_t action, u8_t size)
{
bt_mesh_output_action_t output;
bt_mesh_input_action_t input;
bt_mesh_output_action_t output = 0U;
bt_mesh_input_action_t input = 0U;
link[idx].auth = (u8_t *)osi_calloc(PROV_AUTH_VAL_SIZE);
if (!link[idx].auth) {
@ -2041,10 +2041,11 @@ static int prov_auth(const u8_t idx, u8_t method, u8_t action, u8_t size)
link[idx].expect = PROV_INPUT_COMPLETE;
if (input == BLE_MESH_ENTER_STRING) {
unsigned char str[9];
u8_t j;
unsigned char str[9] = {'\0'};
u8_t j = 0U;
bt_mesh_rand(str, size);
/* Normalize to '0' .. '9' & 'A' .. 'Z' */
for (j = 0U; j < size; j++) {
str[j] %= 36;
@ -2062,7 +2063,7 @@ static int prov_auth(const u8_t idx, u8_t method, u8_t action, u8_t size)
return prov->prov_output_num(AUTH_METHOD_INPUT, input, str, size, idx);
} else {
u32_t div[8] = { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 };
u32_t num;
u32_t num = 0U;
bt_mesh_rand(&num, sizeof(num));
num %= div[size - 1];
@ -2285,7 +2286,7 @@ fail:
static void prov_gen_dh_key(const u8_t idx)
{
u8_t pub_key[64];
u8_t pub_key[64] = {0};
/* Copy device public key in little-endian for bt_mesh_dh_key_gen().
* X and Y halves are swapped independently.
@ -2441,13 +2442,13 @@ static void send_prov_data(const u8_t idx)
{
PROV_BUF(buf, 34);
u16_t prev_addr = BLE_MESH_ADDR_UNASSIGNED;
u16_t max_addr = BLE_MESH_ADDR_UNASSIGNED;
struct bt_mesh_node *node = NULL;
const u8_t *netkey = NULL;
u8_t session_key[16];
u8_t nonce[13];
u8_t pdu[25];
u16_t max_addr;
int err;
u8_t session_key[16] = {0};
u8_t nonce[13] = {0};
u8_t pdu[25] = {0};
int err = 0;
err = bt_mesh_session_key(link[idx].dhkey, link[idx].prov_salt, session_key);
if (err) {
@ -2612,7 +2613,7 @@ fail:
static void prov_random(const u8_t idx, const u8_t *data)
{
u8_t conf_verify[16];
u8_t conf_verify[16] = {0};
BT_DBG("Remote Random: %s", bt_hex(data, 16));
@ -2664,11 +2665,11 @@ fail:
static void prov_complete(const u8_t idx, const u8_t *data)
{
u8_t device_key[16];
u16_t net_idx;
u16_t index;
u16_t rm;
int err;
u8_t device_key[16] = {0};
u16_t net_idx = 0U;
u16_t index = 0U;
u16_t rm = 0U;
int err = 0;
/* Make sure received pdu is ok and cancel the timeout timer */
if (bt_mesh_atomic_test_and_clear_bit(link[idx].flags, TIMEOUT_START)) {
@ -2778,7 +2779,7 @@ static void prov_retransmit(struct k_work *work)
{
s64_t timeout = TRANSACTION_TIMEOUT;
u8_t idx = (u8_t)work->index;
u8_t i;
int i;
BT_DBG("%s", __func__);
@ -2810,7 +2811,7 @@ static void prov_retransmit(struct k_work *work)
bt_mesh_pb_buf_lock();
for (i = 0U; i < ARRAY_SIZE(link[idx].tx.buf); i++) {
for (i = 0; i < ARRAY_SIZE(link[idx].tx.buf); i++) {
struct net_buf *buf = link[idx].tx.buf[i];
if (!buf) {
@ -2860,7 +2861,7 @@ static void link_ack(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *
static void link_close(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf)
{
u8_t reason;
u8_t reason = 0U;
BT_DBG("len %u", buf->len);
@ -2961,7 +2962,7 @@ static void gen_prov_cont(const u8_t idx, struct prov_rx *rx, struct net_buf_sim
BT_ERR("%s, Invalid segment index %u", __func__, seg);
goto fail;
} else if (seg == link[idx].rx.last_seg) {
u8_t expect_len;
u8_t expect_len = 0U;
expect_len = (link[idx].rx.buf->len - 20 -
(23 * (link[idx].rx.last_seg - 1)));
@ -2992,7 +2993,7 @@ fail:
static void gen_prov_ack(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf)
{
u8_t ack_type, pub_key_oob;
u8_t ack_type = 0U, pub_key_oob = 0U;
BT_DBG("len %u", buf->len);
@ -3108,10 +3109,10 @@ static void gen_prov_recv(const u8_t idx, struct prov_rx *rx, struct net_buf_sim
static int find_link(u32_t link_id, u8_t *idx)
{
u8_t i;
int i;
/* link for PB-ADV is from 0 to CONFIG_BLE_MESH_PBA_SAME_TIME */
for (i = 0U; i < CONFIG_BLE_MESH_PBA_SAME_TIME; i++) {
for (i = 0; i < CONFIG_BLE_MESH_PBA_SAME_TIME; i++) {
if (bt_mesh_atomic_test_bit(link[i].flags, LINK_ACTIVE)) {
if (link[i].link_id == link_id) {
if (idx) {
@ -3128,7 +3129,7 @@ static int find_link(u32_t link_id, u8_t *idx)
void bt_mesh_provisioner_pb_adv_recv(struct net_buf_simple *buf)
{
struct prov_rx rx = {0};
u8_t idx;
u8_t idx = 0U;
rx.link_id = net_buf_simple_pull_be32(buf);
if (find_link(rx.link_id, &idx) < 0) {
@ -3154,7 +3155,7 @@ void bt_mesh_provisioner_pb_adv_recv(struct net_buf_simple *buf)
#if defined(CONFIG_BLE_MESH_PB_GATT)
static struct bt_mesh_conn *find_conn(struct bt_mesh_conn *conn, u8_t *idx)
{
u8_t i;
int i;
/* link for PB-GATT is from CONFIG_BLE_MESH_PBA_SAME_TIME to BLE_MESH_PROV_SAME_TIME */
for (i = CONFIG_BLE_MESH_PBA_SAME_TIME; i < BLE_MESH_PROV_SAME_TIME; i++) {
@ -3173,8 +3174,8 @@ static struct bt_mesh_conn *find_conn(struct bt_mesh_conn *conn, u8_t *idx)
int bt_mesh_provisioner_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf)
{
u8_t type;
u8_t idx;
u8_t type = 0U;
u8_t idx = 0U;
BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len));
@ -3216,7 +3217,7 @@ fail:
int bt_mesh_provisioner_set_prov_conn(const u8_t addr[6], struct bt_mesh_conn *conn)
{
u8_t i;
int i;
if (!addr || !conn) {
BT_ERR("%s, Invalid parameter", __func__);
@ -3236,7 +3237,8 @@ int bt_mesh_provisioner_set_prov_conn(const u8_t addr[6], struct bt_mesh_conn *c
int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr)
{
u8_t idx = 0, i;
u8_t idx = 0U;
int i;
BT_DBG("conn %p", conn);
@ -3259,7 +3261,7 @@ int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr)
}
#if defined(CONFIG_BLE_MESH_PB_ADV)
for (i = 0U; i < CONFIG_BLE_MESH_PBA_SAME_TIME; i++) {
for (i = 0; i < CONFIG_BLE_MESH_PBA_SAME_TIME; i++) {
if (bt_mesh_atomic_test_bit(link[i].flags, LINK_ACTIVE)) {
if (!memcmp(link[i].uuid, link[idx].uuid, 16)) {
BT_WARN("Provision using PB-GATT & PB-ADV same time");
@ -3292,7 +3294,7 @@ int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr)
int bt_mesh_provisioner_pb_gatt_close(struct bt_mesh_conn *conn, u8_t reason)
{
u8_t idx;
u8_t idx = 0U;
BT_DBG("conn %p", conn);
@ -3324,7 +3326,7 @@ int bt_mesh_provisioner_pb_gatt_close(struct bt_mesh_conn *conn, u8_t reason)
int bt_mesh_provisioner_prov_init(const struct bt_mesh_prov *prov_info)
{
const u8_t *key = NULL;
size_t i;
int i;
if (!prov_info) {
BT_ERR("%s, No provisioning context provided", __func__);
@ -3347,7 +3349,7 @@ int bt_mesh_provisioner_prov_init(const struct bt_mesh_prov *prov_info)
}
#if defined(CONFIG_BLE_MESH_PB_ADV)
for (i = 0U; i < CONFIG_BLE_MESH_PBA_SAME_TIME; i++) {
for (i = 0; i < CONFIG_BLE_MESH_PBA_SAME_TIME; i++) {
struct prov_adv_buf *adv = &adv_buf[i];
adv->buf.size = ADV_BUF_SIZE;
adv->buf.__buf = adv_buf_data + (i * ADV_BUF_SIZE);
@ -3360,7 +3362,7 @@ int bt_mesh_provisioner_prov_init(const struct bt_mesh_prov *prov_info)
}
#endif
for (i = 0U; i < BLE_MESH_PROV_SAME_TIME; i++) {
for (i = 0; i < BLE_MESH_PROV_SAME_TIME; i++) {
k_delayed_work_init(&link[i].timeout, prov_timeout);
link[i].timeout.work.index = (int)i;
}
@ -3378,7 +3380,7 @@ int bt_mesh_provisioner_prov_init(const struct bt_mesh_prov *prov_info)
int bt_mesh_provisioner_prov_deinit(void)
{
size_t i;
int i;
if (prov == NULL) {
BT_ERR("%s, No provisioning context provided", __func__);
@ -3386,7 +3388,7 @@ int bt_mesh_provisioner_prov_deinit(void)
}
#if defined(CONFIG_BLE_MESH_PB_ADV)
for (i = 0U; i < CONFIG_BLE_MESH_PBA_SAME_TIME; i++) {
for (i = 0; i < CONFIG_BLE_MESH_PBA_SAME_TIME; i++) {
prov_clear_tx(i);
k_delayed_work_free(&link[i].tx.retransmit);
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
@ -3397,7 +3399,7 @@ int bt_mesh_provisioner_prov_deinit(void)
}
#endif /* CONFIG_BLE_MESH_PB_ADV */
for (i = 0U; i < BLE_MESH_PROV_SAME_TIME; i++) {
for (i = 0; i < BLE_MESH_PROV_SAME_TIME; i++) {
prov_memory_free(i);
k_delayed_work_free(&link[i].timeout);
memset(&link[i], 0, sizeof(link[i]));
@ -3426,7 +3428,7 @@ int bt_mesh_provisioner_prov_deinit(void)
static bool is_unprov_dev_info_callback_to_app(bt_mesh_prov_bearer_t bearer,
const u8_t uuid[16], const bt_mesh_addr_t *addr, u16_t oob_info, s8_t rssi)
{
u16_t index;
u16_t index = 0U;
if (prov_ctx.prov_after_match == false) {
u8_t adv_type = (bearer == BLE_MESH_PROV_ADV) ?
@ -3458,7 +3460,7 @@ void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, s8_t rss
#if defined(CONFIG_BLE_MESH_PB_ADV)
const bt_mesh_addr_t *addr = NULL;
const u8_t *uuid = NULL;
u16_t oob_info;
u16_t oob_info = 0U;
if (!(prov_ctx.bearers & BLE_MESH_PROV_ADV)) {
BT_WARN("Provisioner not support PB-ADV bearer");
@ -3493,7 +3495,7 @@ void bt_mesh_provisioner_prov_adv_ind_recv(struct net_buf_simple *buf, const bt_
{
#if defined(CONFIG_BLE_MESH_PB_GATT)
const u8_t *uuid = NULL;
u16_t oob_info;
u16_t oob_info = 0U;
if (!(prov_ctx.bearers & BLE_MESH_PROV_GATT)) {
BT_WARN("Provisioner not support PB-GATT bearer");

View File

@ -61,9 +61,9 @@ static u8_t server_buf_data[SERVER_BUF_SIZE * BLE_MESH_MAX_CONN];
static struct bt_mesh_proxy_server *find_server(struct bt_mesh_conn *conn)
{
u8_t i;
int i;
for (i = 0U; i < ARRAY_SIZE(servers); i++) {
for (i = 0; i < ARRAY_SIZE(servers); i++) {
if (servers[i].conn == conn) {
return &servers[i];
}
@ -122,8 +122,8 @@ static void filter_status(struct bt_mesh_proxy_server *server,
struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf)
{
u8_t filter_type;
u16_t list_size;
u8_t filter_type = 0U;
u16_t list_size = 0U;
if (buf->len != 3) {
BT_ERR("%s, Invalid Proxy Filter Status length %d", __func__, buf->len);
@ -151,8 +151,8 @@ static void proxy_cfg(struct bt_mesh_proxy_server *server)
{
NET_BUF_SIMPLE_DEFINE(buf, 29);
struct bt_mesh_net_rx rx = {0};
u8_t opcode;
int err;
u8_t opcode = 0U;
int err = 0;
err = bt_mesh_net_decode(&server->buf, BLE_MESH_NET_IF_PROXY_CFG,
&rx, &buf);
@ -228,7 +228,7 @@ static ssize_t proxy_recv(struct bt_mesh_conn *conn,
{
struct bt_mesh_proxy_server *server = find_server(conn);
const u8_t *data = buf;
u16_t srvc_uuid;
u16_t srvc_uuid = 0U;
if (!server) {
BT_ERR("%s, No Proxy Server object found", __func__);
@ -325,8 +325,8 @@ static int proxy_send(struct bt_mesh_conn *conn, const void *data, u16_t len)
static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type,
struct net_buf_simple *msg)
{
u16_t mtu;
int err;
u16_t mtu = 0U;
int err = 0;
if (conn == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
@ -488,11 +488,11 @@ static ssize_t prov_recv_ntf(struct bt_mesh_conn *conn, u8_t *data, u16_t len)
int bt_mesh_provisioner_pb_gatt_enable(void)
{
u8_t i;
int i;
BT_DBG("%s", __func__);
for (i = 0U; i < ARRAY_SIZE(servers); i++) {
for (i = 0; i < ARRAY_SIZE(servers); i++) {
if (servers[i].conn) {
servers[i].conn_type = PROV;
}
@ -503,11 +503,11 @@ int bt_mesh_provisioner_pb_gatt_enable(void)
int bt_mesh_provisioner_pb_gatt_disable(void)
{
u8_t i;
int i;
BT_DBG("%s", __func__);
for (i = 0U; i < ARRAY_SIZE(servers); i++) {
for (i = 0; i < ARRAY_SIZE(servers); i++) {
struct bt_mesh_proxy_server *server = &servers[i];
if (server->conn && server->conn_type == PROV) {
@ -568,11 +568,11 @@ static ssize_t proxy_recv_ntf(struct bt_mesh_conn *conn, u8_t *data, u16_t len)
*/
int bt_mesh_proxy_client_enable(void)
{
u8_t i;
int i;
BT_DBG("%s", __func__);
for (i = 0U; i < ARRAY_SIZE(servers); i++) {
for (i = 0; i < ARRAY_SIZE(servers); i++) {
if (servers[i].conn) {
servers[i].conn_type = PROXY;
}
@ -590,7 +590,7 @@ int bt_mesh_proxy_client_enable(void)
int bt_mesh_proxy_client_disable(void)
{
u8_t i;
int i;
BT_DBG("%s", __func__);
@ -601,7 +601,7 @@ int bt_mesh_proxy_client_disable(void)
* it should be disconnected.
*/
for (i = 0U; i < ARRAY_SIZE(servers); i++) {
for (i = 0; i < ARRAY_SIZE(servers); i++) {
struct bt_mesh_proxy_server *server = &servers[i];
if (server->conn && server->conn_type == PROXY) {
@ -631,7 +631,7 @@ static struct bt_mesh_prov_conn_cb conn_callbacks = {
static struct bt_mesh_subnet *bt_mesh_is_net_id_exist(const u8_t net_id[8])
{
struct bt_mesh_subnet *sub = NULL;
size_t size, i;
size_t size = 0U, i = 0U;
size = bt_mesh_rx_netkey_size();
@ -648,7 +648,7 @@ static struct bt_mesh_subnet *bt_mesh_is_net_id_exist(const u8_t net_id[8])
void bt_mesh_proxy_client_adv_ind_recv(struct net_buf_simple *buf, const bt_mesh_addr_t *addr, s8_t rssi)
{
bt_mesh_proxy_adv_ctx_t ctx = {0};
u8_t type;
u8_t type = 0U;
/* Check if connection reaches the maximum limitation */
if (bt_mesh_gattc_get_free_conn_count() == 0) {
@ -690,7 +690,7 @@ void bt_mesh_proxy_client_adv_ind_recv(struct net_buf_simple *buf, const bt_mesh
int bt_mesh_proxy_client_connect(const u8_t addr[6], u8_t addr_type, u16_t net_idx)
{
bt_mesh_addr_t remote_addr = {0};
int result;
int result = 0;
if (!addr || addr_type > BLE_MESH_ADDR_RANDOM) {
BT_ERR("%s, Invalid parameter", __func__);
@ -712,7 +712,7 @@ int bt_mesh_proxy_client_connect(const u8_t addr[6], u8_t addr_type, u16_t net_i
int bt_mesh_proxy_client_disconnect(u8_t conn_handle)
{
struct bt_mesh_conn *conn;
struct bt_mesh_conn *conn = NULL;
if (conn_handle >= BLE_MESH_MAX_CONN) {
BT_ERR("%s, Invalid parameter", __func__);
@ -734,10 +734,10 @@ int bt_mesh_proxy_client_disconnect(u8_t conn_handle)
bool bt_mesh_proxy_client_send(struct net_buf_simple *buf, u16_t dst)
{
bool send = false;
int err;
u8_t i;
int err = 0;
int i;
for (i = 0U; i < ARRAY_SIZE(servers); i++) {
for (i = 0; i < ARRAY_SIZE(servers); i++) {
struct bt_mesh_proxy_server *server = &servers[i];
NET_BUF_SIMPLE_DEFINE(msg, 32);
@ -776,14 +776,14 @@ static int beacon_send(struct bt_mesh_conn *conn, struct bt_mesh_subnet *sub)
bool bt_mesh_proxy_client_beacon_send(struct bt_mesh_subnet *sub)
{
bool send = false;
int err;
u8_t i;
int err = 0;
int i;
/* NULL means we send Secure Network Beacon on all subnets */
if (!sub) {
#if CONFIG_BLE_MESH_NODE
if (bt_mesh_is_provisioned()) {
for (i = 0U; i < ARRAY_SIZE(bt_mesh.sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
if (bt_mesh.sub[i].net_idx != BLE_MESH_KEY_UNUSED) {
send = bt_mesh_proxy_client_beacon_send(&bt_mesh.sub[i]);
}
@ -793,7 +793,7 @@ bool bt_mesh_proxy_client_beacon_send(struct bt_mesh_subnet *sub)
#endif /* CONFIG_BLE_MESH_NODE */
#if CONFIG_BLE_MESH_PROVISIONER
if (bt_mesh_is_provisioner_en()) {
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
if (bt_mesh.p_sub[i] && bt_mesh.p_sub[i]->net_idx != BLE_MESH_KEY_UNUSED) {
send = bt_mesh_proxy_client_beacon_send(bt_mesh.p_sub[i]);
}
@ -804,7 +804,7 @@ bool bt_mesh_proxy_client_beacon_send(struct bt_mesh_subnet *sub)
return send;
}
for (i = 0U; i < ARRAY_SIZE(servers); i++) {
for (i = 0; i < ARRAY_SIZE(servers); i++) {
if (servers[i].conn && servers[i].conn_type == PROXY) {
err = beacon_send(servers[i].conn, sub);
if (err) {
@ -831,8 +831,8 @@ static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_me
.src = bt_mesh_primary_addr(),
};
struct net_buf_simple *buf = NULL;
u16_t alloc_len;
int err;
u16_t alloc_len = 0U;
int err = 0;
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) {
tx.sub = bt_mesh_subnet_get(net_idx);
@ -923,7 +923,7 @@ static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_me
int bt_mesh_proxy_client_send_cfg(u8_t conn_handle, u16_t net_idx, struct bt_mesh_proxy_cfg_pdu *pdu)
{
struct bt_mesh_conn *conn;
struct bt_mesh_conn *conn = NULL;
if (conn_handle >= BLE_MESH_MAX_CONN || !pdu || pdu->opcode > BLE_MESH_PROXY_CFG_FILTER_REMOVE) {
BT_ERR("%s, Invalid parameter", __func__);
@ -954,10 +954,10 @@ int bt_mesh_proxy_client_send_cfg(u8_t conn_handle, u16_t net_idx, struct bt_mes
int bt_mesh_proxy_prov_client_init(void)
{
u8_t i;
int i;
/* Initialize the server receive buffers */
for (i = 0U; i < ARRAY_SIZE(servers); i++) {
for (i = 0; i < ARRAY_SIZE(servers); i++) {
struct bt_mesh_proxy_server *server = &servers[i];
k_delayed_work_init(&server->sar_timer, proxy_sar_timeout);
@ -980,10 +980,10 @@ int bt_mesh_proxy_prov_client_init(void)
int bt_mesh_proxy_prov_client_deinit(void)
{
size_t i;
int i;
/* Initialize the server receive buffers */
for (i = 0U; i < ARRAY_SIZE(servers); i++) {
for (i = 0; i < ARRAY_SIZE(servers); i++) {
struct bt_mesh_proxy_server *server = &servers[i];
k_delayed_work_free(&server->sar_timer);
memset(server, 0, sizeof(struct bt_mesh_proxy_server));

View File

@ -168,7 +168,7 @@ static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type,
static int filter_set(struct bt_mesh_proxy_client *client,
struct net_buf_simple *buf)
{
u8_t type;
u8_t type = 0U;
if (buf->len < 1) {
BT_WARN("Too short Filter Set message");
@ -246,8 +246,8 @@ static void send_filter_status(struct bt_mesh_proxy_client *client,
.ctx = &rx->ctx,
.src = bt_mesh_primary_addr(),
};
u16_t filter_size;
int i, err;
u16_t filter_size = 0U;
int i, err = 0;
/* Configuration messages always have dst unassigned */
tx.ctx->addr = BLE_MESH_ADDR_UNASSIGNED;
@ -288,9 +288,9 @@ static void send_filter_status(struct bt_mesh_proxy_client *client,
static void proxy_cfg(struct bt_mesh_proxy_client *client)
{
NET_BUF_SIMPLE_DEFINE(buf, 29);
struct bt_mesh_net_rx rx;
u8_t opcode;
int err;
struct bt_mesh_net_rx rx = {0};
u8_t opcode = 0U;
int err = 0;
err = bt_mesh_net_decode(&client->buf, BLE_MESH_NET_IF_PROXY_CFG,
&rx, &buf);
@ -317,7 +317,7 @@ static void proxy_cfg(struct bt_mesh_proxy_client *client)
break;
case CFG_FILTER_ADD:
while (buf.len >= 2) {
u16_t addr;
u16_t addr = 0U;
addr = net_buf_simple_pull_be16(&buf);
filter_add(client, addr);
@ -326,7 +326,7 @@ static void proxy_cfg(struct bt_mesh_proxy_client *client)
break;
case CFG_FILTER_REMOVE:
while (buf.len >= 2) {
u16_t addr;
u16_t addr = 0U;
addr = net_buf_simple_pull_be16(&buf);
filter_remove(client, addr);
@ -351,7 +351,7 @@ static int beacon_send(struct bt_mesh_conn *conn, struct bt_mesh_subnet *sub)
static void proxy_send_beacons(struct k_work *work)
{
struct bt_mesh_proxy_client *client;
struct bt_mesh_proxy_client *client = NULL;
int i;
client = CONTAINER_OF(work, struct bt_mesh_proxy_client, send_beacons);
@ -557,7 +557,7 @@ static int conn_count;
static void proxy_connected(struct bt_mesh_conn *conn, u8_t err)
{
struct bt_mesh_proxy_client *client;
struct bt_mesh_proxy_client *client = NULL;
int i;
BT_DBG("conn %p err 0x%02x", conn, err);
@ -634,7 +634,7 @@ static ssize_t prov_ccc_write(struct bt_mesh_conn *conn,
const void *buf, u16_t len,
u16_t offset, u8_t flags)
{
struct bt_mesh_proxy_client *client;
struct bt_mesh_proxy_client *client = NULL;
u16_t *value = attr->user_data;
BT_DBG("len %u: %s", len, bt_hex(buf, len));
@ -769,8 +769,8 @@ static ssize_t proxy_ccc_write(struct bt_mesh_conn *conn,
const void *buf, u16_t len,
u16_t offset, u8_t flags)
{
struct bt_mesh_proxy_client *client;
u16_t value;
struct bt_mesh_proxy_client *client = NULL;
u16_t value = 0U;
BT_DBG("len %u: %s", len, bt_hex(buf, len));
@ -996,7 +996,7 @@ static int proxy_send(struct bt_mesh_conn *conn, const void *data, u16_t len)
static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type,
struct net_buf_simple *msg)
{
u16_t mtu;
u16_t mtu = 0U;
BT_DBG("conn %p type 0x%02x len %u: %s", conn, type, msg->len,
bt_hex(msg->data, msg->len));
@ -1102,9 +1102,9 @@ static size_t gatt_proxy_adv_create(struct bt_mesh_adv_data *proxy_sd)
static int node_id_adv(struct bt_mesh_subnet *sub)
{
struct bt_mesh_adv_data proxy_sd = {0};
size_t proxy_sd_len;
u8_t tmp[16];
int err;
size_t proxy_sd_len = 0U;
u8_t tmp[16] = {0};
int err = 0;
BT_DBG("%s", __func__);
@ -1142,8 +1142,8 @@ static int node_id_adv(struct bt_mesh_subnet *sub)
static int net_id_adv(struct bt_mesh_subnet *sub)
{
struct bt_mesh_adv_data proxy_sd = {0};
size_t proxy_sd_len;
int err;
size_t proxy_sd_len = 0U;
int err = 0;
BT_DBG("%s", __func__);
@ -1223,7 +1223,7 @@ static int sub_count(void)
static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub)
{
s32_t remaining = K_FOREVER;
int subnet_count;
int subnet_count = 0;
BT_DBG("%s", __func__);
@ -1262,7 +1262,7 @@ static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub)
subnet_count = sub_count();
BT_DBG("sub_count %u", subnet_count);
if (subnet_count > 1) {
s32_t max_timeout;
s32_t max_timeout = 0;
/* We use NODE_ID_TIMEOUT as a starting point since it may
* be less than 60 seconds. Divide this period into at least
@ -1289,8 +1289,8 @@ static size_t gatt_prov_adv_create(struct bt_mesh_adv_data prov_sd[2])
const struct bt_mesh_prov *prov = bt_mesh_prov_get();
const char *name = device_name;
size_t name_len = strlen(name);
size_t prov_sd_len = 0;
size_t sd_space = 31;
size_t prov_sd_len = 0U;
size_t sd_space = 31U;
memcpy(prov_svc_data + 2, prov->uuid, 16);
sys_put_be16(prov->oob_info, prov_svc_data + 18);
@ -1375,7 +1375,7 @@ s32_t bt_mesh_proxy_adv_start(void)
void bt_mesh_proxy_adv_stop(void)
{
int err;
int err = 0;
BT_DBG("adv_enabled %u", proxy_adv_enabled);

View File

@ -171,8 +171,8 @@ struct node_info {
static int role_set(const char *name)
{
bool exist;
int err;
bool exist = false;
int err = 0;
BT_DBG("%s", __func__);
@ -193,8 +193,8 @@ static int role_set(const char *name)
static int net_set(const char *name)
{
struct net_val net = {0};
bool exist;
int err;
bool exist = false;
int err = 0;
BT_DBG("%s", __func__);
@ -222,8 +222,8 @@ static int net_set(const char *name)
static int iv_set(const char *name)
{
struct iv_val iv = {0};
bool exist;
int err;
bool exist = false;
int err = 0;
BT_DBG("%s", __func__);
@ -252,8 +252,8 @@ static int iv_set(const char *name)
static int seq_set(const char *name)
{
struct seq_val seq = {0};
bool exist;
int err;
bool exist = false;
int err = 0;
BT_DBG("%s", __func__);
@ -319,8 +319,8 @@ static int rpl_set(const char *name)
struct bt_mesh_rpl *entry = NULL;
struct rpl_val rpl = {0};
char get[16] = {'\0'};
size_t length;
bool exist;
bool exist = false;
size_t length = 0U;
int err = 0;
int i;
@ -389,8 +389,8 @@ static int net_key_set(const char *name)
struct bt_mesh_subnet *sub = NULL;
struct net_key_val key = {0};
char get[16] = {'\0'};
size_t length;
bool exist;
bool exist = false;
size_t length = 0U;
int err = 0;
int i;
@ -447,8 +447,8 @@ static int app_key_set(const char *name)
struct net_buf_simple *buf = NULL;
struct app_key_val key = {0};
char get[16] = {'\0'};
size_t length;
bool exist;
bool exist = false;
size_t length = 0U;
int err = 0;
int i;
@ -511,8 +511,8 @@ static int hb_pub_set(const char *name)
{
struct bt_mesh_hb_pub *hb_pub = bt_mesh_hb_pub_get();
struct hb_pub_val hb_val = {0};
bool exist;
int err;
bool exist = false;
int err = 0;
BT_DBG("%s", __func__);
@ -556,8 +556,8 @@ static int cfg_set(const char *name)
{
struct bt_mesh_cfg_srv *cfg = bt_mesh_cfg_get();
struct cfg_val val = {0};
bool exist;
int err;
bool exist = false;
int err = 0;
BT_DBG("%s", __func__);
@ -587,8 +587,9 @@ static int cfg_set(const char *name)
static int model_set_bind(bool vnd, struct bt_mesh_model *model, u16_t model_key)
{
char name[16] = {'\0'};
bool exist;
int i, err;
bool exist = false;
int err = 0;
int i;
/* Start with empty array regardless of cleared or set value */
for (i = 0; i < ARRAY_SIZE(model->keys); i++) {
@ -608,8 +609,9 @@ static int model_set_bind(bool vnd, struct bt_mesh_model *model, u16_t model_key
static int model_set_sub(bool vnd, struct bt_mesh_model *model, u16_t model_key)
{
char name[16] = {'\0'};
bool exist;
int i, err;
bool exist = false;
int err = 0;
int i;
/* Start with empty array regardless of cleared or set value */
for (i = 0; i < ARRAY_SIZE(model->groups); i++) {
@ -630,8 +632,8 @@ static int model_set_pub(bool vnd, struct bt_mesh_model *model, u16_t model_key)
{
struct mod_pub_val pub = {0};
char name[16] = {'\0'};
bool exist;
int err;
bool exist = false;
int err = 0;
if (!model->pub) {
BT_WARN("%s, Model has no publication context", __func__);
@ -674,8 +676,8 @@ static int model_set(bool vnd, const char *name)
{
struct bt_mesh_model *model = NULL;
struct net_buf_simple *buf = NULL;
u8_t elem_idx, model_idx;
size_t length;
u8_t elem_idx = 0U, model_idx = 0U;
size_t length = 0U;
int err = 0;
int i;
@ -741,11 +743,11 @@ static int va_set(const char *name)
struct net_buf_simple *buf = NULL;
struct va_val va = {0};
char get[16] = {'\0'};
struct label *lab;
size_t length;
bool exist;
struct label *lab = NULL;
size_t length = 0U;
bool exist = false;
int err = 0;
u16_t i;
int i;
BT_DBG("%s", __func__);
@ -756,7 +758,7 @@ static int va_set(const char *name)
length = buf->len;
for (i = 0U; i < length / SETTINGS_ITEM_SIZE; i++) {
for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) {
u16_t index = net_buf_simple_pull_le16(buf);
sprintf(get, "mesh/va/%04x", index);
@ -799,8 +801,8 @@ free:
static int p_prov_set(const char *name)
{
struct prov_info val = {0};
bool exist;
int err;
bool exist = false;
int err = 0;
BT_DBG("%s", __func__);
@ -824,9 +826,9 @@ static int p_prov_set(const char *name)
static int p_net_idx_set(const char *name)
{
u16_t net_idx;
bool exist;
int err;
u16_t net_idx = 0U;
bool exist = false;
int err = 0;
BT_DBG("%s", __func__);
@ -849,9 +851,9 @@ static int p_net_idx_set(const char *name)
static int p_app_idx_set(const char *name)
{
u16_t app_idx;
bool exist;
int err;
u16_t app_idx = 0U;
bool exist = false;
int err = 0;
BT_DBG("%s", __func__);
@ -873,9 +875,9 @@ static int p_app_idx_set(const char *name)
static struct bt_mesh_subnet *p_subnet_alloc(void)
{
size_t i;
int i;
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
if (bt_mesh.p_sub[i] == NULL) {
bt_mesh.p_sub[i] = osi_calloc(sizeof(struct bt_mesh_subnet));
if (!bt_mesh.p_sub[i]) {
@ -892,9 +894,9 @@ static struct bt_mesh_subnet *p_subnet_alloc(void)
static struct bt_mesh_app_key *p_appkey_alloc(void)
{
size_t i;
int i;
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) {
if (bt_mesh.p_app_keys[i] == NULL) {
bt_mesh.p_app_keys[i] = osi_calloc(sizeof(struct bt_mesh_app_key));
if (!bt_mesh.p_app_keys[i]) {
@ -915,10 +917,10 @@ static int p_net_key_set(const char *name)
struct bt_mesh_subnet *sub = NULL;
struct net_key_val key = {0};
char get[16] = {'\0'};
size_t length;
bool exist;
size_t length = 0U;
bool exist = false;
int err = 0;
size_t i;
int i;
BT_DBG("%s", __func__);
@ -929,7 +931,7 @@ static int p_net_key_set(const char *name)
length = buf->len;
for (i = 0U; i < length / SETTINGS_ITEM_SIZE; i++) {
for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) {
u16_t net_idx = net_buf_simple_pull_le16(buf);
sprintf(get, "mesh/pnk/%04x", net_idx);
@ -953,12 +955,14 @@ static int p_net_key_set(const char *name)
}
}
BT_INFO("Restored NetKey Index 0x%03x", net_idx);
sub->net_idx = net_idx;
sub->kr_flag = key.kr_flag;
sub->kr_phase = key.kr_phase;
memcpy(sub->keys[0].net, &key.val[0], 16);
memcpy(sub->keys[1].net, &key.val[1], 16);
BT_INFO("Restored NetIdx 0x%03x", sub->net_idx);
BT_INFO("Restored NetKey %s", bt_hex(sub->keys[0].net, 16));
}
free:
@ -973,10 +977,10 @@ static int p_app_key_set(const char *name)
struct net_buf_simple *buf = NULL;
struct app_key_val key = {0};
char get[16] = {'\0'};
size_t length;
bool exist;
size_t length = 0U;
bool exist = false;
int err = 0;
size_t i;
int i;
BT_DBG("%s", __func__);
@ -987,7 +991,7 @@ static int p_app_key_set(const char *name)
length = buf->len;
for (i = 0U; i < length / SETTINGS_ITEM_SIZE; i++) {
for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) {
u16_t app_idx = net_buf_simple_pull_le16(buf);
sprintf(get, "mesh/pak/%04x", app_idx);
@ -1018,7 +1022,6 @@ static int p_app_key_set(const char *name)
}
}
BT_INFO("Restored AppKey Index 0x%03x", app_idx);
app->net_idx = key.net_idx;
app->app_idx = app_idx;
app->updated = key.updated;
@ -1026,6 +1029,9 @@ static int p_app_key_set(const char *name)
memcpy(app->keys[1].val, key.val[1], 16);
bt_mesh_app_id(app->keys[0].val, &app->keys[0].id);
bt_mesh_app_id(app->keys[1].val, &app->keys[1].id);
BT_INFO("Restored AppIdx %03x, NetIdx 0x%03x", app->app_idx, app->net_idx);
BT_INFO("Restored AppKey %s", bt_hex(app->keys[0].val, 16));
}
free:
@ -1038,7 +1044,7 @@ static int node_info_set(u16_t addr, bool prov, bool *exist)
struct bt_mesh_node node = {0};
struct node_info info = {0};
char get[16] = {'\0'};
int err;
int err = 0;
sprintf(get, prov ? "mesh/pn/%04x/i" : "mesh/sn/%04x/i", addr);
err = bt_mesh_load_core_settings(get, (u8_t *)&info, sizeof(info), exist);
@ -1077,8 +1083,8 @@ static int node_name_set(u16_t addr, bool prov)
{
char name[BLE_MESH_NODE_NAME_SIZE] = {0};
char get[16] = {'\0'};
bool exist;
int err;
bool exist = false;
int err = 0;
sprintf(get, prov ? "mesh/pn/%04x/n" : "mesh/sn/%04x/n", addr);
err = bt_mesh_load_core_settings(get, (u8_t *)name, BLE_MESH_NODE_NAME_SIZE, &exist);
@ -1106,7 +1112,7 @@ static int node_comp_data_set(u16_t addr, bool prov)
{
struct net_buf_simple *buf = NULL;
char get[16] = {'\0'};
int err;
int err = 0;
sprintf(get, prov ? "mesh/pn/%04x/c" : "mesh/sn/%04x/c", addr);
buf = bt_mesh_get_core_settings_item(get);
@ -1128,10 +1134,10 @@ static int node_comp_data_set(u16_t addr, bool prov)
static int p_node_set(const char *name)
{
struct net_buf_simple *buf = NULL;
bool exist, prov;
size_t length;
bool exist = false, prov = false;
size_t length = 0U;
int err = 0;
size_t i;
int i;
buf = bt_mesh_get_core_settings_item(name);
if (!buf) {
@ -1141,7 +1147,7 @@ static int p_node_set(const char *name)
prov = strcmp(name, "mesh/p_pnode") == 0 ? true : false;
length = buf->len;
for (i = 0U; i < length / SETTINGS_ITEM_SIZE; i++) {
for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) {
u16_t addr = net_buf_simple_pull_le16(buf);
if (!BLE_MESH_ADDR_IS_UNICAST(addr)) {
BT_ERR("%s, 0x%04x is not a unicast address", __func__, addr);
@ -1222,11 +1228,11 @@ const struct bt_mesh_setting {
*/
int settings_core_load(void)
{
size_t i;
int i;
BT_DBG("%s", __func__);
for (i = 0U; i < ARRAY_SIZE(settings); i++) {
for (i = 0; i < ARRAY_SIZE(settings); i++) {
if ((!strcmp(settings[i].name, "mesh/net") ||
!strcmp(settings[i].name, "mesh/netkey") ||
!strcmp(settings[i].name, "mesh/appkey") ||
@ -1269,7 +1275,7 @@ int settings_core_load(void)
static int subnet_init(struct bt_mesh_subnet *sub)
{
int err;
int err = 0;
err = bt_mesh_net_keys_create(&sub->keys[0], sub->keys[0].net);
if (err) {
@ -1314,8 +1320,8 @@ static void commit_model(struct bt_mesh_model *model, struct bt_mesh_elem *elem,
int settings_core_commit(void)
{
struct bt_mesh_subnet *sub = NULL;
size_t i;
int err;
int err = 0;
int i;
#if defined(CONFIG_BLE_MESH_NODE)
if (bt_mesh_is_node()) {
@ -1330,7 +1336,7 @@ int settings_core_commit(void)
bt_mesh_proxy_prov_disable(true);
}
for (i = 0U; i < ARRAY_SIZE(bt_mesh.sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
sub = &bt_mesh.sub[i];
if (sub->net_idx == BLE_MESH_KEY_UNUSED) {
@ -1356,7 +1362,7 @@ int settings_core_commit(void)
bt_mesh_comp_provision(bt_mesh_provisioner_get_primary_elem_addr());
for (i = 0U; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
sub = bt_mesh.p_sub[i];
if (sub == NULL || sub->net_idx == BLE_MESH_KEY_UNUSED) {
@ -1428,7 +1434,7 @@ int settings_core_commit(void)
static void schedule_store(int flag)
{
s32_t timeout, remaining;
s32_t timeout = 0, remaining = 0;
bt_mesh_atomic_set_bit(bt_mesh.flags, flag);
@ -1541,7 +1547,7 @@ static void store_rpl(struct bt_mesh_rpl *entry)
{
struct rpl_val rpl = {0};
char name[16] = {'\0'};
int err;
int err = 0;
BT_DBG("src 0x%04x seq 0x%06x old_iv %u", entry->src, entry->seq, entry->old_iv);
@ -1567,8 +1573,8 @@ static void clear_rpl(void)
{
struct net_buf_simple *buf = NULL;
char name[16] = {'\0'};
size_t length;
u16_t src;
size_t length = 0U;
u16_t src = 0U;
int i;
BT_DBG("%s", __func__);
@ -1662,7 +1668,7 @@ static void clear_cfg(void)
static void clear_app_key(u16_t app_idx)
{
char name[16] = {'\0'};
int err;
int err = 0;
BT_DBG("AppKeyIndex 0x%03x", app_idx);
@ -1680,7 +1686,7 @@ static void clear_app_key(u16_t app_idx)
static void clear_net_key(u16_t net_idx)
{
char name[16] = {'\0'};
int err;
int err = 0;
BT_DBG("NetKeyIndex 0x%03x", net_idx);
@ -1699,7 +1705,7 @@ static void store_net_key(struct bt_mesh_subnet *sub)
{
struct net_key_val key = {0};
char name[16] = {'\0'};
int err;
int err = 0;
BT_DBG("NetKeyIndex 0x%03x NetKey %s", sub->net_idx,
bt_hex(sub->keys[0].net, 16));
@ -1728,7 +1734,7 @@ static void store_app_key(struct bt_mesh_app_key *app)
{
struct app_key_val key = {0};
char name[16] = {'\0'};
int err;
int err = 0;
key.net_idx = app->net_idx;
key.updated = app->updated;
@ -1794,8 +1800,8 @@ static void store_pending_keys(void)
static void store_pending_mod_bind(struct bt_mesh_model *model, bool vnd)
{
char name[16] = {'\0'};
u16_t model_key;
int err;
u16_t model_key = 0U;
int err = 0;
model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx);
@ -1825,8 +1831,8 @@ static void store_pending_mod_bind(struct bt_mesh_model *model, bool vnd)
static void store_pending_mod_sub(struct bt_mesh_model *model, bool vnd)
{
char name[16] = {'\0'};
u16_t model_key;
int err;
u16_t model_key = 0U;
int err = 0;
model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx);
@ -1857,8 +1863,8 @@ static void store_pending_mod_pub(struct bt_mesh_model *model, bool vnd)
{
struct mod_pub_val pub = {0};
char name[16] = {'\0'};
u16_t model_key;
int err;
u16_t model_key = 0U;
int err = 0;
if (!model->pub) {
BT_WARN("%s, No model publication to store", __func__);
@ -1927,9 +1933,9 @@ static void store_pending_va(void)
{
struct va_val va = {0};
char name[16] = {'\0'};
struct label *lab;
u16_t i;
int err;
struct label *lab = NULL;
u16_t i = 0U;
int err = 0;
for (i = 0U; (lab = get_label(i)) != NULL; i++) {
if (!bt_mesh_atomic_test_and_clear_bit(lab->flags,
@ -2260,7 +2266,7 @@ void bt_mesh_store_prov_info(u16_t primary_addr, u16_t alloc_addr)
static void clear_p_net_key(u16_t net_idx)
{
char name[16] = {'\0'};
int err;
int err = 0;
sprintf(name, "mesh/pnk/%04x", net_idx);
bt_mesh_save_core_settings(name, NULL, 0);
@ -2274,7 +2280,7 @@ static void clear_p_net_key(u16_t net_idx)
static void clear_p_app_key(u16_t app_idx)
{
char name[16] = {'\0'};
int err;
int err = 0;
sprintf(name, "mesh/pak/%04x", app_idx);
bt_mesh_save_core_settings(name, NULL, 0);
@ -2289,7 +2295,7 @@ static void store_p_net_key(struct bt_mesh_subnet *sub)
{
struct net_key_val key = {0};
char name[16] = {'\0'};
int err;
int err = 0;
memcpy(&key.val[0], sub->keys[0].net, 16);
memcpy(&key.val[1], sub->keys[1].net, 16);
@ -2313,7 +2319,7 @@ static void store_p_app_key(struct bt_mesh_app_key *app)
{
struct app_key_val key = {0};
char name[16] = {'\0'};
int err;
int err = 0;
key.net_idx = app->net_idx;
key.updated = app->updated;
@ -2412,7 +2418,7 @@ void bt_mesh_clear_p_app_key(struct bt_mesh_app_key *key)
void bt_mesh_clear_rpl_single(u16_t src)
{
char name[16] = {'\0'};
int err;
int err = 0;
if (!BLE_MESH_ADDR_IS_UNICAST(src)) {
BT_ERR("%s, Invalid source address 0x%04x", __func__, src);
@ -2432,7 +2438,7 @@ void bt_mesh_store_node_info(struct bt_mesh_node *node, bool prov)
{
struct node_info val = {0};
char name[16] = {'\0'};
int err;
int err = 0;
if (node == NULL) {
BT_ERR("%s, Invalid node", __func__);
@ -2466,7 +2472,7 @@ void bt_mesh_store_node_info(struct bt_mesh_node *node, bool prov)
static void clear_node(u16_t addr, bool prov)
{
char name[16] = {'\0'};
int err;
int err = 0;
/* Clear node information */
sprintf(name, prov ? "mesh/pn/%04x/i" : "mesh/sn/%04x/i", addr);
@ -2502,7 +2508,7 @@ void bt_mesh_store_node_name(struct bt_mesh_node *node, bool prov)
{
char node_name[BLE_MESH_NODE_NAME_SIZE] = {0};
char name[16] = {'\0'};
int err;
int err = 0;
if (node == NULL) {
BT_ERR("%s, Invalid node", __func__);
@ -2522,7 +2528,7 @@ void bt_mesh_store_node_comp_data(struct bt_mesh_node *node, bool prov)
{
char name[16] = {'\0'};
u8_t *data = NULL;
int err;
int err = 0;
if (node == NULL) {
BT_ERR("%s, Invalid node", __func__);

View File

@ -60,8 +60,8 @@ static struct settings_context settings_ctx[] = {
void bt_mesh_settings_foreach(void)
{
size_t i;
int err;
int err = 0;
int i;
#if CONFIG_BLE_MESH_SPECIFIC_PARTITION
err = nvs_flash_init_partition(CONFIG_BLE_MESH_PARTITION_NAME);
@ -71,7 +71,7 @@ void bt_mesh_settings_foreach(void)
}
#endif
for (i = 0U; i < ARRAY_SIZE(settings_ctx); i++) {
for (i = 0; i < ARRAY_SIZE(settings_ctx); i++) {
struct settings_context *ctx = &settings_ctx[i];
#if CONFIG_BLE_MESH_SPECIFIC_PARTITION
@ -103,9 +103,9 @@ void bt_mesh_settings_foreach(void)
void bt_mesh_settings_deforeach(void)
{
size_t i;
int i;
for (i = 0U; i < ARRAY_SIZE(settings_ctx); i++) {
for (i = 0; i < ARRAY_SIZE(settings_ctx); i++) {
struct settings_context *ctx = &settings_ctx[i];
if (ctx->settings_deinit && ctx->settings_deinit()) {
@ -132,7 +132,7 @@ static inline nvs_handle settings_get_nvs_handle(enum settings_type type)
static int settings_save(nvs_handle handle, const char *key, const u8_t *val, size_t len)
{
int err;
int err = 0;
if (key == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
@ -176,7 +176,7 @@ int bt_mesh_save_core_settings(const char *key, const u8_t *val, size_t len)
static int settings_load(nvs_handle handle, const char *key,
u8_t *buf, size_t buf_len, bool *exist)
{
int err;
int err = 0;
if (key == NULL || buf == NULL || exist == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
@ -209,8 +209,8 @@ int bt_mesh_load_core_settings(const char *key, u8_t *buf, size_t buf_len, bool
static size_t settings_get_length(nvs_handle handle, const char *key)
{
size_t len = 0;
int err;
size_t len = 0U;
int err = 0;
if (key == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
@ -236,9 +236,9 @@ static size_t settings_get_length(nvs_handle handle, const char *key)
static struct net_buf_simple *settings_get_item(nvs_handle handle, const char *key)
{
struct net_buf_simple *buf = NULL;
size_t length;
bool exist;
int err;
size_t length = 0U;
bool exist = false;
int err = 0;
length = settings_get_length(handle, key);
if (!length) {
@ -281,7 +281,7 @@ struct net_buf_simple *bt_mesh_get_core_settings_item(const char *key)
static bool is_settings_item_exist(struct net_buf_simple *buf, const u16_t val)
{
struct net_buf_simple_state state = {0};
size_t length;
size_t length = 0U;
int i;
if (!buf) {
@ -309,8 +309,8 @@ static int settings_add_item(nvs_handle handle, const char *key, const u16_t val
{
struct net_buf_simple *store = NULL;
struct net_buf_simple *buf = NULL;
size_t length = 0;
int err;
size_t length = 0U;
int err = 0;
buf = settings_get_item(handle, key);
@ -354,9 +354,10 @@ static int settings_remove_item(nvs_handle handle, const char *key, const u16_t
{
struct net_buf_simple *store = NULL;
struct net_buf_simple *buf = NULL;
size_t length = 0;
size_t buf_len;
int i, err;
size_t length = 0U;
size_t buf_len = 0U;
int err = 0;
int i;
buf = settings_get_item(handle, key);

View File

@ -34,7 +34,7 @@ int bt_mesh_device_auto_enter_network(struct bt_mesh_device_network_info *info)
struct bt_mesh_app_key *key = NULL;
struct bt_mesh_subnet *sub = NULL;
int i, j, k;
int err;
int err = 0;
if (info == NULL || !BLE_MESH_ADDR_IS_UNICAST(info->unicast_addr) ||
!BLE_MESH_ADDR_IS_GROUP(info->group_addr)) {

View File

@ -141,7 +141,7 @@ void bt_mesh_set_hb_sub_dst(u16_t addr)
static int send_unseg(struct bt_mesh_net_tx *tx, struct net_buf_simple *sdu,
const struct bt_mesh_send_cb *cb, void *cb_data)
{
struct net_buf *buf;
struct net_buf *buf = NULL;
BT_DBG("src 0x%04x dst 0x%04x app_idx 0x%04x sdu_len %u",
tx->src, tx->ctx->addr, tx->ctx->app_idx, sdu->len);
@ -301,7 +301,7 @@ static const struct bt_mesh_send_cb seg_sent_cb = {
static void seg_tx_send_unacked(struct seg_tx *tx)
{
int i, err;
int i, err = 0;
bt_mesh_tx_seg_lock();
@ -349,9 +349,9 @@ static void seg_retransmit(struct k_work *work)
static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu,
const struct bt_mesh_send_cb *cb, void *cb_data)
{
u8_t seg_hdr, seg_o;
u16_t seq_zero;
struct seg_tx *tx;
u8_t seg_hdr = 0U, seg_o = 0U;
u16_t seq_zero = 0U;
struct seg_tx *tx = NULL;
int i;
BT_DBG("src 0x%04x dst 0x%04x app_idx 0x%04x aszmic %u sdu_len %u",
@ -418,9 +418,9 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu,
}
for (seg_o = 0U; sdu->len; seg_o++) {
struct net_buf *seg;
u16_t len;
int err;
struct net_buf *seg = NULL;
u16_t len = 0U;
int err = 0;
seg = bt_mesh_adv_create(BLE_MESH_ADV_DATA, net_tx->xmit,
BUF_TIMEOUT);
@ -445,7 +445,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu,
net_buf_simple_pull(sdu, len);
if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
enum bt_mesh_friend_pdu_type type;
enum bt_mesh_friend_pdu_type type = BLE_MESH_FRIEND_PDU_PARTIAL;
if (seg_o == tx->seg_n) {
type = BLE_MESH_FRIEND_PDU_COMPLETE;
@ -518,9 +518,9 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg,
const struct bt_mesh_send_cb *cb, void *cb_data)
{
const u8_t *key = NULL;
u8_t *ad, role;
u8_t aid;
int err;
u8_t *ad = NULL, role = 0U;
u8_t aid = 0U;
int err = 0;
if (net_buf_simple_tailroom(msg) < 4) {
BT_ERR("%s, Insufficient tailroom for Transport MIC", __func__);
@ -660,10 +660,10 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr,
u8_t aszmic, struct net_buf_simple *buf)
{
struct net_buf_simple *sdu = NULL;
size_t array_size = 0;
u8_t *ad;
u16_t i;
int err;
size_t array_size = 0U;
size_t i = 0U;
u8_t *ad = NULL;
int err = 0;
BT_DBG("ASZMIC %u AKF %u AID 0x%02x", aszmic, AKF(&hdr), AID(&hdr));
BT_DBG("len %u: %s", buf->len, bt_hex(buf->data, buf->len));
@ -700,7 +700,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr,
if (!AKF(&hdr)) {
array_size = bt_mesh_rx_devkey_size();
for (i = 0; i < array_size; i++) {
for (i = 0U; i < array_size; i++) {
const u8_t *dev_key = NULL;
dev_key = bt_mesh_rx_devkey_get(i, rx->ctx.addr);
@ -732,7 +732,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr,
array_size = bt_mesh_rx_appkey_size();
for (i = 0; i < array_size; i++) {
for (i = 0U; i < array_size; i++) {
struct bt_mesh_app_keys *keys = NULL;
struct bt_mesh_app_key *key = NULL;
@ -783,7 +783,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr,
static struct seg_tx *seg_tx_lookup(u16_t seq_zero, u8_t obo, u16_t addr)
{
struct seg_tx *tx;
struct seg_tx *tx = NULL;
int i;
for (i = 0; i < ARRAY_SIZE(seg_tx); i++) {
@ -814,11 +814,11 @@ static struct seg_tx *seg_tx_lookup(u16_t seq_zero, u8_t obo, u16_t addr)
static int trans_ack(struct bt_mesh_net_rx *rx, u8_t hdr,
struct net_buf_simple *buf, u64_t *seq_auth)
{
struct seg_tx *tx;
unsigned int bit;
u32_t ack;
u16_t seq_zero;
u8_t obo;
struct seg_tx *tx = NULL;
unsigned int bit = 0;
u32_t ack = 0U;
u16_t seq_zero = 0U;
u8_t obo = 0U;
if (buf->len < 6) {
BT_ERR("%s, Too short ack message", __func__);
@ -885,8 +885,8 @@ static int trans_ack(struct bt_mesh_net_rx *rx, u8_t hdr,
static int trans_heartbeat(struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf)
{
u8_t init_ttl, hops;
u16_t feat;
u8_t init_ttl = 0U, hops = 0U;
u16_t feat = 0U;
if (buf->len < 3) {
BT_ERR("%s, Too short heartbeat message", __func__);
@ -980,7 +980,7 @@ static int ctl_recv(struct bt_mesh_net_rx *rx, u8_t hdr,
static int trans_unseg(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx,
u64_t *seq_auth)
{
u8_t hdr;
u8_t hdr = 0U;
BT_DBG("AFK %u AID 0x%02x", AKF(buf->data), AID(buf->data));
@ -1011,8 +1011,8 @@ static int trans_unseg(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx,
static inline s32_t ack_timeout(struct seg_rx *rx)
{
s32_t to;
u8_t ttl;
s32_t to = 0;
u8_t ttl = 0U;
if (rx->ttl == BLE_MESH_TTL_DEFAULT) {
ttl = bt_mesh_default_ttl_get();
@ -1038,7 +1038,7 @@ int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data,
size_t data_len, u64_t *seq_auth,
const struct bt_mesh_send_cb *cb, void *cb_data)
{
struct net_buf *buf;
struct net_buf *buf = NULL;
BT_DBG("src 0x%04x dst 0x%04x ttl 0x%02x ctl 0x%02x", tx->src,
tx->ctx->addr, tx->ctx->send_ttl, ctl_op);
@ -1087,7 +1087,7 @@ static int send_ack(struct bt_mesh_subnet *sub, u16_t src, u16_t dst,
.xmit = bt_mesh_net_transmit_get(),
};
u16_t seq_zero = *seq_auth & TRANS_SEQ_ZERO_MASK;
u8_t buf[6];
u8_t buf[6] = {0};
BT_DBG("SeqZero 0x%04x Block 0x%08x OBO %u", seq_zero, block, obo);
@ -1270,12 +1270,12 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx,
u8_t *seg_count)
{
struct bt_mesh_rpl *rpl = NULL;
struct seg_rx *rx;
struct seg_rx *rx = NULL;
u8_t *hdr = buf->data;
u16_t seq_zero;
u8_t seg_n;
u8_t seg_o;
int err;
u16_t seq_zero = 0U;
u8_t seg_n = 0U;
u8_t seg_o = 0U;
int err = 0;
if (buf->len < 5) {
BT_ERR("%s, Too short segmented message (len %u)", __func__, buf->len);
@ -1483,9 +1483,9 @@ int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx)
{
u64_t seq_auth = TRANS_SEQ_AUTH_NVAL;
enum bt_mesh_friend_pdu_type pdu_type = BLE_MESH_FRIEND_PDU_SINGLE;
struct net_buf_simple_state state;
struct net_buf_simple_state state = {0};
u8_t seg_count = 0U;
int err;
int err = 0;
if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
rx->friend_match = bt_mesh_friend_match(rx->sub->net_idx,
@ -1612,16 +1612,16 @@ void bt_mesh_trans_init(void)
void bt_mesh_trans_deinit(void)
{
size_t i;
int i;
bt_mesh_rx_reset();
bt_mesh_tx_reset();
for (i = 0U; i < ARRAY_SIZE(seg_tx); i++) {
for (i = 0; i < ARRAY_SIZE(seg_tx); i++) {
k_delayed_work_free(&seg_tx[i].retransmit);
}
for (i = 0U; i < ARRAY_SIZE(seg_rx); i++) {
for (i = 0; i < ARRAY_SIZE(seg_rx); i++) {
k_delayed_work_free(&seg_rx[i].ack);
}
@ -1689,7 +1689,7 @@ void bt_mesh_heartbeat_send(void)
int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, u16_t app_idx,
const u8_t **key, u8_t *aid, u8_t role, u16_t dst)
{
struct bt_mesh_app_key *app_key;
struct bt_mesh_app_key *app_key = NULL;
if (app_idx == BLE_MESH_KEY_DEV) {
*key = bt_mesh_tx_devkey_get(role, dst);

View File

@ -168,7 +168,7 @@ int bt_mesh_client_send_msg(struct bt_mesh_model *model,
bt_mesh_client_internal_data_t *internal = NULL;
bt_mesh_client_user_data_t *cli = NULL;
bt_mesh_client_node_t *node = NULL;
int err;
int err = 0;
if (!model || !ctx || !msg) {
BT_ERR("%s, Invalid parameter", __func__);

View File

@ -146,7 +146,7 @@ static void timeout_handler(struct k_work *work)
struct k_delayed_work *timer = NULL;
bt_mesh_client_node_t *node = NULL;
struct bt_mesh_msg_ctx ctx = {0};
u32_t opcode;
u32_t opcode = 0U;
BT_WARN("Receive generic status message timeout");
@ -177,7 +177,7 @@ static void generic_status(struct bt_mesh_model *model,
bt_mesh_client_node_t *node = NULL;
u8_t *val = NULL;
u8_t evt = 0xFF;
size_t len = 0;
size_t len = 0U;
BT_DBG("%s, len %d, bytes %s", __func__, buf->len, bt_hex(buf->data, buf->len));
@ -697,7 +697,7 @@ const struct bt_mesh_model_op gen_property_cli_op[] = {
static int gen_get_state(bt_mesh_client_common_param_t *common, void *value)
{
NET_BUF_SIMPLE_DEFINE(msg, BLE_MESH_GEN_GET_STATE_MSG_LEN);
int err;
int err = 0;
bt_mesh_model_msg_init(&msg, common->opcode);
@ -747,7 +747,7 @@ static int gen_set_state(bt_mesh_client_common_param_t *common,
void *value, u16_t value_len, bool need_ack)
{
struct net_buf_simple *msg = NULL;
int err;
int err = 0;
msg = bt_mesh_alloc_buf(value_len);
if (!msg) {
@ -991,8 +991,8 @@ int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void
int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status)
{
bt_mesh_generic_client_t *client = NULL;
u16_t length = 0;
bool need_ack = false;
u16_t length = 0U;
bool need_ack = false;
if (!common || !common->model || !set) {
BT_ERR("%s, Invalid parameter", __func__);

View File

@ -155,7 +155,7 @@ static void timeout_handler(struct k_work *work)
struct k_delayed_work *timer = NULL;
bt_mesh_client_node_t *node = NULL;
struct bt_mesh_msg_ctx ctx = {0};
u32_t opcode;
u32_t opcode = 0U;
BT_WARN("Receive light status message timeout");
@ -186,7 +186,7 @@ static void light_status(struct bt_mesh_model *model,
bt_mesh_client_node_t *node = NULL;
u8_t *val = NULL;
u8_t evt = 0xFF;
size_t len = 0;
size_t len = 0U;
BT_DBG("%s, len %d, bytes %s", __func__, buf->len, bt_hex(buf->data, buf->len));
@ -780,7 +780,7 @@ const struct bt_mesh_model_op light_lc_cli_op[] = {
static int light_get_state(bt_mesh_client_common_param_t *common, void *value)
{
NET_BUF_SIMPLE_DEFINE(msg, BLE_MESH_LIGHT_GET_STATE_MSG_LEN);
int err;
int err = 0;
bt_mesh_model_msg_init(&msg, common->opcode);
@ -812,7 +812,7 @@ static int light_set_state(bt_mesh_client_common_param_t *common,
void *value, u16_t value_len, bool need_ack)
{
struct net_buf_simple *msg = NULL;
int err;
int err = 0;
msg = bt_mesh_alloc_buf(value_len);
if (!msg) {
@ -1105,8 +1105,8 @@ int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *
int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status)
{
bt_mesh_light_client_t *client = NULL;
u16_t length = 0;
bool need_ack = false;
u16_t length = 0U;
bool need_ack = false;
if (!common || !common->model || !set) {
BT_ERR("%s, Invalid parameter", __func__);

View File

@ -84,7 +84,7 @@ static void timeout_handler(struct k_work *work)
struct k_delayed_work *timer = NULL;
bt_mesh_client_node_t *node = NULL;
struct bt_mesh_msg_ctx ctx = {0};
u32_t opcode;
u32_t opcode = 0U;
BT_WARN("Receive sensor status message timeout");
@ -115,7 +115,7 @@ static void sensor_status(struct bt_mesh_model *model,
bt_mesh_client_node_t *node = NULL;
u8_t *val = NULL;
u8_t evt = 0xFF;
size_t len = 0;
size_t len = 0U;
BT_DBG("%s, len %d, bytes %s", __func__, buf->len, bt_hex(buf->data, buf->len));
@ -364,7 +364,7 @@ static int sensor_act_state(bt_mesh_client_common_param_t *common,
void *value, u16_t value_len, bool need_ack)
{
struct net_buf_simple *msg = NULL;
int err;
int err = 0;
msg = bt_mesh_alloc_buf(value_len);
if (!msg) {
@ -471,7 +471,7 @@ end:
int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status)
{
bt_mesh_sensor_client_t *client = NULL;
u16_t length = 0;
u16_t length = 0U;
if (!common || !common->model || !get) {
BT_ERR("%s, Invalid parameter", __func__);
@ -536,7 +536,7 @@ int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void
int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status)
{
bt_mesh_sensor_client_t *client = NULL;
u16_t length = 0;
u16_t length = 0U;
bool need_ack = false;
if (!common || !common->model || !set) {

View File

@ -100,7 +100,7 @@ static void timeout_handler(struct k_work *work)
struct k_delayed_work *timer = NULL;
bt_mesh_client_node_t *node = NULL;
struct bt_mesh_msg_ctx ctx = {0};
u32_t opcode;
u32_t opcode = 0U;
BT_WARN("Receive time scene status message timeout");
@ -131,7 +131,7 @@ static void time_scene_status(struct bt_mesh_model *model,
bt_mesh_client_node_t *node = NULL;
u8_t *val = NULL;
u8_t evt = 0xFF;
size_t len = 0;
size_t len = 0U;
BT_DBG("%s, len %d, bytes %s", __func__, buf->len, bt_hex(buf->data, buf->len));
@ -380,7 +380,7 @@ const struct bt_mesh_model_op scheduler_cli_op[] = {
static int time_scene_get_state(bt_mesh_client_common_param_t *common, void *value)
{
NET_BUF_SIMPLE_DEFINE(msg, BLE_MESH_SCENE_GET_STATE_MSG_LEN);
int err;
int err = 0;
bt_mesh_model_msg_init(&msg, common->opcode);
@ -412,7 +412,7 @@ static int time_scene_set_state(bt_mesh_client_common_param_t *common,
void *value, u16_t value_len, bool need_ack)
{
struct net_buf_simple *msg = NULL;
int err;
int err = 0;
msg = bt_mesh_alloc_buf(value_len);
if (!msg) {
@ -546,7 +546,7 @@ int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, v
int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status)
{
bt_mesh_time_scene_client_t *client = NULL;
u16_t length = 0;
u16_t length = 0U;
bool need_ack = false;
if (!common || !common->model || !set) {

View File

@ -132,9 +132,9 @@ static void gen_onoff_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_gen_onoff_srv *srv = model->user_data;
u8_t tid, onoff, trans_time, delay;
bool optional;
s64_t now;
u8_t tid = 0U, onoff = 0U, trans_time = 0U, delay = 0U;
bool optional = false;
s64_t now = 0;
if (srv == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -313,10 +313,10 @@ static void gen_level_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_gen_level_srv *srv = model->user_data;
u8_t tid, trans_time, delay;
bool optional;
s16_t level;
s64_t now;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
bool optional = false;
s16_t level = 0;
s64_t now = 0;
if (srv == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -409,10 +409,10 @@ static void gen_delta_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_gen_level_srv *srv = model->user_data;
u8_t tid, trans_time, delay;
s32_t tmp32, delta;
bool optional;
s64_t now;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
s32_t tmp32 = 0, delta = 0;
bool optional = false;
s64_t now = 0;
if (srv == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -530,11 +530,11 @@ static void gen_move_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_gen_level_srv *srv = model->user_data;
u8_t tid, trans_time, delay;
bool optional;
s16_t delta;
s32_t tmp32;
s64_t now;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
bool optional = false;
s16_t delta = 0;
s32_t tmp32 = 0;
s64_t now = 0;
if (srv == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -717,7 +717,7 @@ static void gen_def_trans_time_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_gen_def_trans_time_srv *srv = model->user_data;
u8_t trans_time;
u8_t trans_time = 0U;
if (srv == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -874,7 +874,7 @@ static void gen_onpowerup_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_gen_power_onoff_setup_srv *srv = model->user_data;
u8_t onpowerup;
u8_t onpowerup = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1002,7 +1002,7 @@ static void gen_power_level_get(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_gen_power_level_srv *srv = model->user_data;
u16_t opcode;
u16_t opcode = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1076,10 +1076,10 @@ static void gen_power_level_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_gen_power_level_srv *srv = model->user_data;
u8_t tid, trans_time, delay;
bool optional;
u16_t power;
s64_t now;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
bool optional = false;
u16_t power = 0U;
s64_t now = 0;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1187,7 +1187,7 @@ static void gen_power_default_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_gen_power_level_setup_srv *srv = model->user_data;
u16_t power;
u16_t power = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1237,7 +1237,7 @@ static void gen_power_range_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_gen_power_level_setup_srv *srv = model->user_data;
u16_t range_min, range_max;
u16_t range_min = 0U, range_max = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1403,7 +1403,7 @@ static void gen_location_get(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_gen_location_srv *srv = model->user_data;
u16_t opcode;
u16_t opcode = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1439,7 +1439,7 @@ static void gen_location_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_gen_location_setup_srv *srv = model->user_data;
u16_t opcode;
u16_t opcode = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1552,9 +1552,9 @@ struct bt_mesh_generic_property *gen_get_user_property(struct bt_mesh_model *mod
u16_t property_id)
{
struct bt_mesh_gen_user_prop_srv *srv = model->user_data;
u8_t i;
int i;
for (i = 0U; i < srv->property_count; i++) {
for (i = 0; i < srv->property_count; i++) {
if (srv->properties[i].id == property_id) {
return &srv->properties[i];
}
@ -1569,7 +1569,7 @@ static void send_gen_user_prop_status(struct bt_mesh_model *model,
{
struct bt_mesh_generic_property *property = NULL;
struct net_buf_simple *msg = NULL;
u16_t length;
u16_t length = 0U;
if (property_id == BLE_MESH_INVALID_DEVICE_PROPERTY_ID) {
BT_ERR("%s, Invalid User Property ID 0x%04x", __func__, property_id);
@ -1690,8 +1690,8 @@ static void gen_user_prop_set(struct bt_mesh_model *model,
{
struct bt_mesh_gen_user_prop_srv *srv = model->user_data;
struct bt_mesh_generic_property *property = NULL;
u16_t property_id;
u8_t expect_len;
u16_t property_id = 0U;
u8_t expect_len = 0U;
if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1756,9 +1756,9 @@ struct bt_mesh_generic_property *gen_get_admin_property(struct bt_mesh_model *mo
u16_t property_id)
{
struct bt_mesh_gen_admin_prop_srv *srv = model->user_data;
u8_t i;
int i;
for (i = 0U; i < srv->property_count; i++) {
for (i = 0; i < srv->property_count; i++) {
if (srv->properties[i].id == property_id) {
return &srv->properties[i];
}
@ -1773,7 +1773,7 @@ static void send_gen_admin_prop_status(struct bt_mesh_model *model,
{
struct bt_mesh_generic_property *property = NULL;
struct net_buf_simple *msg = NULL;
u16_t length;
u16_t length = 0U;
if (property_id == BLE_MESH_INVALID_DEVICE_PROPERTY_ID) {
BT_ERR("%s, Invalid User Property ID 0x%04x", __func__, property_id);
@ -1837,7 +1837,7 @@ static void gen_admin_prop_get(struct bt_mesh_model *model,
if (srv->rsp_ctrl.get_auto_rsp == BLE_MESH_SERVER_RSP_BY_APP) {
bt_mesh_gen_server_recv_get_msg_t get = {0};
const u8_t *param = NULL;
size_t len = 0;
size_t len = 0U;
if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET) {
get.admin_property_get.id = net_buf_simple_pull_le16(buf);
param = (const u8_t *)&get;
@ -1851,7 +1851,7 @@ static void gen_admin_prop_get(struct bt_mesh_model *model,
switch (ctx->recv_op) {
case BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_GET: {
struct net_buf_simple *msg = NULL;
u8_t i;
u8_t i = 0U;
msg = bt_mesh_alloc_buf(1 + srv->property_count * 2 + BLE_MESH_SERVER_TRANS_MIC_SIZE);
if (msg == NULL) {
BT_ERR("%s, Failed to allocate memory", __func__);
@ -1882,8 +1882,8 @@ static void gen_admin_prop_set(struct bt_mesh_model *model,
{
struct bt_mesh_gen_admin_prop_srv *srv = model->user_data;
struct bt_mesh_generic_property *property = NULL;
u16_t property_id;
u8_t access;
u16_t property_id = 0U;
u8_t access = 0U;
if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1944,9 +1944,9 @@ struct bt_mesh_generic_property *gen_get_manu_property(struct bt_mesh_model *mod
u16_t property_id)
{
struct bt_mesh_gen_manu_prop_srv *srv = model->user_data;
u8_t i;
int i;
for (i = 0U; i < srv->property_count; i++) {
for (i = 0; i < srv->property_count; i++) {
if (srv->properties[i].id == property_id) {
return &srv->properties[i];
}
@ -1961,7 +1961,7 @@ static void send_gen_manu_prop_status(struct bt_mesh_model *model,
{
struct bt_mesh_generic_property *property = NULL;
struct net_buf_simple *msg = NULL;
u16_t length;
u16_t length = 0U;
if (property_id == BLE_MESH_INVALID_DEVICE_PROPERTY_ID) {
BT_ERR("%s, Invalid User Property ID 0x%04x", __func__, property_id);
@ -2022,7 +2022,7 @@ static void gen_manu_prop_get(struct bt_mesh_model *model,
if (srv->rsp_ctrl.get_auto_rsp == BLE_MESH_SERVER_RSP_BY_APP) {
bt_mesh_gen_server_recv_get_msg_t get = {0};
const u8_t *param = NULL;
size_t len = 0;
size_t len = 0U;
if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_GET) {
get.manu_property_get.id = net_buf_simple_pull_le16(buf);
param = (const u8_t *)&get;
@ -2036,7 +2036,7 @@ static void gen_manu_prop_get(struct bt_mesh_model *model,
switch (ctx->recv_op) {
case BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_GET: {
struct net_buf_simple *msg = NULL;
u8_t i;
u8_t i = 0U;
msg = bt_mesh_alloc_buf(1 + srv->property_count * 2 + BLE_MESH_SERVER_TRANS_MIC_SIZE);
if (msg == NULL) {
BT_ERR("%s, Failed to allocate memory", __func__);
@ -2067,8 +2067,8 @@ static void gen_manu_prop_set(struct bt_mesh_model *model,
{
struct bt_mesh_gen_manu_prop_srv *srv = model->user_data;
struct bt_mesh_generic_property *property = NULL;
u16_t property_id;
u8_t access;
u16_t property_id = 0U;
u8_t access = 0U;
if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -2123,8 +2123,8 @@ static void gen_manu_prop_set(struct bt_mesh_model *model,
static int search_prop_id_index(const u16_t *array, u8_t array_idx, u16_t id)
{
static const u16_t *start = NULL;
u8_t index;
u16_t temp;
u8_t index = 0U;
u16_t temp = 0U;
if (start == NULL) {
start = array;
@ -2156,9 +2156,9 @@ static void gen_client_prop_get(struct bt_mesh_model *model,
{
struct bt_mesh_gen_client_prop_srv *srv = model->user_data;
struct net_buf_simple *sdu = NULL;
u16_t total_len = 5;
u16_t property_id;
int i, index;
u16_t total_len = 5U;
u16_t property_id = 0U;
int i, index = 0;
if (srv == NULL || srv->id_count == 0U || srv->property_ids == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);

View File

@ -148,7 +148,7 @@ static void light_lightness_get(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_lightness_srv *srv = model->user_data;
u16_t opcode;
u16_t opcode = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -225,10 +225,10 @@ static void light_lightness_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_lightness_srv *srv = model->user_data;
u8_t tid, trans_time, delay;
bool optional;
u16_t actual;
s64_t now;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
bool optional = false;
u16_t actual = 0U;
s64_t now = 0;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -337,10 +337,10 @@ static void light_lightness_linear_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_lightness_srv *srv = model->user_data;
u8_t tid, trans_time, delay;
bool optional;
u16_t linear;
s64_t now;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
bool optional = false;
u16_t linear = 0U;
s64_t now = 0;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -433,7 +433,7 @@ static void light_lightness_default_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_lightness_setup_srv *srv = model->user_data;
u16_t lightness;
u16_t lightness = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -475,7 +475,7 @@ static void light_lightness_range_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_lightness_setup_srv *srv = model->user_data;
u16_t range_min, range_max;
u16_t range_min = 0U, range_max = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -649,7 +649,7 @@ static void light_ctl_get(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_server_rsp_ctrl *rsp_ctrl = NULL;
u16_t opcode;
u16_t opcode = 0U;
if (model->user_data == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -755,11 +755,11 @@ static void light_ctl_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_ctl_srv *srv = model->user_data;
u16_t lightness, temperature;
u8_t tid, trans_time, delay;
s16_t delta_uv;
bool optional;
s64_t now;
u16_t lightness = 0U, temperature = 0U;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
s16_t delta_uv = 0;
bool optional = false;
s64_t now = 0;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -874,8 +874,8 @@ static void light_ctl_default_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_ctl_setup_srv *srv = model->user_data;
u16_t lightness, temperature;
s16_t delta_uv;
u16_t lightness = 0U, temperature = 0U;
s16_t delta_uv = 0;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -938,7 +938,7 @@ static void light_ctl_temp_range_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_ctl_setup_srv *srv = model->user_data;
u16_t min, max;
u16_t min = 0U, max = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1004,11 +1004,11 @@ static void light_ctl_temp_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_ctl_temp_srv *srv = model->user_data;
u8_t tid, trans_time, delay;
u16_t temperature;
s16_t delta_uv;
bool optional;
s64_t now;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
u16_t temperature = 0U;
s16_t delta_uv = 0;
bool optional = false;
s64_t now = 0;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1235,7 +1235,7 @@ static void light_hsl_get(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_server_rsp_ctrl *rsp_ctrl = NULL;
u16_t opcode;
u16_t opcode = 0U;
if (model->user_data == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1364,10 +1364,10 @@ static void light_hsl_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_hsl_srv *srv = model->user_data;
u16_t lightness, hue, saturation;
u8_t tid, trans_time, delay;
bool optional;
s64_t now;
u16_t lightness = 0U, hue = 0U, saturation = 0U;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
bool optional = false;
s64_t now = 0;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1482,7 +1482,7 @@ static void light_hsl_default_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_hsl_setup_srv *srv = model->user_data;
u16_t lightness, hue, saturation;
u16_t lightness = 0U, hue = 0U, saturation = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1542,7 +1542,7 @@ static void light_hsl_range_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_hsl_setup_srv *srv = model->user_data;
u16_t hue_min, hue_max, saturation_min, saturation_max;
u16_t hue_min = 0U, hue_max = 0U, saturation_min = 0U, saturation_max = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1607,10 +1607,10 @@ static void light_hsl_hue_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_hsl_hue_srv *srv = model->user_data;
u8_t tid, trans_time, delay;
bool optional;
u16_t hue;
s64_t now;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
bool optional = false;
u16_t hue = 0U;
s64_t now = 0;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1708,10 +1708,10 @@ static void light_hsl_sat_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_hsl_sat_srv *srv = model->user_data;
u8_t tid, trans_time, delay;
u16_t saturation;
bool optional;
s64_t now;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
u16_t saturation = 0U;
bool optional = false;
s64_t now = 0;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1907,7 +1907,7 @@ static void light_xyl_get(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_xyl_srv *srv = model->user_data;
u16_t opcode;
u16_t opcode = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1981,10 +1981,10 @@ static void light_xyl_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_xyl_srv *srv = model->user_data;
u8_t tid, trans_time, delay;
u16_t lightness, x, y;
bool optional;
s64_t now;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
u16_t lightness = 0U, x = 0U, y = 0U;
bool optional = false;
s64_t now = 0;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -2099,7 +2099,7 @@ static void light_xyl_default_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_xyl_setup_srv *srv = model->user_data;
u16_t lightness, x, y;
u16_t lightness = 0U, x = 0U, y = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -2159,7 +2159,7 @@ static void light_xyl_range_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_xyl_setup_srv *srv = model->user_data;
u16_t x_min, x_max, y_min, y_max;
u16_t x_min = 0U, x_max = 0U, y_min = 0U, y_max = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -2284,7 +2284,7 @@ static void light_lc_get(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_lc_srv *srv = model->user_data;
u16_t opcode;
u16_t opcode = 0U;
if (srv == NULL || srv->lc == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -2335,7 +2335,7 @@ static void light_lc_mode_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_lc_srv *srv = model->user_data;
u8_t mode;
u8_t mode = 0U;
if (srv == NULL || srv->lc == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -2379,7 +2379,7 @@ static void light_lc_om_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_lc_srv *srv = model->user_data;
u8_t om;
u8_t om = 0U;
if (srv == NULL || srv->lc == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -2423,10 +2423,10 @@ static void light_lc_light_onoff_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_lc_srv *srv = model->user_data;
u8_t tid, trans_time, delay;
bool optional;
u8_t onoff;
s64_t now;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
bool optional = false;
u8_t onoff = 0U;
s64_t now = 0;
if (srv == NULL || srv->lc == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -2541,8 +2541,8 @@ static void light_lc_sensor_status(struct bt_mesh_model *model,
*/
struct bt_mesh_light_lc_srv *srv = model->user_data;
bt_mesh_light_server_state_change_t change = {0};
u16_t mpid, prop_id;
u8_t length;
u16_t mpid = 0U, prop_id = 0U;
u8_t length = 0U;
if (srv == NULL || srv->lc == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -2738,7 +2738,7 @@ static void send_light_lc_prop_status(struct bt_mesh_model *model,
{
struct net_buf_simple *msg = NULL;
u8_t length = 1 + 2 + 4;
u8_t *prop_val;
u8_t *prop_val = NULL;
prop_val = get_light_lc_prop_val(model, prop_id);
if (prop_val == NULL) {
@ -2777,7 +2777,7 @@ static void light_lc_prop_get(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_lc_setup_srv *srv = model->user_data;
u16_t prop_id;
u16_t prop_id = 0U;
if (srv == NULL || srv->lc == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -2809,8 +2809,8 @@ static void light_lc_prop_set(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
struct bt_mesh_light_lc_setup_srv *srv = model->user_data;
u8_t *prop_val, expect_len;
u16_t prop_id;
u8_t *prop_val = NULL, expect_len = 0U;
u16_t prop_id = 0U;
if (srv == NULL || srv->lc == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);

View File

@ -34,8 +34,8 @@ static void send_sensor_descriptor_status(struct bt_mesh_model *model,
struct bt_mesh_sensor_srv *srv = model->user_data;
struct bt_mesh_sensor_state *state = NULL;
struct net_buf_simple *msg = NULL;
u16_t total_len = 5;
u8_t i;
u16_t total_len = 5U;
int i;
msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN));
if (msg == NULL) {
@ -46,7 +46,7 @@ static void send_sensor_descriptor_status(struct bt_mesh_model *model,
bt_mesh_model_msg_init(msg, BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS);
if (get_all == true) {
for (i = 0U; i < srv->state_count; i++) {
for (i = 0; i < srv->state_count; i++) {
state = &srv->states[i];
if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID) {
total_len += SENSOR_DESCRIPTOR_LEN;
@ -63,7 +63,7 @@ static void send_sensor_descriptor_status(struct bt_mesh_model *model,
}
}
} else {
for (i = 0U; i < srv->state_count; i++) {
for (i = 0; i < srv->state_count; i++) {
state = &srv->states[i];
if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID &&
state->sensor_property_id == prop_id) {
@ -94,8 +94,8 @@ static void send_sensor_data_status(struct bt_mesh_model *model,
struct bt_mesh_sensor_srv *srv = model->user_data;
struct bt_mesh_sensor_state *state = NULL;
struct net_buf_simple *msg = NULL;
u16_t total_len = 5;
u8_t i;
u16_t total_len = 5U;
int i;
msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN));
if (msg == NULL) {
@ -106,7 +106,7 @@ static void send_sensor_data_status(struct bt_mesh_model *model,
bt_mesh_model_msg_init(msg, BLE_MESH_MODEL_OP_SENSOR_STATUS);
if (get_all == true) {
for (i = 0U; i < srv->state_count; i++) {
for (i = 0; i < srv->state_count; i++) {
state = &srv->states[i];
if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID) {
u8_t mpid_len = (state->sensor_data.format == SENSOR_DATA_FORMAT_A) ?
@ -132,7 +132,7 @@ static void send_sensor_data_status(struct bt_mesh_model *model,
}
}
} else {
for (i = 0U; i < srv->state_count; i++) {
for (i = 0; i < srv->state_count; i++) {
state = &srv->states[i];
if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID &&
state->sensor_property_id == prop_id) {
@ -173,10 +173,10 @@ static void send_sensor_cadence_status(struct bt_mesh_model *model,
struct bt_mesh_sensor_setup_srv *srv = model->user_data;
struct bt_mesh_sensor_state *state = NULL;
struct net_buf_simple *msg = NULL;
u16_t length = 0;
u8_t i;
u16_t length = 0U;
int i;
for (i = 0U; i < srv->state_count; i++) {
for (i = 0; i < srv->state_count; i++) {
state = &srv->states[i];
if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID &&
state->sensor_property_id == prop_id && state->cadence) {
@ -275,8 +275,8 @@ static void send_sensor_settings_status(struct bt_mesh_model *model,
struct bt_mesh_sensor_state *state = NULL;
struct sensor_setting *item = NULL;
struct net_buf_simple *msg = NULL;
u16_t total_len = 7;
u8_t i, j;
u16_t total_len = 7U;
int i, j;
msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN));
if (msg == NULL) {
@ -287,11 +287,11 @@ static void send_sensor_settings_status(struct bt_mesh_model *model,
bt_mesh_model_msg_init(msg, BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS);
net_buf_simple_add_le16(msg, prop_id);
for (i = 0U; i < srv->state_count; i++) {
for (i = 0; i < srv->state_count; i++) {
state = &srv->states[i];
if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID &&
state->sensor_property_id == prop_id) {
for (j = 0U; j < state->setting_count; j++) {
for (j = 0; j < state->setting_count; j++) {
item = &state->settings[j];
if (item->property_id != INVALID_SENSOR_SETTING_PROPERTY_ID) {
total_len += SENSOR_SETTING_PROPERTY_ID_LEN;
@ -320,13 +320,13 @@ static struct sensor_setting *find_sensor_setting(struct bt_mesh_model *model,
struct bt_mesh_sensor_setup_srv *srv = model->user_data;
struct bt_mesh_sensor_state *state = NULL;
struct sensor_setting *item = NULL;
u8_t i, j;
int i, j;
for (i = 0U; i < srv->state_count; i++) {
for (i = 0; i < srv->state_count; i++) {
state = &srv->states[i];
if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID &&
state->sensor_property_id == prop_id) {
for (j = 0U; j < state->setting_count; j++) {
for (j = 0; j < state->setting_count; j++) {
item = &state->settings[j];
if (item->property_id != INVALID_SENSOR_SETTING_PROPERTY_ID &&
item->property_id == set_prop_id) {
@ -345,7 +345,7 @@ static void send_sensor_setting_status(struct bt_mesh_model *model,
{
struct sensor_setting *item = NULL;
struct net_buf_simple *msg = NULL;
u16_t length;
u16_t length = 0U;
item = find_sensor_setting(model, prop_id, set_prop_id);
if (item) {
@ -415,10 +415,10 @@ static void send_sensor_column_status(struct bt_mesh_model *model,
struct bt_mesh_sensor_state *state = NULL;
struct net_buf_simple *msg = NULL;
bool optional = false;
u16_t length = 0;
u8_t i;
u16_t length = 0U;
int i;
for (i = 0U; i < srv->state_count; i++) {
for (i = 0; i < srv->state_count; i++) {
state = &srv->states[i];
if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID &&
state->sensor_property_id == prop_id) {
@ -476,10 +476,10 @@ static void send_sensor_series_status(struct bt_mesh_model *model,
struct bt_mesh_sensor_state *state = NULL;
struct net_buf_simple *msg = NULL;
bool optional = false;
u16_t length;
u8_t i;
u16_t length = 0U;
int i;
for (i = 0U; i < srv->state_count; i++) {
for (i = 0; i < srv->state_count; i++) {
state = &srv->states[i];
if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID &&
state->sensor_property_id == prop_id) {
@ -694,9 +694,9 @@ static void sensor_cadence_set(struct bt_mesh_model *model,
struct bt_mesh_sensor_state *state = NULL;
struct bt_mesh_model *sensor_model = NULL;
struct bt_mesh_elem *element = NULL;
u16_t prop_id, trigger_len;
u8_t val, divisor;
u8_t i;
u16_t prop_id = 0U, trigger_len = 0U;
u8_t val = 0U, divisor = 0U;
int i;
if (srv == NULL || srv->state_count == 0U || srv->states == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -719,7 +719,7 @@ static void sensor_cadence_set(struct bt_mesh_model *model,
return;
}
for (i = 0U; i < srv->state_count; i++) {
for (i = 0; i < srv->state_count; i++) {
state = &srv->states[i];
if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID &&
state->sensor_property_id == prop_id) {
@ -836,7 +836,7 @@ static void update_sensor_periodic_pub(struct bt_mesh_model *model, u16_t prop_i
{
struct bt_mesh_sensor_state *state = NULL;
struct bt_mesh_sensor_srv *srv = NULL;
u8_t i;
int i;
if (model->id != BLE_MESH_MODEL_ID_SENSOR_SRV) {
BT_ERR("%s, Not a Sensor Server Model", __func__);
@ -849,7 +849,7 @@ static void update_sensor_periodic_pub(struct bt_mesh_model *model, u16_t prop_i
return;
}
for (i = 0U; i < srv->state_count; i++) {
for (i = 0; i < srv->state_count; i++) {
state = &srv->states[i];
if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID &&
state->sensor_property_id == prop_id) {
@ -881,7 +881,7 @@ static void sensor_setting_set(struct bt_mesh_model *model,
struct bt_mesh_sensor_setup_srv *srv = model->user_data;
bt_mesh_sensor_server_state_change_t change = {0};
struct sensor_setting *item = NULL;
u16_t prop_id, set_prop_id;
u16_t prop_id = 0U, set_prop_id = 0U;
if (srv == NULL || srv->state_count == 0U || srv->states == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -964,9 +964,9 @@ static int check_sensor_server_init(struct bt_mesh_sensor_state *state_start,
{
struct bt_mesh_sensor_state *state = NULL;
struct sensor_setting *setting = NULL;
u8_t i, j;
int i, j;
for (i = 0U; i < state_count; i++) {
for (i = 0; i < state_count; i++) {
state = &state_start[i];
if (state->sensor_property_id == INVALID_SENSOR_PROPERTY_ID) {
BT_ERR("%s, Invalid Sensor Property ID 0x%04x", __func__, state->sensor_property_id);
@ -976,7 +976,7 @@ static int check_sensor_server_init(struct bt_mesh_sensor_state *state_start,
BT_ERR("%s, Invalid Sensor Setting state", __func__);
return -EINVAL;
}
for (j = 0U; j < state->setting_count; j++) {
for (j = 0; j < state->setting_count; j++) {
setting = &state->settings[j];
if (setting->property_id == INVALID_SENSOR_SETTING_PROPERTY_ID || setting->raw == NULL) {
BT_ERR("%s, Invalid Sensor Setting state internal parameter", __func__);

View File

@ -65,7 +65,7 @@ u8_t bt_mesh_get_default_trans_time(struct bt_mesh_model *model)
int bt_mesh_get_light_lc_trans_time(struct bt_mesh_model *model, u8_t *trans_time)
{
struct bt_mesh_light_lc_srv *srv = NULL;
u32_t value;
u32_t value = 0U;
if (model == NULL || trans_time == NULL) {
BT_ERR("%s, Invalid parameter", __func__);

View File

@ -16,7 +16,7 @@
static float bt_mesh_sqrt(float square)
{
float root, last, diff;
float root = 0.0, last = 0.0, diff = 0.0;
root = square / 3.0;
diff = 1;

View File

@ -18,9 +18,9 @@
void bt_mesh_server_calc_remain_time(struct bt_mesh_state_transition *transition)
{
u8_t steps, resolution;
s32_t duration_remainder;
s64_t now;
u8_t steps = 0U, resolution = 0U;
s32_t duration_remainder = 0;
s64_t now = 0;
if (transition->just_started) {
transition->remain_time = transition->trans_time;
@ -57,7 +57,7 @@ void bt_mesh_server_calc_remain_time(struct bt_mesh_state_transition *transition
static void tt_values_calculator(struct bt_mesh_state_transition *transition)
{
u8_t steps_multiplier, resolution;
u8_t steps_multiplier = 0U, resolution = 0U;
resolution = (transition->trans_time >> 6);
steps_multiplier = (transition->trans_time & 0x3F);

View File

@ -168,8 +168,8 @@ static void time_get(struct bt_mesh_model *model,
{
struct bt_mesh_server_rsp_ctrl *rsp_ctrl = NULL;
u8_t zero[5] = {0};
u16_t opcode, val;
u8_t prev_ttl;
u16_t opcode = 0U, val = 0U;
u8_t prev_ttl = 0U;
if (model->user_data == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -316,8 +316,8 @@ static void time_set(struct bt_mesh_model *model,
{
struct bt_mesh_time_setup_srv *srv = model->user_data;
bt_mesh_time_scene_server_state_change_t change = {0};
u16_t opcode, val;
u8_t role;
u16_t opcode = 0U, val = 0U;
u8_t role = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -501,8 +501,8 @@ static void send_scene_register_status(struct bt_mesh_model *model,
struct bt_mesh_scene_setup_srv *srv = model->user_data;
struct scene_register *scene = NULL;
struct net_buf_simple *msg = NULL;
u16_t total_len = 9;
u16_t i;
u16_t total_len = 9U;
int i;
if (ctx == NULL && publish == false) {
BT_ERR("%s, Invalid parameter", __func__);
@ -526,7 +526,7 @@ static void send_scene_register_status(struct bt_mesh_model *model,
net_buf_simple_add_u8(msg, status_code);
net_buf_simple_add_le16(msg, srv->state->current_scene);
for (i = 0U; i < srv->state->scene_count; i++) {
for (i = 0; i < srv->state->scene_count; i++) {
scene = &srv->state->scenes[i];
if (scene->scene_number != INVALID_SCENE_NUMBER) {
total_len += SCENE_NUMBER_LEN;
@ -602,11 +602,11 @@ static void scene_recall(struct bt_mesh_model *model,
{
struct bt_mesh_scene_srv *srv = model->user_data;
struct scene_register *scene = NULL;
u8_t tid, trans_time, delay;
u16_t scene_number;
bool optional;
s64_t now;
u16_t i;
u8_t tid = 0U, trans_time = 0U, delay = 0U;
u16_t scene_number = 0U;
bool optional = false;
s64_t now = 0;
int i;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -637,7 +637,7 @@ static void scene_recall(struct bt_mesh_model *model,
return;
}
for (i = 0U; i < srv->state->scene_count; i++) {
for (i = 0; i < srv->state->scene_count; i++) {
scene = &srv->state->scenes[i];
if (scene->scene_number == scene_number) {
break;
@ -734,8 +734,8 @@ static void scene_action(struct bt_mesh_model *model,
{
struct bt_mesh_scene_setup_srv *srv = model->user_data;
struct scene_register *scene = NULL;
u16_t scene_number;
u16_t i;
u16_t scene_number = 0U;
int i;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -760,7 +760,7 @@ static void scene_action(struct bt_mesh_model *model,
return;
}
/* Try to find a matching Scene Number */
for (i = 0U; i < srv->state->scene_count; i++) {
for (i = 0; i < srv->state->scene_count; i++) {
scene = &srv->state->scenes[i];
if (scene->scene_number == scene_number) {
srv->state->status_code = SCENE_SUCCESS;
@ -771,7 +771,7 @@ static void scene_action(struct bt_mesh_model *model,
/* Try to find a unset entry if no matching Scene Number is found */
if (i == srv->state->scene_count) {
BT_DBG("%s, No matching Scene Number 0x%04x found", __func__, scene_number);
for (i = 0U; i < srv->state->scene_count; i++) {
for (i = 0; i < srv->state->scene_count; i++) {
scene = &srv->state->scenes[i];
if (scene->scene_number == INVALID_SCENE_NUMBER) {
scene->scene_number = scene_number;
@ -825,7 +825,7 @@ static void scene_action(struct bt_mesh_model *model,
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set));
return;
}
for (i = 0U; i < srv->state->scene_count; i++) {
for (i = 0; i < srv->state->scene_count; i++) {
scene = &srv->state->scenes[i];
if (scene->scene_number == scene_number) {
scene->scene_number = INVALID_SCENE_NUMBER;
@ -863,7 +863,7 @@ static void scene_action(struct bt_mesh_model *model,
break;
}
}
if (i == 0U) {
if (i == 0) {
/* A value of 0x0000 when no scene is active */
srv->state->current_scene = INVALID_SCENE_NUMBER;
}
@ -934,10 +934,10 @@ static void scene_action(struct bt_mesh_model *model,
static u16_t get_schedule_reg_bit(struct bt_mesh_scheduler_state *state)
{
u16_t val = 0;
u8_t i;
u16_t val = 0U;
int i;
for (i = 0U; i < state->schedule_count; i++) {
for (i = 0; i < state->schedule_count; i++) {
if (state->schedules[i].in_use) {
val |= (1 << i);
}
@ -949,7 +949,7 @@ static u16_t get_schedule_reg_bit(struct bt_mesh_scheduler_state *state)
static u64_t get_schedule_reg_state(struct bt_mesh_scheduler_state *state, u8_t index)
{
struct schedule_register *reg = &state->schedules[index];
u64_t val;
u64_t val = 0U;
val = ((u64_t)(reg->year) << 4) | index;
val |= ((u64_t)(reg->day) << 23) | ((u64_t)(reg->month) << 11);
@ -965,7 +965,7 @@ static void send_scheduler_act_status(struct bt_mesh_model *model,
u8_t index)
{
NET_BUF_SIMPLE_DEFINE(msg, 1 + 10 + BLE_MESH_SERVER_TRANS_MIC_SIZE);
u64_t value;
u64_t value = 0U;
bt_mesh_model_msg_init(&msg, BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS);
switch (model->id) {
@ -1059,9 +1059,10 @@ static void scheduler_act_set(struct bt_mesh_model *model,
* queue.
*/
struct bt_mesh_scheduler_setup_srv *srv = model->user_data;
u8_t index, year, day, hour, minute, second, day_of_week, action, trans_time;
u16_t month, scene_number;
u64_t value;
u8_t index = 0U, year = 0U, day = 0U, hour = 0U, minute = 0U,
second = 0U, day_of_week = 0U, action = 0U, trans_time = 0U;
u16_t month = 0U, scene_number = 0U;
u64_t value = 0U;
if (srv == NULL || srv->state == NULL) {
BT_ERR("%s, Invalid model user_data", __func__);
@ -1213,14 +1214,14 @@ const struct bt_mesh_model_op scheduler_setup_srv_op[] = {
static int check_scene_server_init(struct bt_mesh_scenes_state *state)
{
u16_t i;
int i;
if (state->scene_count == 0U || state->scenes == NULL) {
BT_ERR("%s, Invalid Scene state", __func__);
return -EINVAL;
}
for (i = 0U; i < state->scene_count; i++) {
for (i = 0; i < state->scene_count; i++) {
if (state->scenes[i].scene_value == NULL) {
BT_ERR("%s, Invalid Scene value, index %d", __func__, i);
return -EINVAL;

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 KiB

BIN
docs/_static/ble-mesh-generic-onoff.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

BIN
docs/_static/ble-mesh-provision.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

BIN
docs/_static/ble-mesh-scanner.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
docs/_static/ble-mesh-three-nodes-on.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@ -0,0 +1 @@
<mxfile modified="2019-11-27T01:46:07.873Z" host="www.draw.io" agent="Mozilla/5.0 (X11; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0" etag="Div9kEoT7OfzQ736Cges" version="12.3.1" type="device" pages="1"><diagram id="3T7Fh-tElfW0GhIRTNz5" name="Page-1">5Vttd6I4FP41fuyekECAj77Utjut66m2e2a/7EEIygwSNlK18+s3YKhK0ilzTmI71p5T4Sa85Hlubu5L7KD+cnvFgnxxRyOSdiCIth006EBoAdvlX6XkeSfxgBDMWRKJTnvBJPlB6iuF9CmJyOqoY0FpWiT5sTCkWUbC4kgWMEY3x91imh4/NQ/mRBJMwiCVpX8nUbEQo3DAXn5NkvmifrINRMsyqDsLwWoRRHRzIEKXHdRnlBa7o+W2T9ISvBqX3XXDV1pfXoyRrGhzwZOVeJeDP9M7fIvTr9Pbx38W/16Iu6yD9EkM+I6sFlxSMbkSb14813Aw+pRFpLyj1UG9zSIpyCQPwrJ1wxWAyxbFMhXNMc0KwSh/N9RbE1YkHNpumswzLixoeYE8jvqleHeyPRCJcV0RuiQFe+Zd6tYaY6FkCInzzZ4yrnk72eKArhdyAqEm85d775HkBwJMNbCjUezdrxDtdbtxuv3213V/lF4gV0JWL5iBADHksBFWdkjStE9Tyo8HGc1I2YeF4hLEzyi/d1KUENlAE+7gGHcLy7i7WIG7bwx3WaG7eZ5yrSsSmmnW50PEOxBFAfHikMtXBaPfyUELDj0yi83o+osKH2IOFZjbpiCHMuTjm075CkP+/3JdjtUk7rFT/ilxrz7iDgfy3ccQH679h/POjNivWfURKTaUfU+y+W9q2R2FhVFaduT4hsB1JHCHJXSVgakXTv59Gzxzs2xS74kVOcRV6b2PXRRgTQzYxwzYLpIZsBUMYNsQAVjW7o+Eubm50GACuUBhaZRceKYmg+zldMOQrFYfhQwDsGPQEnTsGALdk0B/yPMSazBlQbbKKSvOGX/Paqv22JTa+xIDt3TzaRhwcdslwNQMqLMDBwQI1+aMYffs1vYee6aAl+OrIQmKJ0Z+l1yBDSVzImFqqTCFyBiocgQ1ZAnJIqNKHMcxDJXhaoRn2NGkxDZq2I7aLz+EWxUcQVO220Iq480F450J1wS55X0YyC3cDnIETUEuB6T3JA2ez1G/fe+99VsOUMeMbst3nhC2PksV9+p065sqbizvKEdCe4/kLsiCOVlqT4RJOeCTrZoIKsy4atVEtmUKcTkM2iPeZ0QkZHTq+k9z7pXyE/yK8rv+DGjKujeV33Flr1Cp/LYxd1yOh76Q8o3vScyqzOMnYAG1ZMHYKgvloOjmkZ8/5FFQkM/Age23XQZMGSUox0cVBzcc6m01IULKx6fP8/nIbNiqSshpLROUQ6sRjUjFxJJy6WcgAnl+ayJMxbhQjrpETYo7p+tkxddq7VWp07lHjve2ewRVhXDHN1aVfbUI2CN8qDwKMJEoOx3kzcqgj+QoV1l1dU0FXlAOvLpRNf5VpdovwBsFvLkpwSFeZKssjgdnCOtKVTYsju/KSTXknDIeg3KV8Ko7nZ41C7bfggVlkGaMBTkq7vGjgtKitES7vNtlRti8HEafsnJlnuQkTGKxZee0PA2HPv+oeALAcav1ubGVBFQfMybNAvC9d5JAOcg+Xq/BePCgOfX/FkkzK4pioCLJAi7yiaYlvTGZkKtY0lWTyTflyyI5tuhAnPLH9qJkzQ/n5eEV4dMpCesW/qSDRkX/YzrbXjR4qKUz1uzXvPr8dcP2FdmwOg+7ONoebGpTTJ1V+LlyiETwr7N8/py6NV91Pgeoqq2nZlWOmsa9i+7g8RwZaM4qjBWlFBX+vqlsDnrDoz9/DlyvJQdWXVbVT4Lsyetaxsp6WML5+cRLWdPsnZZwQG+mS5RekzH6+hBexYPrvFDsJ++nielN5K9v6ek5HO2BJg/faTgOQJGwBoYcfCXY8gKjuUj8fmBDVwJbtaKfFG45KVfX5jXr+K/V5ge4Z64277bdfmIKdMWGiN7FLht0/gb9pF7Uerb+vo2G1+56+eXiG5jdRtP/FHvE70lKghXHGQKxe1Cv3muAETe02HKxavOlpdBjqKGGogRSrrKPHidlwqygrPwZq1YMP2YpC0OlDddUZ+en+9/jVm0Hv2pGl/8D</diagram></mxfile>

BIN
docs/_static/esp-ble-mesh-interface.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -0,0 +1 @@
<mxfile modified="2019-09-06T07:49:40.158Z" host="www.draw.io" agent="Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0" etag="BUdTiYyUVL7KduKo_ZSl" pages="1" version="11.2.5" type="device"><diagram id="csV9DYBobAVv9VLuABIz" name="Page-1">5V1Zd9o6EP41PJJjyfL2yJImadMebrO0yUuPgxVw6yDXmK2//spggW2pNngnzUssIQtpZr7RzGgkOvLgbX3lme70M7Gw04GSte7Iww6EQFIV+i+o2exqNN3YVUw82wobHSru7D+YvRnWLmwLz2MNfUIc33bjlWMym+GxH6szPY+s4s1eiRP/VtecYK7ibmw6fO032/Knu1odaof6a2xPpuybgRrO781kjcOZzKemRVaRKvmyIw88Qvzd09t6gJ2AeIwuu/c+/OXT/cA8PPOPecH89ji6sqeoD7Vln3gzMH/0u3DXy9J0FuGEw8H6G0YBjyxmFg46AR25v5raPr5zzXHw6YrynNZN/Tcn/PjVdpwBcYhHyzMyo436hDa2/YD9SKJF0xuHXJZpiZ9EOK8l9ny8jlSFk7rC5A373oY2YZ+ikMChhClhcXVgF9LDummEVToTMTMUkcm+6wMV6UNISDFRn/9D4x+uv9xcrdZfVeKB9Z9BV84mKraolIVF4vlTMiEz07k81PYPtbeEuCF5f2Lf34TkMxc+iRP/wCkpjbRzsvDGOGX8DGemN8F+SrtwWsFcUhnlYcf07WUcUSKqb1/teZ65iTRwiT3z55GeR0HFgf9Qj/MfAD2Og9Pa04fdCA78308lv0gATiR6ruvYY0oXMqMf3Job7BWEHpn5oWjAVP6fAC01TipV56GFBNBCJSDrCSs3t78kfwAfwca3Fqun0U0X5QBSHBU5YIXXtv89eP1CU8LiU9hb8DxcRwsbVpjR+UbfCspPrMegcHhvW2Iv5octPBK2oGzYFlKW/ArUv72kFZ/xfEr/9e8HZwMPgGrEx/Of62ul9+yPPj4PH34vDWx8WnRzrTSlAQRE0XEAy4kAkTIAEmEkCF78uXhz2QSpcVEIQkgAIRGdS4dQrpVPkeWY/CFDy1j59LT2hVe+yWLjgsX1qouk6ydp+fTxavXQ1ZpV2QYyIlIJLiQJHimWMZm8gMoJYsm+YoQ9m9IPe7XpdtSUbjduxtLzmzQD6PfNd8MjL0D3uzIozPwxebPH4TOP9G3Njuh6QUnJqbt0pMUFxTCyVvhtKSkae++wmJyIFFgtpnshGwBxNkAHqg4df9+ylzH5UX8vAn95i7bufMvUHm0AFHd9+JA+TYL/I48s7Tk1sAPbQeqyPukQt93uGpX7TfZs8revKWK8WLaHx1tXQR5SGQiMC24dLMGgUUDcoJGBxhk0hsCeAXIJBo1w9QDKORo0sgLjSkGCKI9SSK4pR+kFoeMkcunba9jsY2bMUNHKddHTSFRaKCwDs1U5ISLMQpETUgpoxV5I8WW/AdAWckLyI1Nk2bUXmYiZdAyZeobLgZS09tW4HI2uGXkNSRWgqABSTwVmyGDFS8axLkc7osBJwaQV1Qsa878bi0cCLSZthvFenNs0iWxa0rS4SoNKuZKWNvWyPaQvxMJR1+jFy99Xze5VFUM9AxcNSfEYXq0umlA0VU40e6MbjpZ0en6cYB6mbDJftg0C/RHijrZW+h1lSGsC1TcPyRcUHXsSUNfBr0FXAc3ssen0wmo/UJ/9ebDbPJvcb3VpF1XDBKjHA68AqBwTZAETYFU80EpRD1tgJKByuQzIdBxe3hWPkaFk8lipiMdCB0Bv1tbItfV50s5nSRs7QoAYAmNWROTS4+e5TAw5kaKgqOleVjJul2hfPKVB6JA26uUzo5Vt7BwrkbAhN18ggMJ2slq2BBZSOkzpNbZ9J+lH650ks6IBWd04RRMJPevcPk+aPJSsaHjNoBgxzaDKKN7FTiDDt9JUTLKjMCS772g3Y66jshwgg7NwYmkiPct0/e02z3mkiqgsTbSxVCrQInviaO0NDDmK4650IQEtD5jLU+xsGczU7KUjvhj7+e2OBKACv+F+6mHTKg1NZdnmSTQpBuLQBLRa0WScozGkxuGUZQ1VjSRB8kK7kCQ0kRpOcKojJ7VaHtfjiBWDN5+hMvLIOhgA/e+TMXFapyQRPEJJig5GVJadCuA5KsmmPEbmCWa7jFqr9CH4B5L0G+Byu8xHmY/69+mT5RH6GpSuydwvTSFW5YNpMq8Q603XB03vH58XVLRjFWJjMbTUcUewcnk3ohU7h2tACeQRxzmDqIVm1Bi1ECKm4XCk1oAFkfd8S0oSWSaCQDv2QZIHVhQtfR8EqUpa+8L7IOJDDsWt2toOOeSLup0kvjkOMhSS1OZOM6YM+29RtdHwIYiqfS9N0281xMQzLZtSOHHwnlUPI5kps0B6OvFz+h0ov27/aL1lzqf7YVSwgux3KuuI1ImTkxu2uWAOmwvEAHhaul7ZS8ixQbqW5CsnVgSUsYLIKHnyoIaddNiwx/yPSCRshUQmczVQRm4H0tS09oUlUhk6v66d3n9DRXq5//Hyg+jjS0aqVpjZ+SQySyBLFbd2HcVNG3W6YfK1ZMOkbGuCC2mLrIl6Q9oKR9e7Qe8LR8Z3lRop6/JFfFlVZT4woNaZHAn4GEtv+Pi+2QCRnsmEWjNUWUpJhAlXvfv7980FpGZzoV4o8KlS758LSjK/qkYuiA+uc0z4gv0V8X51yk5RSz/md4qrHs/wQ4KTJaCqUw1CGkKOhrdktU3yu/fM2dylNubZUFPWm6Ymfyvhg+ueKzWVpqnJ29O98RjP5+dDQtg0CVk6SISGN9Rkkx5cy/Rx6wgoJy9HQZAjoMj3qI5+PKI/4WDAX/Grt3Xr2k5BjRfBeiko8IqxOQ5u5Gw56RBoWPjkhndi84TRpQtJjSe8shPztdyyIBZB0cm0Vt3YJWZ/w1mvQI+dC6J8NI6Vgfy3TdZy80GqlLTkXj9Y/IaVare582kHeFJi01FcF5JPsLd9FlwvfsahWq7nys6JrwelbBscrehbvHHK7s853HKS+HWBjFvVE+2ruX9HEOr6EMgbu1V9+3MU89YZc8mkCMiSWKKuGBBYc2Xc4aE4X7TpoDeaf0M/HLP3uvj0CJjMnZcxJ6OYMRfc7avnMebyY5pZ1+013oTcbjjdAOnRK/r2bCvfdmvGVmNC0ZZVu/g537NftaP5lafnJx4N/XqW82IhdYlbMXcZAB8e8cwiXnsXTc7AEC2aLLmv7EVTjKziPnCNyDpbL6h8fVqOQaymG8Qyk09x+4py0aWWi6QkybG4jaYeHbc5SSzLvaxFIKppIt2SlZ/fgmY/z/fZdN3tVYpFdHzVqeKQpYVneUVQP5mAtHj44b0d+A4/Xyhf/g8=</diagram></mxfile>

View File

@ -191,7 +191,7 @@ int ble_mesh_provisioner_get_node(int argc, char **argv)
{
uint16_t unicast_addr = 0;
uint16_t i = 0;
struct bt_mesh_node *node_info;
esp_ble_mesh_node_t *node_info;
ESP_LOGD(TAG, "enter %s\n", __func__);
int nerrors = arg_parse(argc, argv, (void **) &provisioner_get_node);

View File

@ -51,7 +51,7 @@
#include "lwip/sys.h"
#include <lwip/netdb.h>
#include "esp_coexist_internal.h"
#include "esp_coexist.h"
#define SD_STORE 0
#define TEST_COUNT_MAX 100
@ -463,7 +463,7 @@ static void example_ble_mesh_provisioning_cb(esp_ble_mesh_prov_cb_event_t event,
// if (err) {
// ESP_LOGE(TAG, "config_scan_enable (err %d)", err);
// }
coex_schm_status_set(COEX_SCHM_ST_TYPE_BLE, COEX_SCHM_BLE_ST_MESH_CONFIG);
esp_coex_status_bit_set(ESP_COEX_ST_TYPE_BLE, ESP_COEX_BLE_ST_MESH_CONFIG);
break;
case ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT:
ESP_LOGI(TAG, "ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT, err_code %d", param->provisioner_prov_disable_comp.err_code);

View File

@ -75,32 +75,6 @@ static void scan_done_handler(void)
free(ap_list_buffer);
}
static esp_err_t bt_channel_select(uint8_t wifi_channel)
{
uint8_t low = wifi_channel * 5 - 5;
uint8_t high = wifi_channel * 5 + 15;
esp_bt_gap_afh_channels bt_channel = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
if (wifi_channel != 0) {
if (low/8 < sizeof(bt_channel)) {
bt_channel[low/8] = 0xFF >> (8 - low%8);
}
if (low/8 + 1 < sizeof(bt_channel)) {
bt_channel[low/8 + 1] = 0;
}
if (low/8 + 2 < sizeof(bt_channel)) {
bt_channel[low/8 + 2] = 0;
}
if (high/8 < sizeof(bt_channel)) {
bt_channel[high/8] = 0xFF << (high%8 + 1);
}
}
ESP_LOGI(TAG, "WiFi channel: %d, BT channel: %02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x", wifi_channel,
bt_channel[0], bt_channel[1], bt_channel[2], bt_channel[3], bt_channel[4],
bt_channel[5], bt_channel[6], bt_channel[7], bt_channel[8], bt_channel[9]);
return esp_bt_gap_set_afh_channels(bt_channel);
}
static esp_err_t event_handler(void *ctx, system_event_t *event)
{
switch(event->event_id) {
@ -115,10 +89,8 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
break;
case SYSTEM_EVENT_STA_CONNECTED:
ESP_LOGI(TAG, "L2 connected");
bt_channel_select(event->event_info.connected.channel);
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
bt_channel_select(0);
if (reconnect) {
ESP_LOGI(TAG, "sta disconnect, reconnect...");
esp_wifi_connect();

View File

@ -28,7 +28,7 @@
#include "board.h"
#include "ble_mesh_demo_init.h"
#include "esp_coexist_internal.h"
#include "esp_coexist.h"
#define CID_ESP 0x02E5
#define CID_NVAL 0xFFFF
@ -367,11 +367,12 @@ static void example_ble_mesh_provisioning_cb(esp_ble_mesh_prov_cb_event_t event,
break;
case ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT:
ESP_LOGI(TAG, "ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT, err_code %d", param->provisioner_prov_enable_comp.err_code);
esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BLE, ESP_COEX_BLE_ST_MESH_STANDBY | ESP_COEX_BLE_ST_MESH_TRAFFIC | ESP_COEX_BLE_ST_MESH_CONFIG);
if (iperf_test == true) {
coex_schm_status_set(COEX_SCHM_ST_TYPE_BLE, COEX_SCHM_BLE_ST_MESH_STANDBY);
esp_coex_status_bit_set(ESP_COEX_ST_TYPE_BLE, ESP_COEX_BLE_ST_MESH_STANDBY);
ESP_LOGW(TAG, "BLE Mesh enters Standby mode");
} else {
coex_schm_status_set(COEX_SCHM_ST_TYPE_BLE, COEX_SCHM_BLE_ST_MESH_CONFIG);
esp_coex_status_bit_set(ESP_COEX_ST_TYPE_BLE, ESP_COEX_BLE_ST_MESH_CONFIG);
ESP_LOGW(TAG, "BLE Mesh enters Config mode");
}
break;

View File

@ -14,7 +14,7 @@
#include "iot_button.h"
#include "board.h"
#include "esp_coexist_internal.h"
#include "esp_coexist.h"
#include "esp_ble_mesh_common_api.h"
#define TAG "BOARD"
@ -83,7 +83,8 @@ static void button_tap_cb(void* arg)
}
}
} else {
coex_schm_status_set(COEX_SCHM_ST_TYPE_BLE, COEX_SCHM_BLE_ST_MESH_TRAFFIC);
esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BLE, ESP_COEX_BLE_ST_MESH_STANDBY | ESP_COEX_BLE_ST_MESH_TRAFFIC | ESP_COEX_BLE_ST_MESH_CONFIG);
esp_coex_status_bit_set(ESP_COEX_ST_TYPE_BLE, ESP_COEX_BLE_ST_MESH_TRAFFIC);
ESP_LOGW(TAG, "BLE Mesh enters Traffic mode");