Merge branch 'bugfix/ble_mesh_misc_updates_v4.0' into 'release/v4.0'
Bugfix/ble mesh misc updates (v4.0) See merge request espressif/esp-idf!9642
This commit is contained in:
commit
0dc0c54acd
92 changed files with 2125 additions and 2076 deletions
|
@ -42,7 +42,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) {
|
||||
BT_ERR("%s, Failed to allocate memory for the semaphore", __func__);
|
||||
BT_ERR("Failed to create semaphore");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,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);
|
||||
BT_ERR("%s, BLE Mesh initialise failed", __func__);
|
||||
BT_ERR("Failed to start mesh init");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@ uint16_t esp_ble_mesh_get_primary_element_address(void)
|
|||
return btc_ble_mesh_get_primary_addr();
|
||||
}
|
||||
|
||||
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, uint16_t group_addr)
|
||||
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
|
||||
uint16_t group_addr)
|
||||
{
|
||||
if (model == NULL) {
|
||||
return NULL;
|
||||
|
@ -62,7 +63,8 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *
|
|||
return btc_ble_mesh_model_find_vnd(element, company_id, model_id);
|
||||
}
|
||||
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, uint16_t model_id)
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element,
|
||||
uint16_t model_id)
|
||||
{
|
||||
if (element == NULL) {
|
||||
return NULL;
|
||||
|
|
|
@ -39,12 +39,12 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
|
|||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
if (ctx && ctx->addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
|
||||
BT_ERR("%s, Invalid destination address 0x0000", __func__);
|
||||
BT_ERR("Invalid destination address 0x0000");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (device_role > ROLE_FAST_PROV) {
|
||||
BT_ERR("%s, Invalid device role 0x%02x", __func__, device_role);
|
||||
BT_ERR("Invalid device role 0x%02x", device_role);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,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) {
|
||||
BT_ERR("%s, Model publication msg size %d is too small", __func__, model->pub->msg->size);
|
||||
BT_ERR("Too small publication msg size %d", model->pub->msg->size);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,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)) {
|
||||
BT_ERR("%s, Data length %d is too large", __func__, length);
|
||||
BT_ERR("Too large data length %d", length);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,8 @@ esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data)
|
||||
{
|
||||
if (model == NULL || ctx == NULL ||
|
||||
|
@ -190,9 +191,11 @@ esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data, int32_t msg_timeout,
|
||||
bool need_rsp, esp_ble_mesh_dev_role_t device_role)
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data,
|
||||
int32_t msg_timeout, bool need_rsp,
|
||||
esp_ble_mesh_dev_role_t device_role)
|
||||
{
|
||||
if (model == NULL || ctx == NULL ||
|
||||
ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
|
@ -294,7 +297,8 @@ uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name)
|
|||
return bt_mesh_provisioner_get_node_index(name);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr, uint8_t *data, uint16_t length)
|
||||
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
|
||||
uint8_t *data, uint16_t length)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
|
|
@ -318,8 +318,10 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16],
|
||||
esp_ble_mesh_bd_addr_t addr, esp_ble_mesh_addr_type_t addr_type,
|
||||
esp_ble_mesh_prov_bearer_t bearer, uint16_t oob_info, uint16_t unicast_addr)
|
||||
esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
esp_ble_mesh_prov_bearer_t bearer,
|
||||
uint16_t oob_info, uint16_t unicast_addr)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
|
|
@ -60,7 +60,8 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void)
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx)
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
uint16_t net_idx)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -100,8 +101,8 @@ esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle)
|
|||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
|
||||
uint16_t net_idx, esp_ble_mesh_proxy_filter_type_t filter_type)
|
||||
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_t net_idx,
|
||||
esp_ble_mesh_proxy_filter_type_t filter_type)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -124,8 +125,8 @@ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
|
|||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle,
|
||||
uint16_t net_idx, uint16_t *addr, uint16_t addr_num)
|
||||
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -149,8 +150,8 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle,
|
|||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle,
|
||||
uint16_t net_idx, uint16_t *addr, uint16_t addr_num)
|
||||
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
|
|
@ -55,7 +55,8 @@ uint16_t esp_ble_mesh_get_primary_element_address(void);
|
|||
* to 0x0000 in order to unsubscribe the model from the group.
|
||||
*
|
||||
*/
|
||||
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, uint16_t group_addr);
|
||||
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
|
||||
uint16_t group_addr);
|
||||
|
||||
/**
|
||||
* @brief Find the BLE Mesh element pointer via the element address.
|
||||
|
@ -98,7 +99,8 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *
|
|||
* @return Pointer to the SIG Model on success, or NULL on failure which means the SIG Model is not found.
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, uint16_t model_id);
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element,
|
||||
uint16_t model_id);
|
||||
|
||||
/**
|
||||
* @brief Get the Composition data which has been registered.
|
||||
|
|
|
@ -104,7 +104,8 @@ esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model);
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data);
|
||||
|
||||
/**
|
||||
|
@ -123,9 +124,11 @@ esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data, int32_t msg_timeout,
|
||||
bool need_rsp, esp_ble_mesh_dev_role_t device_role);
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data,
|
||||
int32_t msg_timeout, bool need_rsp,
|
||||
esp_ble_mesh_dev_role_t device_role);
|
||||
|
||||
/**
|
||||
* @brief Send a model publication message.
|
||||
|
@ -226,7 +229,8 @@ uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name);
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr, uint8_t *data, uint16_t length);
|
||||
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
|
||||
uint8_t *data, uint16_t length);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the provisioned node information
|
||||
|
@ -329,7 +333,8 @@ esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr);
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
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);
|
||||
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.
|
||||
|
|
|
@ -257,8 +257,10 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
|
|||
* and "esp_ble_mesh_provisioner_prov_device_with_addr" by a Provisioner.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16],
|
||||
esp_ble_mesh_bd_addr_t addr, esp_ble_mesh_addr_type_t addr_type,
|
||||
esp_ble_mesh_prov_bearer_t bearer, uint16_t oob_info, uint16_t unicast_addr);
|
||||
esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
esp_ble_mesh_prov_bearer_t bearer,
|
||||
uint16_t oob_info, uint16_t unicast_addr);
|
||||
|
||||
/**
|
||||
* @brief Delete device from queue, reset current provisioning link and reset the node.
|
||||
|
|
|
@ -65,7 +65,8 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void);
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx);
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client terminates a connection with the Proxy Server.
|
||||
|
@ -87,8 +88,8 @@ esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle);
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
|
||||
uint16_t net_idx, esp_ble_mesh_proxy_filter_type_t filter_type);
|
||||
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_t net_idx,
|
||||
esp_ble_mesh_proxy_filter_type_t filter_type);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client adds address to the Proxy Server filter list.
|
||||
|
@ -101,8 +102,8 @@ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle,
|
||||
uint16_t net_idx, uint16_t *addr, uint16_t addr_num);
|
||||
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client removes address from the Proxy Server filter list.
|
||||
|
@ -115,8 +116,8 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle,
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle,
|
||||
uint16_t net_idx, uint16_t *addr, uint16_t addr_num);
|
||||
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
memcpy(dst->cfg_client_get_state.params, src->cfg_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->cfg_client_get_state.get_state) {
|
||||
|
@ -60,7 +60,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
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);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -71,7 +71,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
memcpy(dst->cfg_client_set_state.params, src->cfg_client_set_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->cfg_client_set_state.set_state) {
|
||||
|
@ -80,13 +80,13 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
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);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.comp_data_status.composition_data,
|
||||
|
@ -173,7 +173,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.model_sub_list.sub_addr,
|
||||
|
@ -187,7 +187,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.netkey_list.net_idx,
|
||||
|
@ -201,7 +201,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.appkey_list.app_idx,
|
||||
|
@ -217,7 +217,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.model_app_list.app_idx,
|
||||
|
@ -306,8 +306,8 @@ static void btc_ble_mesh_config_client_callback(esp_ble_mesh_cfg_client_cb_param
|
|||
msg.pid = BTC_PID_CONFIG_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_cfg_client_cb_param_t), btc_ble_mesh_config_client_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_client_cb_param_t),
|
||||
btc_ble_mesh_config_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
|
@ -339,7 +339,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:
|
||||
BT_ERR("%s, Unknown config client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Config client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -366,8 +366,7 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_config_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -376,8 +375,8 @@ void btc_ble_mesh_config_client_publish_callback(u32_t opcode,
|
|||
return;
|
||||
}
|
||||
|
||||
bt_mesh_config_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_config_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -403,7 +402,7 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
|
|||
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__);
|
||||
BT_ERR("Invalid Configuration Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
|
@ -467,7 +466,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 bt_mesh_cfg_net_transmit_get(&ctx);
|
||||
default:
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
BT_ERR("Invalid Configuration Get opcode 0x%04x", params->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -485,7 +484,7 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
|
|||
}
|
||||
|
||||
if (params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && set == NULL) {
|
||||
BT_ERR("%s, Invalid config client set", __func__);
|
||||
BT_ERR("Invalid Configuration Set");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -613,7 +612,7 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
|
|||
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET:
|
||||
return bt_mesh_cfg_net_transmit_set(&ctx, set->net_transmit_set.net_transmit);
|
||||
default:
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
BT_ERR("Invalid Configuration Set opcode 0x%04x", params->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -639,7 +638,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
cb.error_code = btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params,
|
||||
|
@ -654,7 +653,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
cb.error_code = btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params,
|
||||
|
@ -686,7 +685,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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_config_client_free_req_data(msg);
|
||||
|
@ -723,8 +722,7 @@ static void btc_ble_mesh_config_server_callback(esp_ble_mesh_cfg_server_cb_param
|
|||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_server_cb_param_t), NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
|
@ -742,7 +740,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:
|
||||
BT_ERR("%s, Unknown config server event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Config server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -779,6 +777,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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
|
|||
memcpy(dst->generic_client_get_state.params, src->generic_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->generic_client_get_state.get_state) {
|
||||
|
@ -58,7 +58,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
|
|||
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);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -78,7 +78,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->user_property_set.property_value,
|
||||
|
@ -91,7 +91,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->admin_property_set.property_value,
|
||||
|
@ -103,12 +103,12 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
|
|||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.user_properties_status.property_ids,
|
||||
|
@ -206,7 +206,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.user_property_status.property_value,
|
||||
|
@ -220,7 +220,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.admin_properties_status.property_ids,
|
||||
|
@ -235,7 +235,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.admin_property_status.property_value,
|
||||
|
@ -249,7 +249,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_properties_status.property_ids,
|
||||
|
@ -264,7 +264,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_property_status.property_value,
|
||||
|
@ -278,7 +278,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.client_properties_status.property_ids,
|
||||
|
@ -374,8 +374,8 @@ static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_
|
|||
msg.pid = BTC_PID_GENERIC_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_generic_client_cb_param_t), btc_ble_mesh_generic_client_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_client_cb_param_t),
|
||||
btc_ble_mesh_generic_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
|
@ -407,7 +407,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:
|
||||
BT_ERR("%s, Unknown generic client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Generic client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -434,8 +434,7 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -444,8 +443,8 @@ void btc_ble_mesh_generic_client_publish_callback(u32_t opcode,
|
|||
return;
|
||||
}
|
||||
|
||||
bt_mesh_generic_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_generic_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -470,7 +469,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
|
@ -496,7 +495,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
|
@ -539,7 +538,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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_client_free_req_data(msg);
|
||||
|
@ -548,8 +547,7 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
|
|||
|
||||
/* Generic Server Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_generic_server_cb_to_app(
|
||||
esp_ble_mesh_generic_server_cb_event_t event,
|
||||
static inline void btc_ble_mesh_generic_server_cb_to_app(esp_ble_mesh_generic_server_cb_event_t event,
|
||||
esp_ble_mesh_generic_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_generic_server_cb_t btc_ble_mesh_cb =
|
||||
|
@ -579,7 +577,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.user_property_set.value,
|
||||
|
@ -593,7 +591,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.admin_property_set.value,
|
||||
|
@ -613,7 +611,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.user_property.property_value,
|
||||
|
@ -627,7 +625,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.admin_property.property_value,
|
||||
|
@ -704,12 +702,11 @@ static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_
|
|||
msg.pid = BTC_PID_GENERIC_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_generic_server_cb_param_t), btc_ble_mesh_generic_server_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_server_cb_param_t),
|
||||
btc_ble_mesh_generic_server_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
|
@ -733,7 +730,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:
|
||||
BT_ERR("%s, Unknown Generic Server event type", __func__);
|
||||
BT_ERR("Unknown Generic Server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -770,7 +767,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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_server_free_req_data(msg);
|
||||
|
|
|
@ -52,7 +52,7 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
memcpy(dst->health_client_get_state.params, src->health_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->health_client_get_state.get_state) {
|
||||
|
@ -61,7 +61,7 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
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);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -75,12 +75,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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.current_status.fault_array,
|
||||
|
@ -166,7 +166,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.fault_status.fault_array,
|
||||
|
@ -240,8 +240,8 @@ static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_pa
|
|||
msg.pid = BTC_PID_HEALTH_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_health_client_cb_param_t), btc_ble_mesh_health_client_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_client_cb_param_t),
|
||||
btc_ble_mesh_health_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
|
@ -273,7 +273,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:
|
||||
BT_ERR("%s, Unknown health client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Health client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -300,8 +300,7 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -310,8 +309,8 @@ void btc_ble_mesh_health_publish_callback(u32_t opcode,
|
|||
return;
|
||||
}
|
||||
|
||||
bt_mesh_health_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_health_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -326,7 +325,7 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param
|
|||
}
|
||||
|
||||
if (params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get == NULL) {
|
||||
BT_ERR("%s, Invalid health client get", __func__);
|
||||
BT_ERR("Invalid Health Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -346,7 +345,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 bt_mesh_health_fault_get(&ctx, get->fault_get.company_id);
|
||||
default:
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
BT_ERR("Invalid Health Get opcode 0x%04x", params->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -389,7 +388,7 @@ static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param
|
|||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
|
||||
return bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, false);
|
||||
default:
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
BT_ERR("Invalid Health Set opcode 0x%04x", params->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -415,7 +414,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
cb.error_code = btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
|
||||
|
@ -431,7 +430,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
cb.error_code = btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
|
||||
|
@ -464,7 +463,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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_client_free_req_data(msg);
|
||||
|
@ -558,8 +557,8 @@ static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_pa
|
|||
msg.pid = BTC_PID_HEALTH_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_health_server_cb_param_t), btc_ble_mesh_health_server_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_server_cb_param_t),
|
||||
btc_ble_mesh_health_server_copy_req_data);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg)
|
||||
|
@ -603,7 +602,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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_server_free_req_data(msg);
|
||||
|
@ -620,7 +619,8 @@ void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t c
|
|||
btc_ble_mesh_health_server_callback(¶m, ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, u8_t test_id, u16_t company_id)
|
||||
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
|
||||
u8_t test_id, u16_t company_id)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_param_t param = {0};
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
|
|||
memcpy(dst->light_client_get_state.params, src->light_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->light_client_get_state.get_state) {
|
||||
|
@ -57,7 +57,7 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
|
|||
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);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -71,12 +71,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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
|
|||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.lc_property_status.property_value,
|
||||
|
@ -218,8 +218,8 @@ static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_p
|
|||
msg.pid = BTC_PID_LIGHTING_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_light_client_cb_param_t), btc_ble_mesh_lighting_client_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_light_client_cb_param_t),
|
||||
btc_ble_mesh_lighting_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
|
@ -251,7 +251,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:
|
||||
BT_ERR("%s, Unknown lighting client event type", __func__);
|
||||
BT_ERR("Unknown Lighting client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -278,8 +278,7 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -288,8 +287,8 @@ void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode,
|
|||
return;
|
||||
}
|
||||
|
||||
bt_mesh_lighting_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_lighting_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -314,7 +313,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
|
@ -340,7 +339,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
|
@ -383,7 +382,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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_client_free_req_data(msg);
|
||||
|
@ -392,8 +391,7 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
|
|||
|
||||
/* Lighting Server Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_lighting_server_cb_to_app(
|
||||
esp_ble_mesh_lighting_server_cb_event_t event,
|
||||
static inline void btc_ble_mesh_lighting_server_cb_to_app(esp_ble_mesh_lighting_server_cb_event_t event,
|
||||
esp_ble_mesh_lighting_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_lighting_server_cb_t btc_ble_mesh_cb =
|
||||
|
@ -422,7 +420,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.lc_property_set.property_value,
|
||||
|
@ -438,7 +436,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.lc_property.property_value,
|
||||
|
@ -453,7 +451,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.status.sensor_status.data,
|
||||
|
@ -516,12 +514,11 @@ static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_c
|
|||
msg.pid = BTC_PID_LIGHTING_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(
|
||||
&msg, cb_params, sizeof(esp_ble_mesh_lighting_server_cb_param_t), btc_ble_mesh_lighting_server_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_lighting_server_cb_param_t),
|
||||
btc_ble_mesh_lighting_server_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
|
@ -548,7 +545,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:
|
||||
BT_ERR("%s, Unknown Lighting Server event type", __func__);
|
||||
BT_ERR("Unknown Lighting server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -585,7 +582,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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_server_free_req_data(msg);
|
||||
|
|
|
@ -82,36 +82,33 @@ void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
|||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR:
|
||||
BT_DBG("%s, BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR", __func__);
|
||||
dst->proxy_client_add_filter_addr.addr = (uint16_t *)bt_mesh_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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR:
|
||||
BT_DBG("%s, BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR", __func__);
|
||||
dst->proxy_client_remove_filter_addr.addr = bt_mesh_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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA:
|
||||
BT_DBG("%s, BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA", __func__);
|
||||
dst->store_node_comp_data.data = bt_mesh_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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -161,35 +158,33 @@ void btc_ble_mesh_model_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
|||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SERVER_MODEL_SEND:
|
||||
case BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND: {
|
||||
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 *)bt_mesh_malloc(src->model_send.length) : NULL;
|
||||
dst->model_send.ctx = bt_mesh_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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of 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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE:
|
||||
BT_DBG("%s, BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE", __func__);
|
||||
dst->model_update_state.value = bt_mesh_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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -245,13 +240,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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of 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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -264,13 +259,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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of 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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -282,7 +277,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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -293,7 +288,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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -366,10 +361,10 @@ static bt_status_t btc_ble_mesh_model_callback(esp_ble_mesh_model_cb_param_t *pa
|
|||
msg.pid = BTC_PID_MODEL;
|
||||
msg.act = act;
|
||||
|
||||
ret = btc_transfer_context(&msg, param,
|
||||
sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_model_copy_req_data);
|
||||
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) {
|
||||
BT_ERR("%s, btc_transfer_context failed", __func__);
|
||||
BT_ERR("btc_transfer_context failed");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -455,7 +450,9 @@ static void btc_ble_mesh_client_model_timeout_cb(struct k_work *work)
|
|||
return;
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_model_send_comp_cb(esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx, u32_t opcode, int err)
|
||||
static void btc_ble_mesh_model_send_comp_cb(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
u32_t opcode, int err)
|
||||
{
|
||||
esp_ble_mesh_model_cb_param_t mesh_param = {0};
|
||||
|
||||
|
@ -493,7 +490,8 @@ static int btc_ble_mesh_model_publish_update(struct bt_mesh_model *mod)
|
|||
}
|
||||
|
||||
static void btc_ble_mesh_server_model_update_state_comp_cb(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_server_state_type_t type, int err)
|
||||
esp_ble_mesh_server_state_type_t type,
|
||||
int err)
|
||||
{
|
||||
esp_ble_mesh_model_cb_param_t mesh_param = {0};
|
||||
|
||||
|
@ -523,7 +521,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) {
|
||||
BT_ERR("%s, btc_transfer_context failed", __func__);
|
||||
BT_ERR("btc_transfer_context failed");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -603,7 +601,8 @@ static void btc_ble_mesh_link_close_cb(bt_mesh_prov_bearer_t bearer)
|
|||
return;
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_complete_cb(u16_t net_idx, const u8_t net_key[16], u16_t addr, u8_t flags, u32_t iv_index)
|
||||
static void btc_ble_mesh_complete_cb(u16_t net_idx, const u8_t net_key[16],
|
||||
u16_t addr, u8_t flags, u32_t iv_index)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
|
@ -649,10 +648,10 @@ static void btc_ble_mesh_prov_set_complete_cb(esp_ble_mesh_prov_cb_param_t *para
|
|||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_PROVISIONER
|
||||
static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb(
|
||||
const u8_t addr[6], const u8_t addr_type,
|
||||
static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb(const u8_t addr[6], const u8_t addr_type,
|
||||
const u8_t adv_type, const u8_t dev_uuid[16],
|
||||
u16_t oob_info, bt_mesh_prov_bearer_t bearer, s8_t rssi)
|
||||
u16_t oob_info, bt_mesh_prov_bearer_t bearer,
|
||||
s8_t rssi)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
|
@ -689,8 +688,8 @@ static int btc_ble_mesh_provisioner_prov_read_oob_pub_key_cb(u8_t link_idx)
|
|||
return (ret == BT_STATUS_SUCCESS) ? 0 : -1;
|
||||
}
|
||||
|
||||
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)
|
||||
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_SUCCESS;
|
||||
|
@ -706,8 +705,8 @@ static int btc_ble_mesh_provisioner_prov_input_cb(u8_t method,
|
|||
return (ret == BT_STATUS_SUCCESS) ? 0 : -1;
|
||||
}
|
||||
|
||||
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)
|
||||
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_SUCCESS;
|
||||
|
@ -753,8 +752,7 @@ static void btc_ble_mesh_provisioner_link_close_cb(bt_mesh_prov_bearer_t bearer,
|
|||
return;
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_provisioner_prov_complete_cb(
|
||||
u16_t node_idx, const u8_t device_uuid[16],
|
||||
static void btc_ble_mesh_provisioner_prov_complete_cb(u16_t node_idx, const u8_t device_uuid[16],
|
||||
u16_t unicast_addr, u8_t element_num,
|
||||
u16_t netkey_idx)
|
||||
{
|
||||
|
@ -841,7 +839,7 @@ void btc_ble_mesh_friend_cb(bool establish, u16_t lpn_addr, u8_t reason)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(lpn_addr)) {
|
||||
BT_ERR("%s, Not a unicast address", __func__);
|
||||
BT_ERR("Not a unicast lpn address 0x%04x", lpn_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -860,8 +858,8 @@ void btc_ble_mesh_friend_cb(bool establish, u16_t lpn_addr, u8_t reason)
|
|||
#endif /* CONFIG_BLE_MESH_FRIEND */
|
||||
|
||||
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr,
|
||||
u8_t type, bt_mesh_proxy_adv_ctx_t *ctx, s8_t rssi)
|
||||
static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr, u8_t type,
|
||||
bt_mesh_proxy_adv_ctx_t *ctx, s8_t rssi)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
|
@ -903,8 +901,8 @@ static void btc_ble_mesh_proxy_client_connect_cb(const bt_mesh_addr_t *addr,
|
|||
return;
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr,
|
||||
u8_t conn_handle, u16_t net_idx, u8_t reason)
|
||||
static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr, u8_t conn_handle,
|
||||
u16_t net_idx, u8_t reason)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
|
@ -925,8 +923,8 @@ static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr,
|
|||
return;
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_proxy_client_filter_status_recv_cb(u8_t conn_handle,
|
||||
u16_t src, u16_t net_idx, u8_t filter_type, u16_t list_size)
|
||||
static void btc_ble_mesh_proxy_client_filter_status_recv_cb(u8_t conn_handle, u16_t src, u16_t net_idx,
|
||||
u8_t filter_type, u16_t list_size)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
|
@ -1432,7 +1430,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. */
|
||||
BT_ERR("%s, Time Setup Server shall not support publication", __func__);
|
||||
BT_ERR("Time Setup Server shall not support publication");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -1570,17 +1568,14 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
|||
}
|
||||
#if CONFIG_BLE_MESH_NODE
|
||||
case BTC_BLE_MESH_ACT_PROV_ENABLE:
|
||||
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:
|
||||
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:
|
||||
BT_DBG("%s, BTC_BLE_MESH_ACT_NODE_RESET", __func__);
|
||||
bt_mesh_node_reset();
|
||||
return;
|
||||
case BTC_BLE_MESH_ACT_SET_OOB_PUB_KEY:
|
||||
|
@ -1612,11 +1607,11 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
|||
break;
|
||||
case BTC_BLE_MESH_ACT_PROXY_GATT_ENABLE:
|
||||
act = ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT;
|
||||
param.node_proxy_gatt_enable_comp.err_code = bt_mesh_proxy_gatt_enable();
|
||||
param.node_proxy_gatt_enable_comp.err_code = bt_mesh_proxy_server_gatt_enable();
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROXY_GATT_DISABLE:
|
||||
act = ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT;
|
||||
param.node_proxy_gatt_disable_comp.err_code = bt_mesh_proxy_gatt_disable();
|
||||
param.node_proxy_gatt_disable_comp.err_code = bt_mesh_proxy_server_gatt_disable();
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_GATT_PROXY_SERVER */
|
||||
#endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */
|
||||
|
@ -1855,7 +1850,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
|||
param.proxy_client_set_filter_type_comp.conn_handle = arg->proxy_client_set_filter_type.conn_handle;
|
||||
param.proxy_client_set_filter_type_comp.net_idx = arg->proxy_client_set_filter_type.net_idx;
|
||||
param.proxy_client_set_filter_type_comp.err_code =
|
||||
bt_mesh_proxy_client_send_cfg(arg->proxy_client_set_filter_type.conn_handle,
|
||||
bt_mesh_proxy_client_cfg_send(arg->proxy_client_set_filter_type.conn_handle,
|
||||
arg->proxy_client_set_filter_type.net_idx, &pdu);
|
||||
break;
|
||||
}
|
||||
|
@ -1869,7 +1864,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
|||
param.proxy_client_add_filter_addr_comp.conn_handle = arg->proxy_client_add_filter_addr.conn_handle;
|
||||
param.proxy_client_add_filter_addr_comp.net_idx = arg->proxy_client_add_filter_addr.net_idx;
|
||||
param.proxy_client_add_filter_addr_comp.err_code =
|
||||
bt_mesh_proxy_client_send_cfg(arg->proxy_client_add_filter_addr.conn_handle,
|
||||
bt_mesh_proxy_client_cfg_send(arg->proxy_client_add_filter_addr.conn_handle,
|
||||
arg->proxy_client_add_filter_addr.net_idx, &pdu);
|
||||
break;
|
||||
}
|
||||
|
@ -1883,7 +1878,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
|||
param.proxy_client_remove_filter_addr_comp.conn_handle = arg->proxy_client_remove_filter_addr.conn_handle;
|
||||
param.proxy_client_remove_filter_addr_comp.net_idx = arg->proxy_client_remove_filter_addr.net_idx;
|
||||
param.proxy_client_remove_filter_addr_comp.err_code =
|
||||
bt_mesh_proxy_client_send_cfg(arg->proxy_client_remove_filter_addr.conn_handle,
|
||||
bt_mesh_proxy_client_cfg_send(arg->proxy_client_remove_filter_addr.conn_handle,
|
||||
arg->proxy_client_remove_filter_addr.net_idx, &pdu);
|
||||
break;
|
||||
}
|
||||
|
@ -1937,7 +1932,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
|||
param.deinit_mesh_comp.err_code = bt_mesh_deinit((struct bt_mesh_deinit_param *)&arg->mesh_deinit.param);
|
||||
break;
|
||||
default:
|
||||
BT_WARN("%s, Invalid msg->act %d", __func__, msg->act);
|
||||
BT_WARN("%s, Unknown act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1964,7 +1959,7 @@ 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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1987,7 +1982,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1999,7 +1994,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
|
|||
/* arg->model_send.length contains opcode & payload, plus extra 4-bytes TransMIC */
|
||||
struct net_buf_simple *buf = bt_mesh_alloc_buf(arg->model_send.length + BLE_MESH_MIC_SHORT);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
break;
|
||||
}
|
||||
net_buf_simple_add_mem(buf, arg->model_send.data, arg->model_send.length);
|
||||
|
@ -2017,7 +2012,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
|
|||
/* arg->model_send.length contains opcode & message, plus extra 4-bytes TransMIC */
|
||||
struct net_buf_simple *buf = bt_mesh_alloc_buf(arg->model_send.length + BLE_MESH_MIC_SHORT);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
break;
|
||||
}
|
||||
net_buf_simple_add_mem(buf, arg->model_send.data, arg->model_send.length);
|
||||
|
@ -2025,7 +2020,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
err = bt_mesh_client_send_msg((struct bt_mesh_model *)arg->model_send.model,
|
||||
|
@ -2046,7 +2041,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
|
|||
arg->model_update_state.type, err);
|
||||
break;
|
||||
default:
|
||||
BT_WARN("%s, Unknown msg->act %d", __func__, msg->act);
|
||||
BT_WARN("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2068,7 +2063,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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_model_free_req_data(msg);
|
||||
|
|
|
@ -58,7 +58,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->column_get.raw_value_x,
|
||||
|
@ -71,7 +71,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x1,
|
||||
|
@ -82,7 +82,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x2,
|
||||
|
@ -94,7 +94,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -113,7 +113,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of 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,
|
||||
|
@ -124,7 +124,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of 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,
|
||||
|
@ -135,7 +135,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low,
|
||||
|
@ -146,7 +146,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high,
|
||||
|
@ -159,7 +159,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw,
|
||||
|
@ -171,12 +171,12 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.descriptor_status.descriptor,
|
||||
|
@ -290,7 +290,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.cadence_status.sensor_cadence_value,
|
||||
|
@ -304,7 +304,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.settings_status.sensor_setting_property_ids,
|
||||
|
@ -319,7 +319,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.setting_status.sensor_setting_raw,
|
||||
|
@ -333,7 +333,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.sensor_status.marshalled_sensor_data,
|
||||
|
@ -347,7 +347,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.column_status.sensor_column_value,
|
||||
|
@ -361,7 +361,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.series_status.sensor_series_value,
|
||||
|
@ -456,8 +456,8 @@ static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_pa
|
|||
msg.pid = BTC_PID_SENSOR_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_sensor_client_cb_param_t), btc_ble_mesh_sensor_client_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_client_cb_param_t),
|
||||
btc_ble_mesh_sensor_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
|
@ -489,7 +489,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:
|
||||
BT_ERR("%s, Unknown sensor client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Sensor client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -516,8 +516,7 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -526,8 +525,8 @@ void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode,
|
|||
return;
|
||||
}
|
||||
|
||||
bt_mesh_sensor_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_sensor_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -552,7 +551,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
|
@ -578,7 +577,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
|
@ -621,7 +620,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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_client_free_req_data(msg);
|
||||
|
@ -630,8 +629,7 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
|
|||
|
||||
/* Sensor Server Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_sensor_server_cb_to_app(
|
||||
esp_ble_mesh_sensor_server_cb_event_t event,
|
||||
static inline void btc_ble_mesh_sensor_server_cb_to_app(esp_ble_mesh_sensor_server_cb_event_t event,
|
||||
esp_ble_mesh_sensor_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_sensor_server_cb_t btc_ble_mesh_cb =
|
||||
|
@ -660,7 +658,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of 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 +669,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of 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 +680,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of 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 +691,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of 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 +704,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of 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 +719,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.get.sensor_column.raw_value_x,
|
||||
|
@ -733,7 +731,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.get.sensor_series.raw_value,
|
||||
|
@ -749,7 +747,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.sensor_cadence.cadence,
|
||||
|
@ -762,7 +760,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.sensor_setting.setting_raw,
|
||||
|
@ -836,12 +834,11 @@ static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_pa
|
|||
msg.pid = BTC_PID_SENSOR_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(
|
||||
&msg, cb_params, sizeof(esp_ble_mesh_sensor_server_cb_param_t), btc_ble_mesh_sensor_server_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_server_cb_param_t),
|
||||
btc_ble_mesh_sensor_server_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
|
@ -865,7 +862,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:
|
||||
BT_ERR("%s, Unknown Sensor Server event type", __func__);
|
||||
BT_ERR("Unknown Sensor server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -902,7 +899,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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_server_free_req_data(msg);
|
||||
|
|
|
@ -48,7 +48,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
|
|||
memcpy(dst->time_scene_client_get_state.params, src->time_scene_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->time_scene_client_get_state.get_state) {
|
||||
|
@ -57,7 +57,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
|
|||
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);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -71,12 +71,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 {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
|
|||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,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) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.scene_register_status.scenes,
|
||||
|
@ -220,8 +220,8 @@ static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_clie
|
|||
msg.pid = BTC_PID_TIME_SCENE_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_time_scene_client_cb_param_t), btc_ble_mesh_time_scene_client_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_client_cb_param_t),
|
||||
btc_ble_mesh_time_scene_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
|
@ -253,7 +253,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:
|
||||
BT_ERR("%s, Unknown time scene client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Time Scene client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -280,8 +280,7 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -290,8 +289,8 @@ void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode,
|
|||
return;
|
||||
}
|
||||
|
||||
bt_mesh_time_scene_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_time_scene_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -316,7 +315,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
|
@ -342,7 +341,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)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
BT_ERR("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
|
@ -385,7 +384,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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_time_scene_client_free_req_data(msg);
|
||||
|
@ -394,8 +393,7 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
|
|||
|
||||
/* Time and Scenes Server Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_time_scene_server_cb_to_app(
|
||||
esp_ble_mesh_time_scene_server_cb_event_t event,
|
||||
static inline void btc_ble_mesh_time_scene_server_cb_to_app(esp_ble_mesh_time_scene_server_cb_event_t event,
|
||||
esp_ble_mesh_time_scene_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_time_scene_server_cb_t btc_ble_mesh_cb =
|
||||
|
@ -420,12 +418,10 @@ static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_serv
|
|||
msg.pid = BTC_PID_TIME_SCENE_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(
|
||||
&msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
|
@ -452,7 +448,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:
|
||||
BT_ERR("%s, Unknown Time Scene Server event type", __func__);
|
||||
BT_ERR("Unknown Time Scene server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -489,7 +485,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 {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -53,8 +53,7 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg);
|
|||
|
||||
void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_config_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
|
@ -70,8 +69,7 @@ typedef enum {
|
|||
BTC_BLE_MESH_EVT_CONFIG_SERVER_MAX,
|
||||
} btc_ble_mesh_config_server_evt_t;
|
||||
|
||||
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
|
|
|
@ -53,8 +53,7 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg);
|
|||
|
||||
void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
|
@ -70,8 +69,7 @@ typedef enum {
|
|||
BTC_BLE_MESH_EVT_GENERIC_SERVER_MAX,
|
||||
} btc_ble_mesh_generic_server_evt_t;
|
||||
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
|
|
|
@ -53,8 +53,7 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg);
|
|||
|
||||
void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_health_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
|
@ -82,7 +81,8 @@ void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
|
||||
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id);
|
||||
|
||||
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, u8_t test_id, u16_t company_id);
|
||||
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
|
||||
u8_t test_id, u16_t company_id);
|
||||
|
||||
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time);
|
||||
|
||||
|
|
|
@ -53,8 +53,7 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg);
|
|||
|
||||
void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
|
@ -71,8 +70,7 @@ typedef enum {
|
|||
BTC_BLE_MESH_EVT_LIGHTING_SERVER_MAX,
|
||||
} btc_ble_mesh_lighting_server_evt_t;
|
||||
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
|
|
|
@ -322,8 +322,7 @@ uint8_t btc_ble_mesh_elem_count(void);
|
|||
esp_ble_mesh_model_t *btc_ble_mesh_model_find_vnd(const esp_ble_mesh_elem_t *elem,
|
||||
uint16_t company, uint16_t id);
|
||||
|
||||
esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem,
|
||||
uint16_t id);
|
||||
esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem, uint16_t id);
|
||||
|
||||
const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void);
|
||||
|
||||
|
|
|
@ -53,8 +53,7 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg);
|
|||
|
||||
void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
|
@ -70,8 +69,7 @@ typedef enum {
|
|||
BTC_BLE_MESH_EVT_SENSOR_SERVER_MAX,
|
||||
} btc_ble_mesh_sensor_server_evt_t;
|
||||
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
|
|
|
@ -53,8 +53,7 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg);
|
|||
|
||||
void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
|
@ -71,8 +70,7 @@ typedef enum {
|
|||
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_MAX,
|
||||
} btc_ble_mesh_time_scene_server_evt_t;
|
||||
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
|
|
|
@ -493,7 +493,7 @@ void net_buf_unref(struct net_buf *buf)
|
|||
pool->uninit_count++;
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
|
||||
pool->avail_count++;
|
||||
NET_BUF_DBG("%s, pool %p, avail_count %d, uninit_count %d", __func__,
|
||||
NET_BUF_DBG("Unref, pool %p, avail_count %d, uninit_count %d",
|
||||
pool, pool->avail_count, pool->uninit_count);
|
||||
NET_BUF_ASSERT(pool->avail_count <= pool->buf_count);
|
||||
#endif
|
||||
|
@ -546,7 +546,7 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
|
|||
|
||||
NET_BUF_ASSERT(pool);
|
||||
|
||||
NET_BUF_DBG("%s, pool %p, uninit_count %d, buf_count %d", __func__,
|
||||
NET_BUF_DBG("Alloc, pool %p, uninit_count %d, buf_count %d",
|
||||
pool, pool->uninit_count, pool->buf_count);
|
||||
|
||||
/* We need to lock interrupts temporarily to prevent race conditions
|
||||
|
@ -570,7 +570,7 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
|
|||
|
||||
bt_mesh_buf_unlock();
|
||||
|
||||
NET_BUF_ERR("%s, Failed to get free buffer", __func__);
|
||||
NET_BUF_ERR("Out of free buffer, pool %p", pool);
|
||||
return NULL;
|
||||
|
||||
success:
|
||||
|
@ -579,11 +579,11 @@ success:
|
|||
if (size) {
|
||||
buf->__buf = data_alloc(buf, &size, timeout);
|
||||
if (!buf->__buf) {
|
||||
NET_BUF_ERR("%s, Failed to allocate data", __func__);
|
||||
NET_BUF_ERR("Out of data, buf %p", buf);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
NET_BUF_WARN("%s, Zero data size", __func__);
|
||||
NET_BUF_WARN("Zero data size, buf %p", buf);
|
||||
buf->__buf = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ struct net_buf_simple *bt_mesh_alloc_buf(u16_t size)
|
|||
|
||||
buf = (struct net_buf_simple *)bt_mesh_calloc(sizeof(struct net_buf_simple) + size);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send)
|
|||
bt_mesh_client_user_data_t *client = NULL;
|
||||
|
||||
if (srv_send) {
|
||||
BT_DBG("%s, Message is sent by a server model", __func__);
|
||||
BT_DBG("Message is sent by a server model");
|
||||
return NODE;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ static bt_mesh_mutex_t atomic_lock;
|
|||
void bt_mesh_mutex_create(bt_mesh_mutex_t *mutex)
|
||||
{
|
||||
if (!mutex) {
|
||||
BT_ERR("%s, Invalid mutex", __func__);
|
||||
BT_ERR("Create, invalid mutex");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ void bt_mesh_mutex_create(bt_mesh_mutex_t *mutex)
|
|||
void bt_mesh_mutex_free(bt_mesh_mutex_t *mutex)
|
||||
{
|
||||
if (!mutex) {
|
||||
BT_ERR("%s, Invalid mutex", __func__);
|
||||
BT_ERR("Free, invalid mutex");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ void bt_mesh_mutex_free(bt_mesh_mutex_t *mutex)
|
|||
void bt_mesh_mutex_lock(bt_mesh_mutex_t *mutex)
|
||||
{
|
||||
if (!mutex) {
|
||||
BT_ERR("%s, Invalid mutex", __func__);
|
||||
BT_ERR("Lock, invalid mutex");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ void bt_mesh_mutex_lock(bt_mesh_mutex_t *mutex)
|
|||
void bt_mesh_mutex_unlock(bt_mesh_mutex_t *mutex)
|
||||
{
|
||||
if (!mutex) {
|
||||
BT_ERR("%s, Invalid mutex", __func__);
|
||||
BT_ERR("Unlock, invalid mutex");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ void bt_mesh_timer_init(void)
|
|||
bm_alarm_hash_map = hash_map_new(BLE_MESH_GENERAL_ALARM_HASH_MAP_SIZE,
|
||||
hash_function_pointer, NULL,
|
||||
(data_free_fn)osi_alarm_free, NULL);
|
||||
__ASSERT(bm_alarm_hash_map, "%s, Failed to create hash map", __func__);
|
||||
__ASSERT(bm_alarm_hash_map, "Failed to create hash map");
|
||||
}
|
||||
|
||||
void bt_mesh_timer_deinit(void)
|
||||
|
@ -74,12 +74,12 @@ int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
|
|||
if (!hash_map_has_key(bm_alarm_hash_map, (void *)work)) {
|
||||
alarm = osi_alarm_new("bt_mesh", (osi_alarm_callback_t)handler, (void *)&work->work, 0);
|
||||
if (alarm == NULL) {
|
||||
BT_ERR("%s, Alarm not created", __func__);
|
||||
BT_ERR("Alarm not created");
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EIO;
|
||||
}
|
||||
if (!hash_map_set(bm_alarm_hash_map, work, (void *)alarm)) {
|
||||
BT_ERR("%s, Alarm not set", __func__);
|
||||
BT_ERR("Alarm not set");
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
|
|||
|
||||
alarm = hash_map_get(bm_alarm_hash_map, work);
|
||||
if (alarm == NULL) {
|
||||
BT_ERR("%s, Alarm not found", __func__);
|
||||
BT_ERR("Init, alarm not found");
|
||||
bt_mesh_alarm_unlock();
|
||||
return -ENODEV;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ int k_delayed_work_submit(struct k_delayed_work *work, s32_t delay)
|
|||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("%s, Alarm not found", __func__);
|
||||
BT_WARN("Submit, alarm not found");
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ int k_delayed_work_submit_periodic(struct k_delayed_work *work, s32_t period)
|
|||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("%s, Alarm not found", __func__);
|
||||
BT_WARN("Submit, alarm not found");
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ int k_delayed_work_cancel(struct k_delayed_work *work)
|
|||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("%s, Alarm not found", __func__);
|
||||
BT_WARN("Cancel, alarm not found");
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ int k_delayed_work_free(struct k_delayed_work *work)
|
|||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("%s, Alarm not found", __func__);
|
||||
BT_WARN("Free, alarm not found");
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ s32_t k_delayed_work_remaining_get(struct k_delayed_work *work)
|
|||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("%s, Alarm not found", __func__);
|
||||
BT_WARN("Get time, alarm not found");
|
||||
bt_mesh_alarm_unlock();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod)
|
|||
int period = 0;
|
||||
|
||||
if (!mod->pub) {
|
||||
BT_ERR("%s, Model has no publication support", __func__);
|
||||
BT_ERR("Model has no publication support");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod)
|
|||
period = K_MINUTES((mod->pub->period & BIT_MASK(6)) * 10U);
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown model publication period", __func__);
|
||||
BT_ERR("Unknown model publication period");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ static s32_t next_period(struct bt_mesh_model *mod)
|
|||
u32_t elapsed = 0U, period = 0U;
|
||||
|
||||
if (!pub) {
|
||||
BT_ERR("%s, Model has no publication support", __func__);
|
||||
BT_ERR("Model has no publication support");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ static void publish_sent(int err, void *user_data)
|
|||
BT_DBG("err %d", err);
|
||||
|
||||
if (!mod->pub) {
|
||||
BT_ERR("%s, Model has no publication support", __func__);
|
||||
BT_ERR("Model has no publication support");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ static int publish_retransmit(struct bt_mesh_model *mod)
|
|||
{
|
||||
struct bt_mesh_model_pub *pub = mod->pub;
|
||||
if (!pub) {
|
||||
BT_ERR("%s, Model has no publication support", __func__);
|
||||
BT_ERR("Model has no publication support");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
@ -399,13 +399,13 @@ static int publish_retransmit(struct bt_mesh_model *mod)
|
|||
|
||||
key = bt_mesh_tx_appkey_get(pub->dev_role, pub->key);
|
||||
if (!key) {
|
||||
BT_ERR("%s, AppKey 0x%03x not exists", __func__, pub->key);
|
||||
BT_ERR("AppKey 0x%03x not exists", pub->key);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
tx.sub = bt_mesh_tx_netkey_get(pub->dev_role, key->net_idx);
|
||||
if (!tx.sub) {
|
||||
BT_ERR("%s, Subnet 0x%04x not exists", __func__, key->net_idx);
|
||||
BT_ERR("Subnet 0x%04x not exists", key->net_idx);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
|
@ -414,7 +414,7 @@ static int publish_retransmit(struct bt_mesh_model *mod)
|
|||
|
||||
sdu = bt_mesh_alloc_buf(pub->msg->len + BLE_MESH_MIC_SHORT);
|
||||
if (!sdu) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,7 @@ static void mod_publish(struct k_work *work)
|
|||
if (pub->count) {
|
||||
err = publish_retransmit(pub->mod);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to retransmit (err %d)", __func__, err);
|
||||
BT_ERR("Failed to retransmit (err %d)", err);
|
||||
|
||||
pub->count = 0U;
|
||||
|
||||
|
@ -486,7 +486,7 @@ static void mod_publish(struct k_work *work)
|
|||
|
||||
err = bt_mesh_model_publish(pub->mod);
|
||||
if (err) {
|
||||
BT_ERR("%s, Publishing failed (err %d)", __func__, err);
|
||||
BT_ERR("Publishing failed (err %d)", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -500,12 +500,12 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
|
|||
struct bt_mesh_elem *elem = NULL;
|
||||
|
||||
if (!dev_comp) {
|
||||
BT_ERR("%s, dev_comp is not initialized", __func__);
|
||||
BT_ERR("dev_comp not initialized");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (elem_idx >= dev_comp->elem_count) {
|
||||
BT_ERR("%s, Invalid element index %u", __func__, elem_idx);
|
||||
BT_ERR("Invalid element index %u", elem_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -513,14 +513,14 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
|
|||
|
||||
if (vnd) {
|
||||
if (mod_idx >= elem->vnd_model_count) {
|
||||
BT_ERR("%s, Invalid vendor model index %u", __func__, mod_idx);
|
||||
BT_ERR("Invalid vendor model index %u", mod_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &elem->vnd_models[mod_idx];
|
||||
} else {
|
||||
if (mod_idx >= elem->model_count) {
|
||||
BT_ERR("%s, Invalid SIG model index %u", __func__, mod_idx);
|
||||
BT_ERR("Invalid SIG model index %u", mod_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -776,7 +776,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
|
|||
case 0x00:
|
||||
case 0x01:
|
||||
if (buf->data[0] == 0x7f) {
|
||||
BT_ERR("%s, Ignoring RFU OpCode", __func__);
|
||||
BT_ERR("Ignoring RFU OpCode");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -784,7 +784,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
|
|||
return 0;
|
||||
case 0x02:
|
||||
if (buf->len < 2) {
|
||||
BT_ERR("%s, Too short payload for 2-octet OpCode", __func__);
|
||||
BT_ERR("Too short payload for 2-octet OpCode");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -792,7 +792,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
|
|||
return 0;
|
||||
case 0x03:
|
||||
if (buf->len < 3) {
|
||||
BT_ERR("%s, Too short payload for 3-octet OpCode", __func__);
|
||||
BT_ERR("Too short payload for 3-octet OpCode");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -838,7 +838,7 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
BT_INFO("recv, len %u: %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
if (get_opcode(buf, &opcode) < 0) {
|
||||
BT_WARN("%s, Unable to decode OpCode", __func__);
|
||||
BT_WARN("Unable to decode OpCode");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -932,7 +932,7 @@ static bool ready_to_send(u8_t role, u16_t dst)
|
|||
return true;
|
||||
} else if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en() && role == PROVISIONER) {
|
||||
if (!bt_mesh_provisioner_check_msg_dst(dst)) {
|
||||
BT_ERR("%s, Failed to find DST 0x%04x", __func__, dst);
|
||||
BT_ERR("Failed to find DST 0x%04x", dst);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -952,7 +952,7 @@ static int model_send(struct bt_mesh_model *model,
|
|||
|
||||
role = bt_mesh_get_device_role(model, tx->ctx->srv_send);
|
||||
if (role == ROLE_NVAL) {
|
||||
BT_ERR("%s, Failed to get model role", __func__);
|
||||
BT_ERR("Failed to get model role");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -961,22 +961,22 @@ static int model_send(struct bt_mesh_model *model,
|
|||
BT_INFO("send, len %u: %s", msg->len, bt_hex(msg->data, msg->len));
|
||||
|
||||
if (!ready_to_send(role, tx->ctx->addr)) {
|
||||
BT_ERR("%s, Not ready", __func__);
|
||||
BT_ERR("Not ready to send");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (net_buf_simple_tailroom(msg) < BLE_MESH_MIC_SHORT) {
|
||||
BT_ERR("%s, Not enough tailroom for TransMIC", __func__);
|
||||
BT_ERR("Not enough tailroom for TransMIC");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (msg->len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SDU_MAX_LEN) - BLE_MESH_MIC_SHORT) {
|
||||
BT_ERR("%s, Too big message", __func__);
|
||||
BT_ERR("Too big message (len %d)", msg->len);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
if (!implicit_bind && !model_has_key(model, tx->ctx->app_idx)) {
|
||||
BT_ERR("%s, Model not bound to AppKey 0x%04x", __func__, tx->ctx->app_idx);
|
||||
BT_ERR("Model not bound to AppKey 0x%04x", tx->ctx->app_idx);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -993,13 +993,13 @@ int bt_mesh_model_send(struct bt_mesh_model *model,
|
|||
|
||||
role = bt_mesh_get_device_role(model, ctx->srv_send);
|
||||
if (role == ROLE_NVAL) {
|
||||
BT_ERR("%s, Failed to get model role", __func__);
|
||||
BT_ERR("Failed to get model role");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
sub = bt_mesh_tx_netkey_get(role, ctx->net_idx);
|
||||
if (!sub) {
|
||||
BT_ERR("%s, Failed to get subnet", __func__);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", ctx->net_idx);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1035,28 +1035,28 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!pub || !pub->msg) {
|
||||
BT_ERR("%s, Model has no publication support", __func__);
|
||||
BT_ERR("Model has no publication support");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (pub->addr == BLE_MESH_ADDR_UNASSIGNED) {
|
||||
BT_WARN("%s, Unassigned model publish address", __func__);
|
||||
BT_WARN("Unassigned publish address");
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
key = bt_mesh_tx_appkey_get(pub->dev_role, pub->key);
|
||||
if (!key) {
|
||||
BT_ERR("%s, AppKey 0x%03x not exists", __func__, pub->key);
|
||||
BT_ERR("Invalid AppKeyIndex 0x%03x", pub->key);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
if (pub->msg->len + BLE_MESH_MIC_SHORT > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SDU_MAX_LEN)) {
|
||||
BT_ERR("%s, Message does not fit maximum SDU size", __func__);
|
||||
BT_ERR("Message does not fit maximum SDU size");
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
if (pub->count) {
|
||||
BT_WARN("%s, Clearing publish retransmit timer", __func__);
|
||||
BT_WARN("Clearing publish retransmit timer");
|
||||
k_delayed_work_cancel(&pub->timer);
|
||||
}
|
||||
|
||||
|
@ -1071,7 +1071,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
|
|||
|
||||
tx.sub = bt_mesh_tx_netkey_get(pub->dev_role, ctx.net_idx);
|
||||
if (!tx.sub) {
|
||||
BT_ERR("%s, Subnet 0x%04x not exists", __func__, ctx.net_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", ctx.net_idx);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
|
@ -1082,7 +1082,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
|
|||
|
||||
sdu = bt_mesh_alloc_buf(pub->msg->len + BLE_MESH_MIC_SHORT);
|
||||
if (!sdu) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -1112,8 +1112,7 @@ struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem,
|
||||
u16_t id)
|
||||
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, u16_t id)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr);
|
|||
|
||||
struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
|
||||
u16_t company, u16_t id);
|
||||
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem,
|
||||
u16_t id);
|
||||
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, u16_t id);
|
||||
|
||||
u16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, u16_t addr);
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ static inline int adv_send(struct net_buf *buf)
|
|||
struct ble_adv_tx *tx = cb_data;
|
||||
|
||||
if (tx == NULL) {
|
||||
BT_ERR("%s, Invalid adv user data", __func__);
|
||||
BT_ERR("Invalid adv user data");
|
||||
net_buf_unref(buf);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ static inline int adv_send(struct net_buf *buf)
|
|||
net_buf_unref(buf);
|
||||
adv_send_start(duration, err, cb, cb_data);
|
||||
if (err) {
|
||||
BT_ERR("%s, Advertising failed: err %d", __func__, err);
|
||||
BT_ERR("Start advertising failed: err %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ static inline int adv_send(struct net_buf *buf)
|
|||
err = bt_le_adv_stop();
|
||||
adv_send_end(err, cb, cb_data);
|
||||
if (err) {
|
||||
BT_ERR("%s, Stop advertising failed: err %d", __func__, err);
|
||||
BT_ERR("Stop advertising failed: err %d", err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -258,11 +258,11 @@ static void adv_thread(void *p)
|
|||
while (!(*buf)) {
|
||||
s32_t timeout;
|
||||
BT_DBG("Mesh Proxy Advertising start");
|
||||
timeout = bt_mesh_proxy_adv_start();
|
||||
timeout = bt_mesh_proxy_server_adv_start();
|
||||
BT_DBG("Mesh Proxy Advertising up to %d ms", timeout);
|
||||
xQueueReceive(adv_queue.handle, &msg, timeout);
|
||||
BT_DBG("Mesh Proxy Advertising stop");
|
||||
bt_mesh_proxy_adv_stop();
|
||||
bt_mesh_proxy_server_adv_stop();
|
||||
}
|
||||
#else
|
||||
xQueueReceive(adv_queue.handle, &msg, portMAX_DELAY);
|
||||
|
@ -281,11 +281,11 @@ static void adv_thread(void *p)
|
|||
while (!(*buf)) {
|
||||
s32_t timeout = 0;
|
||||
BT_DBG("Mesh Proxy Advertising start");
|
||||
timeout = bt_mesh_proxy_adv_start();
|
||||
timeout = bt_mesh_proxy_server_adv_start();
|
||||
BT_DBG("Mesh Proxy Advertising up to %d ms", timeout);
|
||||
handle = xQueueSelectFromSet(mesh_queue_set, timeout);
|
||||
BT_DBG("Mesh Proxy Advertising stop");
|
||||
bt_mesh_proxy_adv_stop();
|
||||
bt_mesh_proxy_server_adv_stop();
|
||||
if (handle) {
|
||||
if (uxQueueMessagesWaiting(adv_queue.handle)) {
|
||||
xQueueReceive(adv_queue.handle, &msg, K_NO_WAIT);
|
||||
|
@ -316,18 +316,18 @@ static void adv_thread(void *p)
|
|||
BLE_MESH_ADV(*buf)->busy = 0U;
|
||||
#if !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
if (adv_send(*buf)) {
|
||||
BT_WARN("%s, Failed to send adv packet", __func__);
|
||||
BT_WARN("Failed to send adv packet");
|
||||
}
|
||||
#else /* !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
if (msg.relay && ignore_relay_packet(msg.timestamp)) {
|
||||
/* If the interval between "current time - msg.timestamp" is bigger than
|
||||
* BLE_MESH_RELAY_TIME_INTERVAL, this relay packet will not be sent.
|
||||
*/
|
||||
BT_INFO("%s, Ignore relay packet", __func__);
|
||||
BT_INFO("Ignore relay packet");
|
||||
net_buf_unref(*buf);
|
||||
} else {
|
||||
if (adv_send(*buf)) {
|
||||
BT_WARN("%s, Failed to send adv packet", __func__);
|
||||
BT_WARN("Failed to send adv packet");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -359,7 +359,7 @@ struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
BT_DBG("%s, pool = %p, buf_count = %d, uinit_count = %d", __func__,
|
||||
BT_DBG("pool %p, buf_count %d, uinit_count %d",
|
||||
buf->pool, pool->buf_count, pool->uninit_count);
|
||||
|
||||
adv = get_id(net_buf_id(buf));
|
||||
|
@ -443,18 +443,18 @@ static void bt_mesh_task_post(bt_mesh_msg_t *msg, uint32_t timeout, bool front)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (adv_queue.handle == NULL) {
|
||||
BT_ERR("%s, Invalid queue", __func__);
|
||||
BT_ERR("Invalid adv queue");
|
||||
return;
|
||||
}
|
||||
|
||||
if (front) {
|
||||
if (xQueueSendToFront(adv_queue.handle, msg, timeout) != pdTRUE) {
|
||||
BT_ERR("%s, Failed to send item to queue front", __func__);
|
||||
BT_ERR("Failed to send item to adv queue front");
|
||||
bt_mesh_unref_buf(msg);
|
||||
}
|
||||
} else {
|
||||
if (xQueueSend(adv_queue.handle, msg, timeout) != pdTRUE) {
|
||||
BT_ERR("%s, Failed to send item to queue back", __func__);
|
||||
BT_ERR("Failed to send item to adv queue back");
|
||||
bt_mesh_unref_buf(msg);
|
||||
}
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (relay_queue.handle == NULL) {
|
||||
BT_ERR("%s, Invalid relay queue", __func__);
|
||||
BT_ERR("Invalid relay queue");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -541,10 +541,10 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
|||
*/
|
||||
handle = xQueueSelectFromSet(mesh_queue_set, K_NO_WAIT);
|
||||
if (handle && uxQueueMessagesWaiting(relay_queue.handle)) {
|
||||
BT_INFO("%s, Full queue, remove the oldest relay packet", __func__);
|
||||
BT_INFO("Full queue, remove the oldest relay packet");
|
||||
/* Remove the oldest relay packet from queue */
|
||||
if (xQueueReceive(relay_queue.handle, &old_msg, K_NO_WAIT) != pdTRUE) {
|
||||
BT_ERR("%s, Failed to remove item from queue", __func__);
|
||||
BT_ERR("Failed to remove item from queue");
|
||||
bt_mesh_unref_buf(msg);
|
||||
return;
|
||||
}
|
||||
|
@ -552,12 +552,12 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
|||
bt_mesh_unref_buf(&old_msg);
|
||||
/* Send the latest relay packet to queue */
|
||||
if (xQueueSend(relay_queue.handle, msg, K_NO_WAIT) != pdTRUE) {
|
||||
BT_ERR("%s, Failed to send item to relay queue", __func__);
|
||||
BT_ERR("Failed to send item to relay queue");
|
||||
bt_mesh_unref_buf(msg);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
BT_WARN("%s, Empty queue, but failed to send the relay packet", __func__);
|
||||
BT_WARN("Empty queue, but failed to send the relay packet");
|
||||
bt_mesh_unref_buf(msg);
|
||||
}
|
||||
}
|
||||
|
@ -590,19 +590,19 @@ u16_t bt_mesh_get_stored_relay_count(void)
|
|||
}
|
||||
#endif /* #if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
|
||||
const bt_mesh_addr_t *bt_mesh_pba_get_addr(void)
|
||||
const bt_mesh_addr_t *bt_mesh_get_unprov_dev_addr(void)
|
||||
{
|
||||
return dev_addr;
|
||||
}
|
||||
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
static bool bt_mesh_is_adv_flags_valid(struct net_buf_simple *buf)
|
||||
static bool adv_flags_valid(struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t flags = 0U;
|
||||
|
||||
if (buf->len != 1U) {
|
||||
BT_DBG("%s, Unexpected flags length", __func__);
|
||||
BT_DBG("Unexpected adv flags length %d", buf->len);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -616,7 +616,7 @@ static bool bt_mesh_is_adv_flags_valid(struct net_buf_simple *buf)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool bt_mesh_is_adv_srv_uuid_valid(struct net_buf_simple *buf, u16_t *uuid)
|
||||
static bool adv_service_uuid_valid(struct net_buf_simple *buf, u16_t *uuid)
|
||||
{
|
||||
if (buf->len != 2U) {
|
||||
BT_DBG("Length not match mesh service uuid");
|
||||
|
@ -649,7 +649,9 @@ static bool bt_mesh_is_adv_srv_uuid_valid(struct net_buf_simple *buf, u16_t *uui
|
|||
#define BLE_MESH_PROXY_SRV_DATA_LEN1 0x09
|
||||
#define BLE_MESH_PROXY_SRV_DATA_LEN2 0x11
|
||||
|
||||
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)
|
||||
static void handle_adv_service_data(struct net_buf_simple *buf,
|
||||
const bt_mesh_addr_t *addr,
|
||||
u16_t uuid, s8_t rssi)
|
||||
{
|
||||
u16_t type = 0U;
|
||||
|
||||
|
@ -660,7 +662,7 @@ static void bt_mesh_adv_srv_data_recv(struct net_buf_simple *buf, const bt_mesh_
|
|||
|
||||
type = net_buf_simple_pull_le16(buf);
|
||||
if (type != uuid) {
|
||||
BT_DBG("%s, Invalid Mesh Service Data UUID 0x%04x", __func__, type);
|
||||
BT_DBG("Invalid Mesh Service Data UUID 0x%04x", type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -669,12 +671,12 @@ static void bt_mesh_adv_srv_data_recv(struct net_buf_simple *buf, const bt_mesh_
|
|||
case BLE_MESH_UUID_MESH_PROV_VAL:
|
||||
if (bt_mesh_is_provisioner_en()) {
|
||||
if (buf->len != BLE_MESH_PROV_SRV_DATA_LEN) {
|
||||
BT_WARN("%s, Invalid Mesh Prov Service Data length %d", __func__, buf->len);
|
||||
BT_WARN("Invalid Mesh Prov Service Data length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("Start to handle Mesh Prov Service Data");
|
||||
bt_mesh_provisioner_prov_adv_ind_recv(buf, addr, rssi);
|
||||
bt_mesh_provisioner_prov_adv_recv(buf, addr, rssi);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
@ -682,12 +684,12 @@ static void bt_mesh_adv_srv_data_recv(struct net_buf_simple *buf, const bt_mesh_
|
|||
case BLE_MESH_UUID_MESH_PROXY_VAL:
|
||||
if (buf->len != BLE_MESH_PROXY_SRV_DATA_LEN1 &&
|
||||
buf->len != BLE_MESH_PROXY_SRV_DATA_LEN2) {
|
||||
BT_WARN("%s, Invalid Mesh Proxy Service Data length %d", __func__, buf->len);
|
||||
BT_WARN("Invalid Mesh Proxy Service Data length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("Start to handle Mesh Proxy Service Data");
|
||||
bt_mesh_proxy_client_adv_ind_recv(buf, addr, rssi);
|
||||
bt_mesh_proxy_client_gatt_adv_recv(buf, addr, rssi);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -708,7 +710,7 @@ static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi,
|
|||
return;
|
||||
}
|
||||
|
||||
BT_DBG("%s, len %u: %s", __func__, buf->len, bt_hex(buf->data, buf->len));
|
||||
BT_DBG("scan, len %u: %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
dev_addr = addr;
|
||||
|
||||
|
@ -763,19 +765,19 @@ 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
|
||||
case BLE_MESH_DATA_FLAGS:
|
||||
if (!bt_mesh_is_adv_flags_valid(buf)) {
|
||||
if (!adv_flags_valid(buf)) {
|
||||
BT_DBG("Adv Flags mismatch, ignore this adv pkt");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BLE_MESH_DATA_UUID16_ALL:
|
||||
if (!bt_mesh_is_adv_srv_uuid_valid(buf, &uuid)) {
|
||||
if (!adv_service_uuid_valid(buf, &uuid)) {
|
||||
BT_DBG("Adv Service UUID mismatch, ignore this adv pkt");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BLE_MESH_DATA_SVC_DATA16:
|
||||
bt_mesh_adv_srv_data_recv(buf, addr, uuid, rssi);
|
||||
handle_adv_service_data(buf, addr, uuid, rssi);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -1109,17 +1111,17 @@ int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param,
|
|||
|
||||
if (param->adv_type != BLE_MESH_ADV_DIRECT_IND &&
|
||||
(param->interval < 0x20 || param->interval > 0x4000)) {
|
||||
BT_ERR("%s, Invalid adv interval 0x%04x", __func__, param->interval);
|
||||
BT_ERR("Invalid adv interval 0x%04x", param->interval);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (param->adv_type > BLE_MESH_ADV_DIRECT_IND_LOW_DUTY) {
|
||||
BT_ERR("%s, Invalid adv type 0x%02x", __func__, param->adv_type);
|
||||
BT_ERR("Invalid adv type 0x%02x", param->adv_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (param->own_addr_type > BLE_MESH_ADDR_RANDOM_ID) {
|
||||
BT_ERR("%s, Invalid own addr type 0x%02x", __func__, param->own_addr_type);
|
||||
BT_ERR("Invalid own addr type 0x%02x", param->own_addr_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1128,29 +1130,29 @@ int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param,
|
|||
param->adv_type == BLE_MESH_ADV_DIRECT_IND ||
|
||||
param->adv_type == BLE_MESH_ADV_DIRECT_IND_LOW_DUTY) &&
|
||||
param->peer_addr_type > BLE_MESH_ADDR_RANDOM) {
|
||||
BT_ERR("%s, Invalid peer addr type 0x%02x", __func__, param->peer_addr_type);
|
||||
BT_ERR("Invalid peer addr type 0x%02x", param->peer_addr_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (data && (data->adv_data_len > 31 || data->scan_rsp_data_len > 31)) {
|
||||
BT_ERR("%s, Invalid adv data length, %d %d", __func__,
|
||||
BT_ERR("Invalid adv data length (adv %d, scan rsp %d)",
|
||||
data->adv_data_len, data->scan_rsp_data_len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (param->priority > BLE_MESH_BLE_ADV_PRIO_HIGH) {
|
||||
BT_ERR("%s, Invalid adv priority %d", __func__, param->priority);
|
||||
BT_ERR("Invalid adv priority %d", param->priority);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (param->duration < ADV_SCAN_INT(param->interval)) {
|
||||
BT_ERR("%s, Too small duration %dms", __func__, param->duration);
|
||||
BT_ERR("Too small duration %dms", param->duration);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
buf = bt_mesh_ble_adv_create(BLE_MESH_ADV_BLE, 0U, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Unable to allocate buffer", __func__);
|
||||
BT_ERR("Unable to allocate buffer");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
|
@ -1200,14 +1202,14 @@ int bt_mesh_stop_ble_advertising(u8_t index)
|
|||
bool unref = true;
|
||||
|
||||
if (index >= ARRAY_SIZE(ble_adv_tx)) {
|
||||
BT_ERR("%s, Invalid index %d", __func__, index);
|
||||
BT_ERR("Invalid adv index %d", index);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tx = &ble_adv_tx[index];
|
||||
|
||||
if (tx->buf == NULL) {
|
||||
BT_WARN("%s, Already stopped, index %d", __func__, index);
|
||||
BT_WARN("Already stopped, index %d", index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ void bt_mesh_unref_buf_from_pool(struct net_buf_pool *pool);
|
|||
void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data);
|
||||
|
||||
const bt_mesh_addr_t *bt_mesh_pba_get_addr(void);
|
||||
const bt_mesh_addr_t *bt_mesh_get_unprov_dev_addr(void);
|
||||
|
||||
struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, u8_t xmit,
|
||||
s32_t timeout);
|
||||
|
|
|
@ -177,7 +177,7 @@ static int secure_beacon_send(void)
|
|||
buf = bt_mesh_adv_create(BLE_MESH_ADV_BEACON, PROV_XMIT,
|
||||
K_NO_WAIT);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Unable to allocate beacon buffer", __func__);
|
||||
BT_ERR("Out of beacon buffer");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ static int unprovisioned_beacon_send(void)
|
|||
|
||||
buf = bt_mesh_adv_create(BLE_MESH_ADV_BEACON, UNPROV_XMIT, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Unable to allocate beacon buffer", __func__);
|
||||
BT_ERR("Out of beacon buffer");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
|
|||
u8_t flags = 0U;
|
||||
|
||||
if (buf->len < 21) {
|
||||
BT_ERR("%s, Too short secure beacon (len %u)", __func__, buf->len);
|
||||
BT_ERR("Too short secure beacon (len %u)", buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -420,7 +420,7 @@ void bt_mesh_beacon_recv(struct net_buf_simple *buf, s8_t rssi)
|
|||
BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
if (buf->len < 1) {
|
||||
BT_ERR("%s, Too short beacon", __func__);
|
||||
BT_ERR("Too short beacon");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -258,7 +258,8 @@ static bool valid_scan_param(const struct bt_mesh_scan_param *param)
|
|||
return true;
|
||||
}
|
||||
|
||||
static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window, u8_t filter_dup, u8_t scan_fil_policy)
|
||||
static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window,
|
||||
u8_t filter_dup, u8_t scan_fil_policy)
|
||||
{
|
||||
UINT8 addr_type_own = BLE_MESH_ADDR_PUBLIC; /* Currently only support Public Address */
|
||||
tGATT_IF client_if = 0xFF; /* Default GATT interface id */
|
||||
|
@ -287,7 +288,7 @@ static void bt_mesh_scan_result_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARC
|
|||
u8_t adv_type = 0U;
|
||||
s8_t rssi = 0;
|
||||
|
||||
BT_DBG("%s, event = %d", __func__, event);
|
||||
BT_DBG("%s, event %d", __func__, event);
|
||||
|
||||
if (event == BTA_DM_INQ_RES_EVT) {
|
||||
/* TODO: How to process scan response here? */
|
||||
|
@ -299,7 +300,7 @@ static void bt_mesh_scan_result_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARC
|
|||
/* scan rsp len: p_data->inq_res.scan_rsp_len */
|
||||
struct net_buf_simple *buf = bt_mesh_alloc_buf(p_data->inq_res.adv_data_len);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(buf, p_data->inq_res.p_eir, p_data->inq_res.adv_data_len);
|
||||
|
@ -309,9 +310,9 @@ static void bt_mesh_scan_result_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARC
|
|||
}
|
||||
bt_mesh_free(buf);
|
||||
} else if (event == BTA_DM_INQ_CMPL_EVT) {
|
||||
BT_INFO("%s, Scan completed, number of scan response %d", __func__, p_data->inq_cmpl.num_resps);
|
||||
BT_INFO("Scan completed, number of scan response %d", p_data->inq_cmpl.num_resps);
|
||||
} else {
|
||||
BT_WARN("%s, Unexpected event 0x%x", __func__, event);
|
||||
BT_WARN("Unexpected scan result event %d", event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -335,13 +336,13 @@ int bt_le_adv_start(const struct bt_mesh_adv_param *param,
|
|||
#endif
|
||||
|
||||
if (!valid_adv_param(param)) {
|
||||
BT_ERR("%s, Invalid adv parameters", __func__);
|
||||
BT_ERR("Invalid adv parameters");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = set_adv_data(BLE_MESH_HCI_OP_SET_ADV_DATA, ad, ad_len);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to set adv data", __func__);
|
||||
BT_ERR("Failed to set adv data");
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -357,7 +358,7 @@ int bt_le_adv_start(const struct bt_mesh_adv_param *param,
|
|||
if (sd && (param->options & BLE_MESH_ADV_OPT_CONNECTABLE)) {
|
||||
err = set_adv_data(BLE_MESH_HCI_OP_SET_SCAN_RSP_DATA, sd, sd_len);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to set scan rsp data", __func__);
|
||||
BT_ERR("Failed to set scan rsp data");
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
@ -475,7 +476,8 @@ int bt_le_scan_start(const struct bt_mesh_scan_param *param, bt_mesh_scan_cb_t c
|
|||
}
|
||||
#endif
|
||||
|
||||
err = start_le_scan(param->type, param->interval, param->window, param->filter_dup, param->scan_fil_policy);
|
||||
err = start_le_scan(param->type, param->interval, param->window,
|
||||
param->filter_dup, param->scan_fil_policy);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
@ -535,7 +537,7 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||
u8_t buf[100] = {0};
|
||||
u16_t len = 0;
|
||||
|
||||
BT_DBG("%s, read: handle = %d", __func__, p_data->req_data.p_data->read_req.handle);
|
||||
BT_DBG("gatts read, handle %d", p_data->req_data.p_data->read_req.handle);
|
||||
|
||||
if (attr != NULL && attr->read != NULL) {
|
||||
if ((len = attr->read(&bt_mesh_gatts_conn[index], attr, buf, 100,
|
||||
|
@ -545,9 +547,9 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||
memcpy(&rsp.attr_value.value[0], buf, len);
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
p_data->req_data.status, &rsp);
|
||||
BT_DBG("%s, Send gatts read response, handle = %x", __func__, attr->handle);
|
||||
BT_DBG("Send gatts read rsp, handle %d", attr->handle);
|
||||
} else {
|
||||
BT_WARN("%s, BLE Mesh gatts read failed", __func__);
|
||||
BT_WARN("Mesh gatts read failed");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -557,7 +559,7 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||
u8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->req_data.conn_id);
|
||||
u16_t len = 0;
|
||||
|
||||
BT_DBG("%s, write: handle = %d, len = %d, data = %s", __func__, p_data->req_data.p_data->write_req.handle,
|
||||
BT_DBG("gatts write, handle %d, len %d, data %s", p_data->req_data.p_data->write_req.handle,
|
||||
p_data->req_data.p_data->write_req.len,
|
||||
bt_hex(p_data->req_data.p_data->write_req.value, p_data->req_data.p_data->write_req.len));
|
||||
|
||||
|
@ -569,7 +571,7 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||
if (p_data->req_data.p_data->write_req.need_rsp) {
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
p_data->req_data.status, NULL);
|
||||
BT_DBG("%s, send mesh write rsp, handle = %x", __func__, attr->handle);
|
||||
BT_DBG("Send gatts write rsp, handle %d", attr->handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -583,7 +585,7 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||
break;
|
||||
case BTA_GATTS_CREATE_EVT:
|
||||
svc_handle = p_data->create.service_id;
|
||||
BT_DBG("%s, svc_handle = %d, future_mesh = %p", __func__, svc_handle, future_mesh);
|
||||
BT_DBG("svc_handle %d, future_mesh %p", svc_handle, future_mesh);
|
||||
if (future_mesh != NULL) {
|
||||
future_ready(future_mesh, FUTURE_SUCCESS);
|
||||
}
|
||||
|
@ -724,7 +726,8 @@ static struct bt_mesh_gatt_attr *bt_mesh_gatts_attr_next(const struct bt_mesh_ga
|
|||
return next;
|
||||
}
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr,
|
||||
ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t buf_len, u16_t offset,
|
||||
const void *value, u16_t value_len)
|
||||
{
|
||||
|
@ -800,8 +803,8 @@ struct gatts_chrc {
|
|||
} __packed;
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr, void *buf,
|
||||
u16_t len, u16_t offset)
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t len, u16_t offset)
|
||||
{
|
||||
struct bt_mesh_gatt_char *chrc = attr->user_data;
|
||||
const struct bt_mesh_gatt_attr *next = NULL;
|
||||
|
@ -818,7 +821,7 @@ ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn,
|
|||
*/
|
||||
next = bt_mesh_gatts_attr_next(attr);
|
||||
if (!next) {
|
||||
BT_WARN("%s, No value for characteristic at 0x%04x", __func__, attr->handle);
|
||||
BT_WARN("No value for characteristic, handle 0x%04x", attr->handle);
|
||||
pdu.value_handle = 0x0000;
|
||||
} else {
|
||||
pdu.value_handle = sys_cpu_to_le16(next->handle);
|
||||
|
@ -850,7 +853,7 @@ static void bta_uuid_to_bt_mesh_uuid(tBT_UUID *bta_uuid, const struct bt_mesh_uu
|
|||
bta_uuid->len = LEN_UUID_128;
|
||||
memcpy(bta_uuid->uu.uuid128, BLE_MESH_UUID_128(uuid)->val, LEN_UUID_128);
|
||||
} else {
|
||||
BT_ERR("%s, Invalid mesh uuid type = %d", __func__, uuid->type);
|
||||
BT_ERR("Invalid mesh uuid type %d", uuid->type);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -868,7 +871,7 @@ static int gatts_register(struct bt_mesh_gatt_service *svc)
|
|||
|
||||
last = SYS_SLIST_PEEK_TAIL_CONTAINER(&bt_mesh_gatts_db, last, node);
|
||||
handle = last->attrs[last->attr_count - 1].handle;
|
||||
BT_DBG("%s, handle = %d", __func__, handle);
|
||||
BT_DBG("gatts register, handle %d", handle);
|
||||
|
||||
((void) handle);
|
||||
|
||||
|
@ -933,11 +936,12 @@ int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc)
|
|||
BTA_GATTS_CreateService(bt_mesh_gatts_if,
|
||||
&bta_uuid, 0, svc->attr_count, true);
|
||||
if (future_await(future_mesh) == FUTURE_FAIL) {
|
||||
BT_ERR("%s, Failed to add primary service", __func__);
|
||||
BT_ERR("Failed to add primary service");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
svc->attrs[i].handle = svc_handle;
|
||||
BT_DBG("Add primary service: svc_uuid = %x, perm = %d, svc_handle = %d", bta_uuid.uu.uuid16, svc->attrs[i].perm, svc_handle);
|
||||
BT_DBG("Add primary service, uuid 0x%04x, perm %d, handle %d",
|
||||
bta_uuid.uu.uuid16, svc->attrs[i].perm, svc_handle);
|
||||
break;
|
||||
}
|
||||
case BLE_MESH_UUID_GATT_SECONDARY_VAL: {
|
||||
|
@ -946,11 +950,12 @@ int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc)
|
|||
BTA_GATTS_CreateService(bt_mesh_gatts_if,
|
||||
&bta_uuid, 0, svc->attr_count, false);
|
||||
if (future_await(future_mesh) == FUTURE_FAIL) {
|
||||
BT_ERR("%s, Failed to add secondary service", __func__);
|
||||
BT_ERR("Failed to add secondary service");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
svc->attrs[i].handle = svc_handle;
|
||||
BT_DBG("Add secondary service: svc_uuid = %x, perm = %d, svc_handle = %d", bta_uuid.uu.uuid16, svc->attrs[i].perm, svc_handle);
|
||||
BT_DBG("Add secondary service, uuid 0x%04x, perm %d, handle %d",
|
||||
bta_uuid.uu.uuid16, svc->attrs[i].perm, svc_handle);
|
||||
break;
|
||||
}
|
||||
case BLE_MESH_UUID_GATT_INCLUDE_VAL: {
|
||||
|
@ -962,13 +967,14 @@ int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc)
|
|||
bta_uuid_to_bt_mesh_uuid(&bta_uuid, gatts_chrc->uuid);
|
||||
BTA_GATTS_AddCharacteristic(svc_handle, &bta_uuid, bt_mesh_perm_to_bta_perm(svc->attrs[i + 1].perm), gatts_chrc->properties, NULL, NULL);
|
||||
if (future_await(future_mesh) == FUTURE_FAIL) {
|
||||
BT_ERR("%s, Failed to add characteristic", __func__);
|
||||
BT_ERR("Failed to add characteristic");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
/* All the characteristic should have two handles: the declaration handle and the value handle */
|
||||
svc->attrs[i].handle = char_handle - 1;
|
||||
svc->attrs[i + 1].handle = char_handle;
|
||||
BT_DBG("Add characteristic: char_uuid = %x, char_handle = %d, perm = %d, char_pro = %d", BLE_MESH_UUID_16(gatts_chrc->uuid)->val, char_handle, svc->attrs[i + 1].perm, gatts_chrc->properties);
|
||||
BT_DBG("Add characteristic, uuid 0x%04x, handle %d, perm %d, properties %d",
|
||||
BLE_MESH_UUID_16(gatts_chrc->uuid)->val, char_handle, svc->attrs[i + 1].perm, gatts_chrc->properties);
|
||||
break;
|
||||
}
|
||||
case BLE_MESH_UUID_GATT_CEP_VAL:
|
||||
|
@ -986,11 +992,12 @@ int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc)
|
|||
bta_uuid_to_bt_mesh_uuid(&bta_uuid, svc->attrs[i].uuid);
|
||||
BTA_GATTS_AddCharDescriptor(svc_handle, bt_mesh_perm_to_bta_perm(svc->attrs[i].perm), &bta_uuid, NULL, NULL);
|
||||
if (future_await(future_mesh) == FUTURE_FAIL) {
|
||||
BT_ERR("%s, Failed to add descriptor", __func__);
|
||||
BT_ERR("Failed to add descriptor");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
svc->attrs[i].handle = char_handle;
|
||||
BT_DBG("Add descriptor: descr_uuid = %x, perm= %d, descr_handle = %d", BLE_MESH_UUID_16(svc->attrs[i].uuid)->val, svc->attrs[i].perm, char_handle);
|
||||
BT_DBG("Add descriptor, uuid 0x%04x, perm %d, handle %d",
|
||||
BLE_MESH_UUID_16(svc->attrs[i].uuid)->val, svc->attrs[i].perm, char_handle);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1034,7 +1041,8 @@ int bt_mesh_gatts_service_unregister(struct bt_mesh_gatt_service *svc)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_gatts_notify(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr,
|
||||
int bt_mesh_gatts_notify(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
const void *data, u16_t len)
|
||||
{
|
||||
u16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gatts_if, conn->handle);
|
||||
|
@ -1082,7 +1090,7 @@ int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc)
|
|||
uuid = (struct bt_mesh_uuid *)svc->attrs[0].user_data;
|
||||
if (uuid && uuid->type == BLE_MESH_UUID_TYPE_16) {
|
||||
uuid_16 = (struct bt_mesh_uuid_16 *)uuid;
|
||||
BT_DBG("%s, type 0x%02x, val 0x%04x", __func__, uuid_16->uuid.type, uuid_16->val);
|
||||
BT_DBG("service start, type 0x%02x, val 0x%04x", uuid_16->uuid.type, uuid_16->val);
|
||||
if (uuid_16->val == BLE_MESH_UUID_MESH_PROXY_VAL) {
|
||||
BTA_GATTS_SendServiceChangeIndication(bt_mesh_gatts_if, bt_mesh_gatts_addr);
|
||||
}
|
||||
|
@ -1137,7 +1145,7 @@ u16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn)
|
|||
}
|
||||
}
|
||||
|
||||
BT_ERR("%s, Conn is not found", __func__);
|
||||
BT_ERR("Conn %p not found", conn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1158,21 +1166,21 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid)
|
|||
|
||||
if (!addr || !memcmp(addr->val, zero, BLE_MESH_ADDR_LEN) ||
|
||||
(addr->type > BLE_ADDR_RANDOM)) {
|
||||
BT_ERR("%s, Invalid remote address", __func__);
|
||||
BT_ERR("Invalid remote address");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (service_uuid != BLE_MESH_UUID_MESH_PROV_VAL &&
|
||||
service_uuid != BLE_MESH_UUID_MESH_PROXY_VAL) {
|
||||
BT_ERR("%s, Invalid service uuid 0x%04x", __func__, service_uuid);
|
||||
BT_ERR("Invalid service uuid 0x%04x", service_uuid);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Check if already creating connection with the device */
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
|
||||
if (!memcmp(bt_mesh_gattc_info[i].addr.val, addr->val, BLE_MESH_ADDR_LEN)) {
|
||||
BT_WARN("%s, Already create connection with %s",
|
||||
__func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN));
|
||||
BT_WARN("Already create connection with %s",
|
||||
bt_hex(addr->val, BLE_MESH_ADDR_LEN));
|
||||
return -EALREADY;
|
||||
}
|
||||
}
|
||||
|
@ -1190,7 +1198,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid)
|
|||
}
|
||||
|
||||
if (i == ARRAY_SIZE(bt_mesh_gattc_info)) {
|
||||
BT_WARN("%s, gattc info is full", __func__);
|
||||
BT_WARN("gattc info is full");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -1199,7 +1207,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid)
|
|||
bt_mesh_atomic_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING);
|
||||
}
|
||||
|
||||
BT_DBG("%s, create conn with %s", __func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN));
|
||||
BT_DBG("Create conn with %s", bt_hex(addr->val, BLE_MESH_ADDR_LEN));
|
||||
|
||||
/* Min_interval: 250ms
|
||||
* Max_interval: 250ms
|
||||
|
@ -1240,7 +1248,8 @@ u16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr,
|
||||
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 = 0U;
|
||||
|
@ -1256,7 +1265,7 @@ int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, const struct bt_mesh_g
|
|||
}
|
||||
}
|
||||
|
||||
BT_ERR("%s, Conn is not found", __func__);
|
||||
BT_ERR("Conn %p not found", conn);
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
|
@ -1281,7 +1290,7 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn)
|
|||
}
|
||||
}
|
||||
|
||||
BT_ERR("%s, Conn is not found", __func__);
|
||||
BT_ERR("Conn %p not found", conn);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1366,7 +1375,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
}
|
||||
|
||||
if (conn == NULL) {
|
||||
BT_ERR("%s, Conn handle is not found", __func__);
|
||||
BT_ERR("Conn handle 0x%04x not found", handle);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1506,12 +1515,12 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
}
|
||||
|
||||
if (conn == NULL) {
|
||||
BT_ERR("%s, Conn handle is not found", __func__);
|
||||
BT_ERR("Conn handle 0x%04x not found", handle);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bt_mesh_gattc_info[i].ccc_handle != p_data->write.handle) {
|
||||
BT_WARN("%s, gattc ccc_handle is not matched", __func__);
|
||||
BT_WARN("gattc ccc_handle not matched");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
}
|
||||
|
@ -1520,7 +1529,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->prov_write_descr != NULL) {
|
||||
len = bt_mesh_gattc_conn_cb->prov_write_descr(&bt_mesh_gattc_info[i].addr, &bt_mesh_gattc_info[i].conn);
|
||||
if (len < 0) {
|
||||
BT_ERR("%s, prov_write_descr failed", __func__);
|
||||
BT_ERR("prov_write_descr failed");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
}
|
||||
|
@ -1530,7 +1539,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->proxy_write_descr != NULL) {
|
||||
len = bt_mesh_gattc_conn_cb->proxy_write_descr(&bt_mesh_gattc_info[i].addr, &bt_mesh_gattc_info[i].conn);
|
||||
if (len < 0) {
|
||||
BT_ERR("%s, proxy_write_descr failed", __func__);
|
||||
BT_ERR("proxy_write_descr failed");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
}
|
||||
|
@ -1558,14 +1567,14 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
}
|
||||
|
||||
if (conn == NULL) {
|
||||
BT_ERR("%s, Conn handle is not found", __func__);
|
||||
BT_ERR("Conn handle 0x%04x not found", handle);
|
||||
return;
|
||||
}
|
||||
|
||||
if (memcmp(bt_mesh_gattc_info[i].addr.val, p_data->notify.bda, BLE_MESH_ADDR_LEN) ||
|
||||
bt_mesh_gattc_info[i].data_out_handle != p_data->notify.handle ||
|
||||
p_data->notify.is_notify == false) {
|
||||
BT_ERR("%s, Notification error", __func__);
|
||||
BT_ERR("Notification error");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
}
|
||||
|
@ -1575,7 +1584,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
len = bt_mesh_gattc_conn_cb->prov_notify(&bt_mesh_gattc_info[i].conn,
|
||||
p_data->notify.value, p_data->notify.len);
|
||||
if (len < 0) {
|
||||
BT_ERR("%s, prov_notify failed", __func__);
|
||||
BT_ERR("prov_notify failed");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
}
|
||||
|
@ -1585,7 +1594,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
len = bt_mesh_gattc_conn_cb->proxy_notify(&bt_mesh_gattc_info[i].conn,
|
||||
p_data->notify.value, p_data->notify.len);
|
||||
if (len < 0) {
|
||||
BT_ERR("%s, proxy_notify failed", __func__);
|
||||
BT_ERR("proxy_notify failed");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
}
|
||||
|
@ -1609,7 +1618,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
if (!bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) {
|
||||
tBTM_STATUS status = BTM_BleScan(true, 0, bt_mesh_scan_results_cb, NULL, NULL);
|
||||
if (status != BTM_SUCCESS && status != BTM_CMD_STARTED) {
|
||||
BT_ERR("%s, Invalid scan status %d", __func__, status);
|
||||
BT_ERR("Invalid scan status %d", status);
|
||||
break;
|
||||
}
|
||||
bt_mesh_atomic_set_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING);
|
||||
|
@ -1622,7 +1631,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
BT_DBG("BTA_GATTC_CONNECT_EVT");
|
||||
|
||||
if (bt_mesh_gattc_if != p_data->connect.client_if) {
|
||||
BT_ERR("%s, gattc_if & connect_if don't match", __func__);
|
||||
BT_ERR("gattc_if & connect_if mismatch");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1641,7 +1650,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
BT_DBG("BTA_GATTC_DISCONNECT_EVT");
|
||||
|
||||
if (bt_mesh_gattc_if != p_data->disconnect.client_if) {
|
||||
BT_ERR("%s, gattc_if & disconnect_if don't match", __func__);
|
||||
BT_ERR("gattc_if & disconnect_if mismatch");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1800,7 +1809,7 @@ int bt_mesh_rand(void *buf, size_t len)
|
|||
memcpy(buf + i * sizeof(u32_t), &rand, sizeof(u32_t));
|
||||
}
|
||||
|
||||
BT_DBG("%s, rand: %s", __func__, bt_hex(buf, len));
|
||||
BT_DBG("Rand %s", bt_hex(buf, len));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2002,13 +2011,13 @@ int bt_mesh_update_exceptional_list(u8_t sub_code, u8_t type, void *info)
|
|||
|
||||
if (type == BLE_MESH_EXCEP_INFO_MESH_LINK_ID) {
|
||||
if (!info) {
|
||||
BT_ERR("%s, NULL Provisioning Link ID", __func__);
|
||||
BT_ERR("Invalid Provisioning Link ID");
|
||||
return -EINVAL;
|
||||
}
|
||||
sys_memcpy_swap(value, info, sizeof(u32_t));
|
||||
}
|
||||
|
||||
BT_DBG("%s, %s type 0x%x", __func__, sub_code ? "Remove" : "Add", type);
|
||||
BT_DBG("%s exceptional list, type 0x%02x", sub_code ? "Remove" : "Add", type);
|
||||
|
||||
/* The parameter "device_info" can't be NULL in the API */
|
||||
BLE_MESH_BTM_CHECK_STATUS(BTM_UpdateBleDuplicateExceptionalList(sub_code, type, value, NULL));
|
||||
|
|
|
@ -151,7 +151,7 @@ static void cfg_client_cancel(struct bt_mesh_model *model,
|
|||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, &buf, true);
|
||||
if (!node) {
|
||||
BT_DBG("Unexpected config status message 0x%x", ctx->recv_op);
|
||||
BT_DBG("Unexpected Config Status 0x%04x", ctx->recv_op);
|
||||
} else {
|
||||
switch (node->opcode) {
|
||||
case OP_BEACON_GET:
|
||||
|
@ -266,7 +266,7 @@ static void comp_data_status(struct bt_mesh_model *model,
|
|||
status.page = net_buf_simple_pull_u8(buf);
|
||||
status.comp_data = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status.comp_data) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ static void mod_sub_list(struct bt_mesh_model *model,
|
|||
|
||||
list.addr = bt_mesh_alloc_buf(buf->len);
|
||||
if (!list.addr) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(list.addr, buf->data, buf->len);
|
||||
|
@ -535,7 +535,7 @@ static void net_key_list(struct bt_mesh_model *model,
|
|||
|
||||
list.net_idx = bt_mesh_alloc_buf(buf->len);
|
||||
if (!list.net_idx) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(list.net_idx, buf->data, buf->len);
|
||||
|
@ -557,7 +557,7 @@ static void app_key_list(struct bt_mesh_model *model,
|
|||
list.net_idx = net_buf_simple_pull_le16(buf);
|
||||
list.app_idx = bt_mesh_alloc_buf(buf->len);
|
||||
if (!list.app_idx) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(list.app_idx, buf->data, buf->len);
|
||||
|
@ -603,7 +603,7 @@ static void mod_app_list(struct bt_mesh_model *model,
|
|||
|
||||
list.app_idx = bt_mesh_alloc_buf(buf->len);
|
||||
if (!list.app_idx) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(list.app_idx, buf->data, buf->len);
|
||||
|
|
|
@ -50,7 +50,7 @@ static int comp_add_elem(struct net_buf_simple *buf, struct bt_mesh_elem *elem,
|
|||
|
||||
if (net_buf_simple_tailroom(buf) <
|
||||
4 + (elem->model_count * 2U) + (elem->vnd_model_count * 4U)) {
|
||||
BT_ERR("%s, Too large device composition", __func__);
|
||||
BT_ERR("Too large device composition");
|
||||
return -E2BIG;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ static void dev_comp_data_get(struct bt_mesh_model *model,
|
|||
|
||||
sdu = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, COMP_DATA_MAX_LEN));
|
||||
if (!sdu) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -142,13 +142,13 @@ static void dev_comp_data_get(struct bt_mesh_model *model,
|
|||
|
||||
net_buf_simple_add_u8(sdu, page);
|
||||
if (comp_get_page_0(sdu) < 0) {
|
||||
BT_ERR("%s, Unable to get composition page 0", __func__);
|
||||
BT_ERR("Unable to get composition page 0");
|
||||
bt_mesh_free_buf(sdu);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, sdu, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Composition Data Status", __func__);
|
||||
BT_ERR("Unable to send Config Composition Data Status");
|
||||
}
|
||||
|
||||
bt_mesh_free_buf(sdu);
|
||||
|
@ -457,7 +457,7 @@ static void app_key_add(struct bt_mesh_model *model,
|
|||
key_idx_pack(&msg, key_net_idx, key_app_idx);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config AppKey Status", __func__);
|
||||
BT_ERR("Unable to send Config AppKey Status");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -492,7 +492,7 @@ static void app_key_update(struct bt_mesh_model *model,
|
|||
key_idx_pack(&msg, key_net_idx, key_app_idx);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config AppKey Status", __func__);
|
||||
BT_ERR("Unable to send Config AppKey Status");
|
||||
}
|
||||
|
||||
if (status == STATUS_SUCCESS) {
|
||||
|
@ -577,7 +577,7 @@ send_status:
|
|||
key_idx_pack(&msg, key_net_idx, key_app_idx);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config AppKey Status", __func__);
|
||||
BT_ERR("Unable to send Config AppKey Status");
|
||||
}
|
||||
|
||||
if (status == STATUS_SUCCESS) {
|
||||
|
@ -603,7 +603,7 @@ static void app_key_get(struct bt_mesh_model *model,
|
|||
|
||||
get_idx = net_buf_simple_pull_le16(buf);
|
||||
if (get_idx > 0xfff) {
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, get_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", get_idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -647,7 +647,7 @@ static void app_key_get(struct bt_mesh_model *model,
|
|||
|
||||
send_status:
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config AppKey List", __func__);
|
||||
BT_ERR("Unable to send Config AppKey List");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -665,7 +665,7 @@ static void beacon_get(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_beacon_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Beacon Status", __func__);
|
||||
BT_ERR("Unable to send Config Beacon Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -705,7 +705,7 @@ static void beacon_set(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_beacon_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Beacon Status", __func__);
|
||||
BT_ERR("Unable to send Config Beacon Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -723,7 +723,7 @@ static void default_ttl_get(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_default_ttl_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Default TTL Status", __func__);
|
||||
BT_ERR("Unable to send Config Default TTL Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -757,7 +757,7 @@ static void default_ttl_set(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_default_ttl_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Default TTL Status", __func__);
|
||||
BT_ERR("Unable to send Config Default TTL Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -770,7 +770,7 @@ static void send_gatt_proxy_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_gatt_proxy_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config GATT Proxy Status", __func__);
|
||||
BT_ERR("Unable to send Config GATT Proxy Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -844,7 +844,7 @@ static void net_transmit_get(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_net_transmit_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Network Transmit Status", __func__);
|
||||
BT_ERR("Unable to send Config Network Transmit Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -877,7 +877,7 @@ static void net_transmit_set(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_net_transmit_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Network Transmit Status", __func__);
|
||||
BT_ERR("Unable to send Config Network Transmit Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -896,7 +896,7 @@ static void relay_get(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_relay_retransmit_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Relay Status", __func__);
|
||||
BT_ERR("Unable to send Config Relay Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -947,7 +947,7 @@ static void relay_set(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_relay_retransmit_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Relay Status", __func__);
|
||||
BT_ERR("Unable to send Config Relay Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -985,7 +985,7 @@ static void send_mod_pub_status(struct bt_mesh_model *cfg_mod,
|
|||
}
|
||||
|
||||
if (bt_mesh_model_send(cfg_mod, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Model Publication Status", __func__);
|
||||
BT_ERR("Unable to send Config Model Publication Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1001,7 +1001,7 @@ static void mod_pub_get(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1049,7 +1049,7 @@ static void mod_pub_set(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1060,7 +1060,7 @@ static void mod_pub_set(struct bt_mesh_model *model,
|
|||
|
||||
pub_ttl = net_buf_simple_pull_u8(buf);
|
||||
if (pub_ttl > BLE_MESH_TTL_MAX && pub_ttl != BLE_MESH_TTL_DEFAULT) {
|
||||
BT_ERR("%s, Invalid TTL value 0x%02x", __func__, pub_ttl);
|
||||
BT_ERR("Invalid TTL value 0x%02x", pub_ttl);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1232,7 +1232,7 @@ static size_t mod_sub_list_clear(struct bt_mesh_model *mod)
|
|||
if (label_uuid) {
|
||||
va_del(label_uuid, NULL);
|
||||
} else {
|
||||
BT_ERR("%s, Label UUID not found", __func__);
|
||||
BT_ERR("Label UUID not found");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1253,7 +1253,7 @@ static void mod_pub_va_set(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1263,7 +1263,7 @@ static void mod_pub_va_set(struct bt_mesh_model *model,
|
|||
pub_app_idx &= BIT_MASK(12);
|
||||
pub_ttl = net_buf_simple_pull_u8(buf);
|
||||
if (pub_ttl > BLE_MESH_TTL_MAX && pub_ttl != BLE_MESH_TTL_DEFAULT) {
|
||||
BT_ERR("%s, Invalid TTL value 0x%02x", __func__, pub_ttl);
|
||||
BT_ERR("Invalid TTL value 0x%02x", pub_ttl);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1333,7 +1333,7 @@ static void mod_pub_va_set(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1393,7 +1393,7 @@ static void send_mod_sub_status(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Model Subscription Status", __func__);
|
||||
BT_ERR("Unable to send Config Model Subscription Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1411,7 +1411,7 @@ static void mod_sub_add(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1497,7 +1497,7 @@ static void mod_sub_del(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1572,7 +1572,7 @@ static void mod_sub_overwrite(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1641,7 +1641,7 @@ static void mod_sub_del_all(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1693,7 +1693,7 @@ static void mod_sub_get(struct bt_mesh_model *model,
|
|||
|
||||
addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1732,7 +1732,7 @@ static void mod_sub_get(struct bt_mesh_model *model,
|
|||
|
||||
send_list:
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Model Subscription List", __func__);
|
||||
BT_ERR("Unable to send Config Model Subscription List");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1749,7 +1749,7 @@ static void mod_sub_get_vnd(struct bt_mesh_model *model,
|
|||
|
||||
addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1792,7 +1792,7 @@ static void mod_sub_get_vnd(struct bt_mesh_model *model,
|
|||
|
||||
send_list:
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Vendor Model Subscription List", __func__);
|
||||
BT_ERR("Unable to send Config Vendor Model Subscription List");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1812,7 +1812,7 @@ static void mod_sub_va_add(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1889,7 +1889,7 @@ static void mod_sub_va_del(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1956,7 +1956,7 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2021,7 +2021,7 @@ static void mod_sub_va_add(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2062,7 +2062,7 @@ static void mod_sub_va_del(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2101,7 +2101,7 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2141,7 +2141,7 @@ static void send_net_key_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_le16(&msg, idx);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config NetKey Status", __func__);
|
||||
BT_ERR("Unable to send Config NetKey Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2155,7 +2155,7 @@ static void net_key_add(struct bt_mesh_model *model,
|
|||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
if (idx > 0xfff) {
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2211,7 +2211,7 @@ static void net_key_add(struct bt_mesh_model *model,
|
|||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
|
||||
sub->node_id = BLE_MESH_NODE_IDENTITY_STOPPED;
|
||||
bt_mesh_proxy_beacon_send(sub);
|
||||
bt_mesh_proxy_server_beacon_send(sub);
|
||||
bt_mesh_adv_update();
|
||||
} else {
|
||||
sub->node_id = BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED;
|
||||
|
@ -2236,7 +2236,7 @@ static void net_key_update(struct bt_mesh_model *model,
|
|||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
if (idx > 0xfff) {
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2323,7 +2323,7 @@ static void net_key_del(struct bt_mesh_model *model,
|
|||
|
||||
del_idx = net_buf_simple_pull_le16(buf);
|
||||
if (del_idx > 0xfff) {
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, del_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", del_idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2392,7 +2392,7 @@ static void net_key_get(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config NetKey List", __func__);
|
||||
BT_ERR("Unable to send Config NetKey List");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2411,7 +2411,7 @@ static void node_identity_get(struct bt_mesh_model *model,
|
|||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
if (idx > 0xfff) {
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2430,7 +2430,7 @@ static void node_identity_get(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, node_id);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Node Identity Status", __func__);
|
||||
BT_ERR("Unable to send Config Node Identity Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2449,13 +2449,13 @@ static void node_identity_set(struct bt_mesh_model *model,
|
|||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
if (idx > 0xfff) {
|
||||
BT_WARN("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
BT_WARN("Invalid NetKeyIndex 0x%04x", idx);
|
||||
return;
|
||||
}
|
||||
|
||||
node_id = net_buf_simple_pull_u8(buf);
|
||||
if (node_id != 0x00 && node_id != 0x01) {
|
||||
BT_WARN("%s, Invalid Node ID value 0x%02x", __func__, node_id);
|
||||
BT_WARN("Invalid Node ID value 0x%02x", node_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2472,9 +2472,9 @@ static void node_identity_set(struct bt_mesh_model *model,
|
|||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
|
||||
if (node_id) {
|
||||
bt_mesh_proxy_identity_start(sub);
|
||||
bt_mesh_proxy_server_identity_start(sub);
|
||||
} else {
|
||||
bt_mesh_proxy_identity_stop(sub);
|
||||
bt_mesh_proxy_server_identity_stop(sub);
|
||||
}
|
||||
bt_mesh_adv_update();
|
||||
}
|
||||
|
@ -2482,7 +2482,7 @@ static void node_identity_set(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Node Identity Status", __func__);
|
||||
BT_ERR("Unable to send Config Node Identity Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2517,7 +2517,7 @@ static void mod_app_bind(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2540,7 +2540,7 @@ static void mod_app_bind(struct bt_mesh_model *model,
|
|||
|
||||
/* Configuration Server only allows device key based access */
|
||||
if (model == mod) {
|
||||
BT_ERR("%s, Client tried to bind AppKey to Configuration Model", __func__);
|
||||
BT_ERR("Client tried to bind AppKey to Configuration Model");
|
||||
status = STATUS_CANNOT_BIND;
|
||||
goto send_status;
|
||||
}
|
||||
|
@ -2553,7 +2553,7 @@ send_status:
|
|||
mod_id);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Model App Bind Status", __func__);
|
||||
BT_ERR("Unable to send Config Model App Bind Status");
|
||||
}
|
||||
|
||||
if (status == STATUS_SUCCESS) {
|
||||
|
@ -2580,7 +2580,7 @@ static void mod_app_unbind(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2609,7 +2609,7 @@ send_status:
|
|||
mod_id);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Model App Unbind Status", __func__);
|
||||
BT_ERR("Unable to send Config Model App Unbind Status");
|
||||
}
|
||||
|
||||
if (status == STATUS_SUCCESS) {
|
||||
|
@ -2642,7 +2642,7 @@ static void mod_app_get(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2693,7 +2693,7 @@ send_list:
|
|||
}
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Model Application List", __func__);
|
||||
BT_ERR("Unable to send Config Model Application List");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2714,7 +2714,7 @@ static void node_reset(struct bt_mesh_model *model,
|
|||
* send it later.
|
||||
*/
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Node Reset Status", __func__);
|
||||
BT_ERR("Unable to send Config Node Reset Status");
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE)) {
|
||||
|
@ -2732,7 +2732,7 @@ static void send_friend_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, cfg->frnd);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Friend Status", __func__);
|
||||
BT_ERR("Unable to send Config Friend Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2832,7 +2832,7 @@ send_rsp:
|
|||
net_buf_simple_add_le24(&msg, timeout);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config LPN PollTimeout Status", __func__);
|
||||
BT_ERR("Unable to send Config LPN PollTimeout Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2849,7 +2849,7 @@ static void send_krp_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, phase);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Key Refresh Phase Status", __func__);
|
||||
BT_ERR("Unable to send Config Key Refresh Phase Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2861,7 +2861,7 @@ static void krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
if (idx > 0xfff) {
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2887,7 +2887,7 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|||
phase = net_buf_simple_pull_u8(buf);
|
||||
|
||||
if (idx > 0xfff) {
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2904,7 +2904,7 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|||
if (phase < BLE_MESH_KR_PHASE_2 || phase > BLE_MESH_KR_PHASE_3 ||
|
||||
(sub->kr_phase == BLE_MESH_KR_NORMAL &&
|
||||
phase == BLE_MESH_KR_PHASE_2)) {
|
||||
BT_WARN("%s, Prohibited transition %u -> %u", __func__, sub->kr_phase, phase);
|
||||
BT_WARN("Prohibited transition %u -> %u", sub->kr_phase, phase);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3007,7 +3007,7 @@ static void hb_pub_send_status(struct bt_mesh_model *model,
|
|||
|
||||
send:
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Heartbeat Publication Status", __func__);
|
||||
BT_ERR("Unable to send Config Heartbeat Publication Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3049,7 +3049,7 @@ static void heartbeat_pub_set(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
if (param->ttl > BLE_MESH_TTL_MAX && param->ttl != BLE_MESH_TTL_DEFAULT) {
|
||||
BT_ERR("%s, Invalid TTL value 0x%02x", __func__, param->ttl);
|
||||
BT_ERR("Invalid TTL value 0x%02x", param->ttl);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3057,7 +3057,7 @@ static void heartbeat_pub_set(struct bt_mesh_model *model,
|
|||
|
||||
idx = sys_le16_to_cpu(param->net_idx);
|
||||
if (idx > 0xfff) {
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3146,7 +3146,7 @@ static void hb_sub_send_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, cfg->hb_sub.max_hops);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Config Heartbeat Subscription Status", __func__);
|
||||
BT_ERR("Unable to send Config Heartbeat Subscription Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3305,8 +3305,8 @@ static void hb_publish(struct k_work *work)
|
|||
|
||||
sub = bt_mesh_subnet_get(cfg->hb_pub.net_idx);
|
||||
if (!sub) {
|
||||
BT_ERR("%s, No matching subnet for idx 0x%02x",
|
||||
__func__, cfg->hb_pub.net_idx);
|
||||
BT_ERR("No matching subnet for idx 0x%04x",
|
||||
cfg->hb_pub.net_idx);
|
||||
cfg->hb_pub.dst = BLE_MESH_ADDR_UNASSIGNED;
|
||||
return;
|
||||
}
|
||||
|
@ -3349,12 +3349,12 @@ int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
||||
|
||||
if (!cfg) {
|
||||
BT_ERR("%s, No Configuration Server context provided", __func__);
|
||||
BT_ERR("No Configuration Server context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!conf_is_valid(cfg)) {
|
||||
BT_ERR("%s, Invalid values in configuration", __func__);
|
||||
BT_ERR("Invalid values in configuration");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -3389,7 +3389,7 @@ int bt_mesh_cfg_srv_deinit(struct bt_mesh_model *model, bool primary)
|
|||
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
||||
|
||||
if (!cfg) {
|
||||
BT_ERR("%s, No Configuration Server context provided", __func__);
|
||||
BT_ERR("No Configuration Server context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst)
|
||||
{
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(dst)) {
|
||||
BT_ERR("%s, Not a unicast address 0x%04x", __func__, dst);
|
||||
BT_ERR("Invalid unicast address 0x%04x", dst);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ u8_t bt_mesh_fast_prov_net_key_add(const u8_t net_key[16])
|
|||
|
||||
err = bt_mesh_provisioner_local_net_key_add(net_key, &net_idx);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to add NetKey 0x%04x", __func__, net_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx);
|
||||
return 0x01; /* status: Add NetKey failed */
|
||||
};
|
||||
|
||||
|
@ -128,7 +128,7 @@ const u8_t *bt_mesh_fast_prov_net_key_get(u16_t net_idx)
|
|||
|
||||
sub = bt_mesh_fast_prov_subnet_get(net_idx);
|
||||
if (!sub) {
|
||||
BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx)
|
|||
|
||||
key = bt_mesh_fast_prov_app_key_find(app_idx);
|
||||
if (!key) {
|
||||
BT_ERR("%s, AppKey Index 0x%03x not exists", __func__, app_idx);
|
||||
BT_ERR("Invalid AppKeyIndex 0x%04x", app_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ u8_t bt_mesh_set_fast_prov_action(u8_t action)
|
|||
bt_mesh_beacon_disable();
|
||||
}
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
|
||||
bt_mesh_provisioner_pb_gatt_enable();
|
||||
bt_mesh_proxy_client_prov_enable();
|
||||
}
|
||||
bt_mesh_provisioner_set_primary_elem_addr(bt_mesh_primary_addr());
|
||||
bt_mesh_provisioner_set_prov_bearer(BLE_MESH_PROV_ADV, false);
|
||||
|
@ -173,7 +173,7 @@ u8_t bt_mesh_set_fast_prov_action(u8_t action)
|
|||
bt_mesh_atomic_or(bt_mesh.flags, BIT(BLE_MESH_PROVISIONER) | BIT(BLE_MESH_VALID_PROV));
|
||||
} else {
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
|
||||
bt_mesh_provisioner_pb_gatt_disable();
|
||||
bt_mesh_proxy_client_prov_disable();
|
||||
}
|
||||
if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) {
|
||||
bt_mesh_beacon_enable();
|
||||
|
|
|
@ -254,7 +254,7 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
struct bt_mesh_ctl_friend_clear_confirm cfm = {0};
|
||||
|
||||
if (buf->len < sizeof(*msg)) {
|
||||
BT_WARN("%s, Too short Friend Clear", __func__);
|
||||
BT_WARN("Too short Friend Clear (len %d)", buf->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
|
||||
frnd = bt_mesh_friend_find(rx->sub->net_idx, lpn_addr, false, false);
|
||||
if (!frnd) {
|
||||
BT_WARN("%s, No matching LPN addr 0x%04x", __func__, lpn_addr);
|
||||
BT_WARN("No matching LPN addr 0x%04x", lpn_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -276,8 +276,8 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
* 65536, is in the range 0 to 255 inclusive.
|
||||
*/
|
||||
if (lpn_counter - frnd->lpn_counter > 255) {
|
||||
BT_WARN("%s, LPN Counter out of range (old %u new %u)",
|
||||
__func__, frnd->lpn_counter, lpn_counter);
|
||||
BT_WARN("LPN Counter out of range (old %u new %u)",
|
||||
frnd->lpn_counter, lpn_counter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ static void friend_sub_add(struct bt_mesh_friend *frnd, u16_t addr)
|
|||
}
|
||||
}
|
||||
|
||||
BT_WARN("%s, No space in friend subscription list", __func__);
|
||||
BT_WARN("No space in friend subscription list");
|
||||
}
|
||||
|
||||
static void friend_sub_rem(struct bt_mesh_friend *frnd, u16_t addr)
|
||||
|
@ -588,7 +588,7 @@ static void enqueue_sub_cfm(struct bt_mesh_friend *frnd, u8_t xact)
|
|||
|
||||
buf = encode_friend_ctl(frnd, TRANS_CTL_OP_FRIEND_SUB_CFM, &sdu);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Unable to encode Subscription List Confirmation", __func__);
|
||||
BT_ERR("Unable to encode Subscription List Confirmation");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -619,18 +619,18 @@ int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx,
|
|||
u8_t xact = 0U;
|
||||
|
||||
if (buf->len < BLE_MESH_FRIEND_SUB_MIN_LEN) {
|
||||
BT_WARN("%s, Too short Friend Subscription Add", __func__);
|
||||
BT_WARN("Too short Friend Subscription Add (len %d)", buf->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, true);
|
||||
if (!frnd) {
|
||||
BT_WARN("%s, No matching LPN addr 0x%04x", __func__, rx->ctx.addr);
|
||||
BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (frnd->pending_buf) {
|
||||
BT_WARN("%s, Previous buffer not yet sent!", __func__);
|
||||
BT_WARN("Previous buffer not yet sent!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -654,18 +654,18 @@ int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx,
|
|||
u8_t xact = 0U;
|
||||
|
||||
if (buf->len < BLE_MESH_FRIEND_SUB_MIN_LEN) {
|
||||
BT_WARN("%s, Too short Friend Subscription Remove", __func__);
|
||||
BT_WARN("Too short Friend Subscription Remove (len %d)", buf->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, true);
|
||||
if (!frnd) {
|
||||
BT_WARN("%s, No matching LPN addr 0x%04x", __func__, rx->ctx.addr);
|
||||
BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (frnd->pending_buf) {
|
||||
BT_WARN("%s, Previous buffer not yet sent!", __func__);
|
||||
BT_WARN("Previous buffer not yet sent!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -694,7 +694,7 @@ static void enqueue_update(struct bt_mesh_friend *frnd, u8_t md)
|
|||
|
||||
buf = encode_update(frnd, md);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Unable to encode Friend Update", __func__);
|
||||
BT_ERR("Unable to encode Friend Update");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -708,23 +708,23 @@ int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
struct bt_mesh_friend *frnd = NULL;
|
||||
|
||||
if (buf->len < sizeof(*msg)) {
|
||||
BT_WARN("%s, Too short Friend Poll", __func__);
|
||||
BT_WARN("Too short Friend Poll (len %d)", buf->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, false);
|
||||
if (!frnd) {
|
||||
BT_WARN("%s, No matching LPN addr 0x%04x", __func__, rx->ctx.addr);
|
||||
BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (msg->fsn & ~1) {
|
||||
BT_WARN("%s, Prohibited (non-zero) padding bits", __func__);
|
||||
BT_WARN("Prohibited (non-zero) padding bits");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (frnd->pending_buf) {
|
||||
BT_WARN("%s, Previous buffer not yet sent!", __func__);
|
||||
BT_WARN("Previous buffer not yet sent!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -856,27 +856,27 @@ int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx,
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (buf->len < sizeof(*msg)) {
|
||||
BT_WARN("%s, Too short Friend Clear Confirm", __func__);
|
||||
BT_WARN("Too short Friend Clear Confirm (len %d)", buf->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
frnd = find_clear(rx->ctx.addr);
|
||||
if (!frnd) {
|
||||
BT_WARN("%s, No pending clear procedure for 0x%02x", __func__, rx->ctx.addr);
|
||||
BT_WARN("No pending clear procedure for 0x%02x", rx->ctx.addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
lpn_addr = sys_be16_to_cpu(msg->lpn_addr);
|
||||
if (lpn_addr != frnd->lpn) {
|
||||
BT_WARN("%s, LPN address mismatch (0x%04x != 0x%04x)",
|
||||
__func__, lpn_addr, frnd->lpn);
|
||||
BT_WARN("LPN address mismatch (0x%04x != 0x%04x)",
|
||||
lpn_addr, frnd->lpn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
lpn_counter = sys_be16_to_cpu(msg->lpn_counter);
|
||||
if (lpn_counter != frnd->lpn_counter) {
|
||||
BT_WARN("%s, LPN counter mismatch (0x%04x != 0x%04x)",
|
||||
__func__, lpn_counter, frnd->lpn_counter);
|
||||
BT_WARN("LPN counter mismatch (0x%04x != 0x%04x)",
|
||||
lpn_counter, frnd->lpn_counter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -906,7 +906,7 @@ static void enqueue_offer(struct bt_mesh_friend *frnd, s8_t rssi)
|
|||
|
||||
buf = encode_friend_ctl(frnd, TRANS_CTL_OP_FRIEND_OFFER, &sdu);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Unable to encode Friend Offer", __func__);
|
||||
BT_ERR("Unable to encode Friend Offer");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -964,47 +964,47 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
int i;
|
||||
|
||||
if (buf->len < sizeof(*msg)) {
|
||||
BT_WARN("%s, Too short Friend Request", __func__);
|
||||
BT_WARN("Too short Friend Request (len %d)", buf->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (msg->recv_delay <= 0x09) {
|
||||
BT_WARN("%s, Prohibited ReceiveDelay (0x%02x)", __func__, msg->recv_delay);
|
||||
BT_WARN("Prohibited ReceiveDelay (0x%02x)", msg->recv_delay);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
poll_to = sys_get_be24(msg->poll_to);
|
||||
|
||||
if (poll_to <= 0x000009 || poll_to >= 0x34bc00) {
|
||||
BT_WARN("%s, Prohibited PollTimeout (0x%06x)", __func__, poll_to);
|
||||
BT_WARN("Prohibited PollTimeout (0x%06x)", poll_to);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (msg->num_elem == 0x00) {
|
||||
BT_WARN("%s, Prohibited NumElements value (0x00)", __func__);
|
||||
BT_WARN("Prohibited NumElements value (0x00)");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(rx->ctx.addr + msg->num_elem - 1)) {
|
||||
BT_WARN("%s, LPN elements stretch outside of unicast range", __func__);
|
||||
BT_WARN("LPN elements stretch outside of unicast range");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!MIN_QUEUE_SIZE_LOG(msg->criteria)) {
|
||||
BT_WARN("%s, Prohibited Minimum Queue Size in Friend Request", __func__);
|
||||
BT_WARN("Prohibited Minimum Queue Size in Friend Request");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE < MIN_QUEUE_SIZE(msg->criteria)) {
|
||||
BT_WARN("%s, We have a too small Friend Queue size (%u < %u)",
|
||||
__func__, CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE,
|
||||
BT_WARN("We have a too small Friend Queue size (%u < %u)",
|
||||
CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE,
|
||||
MIN_QUEUE_SIZE(msg->criteria));
|
||||
return 0;
|
||||
}
|
||||
|
||||
frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, false);
|
||||
if (frnd) {
|
||||
BT_WARN("%s, Existing LPN re-requesting Friendship", __func__);
|
||||
BT_WARN("Existing LPN re-requesting Friendship");
|
||||
friend_clear(frnd, BLE_MESH_FRIENDSHIP_TERMINATE_RECV_FRND_REQ);
|
||||
goto init_friend;
|
||||
}
|
||||
|
@ -1018,7 +1018,7 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
}
|
||||
|
||||
if (!frnd) {
|
||||
BT_WARN("%s, No free Friend contexts for new LPN", __func__);
|
||||
BT_WARN("No free Friend contexts for new LPN");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -1206,14 +1206,14 @@ static void friend_timeout(struct k_work *work)
|
|||
}
|
||||
|
||||
if (frnd->established && !frnd->pending_req) {
|
||||
BT_WARN("%s, Friendship lost with 0x%04x", __func__, frnd->lpn);
|
||||
BT_WARN("Friendship lost with 0x%04x", frnd->lpn);
|
||||
friend_clear(frnd, BLE_MESH_FRIENDSHIP_TERMINATE_POLL_TIMEOUT);
|
||||
return;
|
||||
}
|
||||
|
||||
frnd->last = (void *)sys_slist_get(&frnd->queue);
|
||||
if (!frnd->last) {
|
||||
BT_WARN("%s, Friendship not established with 0x%04x", __func__, frnd->lpn);
|
||||
BT_WARN("Friendship not established with 0x%04x", frnd->lpn);
|
||||
friend_clear(frnd, BLE_MESH_FRIENDSHIP_TERMINATE_ESTABLISH_FAIL);
|
||||
return;
|
||||
}
|
||||
|
@ -1400,7 +1400,7 @@ static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd,
|
|||
|
||||
buf = create_friend_pdu(frnd, &info, sbuf);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Failed to encode Friend buffer", __func__);
|
||||
BT_ERR("Failed to encode Friend buffer");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1437,7 +1437,7 @@ static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd,
|
|||
|
||||
buf = create_friend_pdu(frnd, &info, sbuf);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Failed to encode Friend buffer", __func__);
|
||||
BT_ERR("Failed to encode Friend buffer");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1695,7 +1695,7 @@ void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src,
|
|||
continue;
|
||||
}
|
||||
|
||||
BT_WARN("%s, Clearing incomplete segments for 0x%04x", __func__, src);
|
||||
BT_WARN("Clearing incomplete segments for 0x%04x", src);
|
||||
|
||||
purge_buffers(&seg->queue);
|
||||
seg->seg_count = 0U;
|
||||
|
|
|
@ -106,7 +106,7 @@ static void health_client_cancel(struct bt_mesh_model *model,
|
|||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, &buf, true);
|
||||
if (!node) {
|
||||
BT_DBG("Unexpected health status message 0x%x", ctx->recv_op);
|
||||
BT_DBG("Unexpected Health Status 0x%04x", ctx->recv_op);
|
||||
} else {
|
||||
switch (node->opcode) {
|
||||
case OP_HEALTH_FAULT_GET:
|
||||
|
@ -160,7 +160,7 @@ static void health_fault_status(struct bt_mesh_model *model,
|
|||
status.cid = net_buf_simple_pull_le16(buf);
|
||||
status.fault_array = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status.fault_array) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,7 @@ void bt_mesh_health_cli_timeout_set(s32_t timeout)
|
|||
int bt_mesh_health_cli_set(struct bt_mesh_model *model)
|
||||
{
|
||||
if (!model || !model->user_data) {
|
||||
BT_ERR("%s, No Health Client context for given model", __func__);
|
||||
BT_ERR("No Health Client context for given model");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -451,14 +451,14 @@ int bt_mesh_health_cli_init(struct bt_mesh_model *model, bool primary)
|
|||
|
||||
client = (bt_mesh_health_client_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("%s, No Health Client context provided", __func__);
|
||||
BT_ERR("No Health Client context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!client->internal_data) {
|
||||
internal = bt_mesh_calloc(sizeof(health_internal_data_t));
|
||||
if (!internal) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -493,7 +493,7 @@ int bt_mesh_health_cli_deinit(struct bt_mesh_model *model, bool primary)
|
|||
|
||||
client = (bt_mesh_health_client_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("%s, No Health Client context provided", __func__);
|
||||
BT_ERR("No Health Client context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ static int health_send_fault_status(struct bt_mesh_model *model,
|
|||
|
||||
msg = bt_mesh_alloc_buf(4 + ARRAY_SIZE(srv->test.reg_faults) + 4);
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ static int health_send_fault_status(struct bt_mesh_model *model,
|
|||
|
||||
err = bt_mesh_model_send(model, ctx, msg, NULL, NULL);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send Health Fault Status response", __func__);
|
||||
BT_ERR("Failed to send Health Fault Status response");
|
||||
}
|
||||
|
||||
bt_mesh_free_buf(msg);
|
||||
|
@ -128,13 +128,13 @@ static void health_fault_get(struct bt_mesh_model *model,
|
|||
u16_t company_id = 0U;
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
BT_ERR("No Health Server context provided");
|
||||
return;
|
||||
}
|
||||
|
||||
company_id = net_buf_simple_pull_le16(buf);
|
||||
if (company_id != srv->test.company_id) {
|
||||
BT_ERR("%s, Unknown Company ID 0x%04x", __func__, company_id);
|
||||
BT_ERR("Unknown Company ID 0x%04x", company_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -151,13 +151,13 @@ static void health_fault_clear(struct bt_mesh_model *model,
|
|||
u16_t company_id = 0U;
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
BT_ERR("No Health Server context provided");
|
||||
return;
|
||||
}
|
||||
|
||||
company_id = net_buf_simple_pull_le16(buf);
|
||||
if (company_id != srv->test.company_id) {
|
||||
BT_ERR("%s, Unknown Company ID 0x%04x", __func__, company_id);
|
||||
BT_ERR("Unknown Company ID 0x%04x", company_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -185,19 +185,19 @@ static void health_fault_test(struct bt_mesh_model *model,
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
BT_ERR("No Health Server context provided");
|
||||
return;
|
||||
}
|
||||
|
||||
test_id = net_buf_simple_pull_u8(buf);
|
||||
if (health_is_test_id_exist(model, test_id) == false) {
|
||||
BT_ERR("%s, Unknown Test ID 0x%02x", __func__, test_id);
|
||||
BT_ERR("Unknown Test ID 0x%02x", test_id);
|
||||
return;
|
||||
}
|
||||
|
||||
company_id = net_buf_simple_pull_le16(buf);
|
||||
if (company_id != srv->test.company_id) {
|
||||
BT_ERR("%s, Unknown Company ID 0x%04x", __func__, company_id);
|
||||
BT_ERR("Unknown Company ID 0x%04x", company_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ static void send_attention_status(struct bt_mesh_model *model,
|
|||
u8_t time = 0U;
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
BT_ERR("No Health Server context provided");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ static void send_attention_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, time);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Health Attention Status", __func__);
|
||||
BT_ERR("Unable to send Health Attention Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ static void send_health_period_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, model->pub->period_div);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("%s, Unable to send Health Period Status", __func__);
|
||||
BT_ERR("Unable to send Health Period Status");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ static void health_set_period(struct bt_mesh_model *model,
|
|||
|
||||
period = net_buf_simple_pull_u8(buf);
|
||||
if (period > 15) {
|
||||
BT_WARN("%s, Prohibited period value %u", __func__, period);
|
||||
BT_WARN("Prohibited period value %u", period);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -345,12 +345,12 @@ static size_t health_get_current(struct bt_mesh_model *model,
|
|||
struct bt_mesh_health_srv *srv = model->user_data;
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
BT_ERR("No Health Server context provided");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (msg->size < 4) {
|
||||
BT_ERR("%s, Too small health publication msg size %d", __func__, msg->size);
|
||||
BT_ERR("Too small health publication msg size %d", msg->size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -370,7 +370,7 @@ static int health_pub_update(struct bt_mesh_model *model)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!pub || !pub->msg) {
|
||||
BT_ERR("%s, Invalid health publication context", __func__);
|
||||
BT_ERR("Invalid health publication context");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -390,12 +390,12 @@ int bt_mesh_fault_update(struct bt_mesh_elem *elem)
|
|||
|
||||
model = bt_mesh_model_find(elem, BLE_MESH_MODEL_ID_HEALTH_SRV);
|
||||
if (!model) {
|
||||
BT_ERR("%s, Health Server does not exist", __func__);
|
||||
BT_ERR("Health Server not exists");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!model->pub) {
|
||||
BT_ERR("%s, Health Server has no publication support", __func__);
|
||||
BT_ERR("Health Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ static void attention_off(struct k_work *work)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
BT_ERR("No Health Server context provided");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -443,17 +443,17 @@ int bt_mesh_health_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
return 0;
|
||||
}
|
||||
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
BT_ERR("No Health Server context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (srv->test.id_count == 0 || !srv->test.test_ids) {
|
||||
BT_ERR("%s, No Health Test ID provided", __func__);
|
||||
BT_ERR("No Health Test ID provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!model->pub) {
|
||||
BT_ERR("%s, Health Server has no publication support", __func__);
|
||||
BT_ERR("Health Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -484,17 +484,17 @@ int bt_mesh_health_srv_deinit(struct bt_mesh_model *model, bool primary)
|
|||
return 0;
|
||||
}
|
||||
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
BT_ERR("No Health Server context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (srv->test.id_count == 0 || !srv->test.test_ids) {
|
||||
BT_ERR("%s, No Health Test ID provided", __func__);
|
||||
BT_ERR("No Health Test ID provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!model->pub) {
|
||||
BT_ERR("%s, Health Server has no publication support", __func__);
|
||||
BT_ERR("Health Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -517,7 +517,7 @@ void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)
|
|||
if (!model) {
|
||||
srv = health_srv;
|
||||
if (!srv) {
|
||||
BT_WARN("%s, No Health Server context provided", __func__);
|
||||
BT_WARN("No Health Server context provided");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -525,7 +525,7 @@ void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)
|
|||
} else {
|
||||
srv = model->user_data;
|
||||
if (!srv) {
|
||||
BT_WARN("%s, No Health Server context provided", __func__);
|
||||
BT_WARN("No Health Server context provided");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -712,7 +712,8 @@ ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn,
|
|||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t len, u16_t offset);
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr,
|
||||
ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t buf_len, u16_t offset,
|
||||
const void *value, u16_t value_len);
|
||||
|
||||
|
@ -721,10 +722,11 @@ ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn,
|
|||
void *buf, u16_t len, u16_t offset);
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr, void *buf,
|
||||
u16_t len, u16_t offset);
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t len, u16_t offset);
|
||||
|
||||
int bt_mesh_gatts_notify(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr,
|
||||
int bt_mesh_gatts_notify(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
const void *data, u16_t len);
|
||||
|
||||
u16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn);
|
||||
|
@ -750,7 +752,8 @@ void bt_mesh_gattc_exchange_mtu(u8_t index);
|
|||
|
||||
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,
|
||||
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);
|
||||
|
||||
void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn);
|
||||
|
|
|
@ -23,13 +23,13 @@ static struct bt_mesh_model *find_model(u16_t elem_addr, u16_t cid, u16_t mod_id
|
|||
struct bt_mesh_elem *elem = NULL;
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("%s, Not a unicast address 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("Invalid unicast address 0x%04x", elem_addr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
elem = bt_mesh_elem_find(elem_addr);
|
||||
if (elem == NULL) {
|
||||
BT_ERR("%s, No element found, addr 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("No element found, addr 0x%04x", elem_addr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ static void friend_clear_sent(int err, void *user_data)
|
|||
lpn->req_attempts++;
|
||||
|
||||
if (err) {
|
||||
BT_ERR("%s, Sending Friend Request failed (err %d)", __func__, err);
|
||||
BT_ERR("Sending Friend Clear failed (err %d)", err);
|
||||
lpn_set_state(BLE_MESH_LPN_ENABLED);
|
||||
clear_friendship(false, lpn->disable);
|
||||
return;
|
||||
|
@ -277,7 +277,7 @@ static void friend_req_sent(u16_t duration, int err, void *user_data)
|
|||
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
|
||||
|
||||
if (err) {
|
||||
BT_ERR("%s, Sending Friend Request failed (err %d)", __func__, err);
|
||||
BT_ERR("Sending Friend Request failed (err %d)", err);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_LPN_ESTABLISHMENT)) {
|
||||
bt_mesh_scan_enable();
|
||||
|
@ -339,7 +339,7 @@ static void req_sent(u16_t duration, int err, void *user_data)
|
|||
lpn->sent_req, duration, err, state2str(lpn->state));
|
||||
|
||||
if (err) {
|
||||
BT_ERR("%s, Sending request failed (err %d)", __func__, err);
|
||||
BT_ERR("Sending request failed (err %d)", err);
|
||||
lpn->sent_req = 0U;
|
||||
group_zero(lpn->pending);
|
||||
return;
|
||||
|
@ -699,7 +699,7 @@ static bool sub_update(u8_t op)
|
|||
}
|
||||
|
||||
if (added_count + g >= lpn->queue_size) {
|
||||
BT_WARN("%s, Friend Queue Size exceeded", __func__);
|
||||
BT_WARN("Friend Queue Size exceeded");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
|
|||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
|
||||
if (bt_mesh_proxy_prov_disable(false) == 0) {
|
||||
if (bt_mesh_proxy_server_prov_disable(false) == 0) {
|
||||
pb_gatt_enabled = true;
|
||||
} else {
|
||||
pb_gatt_enabled = false;
|
||||
|
@ -62,7 +62,7 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
|
|||
bt_mesh_atomic_clear_bit(bt_mesh.flags, BLE_MESH_VALID);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && pb_gatt_enabled) {
|
||||
bt_mesh_proxy_prov_enable();
|
||||
bt_mesh_proxy_server_prov_enable();
|
||||
}
|
||||
|
||||
return err;
|
||||
|
@ -114,7 +114,7 @@ void bt_mesh_node_reset(void)
|
|||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
|
||||
bt_mesh_proxy_gatt_disable();
|
||||
bt_mesh_proxy_server_gatt_disable();
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||
|
@ -210,7 +210,7 @@ int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers)
|
|||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
|
||||
(bearers & BLE_MESH_PROV_GATT)) {
|
||||
bt_mesh_proxy_prov_enable();
|
||||
bt_mesh_proxy_server_prov_enable();
|
||||
bt_mesh_adv_update();
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers)
|
|||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
|
||||
(bearers & BLE_MESH_PROV_GATT)) {
|
||||
bt_mesh_proxy_prov_disable(true);
|
||||
bt_mesh_proxy_server_prov_disable(true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -271,7 +271,7 @@ int bt_mesh_suspend(void)
|
|||
err = bt_mesh_scan_disable();
|
||||
if (err) {
|
||||
bt_mesh_atomic_clear_bit(bt_mesh.flags, BLE_MESH_SUSPENDED);
|
||||
BT_WARN("%s, Disabling scanning failed (err %d)", __func__, err);
|
||||
BT_WARN("Disabling scanning failed (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ int bt_mesh_resume(void)
|
|||
|
||||
err = bt_mesh_scan_enable();
|
||||
if (err) {
|
||||
BT_WARN("%s, Re-enabling scanning failed (err %d)", __func__, err);
|
||||
BT_WARN("Re-enabling scanning failed (err %d)", err);
|
||||
bt_mesh_atomic_set_bit(bt_mesh.flags, BLE_MESH_SUSPENDED);
|
||||
return err;
|
||||
}
|
||||
|
@ -356,13 +356,13 @@ int bt_mesh_init(const struct bt_mesh_prov *prov,
|
|||
if ((IS_ENABLED(CONFIG_BLE_MESH_NODE) &&
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) ||
|
||||
IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
|
||||
bt_mesh_proxy_init();
|
||||
bt_mesh_proxy_server_init();
|
||||
}
|
||||
|
||||
if ((IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) &&
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) ||
|
||||
IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) {
|
||||
bt_mesh_proxy_prov_client_init();
|
||||
bt_mesh_proxy_client_init();
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PROV)) {
|
||||
|
@ -427,13 +427,13 @@ int bt_mesh_deinit(struct bt_mesh_deinit_param *param)
|
|||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
|
||||
bt_mesh_proxy_prov_disable(true);
|
||||
bt_mesh_proxy_server_prov_disable(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en()) {
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
|
||||
bt_mesh_provisioner_pb_gatt_disable();
|
||||
bt_mesh_proxy_client_prov_disable();
|
||||
}
|
||||
|
||||
bt_mesh_scan_disable();
|
||||
|
@ -463,13 +463,13 @@ int bt_mesh_deinit(struct bt_mesh_deinit_param *param)
|
|||
if ((IS_ENABLED(CONFIG_BLE_MESH_NODE) &&
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) ||
|
||||
IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
|
||||
bt_mesh_proxy_deinit();
|
||||
bt_mesh_proxy_server_deinit();
|
||||
}
|
||||
|
||||
if ((IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) &&
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) ||
|
||||
IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) {
|
||||
bt_mesh_proxy_prov_client_deinit();
|
||||
bt_mesh_proxy_client_deinit();
|
||||
}
|
||||
|
||||
bt_mesh_gatt_deinit();
|
||||
|
@ -532,7 +532,7 @@ int bt_mesh_provisioner_net_start(bt_mesh_prov_bearer_t bearers)
|
|||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
|
||||
(bearers & BLE_MESH_PROV_GATT)) {
|
||||
bt_mesh_provisioner_pb_gatt_enable();
|
||||
bt_mesh_proxy_client_prov_enable();
|
||||
}
|
||||
|
||||
bt_mesh_atomic_set_bit(bt_mesh.flags, BLE_MESH_VALID_PROV);
|
||||
|
@ -565,13 +565,13 @@ int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers)
|
|||
|
||||
err = bt_mesh_provisioner_set_prov_info();
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to set provisioning info", __func__);
|
||||
BT_ERR("Failed to set provisioning info");
|
||||
return err;
|
||||
}
|
||||
|
||||
err = bt_mesh_provisioner_net_create();
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to create network", __func__);
|
||||
BT_ERR("Failed to create network");
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -608,7 +608,7 @@ int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers)
|
|||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
|
||||
(enable & BLE_MESH_PROV_GATT) &&
|
||||
(bearers & BLE_MESH_PROV_GATT)) {
|
||||
bt_mesh_provisioner_pb_gatt_disable();
|
||||
bt_mesh_proxy_client_prov_disable();
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE,
|
||||
BLE_MESH_EXCEP_INFO_MESH_PROV_ADV, NULL);
|
||||
|
|
|
@ -171,7 +171,7 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys,
|
|||
|
||||
err = bt_mesh_k2(key, p, sizeof(p), &nid, keys->enc, keys->privacy);
|
||||
if (err) {
|
||||
BT_ERR("%s, Unable to generate NID, EncKey & PrivacyKey", __func__);
|
||||
BT_ERR("Unable to generate NID, EncKey & PrivacyKey");
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys,
|
|||
|
||||
err = bt_mesh_k3(key, keys->net_id);
|
||||
if (err) {
|
||||
BT_ERR("%s, Unable to generate Net ID", __func__);
|
||||
BT_ERR("Unable to generate Net ID");
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys,
|
|||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||
err = bt_mesh_identity_key(key, keys->identity);
|
||||
if (err) {
|
||||
BT_ERR("%s, Unable to generate IdentityKey", __func__);
|
||||
BT_ERR("Unable to generate IdentityKey");
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys,
|
|||
|
||||
err = bt_mesh_beacon_key(key, keys->beacon);
|
||||
if (err) {
|
||||
BT_ERR("%s, Unable to generate beacon key", __func__);
|
||||
BT_ERR("Unable to generate beacon key");
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ int friend_cred_set(struct friend_cred *cred, u8_t idx, const u8_t net_key[16])
|
|||
err = bt_mesh_k2(net_key, p, sizeof(p), &cred->cred[idx].nid,
|
||||
cred->cred[idx].enc, cred->cred[idx].privacy);
|
||||
if (err) {
|
||||
BT_ERR("%s, Unable to generate NID, EncKey & PrivacyKey", __func__);
|
||||
BT_ERR("Unable to generate NID, EncKey & PrivacyKey");
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -597,7 +597,7 @@ void bt_mesh_iv_update_test(bool enable)
|
|||
bool bt_mesh_iv_update(void)
|
||||
{
|
||||
if (!bt_mesh_is_provisioned()) {
|
||||
BT_ERR("%s, Not yet provisioned", __func__);
|
||||
BT_ERR("Not yet provisioned");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -622,7 +622,7 @@ void bt_mesh_net_sec_update(struct bt_mesh_subnet *sub)
|
|||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) &&
|
||||
bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED) {
|
||||
bt_mesh_proxy_beacon_send(sub);
|
||||
bt_mesh_proxy_server_beacon_send(sub);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -778,13 +778,13 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf,
|
|||
|
||||
err = bt_mesh_net_obfuscate(buf->data, BLE_MESH_NET_IVI_TX, priv);
|
||||
if (err) {
|
||||
BT_ERR("%s, De-obfuscate failed (err %d)", __func__, err);
|
||||
BT_ERR("De-obfuscate failed (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = bt_mesh_net_decrypt(enc, &buf->b, BLE_MESH_NET_IVI_TX, false);
|
||||
if (err) {
|
||||
BT_ERR("%s, Decrypt failed (err %d)", __func__, err);
|
||||
BT_ERR("Decrypt failed (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -797,18 +797,18 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf,
|
|||
|
||||
err = bt_mesh_net_encrypt(enc, &buf->b, BLE_MESH_NET_IVI_TX, false);
|
||||
if (err) {
|
||||
BT_ERR("%s, Encrypt failed (err %d)", __func__, err);
|
||||
BT_ERR("Encrypt failed (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = bt_mesh_net_obfuscate(buf->data, BLE_MESH_NET_IVI_TX, priv);
|
||||
if (err) {
|
||||
BT_ERR("%s, Obfuscate failed (err %d)", __func__, err);
|
||||
BT_ERR("Obfuscate failed (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) &&
|
||||
bt_mesh_proxy_relay(&buf->b, dst) &&
|
||||
bt_mesh_proxy_server_relay(&buf->b, dst) &&
|
||||
BLE_MESH_ADDR_IS_UNICAST(dst)) {
|
||||
send_cb_finalize(cb, cb_data);
|
||||
return 0;
|
||||
|
@ -838,10 +838,10 @@ int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct net_buf_simple *buf,
|
|||
int err = 0;
|
||||
|
||||
if (ctl && net_buf_simple_tailroom(buf) < BLE_MESH_MIC_LONG) {
|
||||
BT_ERR("%s, Insufficient MIC space for CTL PDU", __func__);
|
||||
BT_ERR("Insufficient MIC space for CTL PDU");
|
||||
return -EINVAL;
|
||||
} else if (net_buf_simple_tailroom(buf) < BLE_MESH_MIC_SHORT) {
|
||||
BT_ERR("%s, Insufficient MIC space for PDU", __func__);
|
||||
BT_ERR("Insufficient MIC space for PDU");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -913,7 +913,7 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf,
|
|||
*/
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) &&
|
||||
tx->ctx->send_ttl != 1U) {
|
||||
if (bt_mesh_proxy_relay(&buf->b, tx->ctx->addr) &&
|
||||
if (bt_mesh_proxy_server_relay(&buf->b, tx->ctx->addr) &&
|
||||
BLE_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) {
|
||||
/* Notify completion if this only went
|
||||
* through the Mesh Proxy.
|
||||
|
@ -925,9 +925,9 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf,
|
|||
}
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
if (tx->ctx->send_ttl != 1U) {
|
||||
if (bt_mesh_proxy_client_send(&buf->b, tx->ctx->addr)) {
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT) &&
|
||||
tx->ctx->send_ttl != 1U) {
|
||||
if (bt_mesh_proxy_client_relay(&buf->b, tx->ctx->addr)) {
|
||||
/* If Proxy Client succeeds to send messages with GATT bearer,
|
||||
* we can directly finish here. And if not, which means no
|
||||
* connection has been created with Proxy Client, here we will
|
||||
|
@ -939,7 +939,6 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf,
|
|||
goto done;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Deliver to local network interface if necessary */
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned() &&
|
||||
|
@ -1116,7 +1115,7 @@ static bool net_find_and_decrypt(const u8_t *data, size_t data_len,
|
|||
for (i = 0; i < array_size; i++) {
|
||||
sub = bt_mesh_rx_netkey_get(i);
|
||||
if (!sub) {
|
||||
BT_DBG("%s, NULL subnet", __func__);
|
||||
BT_DBG("Subnet not found");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1239,7 +1238,7 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf,
|
|||
#endif
|
||||
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Out of relay buffers", __func__);
|
||||
BT_ERR("Out of relay buffers");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1269,12 +1268,12 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf,
|
|||
* layer nonce includes the IVI.
|
||||
*/
|
||||
if (bt_mesh_net_encrypt(enc, &buf->b, BLE_MESH_NET_IVI_RX(rx), false)) {
|
||||
BT_ERR("%s, Re-encrypting failed", __func__);
|
||||
BT_ERR("Re-encrypting failed");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (bt_mesh_net_obfuscate(buf->data, BLE_MESH_NET_IVI_RX(rx), priv)) {
|
||||
BT_ERR("%s, Re-obfuscating failed", __func__);
|
||||
BT_ERR("Re-obfuscating failed");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -1284,7 +1283,7 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf,
|
|||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) &&
|
||||
(bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED ||
|
||||
rx->net_if == BLE_MESH_NET_IF_LOCAL)) {
|
||||
if (bt_mesh_proxy_relay(&buf->b, rx->ctx.recv_dst) &&
|
||||
if (bt_mesh_proxy_server_relay(&buf->b, rx->ctx.recv_dst) &&
|
||||
BLE_MESH_ADDR_IS_UNICAST(rx->ctx.recv_dst)) {
|
||||
goto done;
|
||||
}
|
||||
|
@ -1355,12 +1354,12 @@ int bt_mesh_net_decode(struct net_buf_simple *data, enum bt_mesh_net_if net_if,
|
|||
|
||||
if (net_if != BLE_MESH_NET_IF_PROXY_CFG &&
|
||||
rx->ctx.recv_dst == BLE_MESH_ADDR_UNASSIGNED) {
|
||||
BT_ERR("%s, Destination address is unassigned; dropping packet", __func__);
|
||||
BT_ERR("Destination address is unassigned; dropping packet");
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
if (BLE_MESH_ADDR_IS_RFU(rx->ctx.recv_dst)) {
|
||||
BT_ERR("%s, Destination address is RFU; dropping packet", __func__);
|
||||
BT_ERR("Destination address is RFU; dropping packet");
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
|
@ -1447,7 +1446,7 @@ void bt_mesh_net_recv(struct net_buf_simple *data, s8_t rssi,
|
|||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) &&
|
||||
net_if == BLE_MESH_NET_IF_PROXY) {
|
||||
bt_mesh_proxy_addr_add(data, rx.ctx.addr);
|
||||
bt_mesh_proxy_server_addr_add(data, rx.ctx.addr);
|
||||
|
||||
if (bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_DISABLED &&
|
||||
!rx.local_match) {
|
||||
|
@ -1516,7 +1515,7 @@ void bt_mesh_net_start(void)
|
|||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) &&
|
||||
bt_mesh_gatt_proxy_get() != BLE_MESH_GATT_PROXY_NOT_SUPPORTED) {
|
||||
bt_mesh_proxy_gatt_enable();
|
||||
bt_mesh_proxy_server_gatt_enable();
|
||||
bt_mesh_adv_update();
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ static int ble_on_subscribe(uint16_t conn_handle,
|
|||
conn = &bt_mesh_gattc_info[i].conn;
|
||||
|
||||
if (bt_mesh_gattc_info[i].ccc_handle != attr->handle) {
|
||||
BT_WARN("%s, gattc ccc_handle is not matched", __func__);
|
||||
BT_WARN("gattc ccc_handle not matched");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return 0;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ static int ble_on_subscribe(uint16_t conn_handle,
|
|||
if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->prov_write_descr != NULL) {
|
||||
len = bt_mesh_gattc_conn_cb->prov_write_descr(&bt_mesh_gattc_info[i].addr, &bt_mesh_gattc_info[i].conn);
|
||||
if (len < 0) {
|
||||
BT_ERR("%s, prov_write_descr failed", __func__);
|
||||
BT_ERR("prov_write_descr failed");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return 0;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ static int ble_on_subscribe(uint16_t conn_handle,
|
|||
if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->proxy_write_descr != NULL) {
|
||||
len = bt_mesh_gattc_conn_cb->proxy_write_descr(&bt_mesh_gattc_info[i].addr, &bt_mesh_gattc_info[i].conn);
|
||||
if (len < 0) {
|
||||
BT_ERR("%s, proxy_write_descr failed", __func__);
|
||||
BT_ERR("proxy_write_descr failed");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return 0;
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ static int svc_disced(uint16_t conn_handle, const struct ble_gatt_error *error,
|
|||
}
|
||||
|
||||
if (i == ARRAY_SIZE(bt_mesh_gattc_info)) {
|
||||
BT_ERR("%s, Conn handle is not found", __func__);
|
||||
BT_ERR("Conn handle 0x%04x not found", conn_handle);
|
||||
return 0;
|
||||
}
|
||||
conn = &bt_mesh_gattc_info[i].conn;
|
||||
|
@ -388,7 +388,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg)
|
|||
|
||||
struct net_buf_simple *buf = bt_mesh_alloc_buf(desc->length_data);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return 0;
|
||||
}
|
||||
net_buf_simple_add_mem(buf, desc->data, desc->length_data);
|
||||
|
@ -421,7 +421,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg)
|
|||
if (!bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) {
|
||||
rc = ble_gap_disc(BLE_OWN_ADDR_PUBLIC, BLE_HS_FOREVER, &scan_param, disc_cb, NULL);
|
||||
if (rc != 0) {
|
||||
BT_ERR("%s, Invalid scan status %d", __func__, rc);
|
||||
BT_ERR("Invalid scan status %d", rc);
|
||||
break;
|
||||
}
|
||||
bt_mesh_atomic_set_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING);
|
||||
|
@ -505,7 +505,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg)
|
|||
}
|
||||
|
||||
if (i == ARRAY_SIZE(bt_mesh_gattc_info)) {
|
||||
BT_ERR("%s, Conn handle is not found", __func__);
|
||||
BT_ERR("Conn handle 0x%04x not found", event->notify_rx.conn_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -520,7 +520,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg)
|
|||
if (memcmp(bt_mesh_gattc_info[i].addr.val, conn_desc.peer_id_addr.val, BLE_MESH_ADDR_LEN) ||
|
||||
(bt_mesh_gattc_info[i].data_out_handle != event->notify_rx.attr_handle) ||
|
||||
(event->notify_rx.indication != 0)) {
|
||||
BT_ERR("%s, Notification error", __func__);
|
||||
BT_ERR("Notification error");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return 0;
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg)
|
|||
len = bt_mesh_gattc_conn_cb->prov_notify(&bt_mesh_gattc_info[i].conn,
|
||||
notif_data, notif_len);
|
||||
if (len < 0) {
|
||||
BT_ERR("%s, prov_notify failed", __func__);
|
||||
BT_ERR("prov_notify failed");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return 0;
|
||||
}
|
||||
|
@ -543,7 +543,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg)
|
|||
len = bt_mesh_gattc_conn_cb->proxy_notify(&bt_mesh_gattc_info[i].conn,
|
||||
notif_data, notif_len);
|
||||
if (len < 0) {
|
||||
BT_ERR("%s, proxy_notify failed", __func__);
|
||||
BT_ERR("proxy_notify failed");
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1059,7 +1059,8 @@ static struct bt_mesh_gatt_attr *bt_mesh_gatts_attr_next(const struct bt_mesh_ga
|
|||
return next;
|
||||
}
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr,
|
||||
ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t buf_len, u16_t offset,
|
||||
const void *value, u16_t value_len)
|
||||
{
|
||||
|
@ -1135,8 +1136,8 @@ struct gatts_chrc {
|
|||
} __packed;
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr, void *buf,
|
||||
u16_t len, u16_t offset)
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t len, u16_t offset)
|
||||
{
|
||||
struct bt_mesh_gatt_char *chrc = attr->user_data;
|
||||
const struct bt_mesh_gatt_attr *next = NULL;
|
||||
|
@ -1153,7 +1154,7 @@ ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn,
|
|||
*/
|
||||
next = bt_mesh_gatts_attr_next(attr);
|
||||
if (!next) {
|
||||
BT_WARN("%s, No value for characteristic at 0x%04x", __func__, attr->handle);
|
||||
BT_WARN("No value for characteristic, handle 0x%04x", attr->handle);
|
||||
pdu.value_handle = 0x0000;
|
||||
} else {
|
||||
pdu.value_handle = sys_cpu_to_le16(next->handle);
|
||||
|
@ -1183,7 +1184,7 @@ static int gatts_register(struct bt_mesh_gatt_service *svc)
|
|||
|
||||
last = SYS_SLIST_PEEK_TAIL_CONTAINER(&bt_mesh_gatts_db, last, node);
|
||||
handle = last->attrs[last->attr_count - 1].handle;
|
||||
BT_DBG("%s, handle = %d", __func__, handle);
|
||||
BT_DBG("gatts register, handle %d", handle);
|
||||
|
||||
populate:
|
||||
sys_slist_append(&bt_mesh_gatts_db, &svc->node);
|
||||
|
@ -1236,11 +1237,12 @@ int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, u8_t reason)
|
|||
int bt_mesh_gatts_service_unregister(struct bt_mesh_gatt_service *svc)
|
||||
{
|
||||
assert(svc != NULL);
|
||||
BT_ERR("%s, Unsupported for NimBLE host", __func__);
|
||||
BT_ERR("Unsupported for NimBLE host");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_gatts_notify(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr,
|
||||
int bt_mesh_gatts_notify(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
const void *data, u16_t len)
|
||||
{
|
||||
struct os_mbuf *om;
|
||||
|
@ -1372,21 +1374,21 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid)
|
|||
|
||||
if (!addr || !memcmp(addr->val, zero, BLE_MESH_ADDR_LEN) ||
|
||||
(addr->type > BLE_ADDR_RANDOM)) {
|
||||
BT_ERR("%s, Invalid remote address", __func__);
|
||||
BT_ERR("Invalid remote address");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (service_uuid != BLE_MESH_UUID_MESH_PROV_VAL &&
|
||||
service_uuid != BLE_MESH_UUID_MESH_PROXY_VAL) {
|
||||
BT_ERR("%s, Invalid service uuid 0x%04x", __func__, service_uuid);
|
||||
BT_ERR("Invalid service uuid 0x%04x", service_uuid);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Check if already creating connection with the device */
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
|
||||
if (!memcmp(bt_mesh_gattc_info[i].addr.val, addr->val, BLE_MESH_ADDR_LEN)) {
|
||||
BT_WARN("%s, Already create connection with %s",
|
||||
__func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN));
|
||||
BT_WARN("Already create connection with %s",
|
||||
bt_hex(addr->val, BLE_MESH_ADDR_LEN));
|
||||
return -EALREADY;
|
||||
}
|
||||
}
|
||||
|
@ -1404,7 +1406,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid)
|
|||
}
|
||||
|
||||
if (i == ARRAY_SIZE(bt_mesh_gattc_info)) {
|
||||
BT_WARN("%s, gattc info is full", __func__);
|
||||
BT_WARN("gattc info is full");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -1416,7 +1418,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid)
|
|||
bt_mesh_atomic_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING);
|
||||
}
|
||||
|
||||
BT_DBG("%s, create conn with %s", __func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN));
|
||||
BT_DBG("Create conn with %s", bt_hex(addr->val, BLE_MESH_ADDR_LEN));
|
||||
|
||||
/* Min_interval: 250ms
|
||||
* Max_interval: 250ms
|
||||
|
@ -1486,7 +1488,8 @@ u16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr,
|
||||
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;
|
||||
|
@ -1499,7 +1502,7 @@ int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, const struct bt_mesh_g
|
|||
}
|
||||
|
||||
if (i == ARRAY_SIZE(bt_mesh_gattc_info)) {
|
||||
BT_ERR("%s, Conn is not found", __func__);
|
||||
BT_ERR("Conn %p not found", conn);
|
||||
/** Here we return 0 for prov_send() return value check in provisioner.c
|
||||
*/
|
||||
return 0;
|
||||
|
@ -1542,7 +1545,7 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn)
|
|||
}
|
||||
|
||||
if (i == ARRAY_SIZE(bt_mesh_gattc_info)) {
|
||||
BT_ERR("%s, Conn is not found", __func__);
|
||||
BT_ERR("Conn %p not found", conn);
|
||||
return;
|
||||
}
|
||||
ble_gap_terminate(bt_mesh_gattc_info[i].conn.handle, BLE_ERR_REM_USER_CONN_TERM);
|
||||
|
@ -1582,7 +1585,7 @@ static int proxy_char_access_cb(uint16_t conn_handle, uint16_t attr_handle,
|
|||
u8_t index = BLE_MESH_GATT_GET_CONN_ID(conn_handle);
|
||||
u16_t len = 0;
|
||||
|
||||
BT_DBG("%s, write: handle = %d, len = %d, data = %s", __func__, attr_handle,
|
||||
BT_DBG("write, handle %d, len %d, data %s", attr_handle,
|
||||
ctxt->om->om_len,
|
||||
bt_hex(ctxt->om->om_data, ctxt->om->om_len));
|
||||
|
||||
|
@ -1594,7 +1597,7 @@ static int proxy_char_access_cb(uint16_t conn_handle, uint16_t attr_handle,
|
|||
}
|
||||
}
|
||||
} else if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR || ctxt->op == BLE_GATT_ACCESS_OP_READ_DSC) {
|
||||
BT_ERR("%s, Unhandled read request for chr and dsc: opcode - %d", __func__, ctxt->op);
|
||||
BT_ERR("Unhandled read request for chr and dsc: opcode - %d", ctxt->op);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1765,7 +1768,7 @@ int bt_mesh_rand(void *buf, size_t len)
|
|||
memcpy(buf + i * sizeof(u32_t), &rand, sizeof(u32_t));
|
||||
}
|
||||
|
||||
BT_DBG("%s, rand: %s", __func__, bt_hex(buf, len));
|
||||
BT_DBG("Rand %s", bt_hex(buf, len));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1798,7 +1801,7 @@ const u8_t *bt_mesh_pub_key_get(void)
|
|||
|
||||
int rc = ble_sm_alg_gen_key_pair(bt_mesh_public_key, pri_key);
|
||||
if (rc != 0) {
|
||||
BT_ERR("%s, Failed to generate the key pair", __func__);
|
||||
BT_ERR("Failed to generate the key pair");
|
||||
return NULL;
|
||||
}
|
||||
memcpy(bt_mesh_private_key, pri_key, 32);
|
||||
|
@ -1971,7 +1974,7 @@ int bt_mesh_encrypt_be(const u8_t key[16], const u8_t plaintext[16],
|
|||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
int bt_mesh_update_exceptional_list(u8_t sub_code, u8_t type, void *info)
|
||||
{
|
||||
BT_ERR("%s, Unsupported for NimBLE host", __func__);
|
||||
BT_ERR("Unsupported for NimBLE host");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -242,7 +242,7 @@ static void reset_state(void)
|
|||
link.rx.prev_id = XACT_NVAL;
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_PB_GATT)
|
||||
link.rx.buf = bt_mesh_proxy_get_buf();
|
||||
link.rx.buf = bt_mesh_proxy_server_get_buf();
|
||||
#else
|
||||
net_buf_simple_reset(&rx_buf);
|
||||
link.rx.buf = &rx_buf;
|
||||
|
@ -323,7 +323,7 @@ static struct net_buf *adv_buf_create(void)
|
|||
|
||||
buf = bt_mesh_adv_create(BLE_MESH_ADV_PROV, PROV_XMIT, BUF_TIMEOUT);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Out of provisioning buffers", __func__);
|
||||
BT_ERR("Out of provisioning buffers");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -447,7 +447,7 @@ static int prov_send_adv(struct net_buf_simple *msg)
|
|||
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));
|
||||
BT_DBG("len %u: %s", msg->len, bt_hex(msg->data, msg->len));
|
||||
|
||||
prov_clear_tx();
|
||||
|
||||
|
@ -476,7 +476,7 @@ static int prov_send_adv(struct net_buf_simple *msg)
|
|||
buf = start;
|
||||
for (seg_id = 1U; msg->len > 0; seg_id++) {
|
||||
if (seg_id >= ARRAY_SIZE(link.tx.buf)) {
|
||||
BT_ERR("%s, Too big message", __func__);
|
||||
BT_ERR("Too big message (seg_id %d)", seg_id);
|
||||
free_segments();
|
||||
return -E2BIG;
|
||||
}
|
||||
|
@ -530,9 +530,9 @@ static int prov_send_gatt(struct net_buf_simple *msg)
|
|||
/* Changed by Espressif, add provisioning timeout timer operations.
|
||||
* When sending a provisioning PDU successfully, restart the 60s timer.
|
||||
*/
|
||||
err = bt_mesh_proxy_send(link.conn, BLE_MESH_PROXY_PROV, msg);
|
||||
err = bt_mesh_proxy_server_send(link.conn, BLE_MESH_PROXY_PROV, msg);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send provisioning PDU", __func__);
|
||||
BT_ERR("Failed to send provisioning PDU");
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -617,7 +617,7 @@ static void prov_invite(const u8_t *data)
|
|||
memcpy(&link.conf_inputs[1], &buf.data[1], 11);
|
||||
|
||||
if (prov_send(&buf)) {
|
||||
BT_ERR("%s, Failed to send capabilities", __func__);
|
||||
BT_ERR("Failed to send capabilities");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -795,13 +795,13 @@ static void prov_start(const u8_t *data)
|
|||
BT_INFO("Auth Size: 0x%02x", data[4]);
|
||||
|
||||
if (data[0] != PROV_ALG_P256) {
|
||||
BT_ERR("%s, Unknown algorithm 0x%02x", __func__, data[0]);
|
||||
BT_ERR("Unknown algorithm 0x%02x", data[0]);
|
||||
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data[1] != prov->oob_pub_key) {
|
||||
BT_ERR("%s, Invalid public key type: 0x%02x", __func__, data[1]);
|
||||
BT_ERR("Invalid public key type: 0x%02x", data[1]);
|
||||
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
|
||||
return;
|
||||
}
|
||||
|
@ -820,9 +820,9 @@ static void prov_start(const u8_t *data)
|
|||
}
|
||||
|
||||
if (prov_auth(data[2], data[3], data[4]) < 0) {
|
||||
BT_ERR("%s, Invalid authentication method: 0x%02x; "
|
||||
BT_ERR("Invalid authentication method: 0x%02x; "
|
||||
"action: 0x%02x; size: 0x%02x",
|
||||
__func__, data[2], data[3], data[4]);
|
||||
data[2], data[3], data[4]);
|
||||
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
|
||||
}
|
||||
}
|
||||
|
@ -836,7 +836,7 @@ static void send_confirm(void)
|
|||
BT_DBG("ConfInputs[128] %s", bt_hex(&link.conf_inputs[128], 17));
|
||||
|
||||
if (bt_mesh_prov_conf_salt(link.conf_inputs, link.conf_salt)) {
|
||||
BT_ERR("%s, Unable to generate confirmation salt", __func__);
|
||||
BT_ERR("Unable to generate confirmation salt");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_ERR);
|
||||
return;
|
||||
}
|
||||
|
@ -844,7 +844,7 @@ static void send_confirm(void)
|
|||
BT_DBG("ConfirmationSalt: %s", bt_hex(link.conf_salt, 16));
|
||||
|
||||
if (bt_mesh_prov_conf_key(link.dhkey, link.conf_salt, link.conf_key)) {
|
||||
BT_ERR("%s, Unable to generate confirmation key", __func__);
|
||||
BT_ERR("Unable to generate confirmation key");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_ERR);
|
||||
return;
|
||||
}
|
||||
|
@ -852,7 +852,7 @@ static void send_confirm(void)
|
|||
BT_DBG("ConfirmationKey: %s", bt_hex(link.conf_key, 16));
|
||||
|
||||
if (bt_mesh_rand(link.rand, 16)) {
|
||||
BT_ERR("%s, Unable to generate random number", __func__);
|
||||
BT_ERR("Unable to generate random number");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_ERR);
|
||||
return;
|
||||
}
|
||||
|
@ -863,13 +863,13 @@ static void send_confirm(void)
|
|||
|
||||
if (bt_mesh_prov_conf(link.conf_key, link.rand, link.auth,
|
||||
net_buf_simple_add(&cfm, 16))) {
|
||||
BT_ERR("%s, Unable to generate confirmation value", __func__);
|
||||
BT_ERR("Unable to generate confirmation value");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (prov_send(&cfm)) {
|
||||
BT_ERR("%s, Unable to send Provisioning Confirm", __func__);
|
||||
BT_ERR("Unable to send Provisioning Confirm");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -937,7 +937,7 @@ static void prov_dh_key_cb(const u8_t key[32], const u8_t idx)
|
|||
BT_DBG("%p", key);
|
||||
|
||||
if (!key) {
|
||||
BT_ERR("%s, DHKey generation failed", __func__);
|
||||
BT_ERR("DHKey generation failed");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_ERR);
|
||||
return;
|
||||
}
|
||||
|
@ -972,14 +972,14 @@ static void send_pub_key(void)
|
|||
sys_memcpy_swap(&buf.data[32], &link.conf_inputs[49], 32);
|
||||
|
||||
if (bt_mesh_dh_key_gen(buf.data, prov_dh_key_cb, 0)) {
|
||||
BT_ERR("%s, Unable to generate DHKey", __func__);
|
||||
BT_ERR("Unable to generate DHKey");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
key = bt_mesh_pub_key_get();
|
||||
if (!key) {
|
||||
BT_ERR("%s, No public key available", __func__);
|
||||
BT_ERR("No public key available");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_ERR);
|
||||
return;
|
||||
}
|
||||
|
@ -1014,7 +1014,7 @@ static int bt_mesh_calc_dh_key(void)
|
|||
sys_memcpy_swap(&buf.data[32], &link.conf_inputs[49], 32);
|
||||
|
||||
if (bt_mesh_dh_key_gen(buf.data, prov_dh_key_cb, 0)) {
|
||||
BT_ERR("%s, Unable to generate DHKey", __func__);
|
||||
BT_ERR("Unable to generate DHKey");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_ERR);
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -1059,7 +1059,7 @@ static void prov_pub_key(const u8_t *data)
|
|||
* (3) X = 0, Y = 0
|
||||
*/
|
||||
if (!bt_mesh_check_public_key(data)) {
|
||||
BT_ERR("%s, Invalid public key", __func__);
|
||||
BT_ERR("Invalid public key");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_PDU);
|
||||
return;
|
||||
}
|
||||
|
@ -1116,13 +1116,13 @@ static void prov_random(const u8_t *data)
|
|||
BT_DBG("Remote Random: %s", bt_hex(data, 16));
|
||||
|
||||
if (bt_mesh_prov_conf(link.conf_key, data, link.auth, conf_verify)) {
|
||||
BT_ERR("%s, Unable to calculate confirmation verification", __func__);
|
||||
BT_ERR("Unable to calculate confirmation verification");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (memcmp(conf_verify, link.conf, 16)) {
|
||||
BT_ERR("%s, Invalid confirmation value", __func__);
|
||||
BT_ERR("Invalid confirmation value");
|
||||
BT_DBG("Received: %s", bt_hex(link.conf, 16));
|
||||
BT_DBG("Calculated: %s", bt_hex(conf_verify, 16));
|
||||
prov_send_fail_msg(PROV_ERR_CFM_FAILED);
|
||||
|
@ -1133,13 +1133,13 @@ static void prov_random(const u8_t *data)
|
|||
net_buf_simple_add_mem(&rnd, link.rand, 16);
|
||||
|
||||
if (prov_send(&rnd)) {
|
||||
BT_ERR("%s, Failed to send Provisioning Random", __func__);
|
||||
BT_ERR("Failed to send Provisioning Random");
|
||||
return;
|
||||
}
|
||||
|
||||
if (bt_mesh_prov_salt(link.conf_salt, data, link.rand,
|
||||
link.prov_salt)) {
|
||||
BT_ERR("%s, Failed to generate provisioning salt", __func__);
|
||||
BT_ERR("Failed to generate provisioning salt");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_ERR);
|
||||
return;
|
||||
}
|
||||
|
@ -1176,7 +1176,7 @@ static void prov_data(const u8_t *data)
|
|||
|
||||
err = bt_mesh_session_key(link.dhkey, link.prov_salt, session_key);
|
||||
if (err) {
|
||||
BT_ERR("%s, Unable to generate session key", __func__);
|
||||
BT_ERR("Unable to generate session key");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_ERR);
|
||||
return;
|
||||
}
|
||||
|
@ -1185,7 +1185,7 @@ static void prov_data(const u8_t *data)
|
|||
|
||||
err = bt_mesh_prov_nonce(link.dhkey, link.prov_salt, nonce);
|
||||
if (err) {
|
||||
BT_ERR("%s, Unable to generate session nonce", __func__);
|
||||
BT_ERR("Unable to generate session nonce");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_ERR);
|
||||
return;
|
||||
}
|
||||
|
@ -1194,14 +1194,14 @@ static void prov_data(const u8_t *data)
|
|||
|
||||
err = bt_mesh_prov_decrypt(session_key, nonce, data, pdu);
|
||||
if (err) {
|
||||
BT_ERR("%s, Unable to decrypt provisioning data", __func__);
|
||||
BT_ERR("Unable to decrypt provisioning data");
|
||||
prov_send_fail_msg(PROV_ERR_DECRYPT);
|
||||
return;
|
||||
}
|
||||
|
||||
err = bt_mesh_dev_key(link.dhkey, link.prov_salt, dev_key);
|
||||
if (err) {
|
||||
BT_ERR("%s, Unable to generate device key", __func__);
|
||||
BT_ERR("Unable to generate device key");
|
||||
prov_send_fail_msg(PROV_ERR_UNEXP_ERR);
|
||||
return;
|
||||
}
|
||||
|
@ -1328,7 +1328,7 @@ static void link_open(struct prov_rx *rx, struct net_buf_simple *buf)
|
|||
BT_DBG("len %u", buf->len);
|
||||
|
||||
if (buf->len < 16) {
|
||||
BT_ERR("%s, Too short bearer open message (len %u)", __func__, buf->len);
|
||||
BT_ERR("Too short bearer open message (len %u)", buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1403,7 +1403,7 @@ static void gen_prov_ctl(struct prov_rx *rx, struct net_buf_simple *buf)
|
|||
link_close(rx, buf);
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown bearer opcode: 0x%02x", __func__, BEARER_CTL(rx->gpc));
|
||||
BT_ERR("Unknown bearer opcode: 0x%02x", BEARER_CTL(rx->gpc));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1415,7 +1415,7 @@ static void prov_msg_recv(void)
|
|||
BT_DBG("type 0x%02x len %u", type, link.rx.buf->len);
|
||||
|
||||
if (!bt_mesh_fcs_check(link.rx.buf, link.rx.fcs)) {
|
||||
BT_ERR("%s, Incorrect FCS", __func__);
|
||||
BT_ERR("Incorrect FCS");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1436,14 +1436,14 @@ static void prov_msg_recv(void)
|
|||
}
|
||||
|
||||
if (type >= ARRAY_SIZE(prov_handlers)) {
|
||||
BT_ERR("%s, Unknown provisioning PDU type 0x%02x", __func__, type);
|
||||
BT_ERR("Unknown provisioning PDU type 0x%02x", type);
|
||||
prov_send_fail_msg(PROV_ERR_NVAL_PDU);
|
||||
return;
|
||||
}
|
||||
|
||||
if (1 + prov_handlers[type].len != link.rx.buf->len) {
|
||||
BT_ERR("%s, Invalid length %u for type 0x%02x",
|
||||
__func__, link.rx.buf->len, type);
|
||||
BT_ERR("Invalid length %u for type 0x%02x",
|
||||
link.rx.buf->len, type);
|
||||
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
|
||||
return;
|
||||
}
|
||||
|
@ -1475,7 +1475,7 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf)
|
|||
}
|
||||
|
||||
if (seg > link.rx.last_seg) {
|
||||
BT_ERR("%s, Invalid segment index %u", __func__, seg);
|
||||
BT_ERR("Invalid segment index %u", seg);
|
||||
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
|
||||
return;
|
||||
} else if (seg == link.rx.last_seg) {
|
||||
|
@ -1484,8 +1484,8 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf)
|
|||
expect_len = (link.rx.buf->len - 20U -
|
||||
((link.rx.last_seg - 1) * 23U));
|
||||
if (expect_len != buf->len) {
|
||||
BT_ERR("%s, Incorrect last seg len: %u != %u",
|
||||
__func__, expect_len, buf->len);
|
||||
BT_ERR("Incorrect last seg len: %u != %u",
|
||||
expect_len, buf->len);
|
||||
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
|
||||
return;
|
||||
}
|
||||
|
@ -1538,20 +1538,20 @@ static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf)
|
|||
START_LAST_SEG(rx->gpc), link.rx.buf->len, link.rx.fcs);
|
||||
|
||||
if (link.rx.buf->len < 1) {
|
||||
BT_ERR("%s, Ignoring zero-length provisioning PDU", __func__);
|
||||
BT_ERR("Ignoring zero-length provisioning PDU");
|
||||
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (link.rx.buf->len > link.rx.buf->size) {
|
||||
BT_ERR("%s, Too large provisioning PDU (%u bytes)",
|
||||
__func__, link.rx.buf->len);
|
||||
BT_ERR("Too large provisioning PDU (%u bytes)",
|
||||
link.rx.buf->len);
|
||||
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (START_LAST_SEG(rx->gpc) > 0 && link.rx.buf->len <= 20U) {
|
||||
BT_ERR("%s, Too small total length for multi-segment PDU", __func__);
|
||||
BT_ERR("Too small total length for multi-segment PDU");
|
||||
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
|
||||
return;
|
||||
}
|
||||
|
@ -1580,7 +1580,7 @@ static const struct {
|
|||
static void gen_prov_recv(struct prov_rx *rx, struct net_buf_simple *buf)
|
||||
{
|
||||
if (buf->len < gen_prov[GPCF(rx->gpc)].min_len) {
|
||||
BT_ERR("%s, Too short GPC message type %u", __func__, GPCF(rx->gpc));
|
||||
BT_ERR("Too short GPC message type %u", GPCF(rx->gpc));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1647,12 +1647,12 @@ int bt_mesh_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf)
|
|||
}
|
||||
|
||||
if (type >= ARRAY_SIZE(prov_handlers)) {
|
||||
BT_ERR("%s, Unknown provisioning PDU type 0x%02x", __func__, type);
|
||||
BT_ERR("Unknown provisioning PDU type 0x%02x", type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (prov_handlers[type].len != buf->len) {
|
||||
BT_ERR("%s, Invalid length %u for type 0x%02x", __func__, buf->len, type);
|
||||
BT_ERR("Invalid length %u for type 0x%02x", buf->len, type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1689,7 +1689,7 @@ int bt_mesh_pb_gatt_close(struct bt_mesh_conn *conn)
|
|||
BT_DBG("conn %p", conn);
|
||||
|
||||
if (link.conn != conn) {
|
||||
BT_ERR("%s, Not connected", __func__);
|
||||
BT_ERR("Not connected");
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
|
@ -1739,23 +1739,23 @@ int bt_mesh_prov_init(const struct bt_mesh_prov *prov_info)
|
|||
const u8_t *key = NULL;
|
||||
|
||||
if (!prov_info) {
|
||||
BT_ERR("%s, No provisioning context provided", __func__);
|
||||
BT_ERR("No provisioning context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (prov_info->static_val_len > BLE_MESH_PROV_STATIC_OOB_MAX_LEN ||
|
||||
prov_info->output_size > BLE_MESH_PROV_OUTPUT_OOB_MAX_LEN ||
|
||||
prov_info->input_size > BLE_MESH_PROV_INPUT_OOB_MAX_LEN) {
|
||||
BT_ERR("%s, Invalid auth oob length", __func__);
|
||||
BT_ERR("Invalid authentication oob length");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
__ASSERT(prov_info->uuid, "%s, Device UUID is not initialized", __func__);
|
||||
__ASSERT(prov_info->uuid, "Device UUID not initialized");
|
||||
|
||||
/* Changed by Espressif. Use micro-ecc to generate public key now. */
|
||||
key = bt_mesh_pub_key_get();
|
||||
if (!key) {
|
||||
BT_ERR("%s, Failed to generate public key", __func__);
|
||||
BT_ERR("Failed to generate public key");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -1779,7 +1779,7 @@ int bt_mesh_prov_init(const struct bt_mesh_prov *prov_info)
|
|||
int bt_mesh_prov_deinit(void)
|
||||
{
|
||||
if (prov == NULL) {
|
||||
BT_ERR("%s, No provisioning context provided", __func__);
|
||||
BT_ERR("No provisioning context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1806,7 +1806,8 @@ int bt_mesh_prov_deinit(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void bt_mesh_prov_complete(u16_t net_idx, const u8_t net_key[16], u16_t addr, u8_t flags, u32_t iv_index)
|
||||
void bt_mesh_prov_complete(u16_t net_idx, const u8_t net_key[16],
|
||||
u16_t addr, u8_t flags, u32_t iv_index)
|
||||
{
|
||||
if (prov->complete) {
|
||||
prov->complete(net_idx, net_key, addr, flags, iv_index);
|
||||
|
|
|
@ -32,7 +32,8 @@ const struct bt_mesh_prov *bt_mesh_prov_get(void);
|
|||
int bt_mesh_prov_init(const struct bt_mesh_prov *prov);
|
||||
int bt_mesh_prov_deinit(void);
|
||||
|
||||
void bt_mesh_prov_complete(u16_t net_idx, const u8_t net_key[16], u16_t addr, u8_t flags, u32_t iv_index);
|
||||
void bt_mesh_prov_complete(u16_t net_idx, const u8_t net_key[16],
|
||||
u16_t addr, u8_t flags, u32_t iv_index);
|
||||
void bt_mesh_prov_reset(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -79,7 +79,7 @@ int bt_mesh_provisioner_net_create(void)
|
|||
|
||||
prov = bt_mesh_provisioner_get_prov_info();
|
||||
if (!prov) {
|
||||
BT_ERR("%s, NULL provisioning context", __func__);
|
||||
BT_ERR("No provisioning context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -99,20 +99,20 @@ int bt_mesh_provisioner_net_create(void)
|
|||
|
||||
/* Generate the primary netkey */
|
||||
if (bt_mesh_rand(p_key, 16)) {
|
||||
BT_ERR("%s, Failed to generate Primary NetKey", __func__);
|
||||
BT_ERR("Failed to generate Primary NetKey");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
sub = bt_mesh_calloc(sizeof(struct bt_mesh_subnet));
|
||||
if (!sub) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
sub->kr_flag = BLE_MESH_KEY_REFRESH(prov->flags);
|
||||
if (sub->kr_flag) {
|
||||
if (bt_mesh_net_keys_create(&sub->keys[1], p_key)) {
|
||||
BT_ERR("%s, Failed to generate net-related keys", __func__);
|
||||
BT_ERR("Failed to generate net-related keys");
|
||||
bt_mesh_free(sub);
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ int bt_mesh_provisioner_net_create(void)
|
|||
} else {
|
||||
/* Currently provisioner only use keys[0] */
|
||||
if (bt_mesh_net_keys_create(&sub->keys[0], p_key)) {
|
||||
BT_ERR("%s, Failed to create net-related keys", __func__);
|
||||
BT_ERR("Failed to create net-related keys");
|
||||
bt_mesh_free(sub);
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ int bt_mesh_provisioner_net_create(void)
|
|||
}
|
||||
|
||||
done:
|
||||
BT_INFO("NetKey Index 0x%03x, NID 0x%02x", sub->net_idx, sub->keys[0].nid);
|
||||
BT_INFO("NetKeyIndex 0x%03x, NID 0x%02x", sub->net_idx, sub->keys[0].nid);
|
||||
BT_INFO("NetKey %s", bt_hex(sub->keys[0].net, 16));
|
||||
|
||||
return 0;
|
||||
|
@ -216,13 +216,13 @@ bool bt_mesh_provisioner_check_is_addr_dup(u16_t addr, u8_t elem_num, bool comp_
|
|||
if (comp_with_own) {
|
||||
comp = bt_mesh_comp_get();
|
||||
if (!comp) {
|
||||
BT_ERR("NULL composition data");
|
||||
BT_ERR("Invalid composition data");
|
||||
return true;
|
||||
}
|
||||
|
||||
primary_addr = bt_mesh_provisioner_get_primary_elem_addr();
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(primary_addr)) {
|
||||
BT_ERR("%s, Not a unicast address 0x%04x", __func__, primary_addr);
|
||||
BT_ERR("Invalid unicast address 0x%04x", primary_addr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ static int provisioner_store_node(struct bt_mesh_node *node, bool store, u16_t *
|
|||
if (mesh_nodes[i] == NULL) {
|
||||
mesh_nodes[i] = bt_mesh_calloc(sizeof(struct bt_mesh_node));
|
||||
if (!mesh_nodes[i]) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_provisioner_unlock();
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -318,9 +318,11 @@ int bt_mesh_provisioner_restore_node_info(struct bt_mesh_node *node)
|
|||
return provisioner_store_node(node, false, NULL);
|
||||
}
|
||||
|
||||
int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16], u16_t oob_info,
|
||||
u16_t unicast_addr, u8_t element_num, u16_t net_idx, u8_t flags,
|
||||
u32_t iv_index, const u8_t dev_key[16], u16_t *index)
|
||||
int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16],
|
||||
u16_t oob_info, u16_t unicast_addr,
|
||||
u8_t element_num, u16_t net_idx,
|
||||
u8_t flags, u32_t iv_index,
|
||||
const u8_t dev_key[16], u16_t *index)
|
||||
{
|
||||
struct bt_mesh_node node = {0};
|
||||
|
||||
|
@ -331,10 +333,10 @@ int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
BT_INFO("unicast_addr 0x%04x, elem_num %d, net_idx 0x%04x",
|
||||
BT_INFO("Unicast addr 0x%04x, element num %d, NetKeyIndex 0x%04x",
|
||||
unicast_addr, element_num, net_idx);
|
||||
BT_INFO("dev_uuid %s", bt_hex(uuid, 16));
|
||||
BT_INFO("dev_key %s", bt_hex(dev_key, 16));
|
||||
BT_INFO("UUID %s", bt_hex(uuid, 16));
|
||||
BT_INFO("DevKey %s", bt_hex(dev_key, 16));
|
||||
|
||||
memcpy(node.addr, addr->val, BLE_MESH_ADDR_LEN);
|
||||
node.addr_type = addr->type;
|
||||
|
@ -404,7 +406,7 @@ static struct bt_mesh_node *provisioner_find_node_with_uuid(const u8_t uuid[16],
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (uuid == NULL) {
|
||||
BT_ERR("%s, Invalid device uuid", __func__);
|
||||
BT_ERR("Invalid device uuid");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -441,7 +443,7 @@ int bt_mesh_provisioner_remove_node(const u8_t uuid[16])
|
|||
|
||||
node = provisioner_find_node_with_uuid(uuid, &index);
|
||||
if (!node) {
|
||||
BT_WARN("%s, Node not exists, uuid %s", __func__, bt_hex(uuid, 16));
|
||||
BT_WARN("Node not found, uuid %s", bt_hex(uuid, 16));
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -457,7 +459,7 @@ static struct bt_mesh_node *provisioner_find_node_with_addr(u16_t addr, u16_t *i
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(addr)) {
|
||||
BT_ERR("%s, Not a unicast address 0x%04x", __func__, addr);
|
||||
BT_ERR("Invalid unicast address 0x%04x", addr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -485,7 +487,7 @@ int bt_mesh_provisioner_restore_node_name(u16_t addr, const char *name)
|
|||
|
||||
node = provisioner_find_node_with_addr(addr, NULL);
|
||||
if (node == NULL) {
|
||||
BT_ERR("%s, Node not exists, addr 0x%04x", __func__, addr);
|
||||
BT_ERR("Node not found, addr 0x%04x", addr);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -512,7 +514,7 @@ int bt_mesh_provisioner_delete_node_with_uuid(const u8_t uuid[16])
|
|||
|
||||
node = provisioner_find_node_with_uuid(uuid, &index);
|
||||
if (!node) {
|
||||
BT_WARN("%s, Node not exists, uuid %s", __func__, bt_hex(uuid, 16));
|
||||
BT_WARN("Node not found, uuid %s", bt_hex(uuid, 16));
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -527,7 +529,7 @@ int bt_mesh_provisioner_delete_node_with_node_addr(u16_t unicast_addr)
|
|||
|
||||
node = provisioner_find_node_with_addr(unicast_addr, &index);
|
||||
if (!node) {
|
||||
BT_WARN("%s, Node not exists, addr 0x%04x", __func__, unicast_addr);
|
||||
BT_WARN("Node not found, addr 0x%04x", unicast_addr);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -672,24 +674,24 @@ static int store_node_comp_data(u16_t addr, const u8_t *data, u16_t length, bool
|
|||
struct bt_mesh_node *node = NULL;
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(addr)) {
|
||||
BT_ERR("%s, Not a unicast address 0x%04x", __func__, addr);
|
||||
BT_ERR("Invalid unicast address 0x%04x", addr);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (data == NULL || (length % 2) || length < COMP_DATA_PAGE_0_MIN_LEN) {
|
||||
BT_ERR("%s, Invalid composition data", __func__);
|
||||
BT_ERR("Invalid composition data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
node = provisioner_find_node_with_addr(addr, NULL);
|
||||
if (node == NULL) {
|
||||
BT_ERR("%s, Node not exists, addr 0x%04x", __func__, addr);
|
||||
BT_ERR("Node not found, addr 0x%04x", addr);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
node->comp_data = bt_mesh_calloc(length);
|
||||
if (node->comp_data == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -791,7 +793,7 @@ const u8_t *bt_mesh_provisioner_dev_key_get(u16_t dst)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(dst)) {
|
||||
BT_ERR("%s, Not a unicast address 0x%04x", __func__, dst);
|
||||
BT_ERR("Invalid unicast address 0x%04x", dst);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -947,7 +949,8 @@ static int provisioner_check_net_key_full(void)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
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_add(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;
|
||||
|
@ -955,7 +958,7 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx,
|
|||
int add = -1;
|
||||
|
||||
if (bt_mesh.p_app_idx_next >= 0x1000) {
|
||||
BT_ERR("No AppKey Index available");
|
||||
BT_ERR("No AppKeyIndex available");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -966,19 +969,19 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx,
|
|||
|
||||
/* Check if the same application key already exists */
|
||||
if (provisioner_check_app_key(app_key, app_idx)) {
|
||||
BT_WARN("AppKey exists, AppKey Index updated");
|
||||
BT_WARN("AppKey exists, AppKeyIndex updated");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Check if the net_idx exists */
|
||||
if (provisioner_check_net_idx(net_idx, false)) {
|
||||
BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Check if the same app_idx already exists */
|
||||
if (provisioner_check_app_idx(*app_idx, true)) {
|
||||
BT_ERR("%s, AppKey Index 0x%03x exists", __func__, *app_idx);
|
||||
BT_ERR("Invalid AppKeyIndex 0x%04x", *app_idx);
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
|
@ -999,13 +1002,13 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx,
|
|||
|
||||
key = bt_mesh_calloc(sizeof(struct bt_mesh_app_key));
|
||||
if (!key) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
keys = &key->keys[0];
|
||||
if (bt_mesh_app_id(p_key, &keys->id)) {
|
||||
BT_ERR("%s, Failed to generate AID", __func__);
|
||||
BT_ERR("Failed to generate AID");
|
||||
bt_mesh_free(key);
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -1020,7 +1023,7 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx,
|
|||
if (provisioner_check_app_idx(key->app_idx, true)) {
|
||||
key->app_idx = (++bt_mesh.p_app_idx_next);
|
||||
if (key->app_idx >= 0x1000) {
|
||||
BT_ERR("No AppKey Index available");
|
||||
BT_ERR("No AppKeyIndex available");
|
||||
bt_mesh_free(key);
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -1042,13 +1045,14 @@ 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)
|
||||
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__);
|
||||
BT_ERR("Invalid AppKey");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1056,19 +1060,19 @@ int bt_mesh_provisioner_local_app_key_update(const u8_t app_key[16], u16_t net_i
|
|||
|
||||
/* Check if the net_idx exists */
|
||||
if (provisioner_check_net_idx(net_idx, false)) {
|
||||
BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
key = bt_mesh_provisioner_app_key_find(app_idx);
|
||||
if (key == NULL) {
|
||||
BT_ERR("%s, AppKey Index 0x%03x not exists", __func__, app_idx);
|
||||
BT_ERR("Invalid AppKeyIndex 0x%04x", 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__);
|
||||
BT_ERR("Failed to generate AID");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -1093,12 +1097,12 @@ const u8_t *bt_mesh_provisioner_local_app_key_get(u16_t net_idx, u16_t app_idx)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (provisioner_check_net_idx(net_idx, false)) {
|
||||
BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (provisioner_check_app_idx(app_idx, false)) {
|
||||
BT_ERR("%s, AppKey Index 0x%03x not exists", __func__, app_idx);
|
||||
BT_ERR("Invalid AppKeyIndex 0x%04x", app_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1182,12 +1186,12 @@ int bt_mesh_provisioner_local_app_key_delete(u16_t net_idx, u16_t app_idx)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (provisioner_check_net_idx(net_idx, false)) {
|
||||
BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (provisioner_check_app_idx(app_idx, false)) {
|
||||
BT_ERR("%s, AppKey Index 0x%03x not exists", __func__, app_idx);
|
||||
BT_ERR("Invalid AppKeyIndex 0x%04x", app_idx);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -1219,7 +1223,7 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx
|
|||
int add = -1;
|
||||
|
||||
if (bt_mesh.p_net_idx_next >= 0x1000) {
|
||||
BT_ERR("No NetKey Index available");
|
||||
BT_ERR("No NetKeyIndex available");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -1230,13 +1234,13 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx
|
|||
|
||||
/* Check if the same network key already exists */
|
||||
if (provisioner_check_net_key(net_key, net_idx)) {
|
||||
BT_WARN("NetKey exists, NetKey Index updated");
|
||||
BT_WARN("NetKey exists, NetKeyIndex updated");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Check if the same net_idx already exists */
|
||||
if (provisioner_check_net_idx(*net_idx, true)) {
|
||||
BT_ERR("%s, NetKey Index 0x%03x exists", __func__, *net_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", *net_idx);
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
|
@ -1257,12 +1261,12 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx
|
|||
|
||||
sub = bt_mesh_calloc(sizeof(struct bt_mesh_subnet));
|
||||
if (!sub) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (bt_mesh_net_keys_create(&sub->keys[0], p_key)) {
|
||||
BT_ERR("%s, Failed to generate NID", __func__);
|
||||
BT_ERR("Failed to generate NID");
|
||||
bt_mesh_free(sub);
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -1275,7 +1279,7 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx
|
|||
if (provisioner_check_net_idx(sub->net_idx, true)) {
|
||||
sub->net_idx = (++bt_mesh.p_net_idx_next);
|
||||
if (sub->net_idx >= 0x1000) {
|
||||
BT_ERR("No NetKey Index available");
|
||||
BT_ERR("No NetKeyIndex available");
|
||||
bt_mesh_free(sub);
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -1305,7 +1309,7 @@ int bt_mesh_provisioner_local_net_key_update(const u8_t net_key[16], u16_t net_i
|
|||
int err = 0;
|
||||
|
||||
if (net_key == NULL) {
|
||||
BT_ERR("%s, Invalid NetKey", __func__);
|
||||
BT_ERR("Invalid NetKey");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1313,13 +1317,13 @@ int bt_mesh_provisioner_local_net_key_update(const u8_t net_key[16], u16_t net_i
|
|||
|
||||
sub = bt_mesh_provisioner_subnet_get(net_idx);
|
||||
if (sub == NULL) {
|
||||
BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", 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__);
|
||||
BT_ERR("Failed to generate NID");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -1332,7 +1336,7 @@ int bt_mesh_provisioner_local_net_key_update(const u8_t net_key[16], u16_t net_i
|
|||
|
||||
err = bt_mesh_net_beacon_update(sub);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to update secure beacon", __func__);
|
||||
BT_ERR("Failed to update secure beacon");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -1351,7 +1355,7 @@ const u8_t *bt_mesh_provisioner_local_net_key_get(u16_t net_idx)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (provisioner_check_net_idx(net_idx, false)) {
|
||||
BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1376,7 +1380,7 @@ int bt_mesh_provisioner_local_net_key_delete(u16_t net_idx)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (provisioner_check_net_idx(net_idx, false)) {
|
||||
BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -1414,7 +1418,7 @@ int bt_mesh_provisioner_bind_local_model_app_idx(u16_t elem_addr, u16_t mod_id,
|
|||
|
||||
elem = bt_mesh_elem_find(elem_addr);
|
||||
if (!elem) {
|
||||
BT_ERR("%s, No element found, addr 0x%04x", __func__, elem_addr);
|
||||
BT_ERR("No element found, addr 0x%04x", elem_addr);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -1424,12 +1428,12 @@ int bt_mesh_provisioner_bind_local_model_app_idx(u16_t elem_addr, u16_t mod_id,
|
|||
model = bt_mesh_model_find_vnd(elem, cid, mod_id);
|
||||
}
|
||||
if (!model) {
|
||||
BT_ERR("%s, No model is found", __func__);
|
||||
BT_ERR("No model found, model id 0x%04x, cid 0x%04x", mod_id, cid);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (provisioner_check_app_idx(app_idx, false)) {
|
||||
BT_ERR("%s, AppKey Index 0x%03x not exists", __func__, app_idx);
|
||||
BT_ERR("Invalid AppKeyIndex 0x%04x", app_idx);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -1464,7 +1468,7 @@ int bt_mesh_print_local_composition_data(void)
|
|||
|
||||
comp = bt_mesh_comp_get();
|
||||
if (!comp) {
|
||||
BT_ERR("%s, NULL composition data", __func__);
|
||||
BT_ERR("Invalid composition data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1502,33 +1506,33 @@ int bt_mesh_provisioner_store_node_info(struct bt_mesh_node *node)
|
|||
}
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(node->unicast_addr)) {
|
||||
BT_ERR("%s, Not a unicast address 0x%04x", __func__, node->unicast_addr);
|
||||
BT_ERR("Invalid unicast address 0x%04x", node->unicast_addr);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (node->element_num == 0) {
|
||||
BT_ERR("%s, Invalid element count %d", __func__, node->element_num);
|
||||
BT_ERR("Invalid element count %d", node->element_num);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (bt_mesh_provisioner_check_is_addr_dup(node->unicast_addr, node->element_num, true)) {
|
||||
BT_ERR("%s, Unicast address 0x%04x is duplicated", __func__, node->unicast_addr);
|
||||
BT_ERR("Duplicate unicast address 0x%04x", node->unicast_addr);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (node->unicast_addr + node->element_num - 1 > 0x7FFF) {
|
||||
BT_ERR("%s, Not enough unicast address for the node", __func__);
|
||||
BT_ERR("Not enough unicast address for the node");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (bt_mesh_provisioner_net_key_get(node->net_idx) == NULL) {
|
||||
BT_ERR("%s, Invalid NetKey Index 0x%03x", __func__, node->net_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", node->net_idx);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = provisioner_store_node(node, true, NULL);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to store node info", __func__);
|
||||
BT_ERR("Failed to store node info");
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,9 +59,11 @@ u16_t bt_mesh_provisioner_get_node_count(void);
|
|||
|
||||
int bt_mesh_provisioner_restore_node_info(struct bt_mesh_node *node);
|
||||
|
||||
int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16], u16_t oob_info,
|
||||
u16_t unicast_addr, u8_t element_num, u16_t net_idx, u8_t flags,
|
||||
u32_t iv_index, const u8_t dev_key[16], u16_t *index);
|
||||
int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16],
|
||||
u16_t oob_info, u16_t unicast_addr,
|
||||
u8_t element_num, u16_t net_idx,
|
||||
u8_t flags, u32_t iv_index,
|
||||
const u8_t dev_key[16], u16_t *index);
|
||||
|
||||
int bt_mesh_provisioner_remove_node(const u8_t uuid[16]);
|
||||
|
||||
|
@ -101,9 +103,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);
|
||||
|
||||
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_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);
|
||||
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);
|
||||
|
||||
|
|
|
@ -447,7 +447,7 @@ void bt_mesh_provisioner_clear_link_info(const u8_t addr[6])
|
|||
return;
|
||||
}
|
||||
|
||||
BT_DBG("%s, Clear device %s info", __func__, bt_hex(addr, BLE_MESH_ADDR_LEN));
|
||||
BT_DBG("Clear device info, addr %s", bt_hex(addr, BLE_MESH_ADDR_LEN));
|
||||
|
||||
for (i = CONFIG_BLE_MESH_PBA_SAME_TIME; i < BLE_MESH_PROV_SAME_TIME; i++) {
|
||||
if (!memcmp(link[i].addr.val, addr, BLE_MESH_ADDR_LEN)) {
|
||||
|
@ -464,7 +464,7 @@ void bt_mesh_provisioner_clear_link_info(const u8_t addr[6])
|
|||
}
|
||||
}
|
||||
|
||||
BT_WARN("Device address %s is not found", bt_hex(addr, BLE_MESH_ADDR_LEN));
|
||||
BT_WARN("Device not found, addr %s", bt_hex(addr, BLE_MESH_ADDR_LEN));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -520,7 +520,7 @@ static int provisioner_dev_find(const bt_mesh_addr_t *addr, const u8_t uuid[16],
|
|||
}
|
||||
|
||||
if (!uuid_match && !addr_match) {
|
||||
BT_DBG("%s, Device does not exist in queue", __func__);
|
||||
BT_DBG("Device not exists in queue");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -568,7 +568,7 @@ static bool is_unprov_dev_being_provision(const u8_t uuid[16])
|
|||
if (link[i].connecting || bt_mesh_atomic_test_bit(link[i].flags, LINK_ACTIVE)) {
|
||||
#endif
|
||||
if (!memcmp(link[i].uuid, uuid, 16)) {
|
||||
BT_DBG("%s, Device is being provisioned", __func__);
|
||||
BT_DBG("Device is being provisioning");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ static int provisioner_check_unprov_dev_info(const u8_t uuid[16], bt_mesh_prov_b
|
|||
|
||||
/* Check if the device uuid matches configured value */
|
||||
if (is_unprov_dev_uuid_match(uuid) == false) {
|
||||
BT_DBG("%s, Device uuid mismatch", __func__);
|
||||
BT_DBG("Device uuid mismatch");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -685,7 +685,7 @@ static int provisioner_start_prov_pb_adv(const u8_t uuid[16], const bt_mesh_addr
|
|||
}
|
||||
}
|
||||
|
||||
BT_ERR("%s, No PB-ADV link is available", __func__);
|
||||
BT_ERR("No PB-ADV link available");
|
||||
bt_mesh_pb_adv_unlock();
|
||||
|
||||
return -ENOMEM;
|
||||
|
@ -753,7 +753,7 @@ static int provisioner_start_prov_pb_gatt(const u8_t uuid[16], const bt_mesh_add
|
|||
}
|
||||
}
|
||||
|
||||
BT_ERR("%s, No PB-GATT link is available", __func__);
|
||||
BT_ERR("No PB-GATT link available");
|
||||
bt_mesh_pb_gatt_unlock();
|
||||
|
||||
return -ENOMEM;
|
||||
|
@ -785,31 +785,31 @@ int bt_mesh_provisioner_add_unprov_dev(struct bt_mesh_unprov_dev_add *add_dev, u
|
|||
|
||||
if ((add_dev->bearer & BLE_MESH_PROV_ADV) && (add_dev->bearer & BLE_MESH_PROV_GATT) &&
|
||||
(flags & START_PROV_NOW)) {
|
||||
BT_ERR("%s, Can not start PB-ADV & PB-GATT simultaneously", __func__);
|
||||
BT_ERR("Can not start PB-ADV & PB-GATT simultaneously");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((uuid_cmp == 0) && (flags & START_PROV_NOW)) {
|
||||
BT_ERR("%s, Can not start provisioning with zero uuid", __func__);
|
||||
BT_ERR("Can not start provisioning with zero uuid");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((add_dev->bearer & BLE_MESH_PROV_GATT) && (flags & START_PROV_NOW) &&
|
||||
((addr_cmp == 0) || add_dev->addr_type > BLE_MESH_ADDR_RANDOM)) {
|
||||
BT_ERR("%s, Invalid device address for PB-GATT", __func__);
|
||||
BT_ERR("Invalid device address for PB-GATT");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (add_dev->bearer & BLE_MESH_PROV_GATT) {
|
||||
#if !CONFIG_BLE_MESH_PB_GATT
|
||||
BT_ERR("%s, Not support PB-GATT", __func__);
|
||||
BT_ERR("Not support PB-GATT");
|
||||
return -EINVAL;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (add_dev->bearer & BLE_MESH_PROV_ADV) {
|
||||
#if !CONFIG_BLE_MESH_PB_ADV
|
||||
BT_ERR("%s, Not support PB-ADV", __func__);
|
||||
BT_ERR("Not support PB-ADV");
|
||||
return -EINVAL;
|
||||
#endif
|
||||
}
|
||||
|
@ -872,7 +872,7 @@ int bt_mesh_provisioner_add_unprov_dev(struct bt_mesh_unprov_dev_add *add_dev, u
|
|||
}
|
||||
}
|
||||
|
||||
BT_ERR("%s, Unprovisioned device queue is full", __func__);
|
||||
BT_ERR("Unprovisioned device queue is full");
|
||||
return -ENOMEM;
|
||||
|
||||
start:
|
||||
|
@ -920,32 +920,32 @@ int bt_mesh_provisioner_prov_device_with_addr(const u8_t uuid[16], const u8_t ad
|
|||
int err = 0;
|
||||
|
||||
if (uuid == NULL) {
|
||||
BT_ERR("%s, NULL device uuid", __func__);
|
||||
BT_ERR("Invalid device uuid");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (bearer != BLE_MESH_PROV_ADV && bearer != BLE_MESH_PROV_GATT) {
|
||||
BT_ERR("%s, Invalid provisioning bearer 0x%02x", __func__, bearer);
|
||||
BT_ERR("Invalid provisioning bearer 0x%02x", bearer);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) && bearer == BLE_MESH_PROV_ADV) {
|
||||
BT_ERR("%s, Not support PB-ADV", __func__);
|
||||
BT_ERR("Not support PB-ADV");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (!IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && bearer == BLE_MESH_PROV_GATT) {
|
||||
BT_ERR("%s, Not support PB-GATT", __func__);
|
||||
BT_ERR("Not support PB-GATT");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (bearer == BLE_MESH_PROV_GATT && (addr == NULL || addr_type > BLE_MESH_ADDR_RANDOM)) {
|
||||
BT_ERR("%s, Invalid device address info", __func__);
|
||||
BT_ERR("Invalid device address info");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) {
|
||||
BT_ERR("%s, Invalid unicast address 0x%04x", __func__, unicast_addr);
|
||||
BT_ERR("Invalid unicast address 0x%04x", unicast_addr);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1037,7 +1037,7 @@ int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev)
|
|||
/* First: find if the device is in the device queue */
|
||||
err = provisioner_dev_find(&del_addr, del_dev->uuid, &i);
|
||||
if (err) {
|
||||
BT_DBG("%s, Device is not in the queue", __func__);
|
||||
BT_DBG("Device not in queue");
|
||||
} else {
|
||||
memset(&unprov_dev[i], 0x0, sizeof(struct unprov_dev_queue));
|
||||
}
|
||||
|
@ -1115,7 +1115,7 @@ int bt_mesh_provisioner_set_prov_data_info(struct bt_mesh_prov_data_info *info)
|
|||
if (info->flag & NET_IDX_FLAG) {
|
||||
key = bt_mesh_provisioner_net_key_get(info->net_idx);
|
||||
if (!key) {
|
||||
BT_ERR("%s, Failed to get NetKey", __func__);
|
||||
BT_ERR("Failed to get NetKey");
|
||||
return -EINVAL;
|
||||
}
|
||||
prov_ctx.curr_net_idx = info->net_idx;
|
||||
|
@ -1138,14 +1138,14 @@ int bt_mesh_provisioner_set_prov_info(void)
|
|||
*/
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(prov->prov_unicast_addr) ||
|
||||
!BLE_MESH_ADDR_IS_UNICAST(prov->prov_start_address)) {
|
||||
BT_ERR("%s, Invalid address, own 0x%04x, start 0x%04x",
|
||||
__func__, prov->prov_unicast_addr, prov->prov_start_address);
|
||||
BT_ERR("Invalid address, own 0x%04x, start 0x%04x",
|
||||
prov->prov_unicast_addr, prov->prov_start_address);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
comp = bt_mesh_comp_get();
|
||||
if (!comp) {
|
||||
BT_ERR("%s, NULL composition data", __func__);
|
||||
BT_ERR("Invalid composition data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1195,7 +1195,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 = 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__);
|
||||
BT_ERR("Static OOB is being used");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1224,7 +1224,7 @@ int bt_mesh_provisioner_set_primary_elem_addr(u16_t addr)
|
|||
|
||||
comp = bt_mesh_comp_get();
|
||||
if (!comp) {
|
||||
BT_ERR("NULL composition data");
|
||||
BT_ERR("Invalid composition data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1259,7 +1259,7 @@ int bt_mesh_test_provisioner_update_alloc_addr(u16_t unicast_addr, u16_t element
|
|||
u16_t max_addr = FAST_PROV_ENABLE() ? prov_ctx.fast_prov.unicast_addr_max : PROV_MAX_ADDR_TO_ASSIGN;
|
||||
|
||||
if (unicast_addr + element_num > max_addr) {
|
||||
BT_WARN("%s, Not enough unicast address to allocate", __func__);
|
||||
BT_WARN("Not enough unicast address to allocate");
|
||||
prov_ctx.curr_alloc_addr = BLE_MESH_ADDR_UNASSIGNED;
|
||||
} else {
|
||||
prov_ctx.curr_alloc_addr = unicast_addr + element_num;
|
||||
|
@ -1293,17 +1293,17 @@ u16_t bt_mesh_provisioner_get_fast_prov_net_idx(void)
|
|||
u8_t bt_mesh_set_fast_prov_unicast_addr_range(u16_t min, u16_t max)
|
||||
{
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(min) || !BLE_MESH_ADDR_IS_UNICAST(max)) {
|
||||
BT_ERR("%s, Not a unicast address", __func__);
|
||||
BT_ERR("Invalid unicast address, min 0x%04x, max 0x%04x", min, max);
|
||||
return 0x01; /* status: not a unicast address */
|
||||
}
|
||||
|
||||
if (min > max) {
|
||||
BT_ERR("%s, Min bigger than max", __func__);
|
||||
BT_ERR("Unicast address min is bigger than max");
|
||||
return 0x02; /* status: min is bigger than max */
|
||||
}
|
||||
|
||||
if (min <= prov_ctx.fast_prov.unicast_addr_max) {
|
||||
BT_ERR("%s, Address overlap", __func__);
|
||||
BT_ERR("Unicast address overlap");
|
||||
return 0x03; /* status: address overlaps with current value */
|
||||
}
|
||||
|
||||
|
@ -1620,7 +1620,7 @@ static int prov_send_adv(const u8_t idx, struct net_buf_simple *msg)
|
|||
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));
|
||||
BT_DBG("len %u: %s", msg->len, bt_hex(msg->data, msg->len));
|
||||
|
||||
prov_clear_tx(idx);
|
||||
|
||||
|
@ -1649,7 +1649,7 @@ static int prov_send_adv(const u8_t idx, struct net_buf_simple *msg)
|
|||
buf = start;
|
||||
for (seg_id = 1; msg->len > 0; seg_id++) {
|
||||
if (seg_id >= ARRAY_SIZE(link[idx].tx.buf)) {
|
||||
BT_ERR("%s, Too big message", __func__);
|
||||
BT_ERR("Too big message (seg_id %d)", seg_id);
|
||||
free_segments(idx);
|
||||
return -E2BIG;
|
||||
}
|
||||
|
@ -1698,9 +1698,9 @@ static int prov_send_gatt(const u8_t idx, struct net_buf_simple *msg)
|
|||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
err = bt_mesh_proxy_prov_client_send(link[idx].conn, BLE_MESH_PROXY_PROV, msg);
|
||||
err = bt_mesh_proxy_client_send(link[idx].conn, BLE_MESH_PROXY_PROV, msg);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send PB-GATT pdu", __func__);
|
||||
BT_ERR("Failed to send PB-GATT pdu");
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -1730,7 +1730,7 @@ static inline int prov_send(const u8_t idx, struct net_buf_simple *buf)
|
|||
}
|
||||
#endif
|
||||
|
||||
BT_ERR("%s, Invalid link index %d", __func__, idx);
|
||||
BT_ERR("Invalid link index %d", idx);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1766,7 +1766,7 @@ static void send_invite(const u8_t idx)
|
|||
link[idx].conf_inputs[0] = prov->prov_attention;
|
||||
|
||||
if (prov_send(idx, &buf)) {
|
||||
BT_ERR("%s, Failed to send Provisioning Invite", __func__);
|
||||
BT_ERR("Failed to send Provisioning Invite");
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
@ -1785,7 +1785,7 @@ static void prov_capabilities(const u8_t idx, const u8_t *data)
|
|||
element_num = data[0];
|
||||
BT_INFO("Elements: 0x%02x", element_num);
|
||||
if (!element_num) {
|
||||
BT_ERR("%s, Invalid element number", __func__);
|
||||
BT_ERR("Invalid element number %d", element_num);
|
||||
goto fail;
|
||||
}
|
||||
link[idx].element_num = element_num;
|
||||
|
@ -1793,14 +1793,14 @@ static void prov_capabilities(const u8_t idx, const u8_t *data)
|
|||
algorithms = sys_get_be16(&data[1]);
|
||||
BT_INFO("Algorithms: 0x%04x", algorithms);
|
||||
if (algorithms != BIT(PROV_ALG_P256)) {
|
||||
BT_ERR("%s, Invalid algorithms", __func__);
|
||||
BT_ERR("Invalid algorithms 0x%04x", algorithms);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pub_key_oob = data[3];
|
||||
BT_INFO("Public Key Type: 0x%02x", pub_key_oob);
|
||||
if (pub_key_oob > 0x01) {
|
||||
BT_ERR("%s, Invalid public key type", __func__);
|
||||
BT_ERR("Invalid public key type 0x%02x", pub_key_oob);
|
||||
goto fail;
|
||||
}
|
||||
pub_key_oob = ((prov->prov_pub_key_oob &&
|
||||
|
@ -1809,7 +1809,7 @@ static void prov_capabilities(const u8_t idx, const u8_t *data)
|
|||
static_oob = data[4];
|
||||
BT_INFO("Static OOB Type: 0x%02x", static_oob);
|
||||
if (static_oob > 0x01) {
|
||||
BT_ERR("%s, Invalid Static OOB type", __func__);
|
||||
BT_ERR("Invalid Static OOB type 0x%02x", static_oob);
|
||||
goto fail;
|
||||
}
|
||||
static_oob = (prov_ctx.static_oob_len ? static_oob : 0x00);
|
||||
|
@ -1817,14 +1817,14 @@ static void prov_capabilities(const u8_t idx, const u8_t *data)
|
|||
output_size = data[5];
|
||||
BT_INFO("Output OOB Size: 0x%02x", output_size);
|
||||
if (output_size > 0x08) {
|
||||
BT_ERR("%s, Invalid Output OOB size", __func__);
|
||||
BT_ERR("Invalid Output OOB size %d", output_size);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
output_action = sys_get_be16(&data[6]);
|
||||
BT_INFO("Output OOB Action: 0x%04x", output_action);
|
||||
if (output_action > 0x1f) {
|
||||
BT_ERR("%s, Invalid Output OOB action", __func__);
|
||||
BT_ERR("Invalid Output OOB action 0x%04x", output_action);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -1839,14 +1839,14 @@ static void prov_capabilities(const u8_t idx, const u8_t *data)
|
|||
input_size = data[8];
|
||||
BT_INFO("Input OOB Size: 0x%02x", input_size);
|
||||
if (input_size > 0x08) {
|
||||
BT_ERR("%s, Invalid Input OOB size", __func__);
|
||||
BT_ERR("Invalid Input OOB size %d", input_size);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
input_action = sys_get_be16(&data[9]);
|
||||
BT_INFO("Input OOB Action: 0x%04x", input_action);
|
||||
if (input_action > 0x0f) {
|
||||
BT_ERR("%s, Invalid Input OOB action", __func__);
|
||||
BT_ERR("Invalid Input OOB action 0x%04x", input_action);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -1897,7 +1897,7 @@ static void prov_capabilities(const u8_t idx, const u8_t *data)
|
|||
memcpy(&link[idx].conf_inputs[12], &buf.data[1], 5);
|
||||
|
||||
if (prov_send(idx, &buf)) {
|
||||
BT_ERR("%s, Failed to send Provisioning Start", __func__);
|
||||
BT_ERR("Failed to send Provisioning Start");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -1911,7 +1911,7 @@ static void prov_capabilities(const u8_t idx, const u8_t *data)
|
|||
*/
|
||||
if (pub_key_oob) {
|
||||
if (prov->prov_pub_key_oob_cb(idx)) {
|
||||
BT_ERR("%s, Failed to notify input OOB Public Key", __func__);
|
||||
BT_ERR("Failed to notify input OOB Public Key");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
@ -1975,7 +1975,7 @@ static int prov_auth(const u8_t idx, u8_t method, u8_t action, u8_t size)
|
|||
|
||||
link[idx].auth = (u8_t *)bt_mesh_calloc(PROV_AUTH_VAL_SIZE);
|
||||
if (!link[idx].auth) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -2064,25 +2064,25 @@ static void send_confirm(const u8_t idx)
|
|||
|
||||
link[idx].conf_salt = (u8_t *)bt_mesh_calloc(PROV_CONF_SALT_SIZE);
|
||||
if (!link[idx].conf_salt) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
link[idx].conf_key = (u8_t *)bt_mesh_calloc(PROV_CONF_KEY_SIZE);
|
||||
if (!link[idx].conf_key) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (bt_mesh_prov_conf_salt(link[idx].conf_inputs, link[idx].conf_salt)) {
|
||||
BT_ERR("%s, Failed to generate confirmation salt", __func__);
|
||||
BT_ERR("Failed to generate confirmation salt");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
BT_DBG("ConfirmationSalt: %s", bt_hex(link[idx].conf_salt, 16));
|
||||
|
||||
if (bt_mesh_prov_conf_key(link[idx].dhkey, link[idx].conf_salt, link[idx].conf_key)) {
|
||||
BT_ERR("%s, Failed to generate confirmation key", __func__);
|
||||
BT_ERR("Failed to generate confirmation key");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -2094,7 +2094,7 @@ static void send_confirm(const u8_t idx)
|
|||
*/
|
||||
if (!(prov_ctx.rand_gen_done & BIT(0))) {
|
||||
if (bt_mesh_rand(prov_ctx.random, 16)) {
|
||||
BT_ERR("%s, Failed to generate random number", __func__);
|
||||
BT_ERR("Failed to generate random number");
|
||||
goto fail;
|
||||
}
|
||||
link[idx].rand = prov_ctx.random;
|
||||
|
@ -2110,12 +2110,12 @@ static void send_confirm(const u8_t idx)
|
|||
|
||||
if (bt_mesh_prov_conf(link[idx].conf_key, link[idx].rand, link[idx].auth,
|
||||
net_buf_simple_add(&buf, 16))) {
|
||||
BT_ERR("%s, Failed to generate confirmation value", __func__);
|
||||
BT_ERR("Failed to generate confirmation value");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (prov_send(idx, &buf)) {
|
||||
BT_ERR("%s, Failed to send Provisioning Confirm", __func__);
|
||||
BT_ERR("Failed to send Provisioning Confirm");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -2140,7 +2140,7 @@ int bt_mesh_provisioner_set_oob_input_data(const u8_t idx, const u8_t *val, bool
|
|||
* input by provisioner is number or string.
|
||||
*/
|
||||
if (!link[idx].auth) {
|
||||
BT_ERR("%s, Link auth is NULL", __func__);
|
||||
BT_ERR("Invalid link auth");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2159,7 +2159,8 @@ int bt_mesh_provisioner_set_oob_input_data(const u8_t idx, const u8_t *val, bool
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, u8_t size, bool num_flag)
|
||||
int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num,
|
||||
u8_t size, bool num_flag)
|
||||
{
|
||||
/** This function should be called in the prov_output_num
|
||||
* callback, after the data has been output by provisioner.
|
||||
|
@ -2176,7 +2177,7 @@ int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, u8_
|
|||
}
|
||||
|
||||
if (!link[idx].auth) {
|
||||
BT_ERR("%s, link auth is NULL", __func__);
|
||||
BT_ERR("Invalid link auth");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2197,10 +2198,11 @@ int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, u8_
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_provisioner_read_oob_pub_key(const u8_t idx, const u8_t pub_key_x[32], const u8_t pub_key_y[32])
|
||||
int bt_mesh_provisioner_read_oob_pub_key(const u8_t idx, const u8_t pub_key_x[32],
|
||||
const u8_t pub_key_y[32])
|
||||
{
|
||||
if (!link[idx].conf_inputs) {
|
||||
BT_ERR("%s, Link conf_inputs is NULL", __func__);
|
||||
BT_ERR("Invalid link conf_inputs");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2222,13 +2224,13 @@ static void prov_dh_key_cb(const u8_t key[32], const u8_t idx)
|
|||
BT_DBG("%p", key);
|
||||
|
||||
if (!key) {
|
||||
BT_ERR("%s, Failed to generate DHKey", __func__);
|
||||
BT_ERR("Failed to generate DHKey");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
link[idx].dhkey = (u8_t *)bt_mesh_calloc(PROV_DH_KEY_SIZE);
|
||||
if (!link[idx].dhkey) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
goto fail;
|
||||
}
|
||||
sys_memcpy_swap(link[idx].dhkey, key, 32);
|
||||
|
@ -2246,7 +2248,7 @@ static void prov_dh_key_cb(const u8_t key[32], const u8_t idx)
|
|||
*/
|
||||
if (prov_auth(idx, link[idx].auth_method,
|
||||
link[idx].auth_action, link[idx].auth_size) < 0) {
|
||||
BT_ERR("%s, Failed to authenticate", __func__);
|
||||
BT_ERR("Failed to authenticate");
|
||||
goto fail;
|
||||
}
|
||||
if (link[idx].auth_method == AUTH_METHOD_OUTPUT ||
|
||||
|
@ -2275,7 +2277,7 @@ static void prov_gen_dh_key(const u8_t idx)
|
|||
sys_memcpy_swap(&pub_key[32], &link[idx].conf_inputs[113], 32);
|
||||
|
||||
if (bt_mesh_dh_key_gen(pub_key, prov_dh_key_cb, idx)) {
|
||||
BT_ERR("%s, Failed to generate DHKey", __func__);
|
||||
BT_ERR("Failed to generate DHKey");
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
@ -2288,7 +2290,7 @@ static void send_pub_key(const u8_t idx, u8_t oob)
|
|||
|
||||
key = bt_mesh_pub_key_get();
|
||||
if (!key) {
|
||||
BT_ERR("%s, No public key available", __func__);
|
||||
BT_ERR("No public key available");
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
@ -2307,7 +2309,7 @@ static void send_pub_key(const u8_t idx, u8_t oob)
|
|||
memcpy(&link[idx].conf_inputs[17], &buf.data[1], 64);
|
||||
|
||||
if (prov_send(idx, &buf)) {
|
||||
BT_ERR("%s, Failed to send Provisioning Public Key", __func__);
|
||||
BT_ERR("Failed to send Provisioning Public Key");
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
@ -2391,7 +2393,7 @@ static void prov_confirm(const u8_t idx, const u8_t *data)
|
|||
|
||||
link[idx].conf = (u8_t *)bt_mesh_calloc(PROV_CONFIRM_SIZE);
|
||||
if (!link[idx].conf) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
@ -2410,7 +2412,7 @@ static void prov_confirm(const u8_t idx, const u8_t *data)
|
|||
net_buf_simple_add_mem(&buf, link[idx].rand, 16);
|
||||
|
||||
if (prov_send(idx, &buf)) {
|
||||
BT_ERR("%s, Failed to send Provisioning Random", __func__);
|
||||
BT_ERR("Failed to send Provisioning Random");
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
@ -2432,14 +2434,14 @@ static void send_prov_data(const u8_t idx)
|
|||
|
||||
err = bt_mesh_session_key(link[idx].dhkey, link[idx].prov_salt, session_key);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to generate session key", __func__);
|
||||
BT_ERR("Failed to generate session key");
|
||||
goto fail;
|
||||
}
|
||||
BT_DBG("SessionKey: %s", bt_hex(session_key, 16));
|
||||
|
||||
err = bt_mesh_prov_nonce(link[idx].dhkey, link[idx].prov_salt, nonce);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to generate session nonce", __func__);
|
||||
BT_ERR("Failed to generate session nonce");
|
||||
goto fail;
|
||||
}
|
||||
BT_DBG("Nonce: %s", bt_hex(nonce, 13));
|
||||
|
@ -2504,14 +2506,14 @@ static void send_prov_data(const u8_t idx)
|
|||
} else {
|
||||
/* If this device to be provisioned is a new device */
|
||||
if (prov_ctx.curr_alloc_addr == BLE_MESH_ADDR_UNASSIGNED) {
|
||||
BT_ERR("%s, No unicast address can be allocated", __func__);
|
||||
BT_ERR("Not enough unicast address to be allocated");
|
||||
goto fail;
|
||||
}
|
||||
alloc_addr = prov_ctx.curr_alloc_addr;
|
||||
}
|
||||
|
||||
if (alloc_addr + link[idx].element_num - 1 > max_addr) {
|
||||
BT_ERR("%s, Not enough unicast address for the device", __func__);
|
||||
BT_ERR("Not enough unicast address for the device");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -2520,7 +2522,7 @@ static void send_prov_data(const u8_t idx)
|
|||
* any unicast address of Provisioner.
|
||||
*/
|
||||
if (bt_mesh_provisioner_check_is_addr_dup(alloc_addr, link[idx].element_num, true)) {
|
||||
BT_ERR("%s, Assigned address 0x%04x is duplicated", __func__, alloc_addr);
|
||||
BT_ERR("Duplicate assigned address 0x%04x", alloc_addr);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -2532,12 +2534,12 @@ static void send_prov_data(const u8_t idx)
|
|||
|
||||
err = bt_mesh_prov_encrypt(session_key, nonce, pdu, net_buf_simple_add(&buf, 33));
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to encrypt provisioning data", __func__);
|
||||
BT_ERR("Failed to encrypt provisioning data");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (prov_send(idx, &buf)) {
|
||||
BT_ERR("%s, Failed to send Provisioning Data", __func__);
|
||||
BT_ERR("Failed to send Provisioning Data");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -2595,12 +2597,12 @@ static void prov_random(const u8_t idx, const u8_t *data)
|
|||
BT_DBG("Remote Random: %s", bt_hex(data, 16));
|
||||
|
||||
if (bt_mesh_prov_conf(link[idx].conf_key, data, link[idx].auth, conf_verify)) {
|
||||
BT_ERR("%s, Failed to calculate confirmation verification", __func__);
|
||||
BT_ERR("Failed to calculate confirmation verification");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (memcmp(conf_verify, link[idx].conf, 16)) {
|
||||
BT_ERR("%s, Invalid confirmation value", __func__);
|
||||
BT_ERR("Invalid confirmation value");
|
||||
BT_DBG("Received: %s", bt_hex(link[idx].conf, 16));
|
||||
BT_DBG("Calculated: %s", bt_hex(conf_verify, 16));
|
||||
goto fail;
|
||||
|
@ -2620,13 +2622,13 @@ static void prov_random(const u8_t idx, const u8_t *data)
|
|||
*/
|
||||
link[idx].prov_salt = (u8_t *)bt_mesh_calloc(PROV_PROV_SALT_SIZE);
|
||||
if (!link[idx].prov_salt) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (bt_mesh_prov_salt(link[idx].conf_salt, link[idx].rand, data,
|
||||
link[idx].prov_salt)) {
|
||||
BT_ERR("%s, Failed to generate ProvisioningSalt", __func__);
|
||||
BT_ERR("Failed to generate ProvisioningSalt");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -2655,7 +2657,7 @@ static void prov_complete(const u8_t idx, const u8_t *data)
|
|||
|
||||
err = bt_mesh_dev_key(link[idx].dhkey, link[idx].prov_salt, device_key);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to generate device key", __func__);
|
||||
BT_ERR("Failed to generate device key");
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
@ -2669,7 +2671,7 @@ static void prov_complete(const u8_t idx, const u8_t *data)
|
|||
link[idx].unicast_addr, link[idx].element_num, net_idx,
|
||||
link[idx].ki_flags, link[idx].iv_index, device_key, &index);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to store node info", __func__);
|
||||
BT_ERR("Failed to store node info");
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
@ -2685,7 +2687,7 @@ static void prov_complete(const u8_t idx, const u8_t *data)
|
|||
memset(&unprov_dev[rm], 0, sizeof(struct unprov_dev_queue));
|
||||
}
|
||||
} else if (err == -ENODEV) {
|
||||
BT_DBG("Device is not found in queue");
|
||||
BT_DBG("Device not found in queue");
|
||||
} else {
|
||||
BT_ERR("Failed to remove device from queue");
|
||||
}
|
||||
|
@ -2695,7 +2697,7 @@ static void prov_complete(const u8_t idx, const u8_t *data)
|
|||
|
||||
static void prov_failed(const u8_t idx, const u8_t *data)
|
||||
{
|
||||
BT_WARN("%s, Error 0x%02x", __func__, data[0]);
|
||||
BT_WARN("Error 0x%02x", data[0]);
|
||||
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
}
|
||||
|
@ -2738,7 +2740,7 @@ static void close_link(const u8_t idx, u8_t reason)
|
|||
}
|
||||
#endif
|
||||
|
||||
BT_ERR("%s, Invalid link index %d", __func__, idx);
|
||||
BT_ERR("Invalid link idx %d", idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2816,19 +2818,19 @@ static void link_ack(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *
|
|||
BT_DBG("len %u", buf->len);
|
||||
|
||||
if (buf->len) {
|
||||
BT_ERR("%s, Invalid Link ACK length", __func__);
|
||||
BT_ERR("Invalid Link ACK length %d", buf->len);
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (link[idx].expect == PROV_CAPABILITIES) {
|
||||
BT_INFO("%s, Link ACK is already received", __func__);
|
||||
BT_INFO("Link ACK is already received");
|
||||
return;
|
||||
}
|
||||
|
||||
link[idx].conf_inputs = (u8_t *)bt_mesh_calloc(PROV_CONF_INPUTS_SIZE);
|
||||
if (!link[idx].conf_inputs) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
@ -2870,7 +2872,7 @@ static void gen_prov_ctl(const u8_t idx, struct prov_rx *rx, struct net_buf_simp
|
|||
break;
|
||||
|
||||
default:
|
||||
BT_ERR("%s, Unknown bearer opcode 0x%02x", __func__, BEARER_CTL(rx->gpc));
|
||||
BT_ERR("Unknown bearer opcode 0x%02x", BEARER_CTL(rx->gpc));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2886,22 +2888,22 @@ static void prov_msg_recv(const u8_t idx)
|
|||
* Provisioning PDU. If the check succeeds then check fcs.
|
||||
*/
|
||||
if (type != PROV_FAILED && type != link[idx].expect) {
|
||||
BT_ERR("%s, Unexpected msg 0x%02x != 0x%02x", __func__, type, link[idx].expect);
|
||||
BT_ERR("Unexpected msg 0x%02x != 0x%02x", type, link[idx].expect);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (type >= 0x0A) {
|
||||
BT_ERR("%s, Unknown provisioning PDU type 0x%02x", __func__, type);
|
||||
BT_ERR("Unknown provisioning PDU type 0x%02x", type);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (1 + prov_handlers[type].len != link[idx].rx.buf->len) {
|
||||
BT_ERR("%s, Invalid length %u for type 0x%02x", __func__, link[idx].rx.buf->len, type);
|
||||
BT_ERR("Invalid length %u for type 0x%02x", link[idx].rx.buf->len, type);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!bt_mesh_fcs_check(link[idx].rx.buf, link[idx].rx.fcs)) {
|
||||
BT_ERR("%s, Incorrect FCS", __func__);
|
||||
BT_ERR("Incorrect FCS");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -2924,7 +2926,7 @@ static void gen_prov_cont(const u8_t idx, struct prov_rx *rx, struct net_buf_sim
|
|||
BT_DBG("len %u, seg_index %u", buf->len, seg);
|
||||
|
||||
if (!link[idx].rx.seg && link[idx].rx.prev_id == rx->xact_id) {
|
||||
BT_INFO("%s, Resending ack", __func__);
|
||||
BT_INFO("Resending ack");
|
||||
gen_prov_ack_send(idx, rx->xact_id);
|
||||
return;
|
||||
}
|
||||
|
@ -2936,7 +2938,7 @@ static void gen_prov_cont(const u8_t idx, struct prov_rx *rx, struct net_buf_sim
|
|||
}
|
||||
|
||||
if (seg > link[idx].rx.last_seg) {
|
||||
BT_ERR("%s, Invalid segment index %u", __func__, seg);
|
||||
BT_ERR("Invalid segment index %u", seg);
|
||||
goto fail;
|
||||
} else if (seg == link[idx].rx.last_seg) {
|
||||
u8_t expect_len = 0U;
|
||||
|
@ -2944,14 +2946,14 @@ static void gen_prov_cont(const u8_t idx, struct prov_rx *rx, struct net_buf_sim
|
|||
expect_len = (link[idx].rx.buf->len - 20 -
|
||||
(23 * (link[idx].rx.last_seg - 1)));
|
||||
if (expect_len != buf->len) {
|
||||
BT_ERR("%s, Incorrect last seg len: %u != %u",
|
||||
__func__, expect_len, buf->len);
|
||||
BT_ERR("Incorrect last seg len: %u != %u",
|
||||
expect_len, buf->len);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(link[idx].rx.seg & BIT(seg))) {
|
||||
BT_INFO("%s, Ignore already received segment", __func__);
|
||||
BT_INFO("Ignore already received segment");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3004,12 +3006,12 @@ static void gen_prov_ack(const u8_t idx, struct prov_rx *rx, struct net_buf_simp
|
|||
static void gen_prov_start(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf)
|
||||
{
|
||||
if (link[idx].rx.seg) {
|
||||
BT_INFO("%s, Get Start while there are unreceived segments", __func__);
|
||||
BT_INFO("Get Start while there are unreceived segments");
|
||||
return;
|
||||
}
|
||||
|
||||
if (link[idx].rx.prev_id == rx->xact_id) {
|
||||
BT_INFO("%s, Resending ack", __func__);
|
||||
BT_INFO("Resending ack");
|
||||
gen_prov_ack_send(idx, rx->xact_id);
|
||||
return;
|
||||
}
|
||||
|
@ -3023,20 +3025,20 @@ static void gen_prov_start(const u8_t idx, struct prov_rx *rx, struct net_buf_si
|
|||
|
||||
/* Provisioner can not receive zero-length provisioning pdu */
|
||||
if (link[idx].rx.buf->len < 1) {
|
||||
BT_ERR("%s, Ignoring zero-length provisioning PDU", __func__);
|
||||
BT_ERR("Ignoring zero-length provisioning PDU");
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (link[idx].rx.buf->len > link[idx].rx.buf->size) {
|
||||
BT_ERR("%s, Too large provisioning PDU (%u bytes)",
|
||||
__func__, link[idx].rx.buf->len);
|
||||
BT_ERR("Too large provisioning PDU (%u bytes)",
|
||||
link[idx].rx.buf->len);
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (START_LAST_SEG(rx->gpc) > 0 && link[idx].rx.buf->len <= 20) {
|
||||
BT_ERR("%s, Too small total length for multi-segment PDU", __func__);
|
||||
BT_ERR("Too small total length for multi-segment PDU");
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
@ -3065,7 +3067,7 @@ static const struct {
|
|||
static void gen_prov_recv(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf)
|
||||
{
|
||||
if (buf->len < gen_prov[GPCF(rx->gpc)].min_len) {
|
||||
BT_ERR("%s, Too short GPC message type %u", __func__, GPCF(rx->gpc));
|
||||
BT_ERR("Too short GPC message type %u", GPCF(rx->gpc));
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
@ -3110,12 +3112,12 @@ void bt_mesh_provisioner_pb_adv_recv(struct net_buf_simple *buf)
|
|||
|
||||
rx.link_id = net_buf_simple_pull_be32(buf);
|
||||
if (find_link(rx.link_id, &idx) < 0) {
|
||||
BT_DBG("%s, Data for unexpected link", __func__);
|
||||
BT_DBG("Data for unexpected link");
|
||||
return;
|
||||
}
|
||||
|
||||
if (buf->len < 2) {
|
||||
BT_ERR("%s, Too short provisioning packet (len %u)", __func__, buf->len);
|
||||
BT_ERR("Too short provisioning packet (len %u)", buf->len);
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return;
|
||||
}
|
||||
|
@ -3157,28 +3159,28 @@ int bt_mesh_provisioner_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_s
|
|||
BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
if (!find_conn(conn, &idx)) {
|
||||
BT_ERR("%s, Data for unexpected connection", __func__);
|
||||
BT_ERR("Data for unexpected connection");
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
if (buf->len < 1) {
|
||||
BT_ERR("%s, Too short provisioning packet (len %u)", __func__, buf->len);
|
||||
BT_ERR("Too short provisioning packet (len %u)", buf->len);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
type = net_buf_simple_pull_u8(buf);
|
||||
if (type != PROV_FAILED && type != link[idx].expect) {
|
||||
BT_ERR("%s, Unexpected msg 0x%02x != 0x%02x", __func__, type, link[idx].expect);
|
||||
BT_ERR("Unexpected msg 0x%02x != 0x%02x", type, link[idx].expect);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (type >= 0x0A) {
|
||||
BT_ERR("%s, Unknown provisioning PDU type 0x%02x", __func__, type);
|
||||
BT_ERR("Unknown provisioning PDU type 0x%02x", type);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (prov_handlers[type].len != buf->len) {
|
||||
BT_ERR("%s, Invalid length %u for type 0x%02x", __func__, buf->len, type);
|
||||
BT_ERR("Invalid length %u for type 0x%02x", buf->len, type);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -3208,7 +3210,7 @@ int bt_mesh_provisioner_set_prov_conn(const u8_t addr[6], struct bt_mesh_conn *c
|
|||
}
|
||||
}
|
||||
|
||||
BT_ERR("%s, Address %s is not found", __func__, bt_hex(addr, BLE_MESH_ADDR_LEN));
|
||||
BT_ERR("Addr %s not found", bt_hex(addr, BLE_MESH_ADDR_LEN));
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -3233,7 +3235,7 @@ int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr)
|
|||
}
|
||||
|
||||
if (i == BLE_MESH_PROV_SAME_TIME) {
|
||||
BT_ERR("%s, Link is not found", __func__);
|
||||
BT_ERR("Link not found");
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
|
@ -3260,7 +3262,7 @@ int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr)
|
|||
link[idx].conf_inputs = (u8_t *)bt_mesh_calloc(PROV_CONF_INPUTS_SIZE);
|
||||
if (!link[idx].conf_inputs) {
|
||||
/* Disconnect this connection, clear corresponding informations */
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
close_link(idx, CLOSE_REASON_FAILED);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -3276,7 +3278,7 @@ int bt_mesh_provisioner_pb_gatt_close(struct bt_mesh_conn *conn, u8_t reason)
|
|||
BT_DBG("conn %p", conn);
|
||||
|
||||
if (!find_conn(conn, &idx)) {
|
||||
BT_ERR("%s, Conn %p is not found", __func__, conn);
|
||||
BT_ERR("Conn %p not found", conn);
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
|
@ -3306,13 +3308,13 @@ int bt_mesh_provisioner_prov_init(const struct bt_mesh_prov *prov_info)
|
|||
int i;
|
||||
|
||||
if (!prov_info) {
|
||||
BT_ERR("%s, No provisioning context provided", __func__);
|
||||
BT_ERR("No provisioning context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
key = bt_mesh_pub_key_get();
|
||||
if (!key) {
|
||||
BT_ERR("%s, Failed to generate Public Key", __func__);
|
||||
BT_ERR("Failed to generate Public Key");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -3360,7 +3362,7 @@ int bt_mesh_provisioner_prov_deinit(bool erase)
|
|||
int i;
|
||||
|
||||
if (prov == NULL) {
|
||||
BT_ERR("%s, No provisioning context provided", __func__);
|
||||
BT_ERR("No provisioning context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -3416,7 +3418,7 @@ static bool is_unprov_dev_info_callback_to_app(bt_mesh_prov_bearer_t bearer,
|
|||
BLE_MESH_ADV_NONCONN_IND : BLE_MESH_ADV_IND;
|
||||
|
||||
if (provisioner_dev_find(addr, uuid, &index)) {
|
||||
BT_DBG("%s, Device is not in queue, notify to upper layer", __func__);
|
||||
BT_DBG("Device not in queue, notify to app layer");
|
||||
if (notify_unprov_adv_pkt_cb) {
|
||||
notify_unprov_adv_pkt_cb(addr->val, addr->type, adv_type, uuid, oob_info, bearer, rssi);
|
||||
}
|
||||
|
@ -3444,16 +3446,16 @@ void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, s8_t rss
|
|||
u16_t oob_info = 0U;
|
||||
|
||||
if (!(prov_ctx.bearers & BLE_MESH_PROV_ADV)) {
|
||||
BT_WARN("Provisioner not support PB-ADV bearer");
|
||||
BT_WARN("Not support PB-ADV bearer");
|
||||
return;
|
||||
}
|
||||
|
||||
if (buf->len != 0x12 && buf->len != 0x16) {
|
||||
BT_ERR("%s, Invalid Unprovisioned Device Beacon length", __func__);
|
||||
BT_ERR("Invalid Unprovisioned Device Beacon length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
addr = bt_mesh_pba_get_addr();
|
||||
addr = bt_mesh_get_unprov_dev_addr();
|
||||
uuid = buf->data;
|
||||
net_buf_simple_pull(buf, 16);
|
||||
/* Mesh beacon uses big-endian to send beacon data */
|
||||
|
@ -3472,14 +3474,15 @@ void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, s8_t rss
|
|||
#endif /* CONFIG_BLE_MESH_PB_ADV */
|
||||
}
|
||||
|
||||
void bt_mesh_provisioner_prov_adv_ind_recv(struct net_buf_simple *buf, const bt_mesh_addr_t *addr, s8_t rssi)
|
||||
void bt_mesh_provisioner_prov_adv_recv(struct net_buf_simple *buf,
|
||||
const bt_mesh_addr_t *addr, s8_t rssi)
|
||||
{
|
||||
#if defined(CONFIG_BLE_MESH_PB_GATT)
|
||||
const u8_t *uuid = NULL;
|
||||
u16_t oob_info = 0U;
|
||||
|
||||
if (!(prov_ctx.bearers & BLE_MESH_PROV_GATT)) {
|
||||
BT_WARN("Provisioner not support PB-GATT bearer");
|
||||
BT_WARN("Not support PB-GATT bearer");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,8 @@ int bt_mesh_provisioner_prov_deinit(bool erase);
|
|||
*/
|
||||
void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, s8_t rssi);
|
||||
|
||||
void bt_mesh_provisioner_prov_adv_ind_recv(struct net_buf_simple *buf, const bt_mesh_addr_t *addr, s8_t rssi);
|
||||
void bt_mesh_provisioner_prov_adv_recv(struct net_buf_simple *buf,
|
||||
const bt_mesh_addr_t *addr, s8_t rssi);
|
||||
|
||||
/**
|
||||
* @brief This function gets the bt_mesh_prov pointer.
|
||||
|
@ -359,7 +360,8 @@ int bt_mesh_provisioner_set_oob_input_data(const u8_t idx, const u8_t *val, bool
|
|||
*
|
||||
* @return Zero - success, otherwise - fail
|
||||
*/
|
||||
int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, u8_t size, bool num_flag);
|
||||
int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num,
|
||||
u8_t size, bool num_flag);
|
||||
|
||||
/**
|
||||
* @brief This function is called to read unprovisioned device's oob public key.
|
||||
|
@ -370,7 +372,8 @@ int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, u8_
|
|||
*
|
||||
* @return Zero - success, otherwise - fail
|
||||
*/
|
||||
int bt_mesh_provisioner_read_oob_pub_key(const u8_t idx, const u8_t pub_key_x[32], const u8_t pub_key_y[32]);
|
||||
int bt_mesh_provisioner_read_oob_pub_key(const u8_t idx, const u8_t pub_key_x[32],
|
||||
const u8_t pub_key_y[32]);
|
||||
|
||||
/* The following APIs are for fast provisioning */
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ static void proxy_sar_timeout(struct k_work *work)
|
|||
|
||||
server = CONTAINER_OF(work, struct bt_mesh_proxy_server, sar_timer.work);
|
||||
if (!server || !server->conn) {
|
||||
BT_ERR("%s, Invalid proxy server parameter", __func__);
|
||||
BT_ERR("Invalid proxy server parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -126,19 +126,19 @@ static void filter_status(struct bt_mesh_proxy_server *server,
|
|||
u16_t list_size = 0U;
|
||||
|
||||
if (buf->len != 3) {
|
||||
BT_ERR("%s, Invalid Proxy Filter Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Proxy Filter Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
filter_type = net_buf_simple_pull_u8(buf);
|
||||
if (filter_type > 0x01) {
|
||||
BT_ERR("%s, Invalid filter type 0x%02x", __func__, filter_type);
|
||||
BT_ERR("Invalid proxy filter type 0x%02x", filter_type);
|
||||
return;
|
||||
}
|
||||
|
||||
list_size = net_buf_simple_pull_be16(buf);
|
||||
|
||||
BT_INFO("%s, filter_type 0x%02x list_size %d", __func__, filter_type, list_size);
|
||||
BT_INFO("filter_type 0x%02x, list_size %d", filter_type, list_size);
|
||||
|
||||
if (proxy_client_filter_status_recv_cb) {
|
||||
proxy_client_filter_status_recv_cb(server - servers, rx->ctx.addr, server->net_idx, filter_type, list_size);
|
||||
|
@ -162,12 +162,12 @@ static void proxy_cfg(struct bt_mesh_proxy_server *server)
|
|||
err = bt_mesh_net_decode(&server->buf, BLE_MESH_NET_IF_PROXY_CFG,
|
||||
&rx, &buf);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to decode Proxy Configuration (err %d)", __func__, err);
|
||||
BT_ERR("Failed to decode Proxy Configuration (err %d)", err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(rx.ctx.addr)) {
|
||||
BT_ERR("%s, Proxy Configuration from non-unicast addr 0x%04x", __func__, rx.ctx.addr);
|
||||
BT_ERR("Proxy Configuration from non-unicast addr 0x%04x", rx.ctx.addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ static ssize_t proxy_recv(struct bt_mesh_conn *conn,
|
|||
u16_t srvc_uuid = 0U;
|
||||
|
||||
if (!server) {
|
||||
BT_ERR("%s, No Proxy Server object found", __func__);
|
||||
BT_ERR("No Proxy Server object found");
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ static ssize_t proxy_recv(struct bt_mesh_conn *conn,
|
|||
|
||||
srvc_uuid = bt_mesh_gattc_get_service_uuid(conn);
|
||||
if (!srvc_uuid) {
|
||||
BT_ERR("%s, No service uuid found", __func__);
|
||||
BT_ERR("No service uuid found");
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type,
|
|||
|
||||
mtu = bt_mesh_gattc_get_mtu_info(conn);
|
||||
if (!mtu) {
|
||||
BT_ERR("%s, Conn used to get mtu does not exist", __func__);
|
||||
BT_ERR("Conn %p used to get mtu not exists", conn);
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
|
@ -373,18 +373,18 @@ static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type,
|
|||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_proxy_prov_client_send(struct bt_mesh_conn *conn, u8_t type,
|
||||
int bt_mesh_proxy_client_send(struct bt_mesh_conn *conn, u8_t type,
|
||||
struct net_buf_simple *msg)
|
||||
{
|
||||
struct bt_mesh_proxy_server *server = find_server(conn);
|
||||
|
||||
if (!server) {
|
||||
BT_ERR("$%s, No Proxy Server object found", __func__);
|
||||
BT_ERR("No Proxy Server object found");
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
if ((server->conn_type == PROV) != (type == BLE_MESH_PROXY_PROV)) {
|
||||
BT_ERR("%s, Invalid PDU type for Proxy Server", __func__);
|
||||
BT_ERR("Invalid PDU type for Proxy Server");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,7 @@ static void proxy_connected(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, int
|
|||
}
|
||||
|
||||
if (!server) {
|
||||
BT_ERR("%s, No free Proxy Server objects", __func__);
|
||||
BT_ERR("No free Proxy Server objects");
|
||||
/** Disconnect current connection, clear part of prov_link
|
||||
* information, like uuid, dev_addr, linking flag, etc.
|
||||
*/
|
||||
|
@ -423,7 +423,7 @@ static void proxy_disconnected(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn,
|
|||
BT_DBG("conn %p, handle is %d, reason 0x%02x", conn, conn->handle, reason);
|
||||
|
||||
if (!server) {
|
||||
BT_ERR("%s, No Proxy Server object found", __func__);
|
||||
BT_ERR("No Proxy Server object found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -457,7 +457,7 @@ static ssize_t prov_write_ccc(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn)
|
|||
struct bt_mesh_proxy_server *server = find_server(conn);
|
||||
|
||||
if (!server) {
|
||||
BT_ERR("%s, No Proxy Server object found", __func__);
|
||||
BT_ERR("No Proxy Server object found");
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
|
@ -465,7 +465,6 @@ static ssize_t prov_write_ccc(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn)
|
|||
server->conn_type = PROV;
|
||||
|
||||
if (bt_mesh_provisioner_set_prov_conn(addr->val, server->conn)) {
|
||||
BT_ERR("%s, bt_mesh_provisioner_set_prov_conn failed", __func__);
|
||||
bt_mesh_gattc_disconnect(server->conn);
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -480,7 +479,7 @@ static ssize_t prov_recv_ntf(struct bt_mesh_conn *conn, u8_t *data, u16_t len)
|
|||
struct bt_mesh_proxy_server *server = find_server(conn);
|
||||
|
||||
if (!server) {
|
||||
BT_ERR("%s, No Proxy Server object found", __func__);
|
||||
BT_ERR("No Proxy Server object found");
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
|
@ -491,7 +490,7 @@ static ssize_t prov_recv_ntf(struct bt_mesh_conn *conn, u8_t *data, u16_t len)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
int bt_mesh_provisioner_pb_gatt_enable(void)
|
||||
int bt_mesh_proxy_client_prov_enable(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -506,7 +505,7 @@ int bt_mesh_provisioner_pb_gatt_enable(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_provisioner_pb_gatt_disable(void)
|
||||
int bt_mesh_proxy_client_prov_disable(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -531,7 +530,7 @@ static ssize_t proxy_write_ccc(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn)
|
|||
struct bt_mesh_proxy_server *server = find_server(conn);
|
||||
|
||||
if (!server) {
|
||||
BT_ERR("%s, No Proxy Server object found", __func__);
|
||||
BT_ERR("No Proxy Server object found");
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
|
@ -552,7 +551,7 @@ static ssize_t proxy_recv_ntf(struct bt_mesh_conn *conn, u8_t *data, u16_t len)
|
|||
struct bt_mesh_proxy_server *server = find_server(conn);
|
||||
|
||||
if (!server) {
|
||||
BT_ERR("%s, No Proxy Server object found", __func__);
|
||||
BT_ERR("No Proxy Server object found");
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
|
@ -564,14 +563,14 @@ static ssize_t proxy_recv_ntf(struct bt_mesh_conn *conn, u8_t *data, u16_t len)
|
|||
}
|
||||
|
||||
/**
|
||||
* Currently proxy client doesn't need bt_mesh_proxy_client_enable() and
|
||||
* bt_mesh_proxy_client_disable() functions, and once they are used,
|
||||
* proxy client can be enabled to parse node_id_adv and net_id_adv in
|
||||
* order to support proxy client role.
|
||||
* Currently proxy client doesn't need bt_mesh_proxy_client_gatt_enable()
|
||||
* and bt_mesh_proxy_client_gatt_disable() functions, and once they are
|
||||
* used, proxy client can be enabled to parse node_id_adv and net_id_adv
|
||||
* in order to support proxy client role.
|
||||
* And if gatt proxy is disabled, proxy client can stop handling these
|
||||
* two kinds of connectable advertising packets.
|
||||
*/
|
||||
int bt_mesh_proxy_client_enable(void)
|
||||
int bt_mesh_proxy_client_gatt_enable(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -593,7 +592,7 @@ int bt_mesh_proxy_client_enable(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_proxy_client_disable(void)
|
||||
int bt_mesh_proxy_client_gatt_disable(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -650,7 +649,8 @@ static struct bt_mesh_subnet *bt_mesh_is_net_id_exist(const u8_t net_id[8])
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void bt_mesh_proxy_client_adv_ind_recv(struct net_buf_simple *buf, const bt_mesh_addr_t *addr, s8_t rssi)
|
||||
void bt_mesh_proxy_client_gatt_adv_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 = 0U;
|
||||
|
@ -688,7 +688,7 @@ void bt_mesh_proxy_client_adv_ind_recv(struct net_buf_simple *buf, const bt_mesh
|
|||
*/
|
||||
return;
|
||||
default:
|
||||
BT_DBG("%s, Unknown Mesh Proxy adv type 0x%02x", __func__, type);
|
||||
BT_DBG("Unknown Mesh Proxy adv type 0x%02x", type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -733,7 +733,7 @@ int bt_mesh_proxy_client_disconnect(u8_t conn_handle)
|
|||
|
||||
conn = servers[conn_handle].conn;
|
||||
if (!conn) {
|
||||
BT_ERR("%s, Not connected, conn_handle %d", __func__, conn_handle);
|
||||
BT_ERR("Not connected, conn handle %d", conn_handle);
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
|
@ -741,7 +741,7 @@ int bt_mesh_proxy_client_disconnect(u8_t conn_handle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool bt_mesh_proxy_client_send(struct net_buf_simple *buf, u16_t dst)
|
||||
bool bt_mesh_proxy_client_relay(struct net_buf_simple *buf, u16_t dst)
|
||||
{
|
||||
bool send = false;
|
||||
int err = 0;
|
||||
|
@ -761,9 +761,9 @@ bool bt_mesh_proxy_client_send(struct net_buf_simple *buf, u16_t dst)
|
|||
net_buf_simple_init(&msg, 1);
|
||||
net_buf_simple_add_mem(&msg, buf->data, buf->len);
|
||||
|
||||
err = bt_mesh_proxy_prov_client_send(server->conn, BLE_MESH_PROXY_NET_PDU, &msg);
|
||||
err = bt_mesh_proxy_client_send(server->conn, BLE_MESH_PROXY_NET_PDU, &msg);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send proxy net message (err %d)", __func__, err);
|
||||
BT_ERR("Failed to send proxy network message (err %d)", err);
|
||||
} else {
|
||||
BT_INFO("%u bytes to dst 0x%04x", buf->len, dst);
|
||||
send = true;
|
||||
|
@ -780,7 +780,7 @@ static int beacon_send(struct bt_mesh_conn *conn, struct bt_mesh_subnet *sub)
|
|||
net_buf_simple_init(&buf, 1);
|
||||
bt_mesh_beacon_create(sub, &buf);
|
||||
|
||||
return bt_mesh_proxy_prov_client_send(conn, BLE_MESH_PROXY_BEACON, &buf);
|
||||
return bt_mesh_proxy_client_send(conn, BLE_MESH_PROXY_BEACON, &buf);
|
||||
}
|
||||
|
||||
bool bt_mesh_proxy_client_beacon_send(struct bt_mesh_subnet *sub)
|
||||
|
@ -818,7 +818,7 @@ bool bt_mesh_proxy_client_beacon_send(struct bt_mesh_subnet *sub)
|
|||
if (servers[i].conn && servers[i].conn_type == PROXY) {
|
||||
err = beacon_send(servers[i].conn, sub);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send proxy beacon message (err %d)", __func__, err);
|
||||
BT_ERR("Failed to send proxy beacon message (err %d)", err);
|
||||
} else {
|
||||
send = true;
|
||||
}
|
||||
|
@ -850,14 +850,14 @@ static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_me
|
|||
tx.sub = bt_mesh_provisioner_subnet_get(net_idx);
|
||||
}
|
||||
if (!tx.sub) {
|
||||
BT_ERR("%s, Failed to find subnet", __func__);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
switch (cfg->opcode) {
|
||||
case BLE_MESH_PROXY_CFG_FILTER_SET:
|
||||
if (cfg->set.filter_type > 0x01) {
|
||||
BT_ERR("%s, Invalid filter type 0x%02x", __func__, cfg->set.filter_type);
|
||||
BT_ERR("Invalid proxy filter type 0x%02x", cfg->set.filter_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -865,7 +865,7 @@ static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_me
|
|||
break;
|
||||
case BLE_MESH_PROXY_CFG_FILTER_ADD:
|
||||
if (cfg->add.addr == NULL || cfg->add.addr_num == 0) {
|
||||
BT_ERR("%s, Add address list is NULL", __func__);
|
||||
BT_ERR("Empty proxy addr list to add");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -873,14 +873,14 @@ static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_me
|
|||
break;
|
||||
case BLE_MESH_PROXY_CFG_FILTER_REMOVE:
|
||||
if (cfg->remove.addr == NULL || cfg->remove.addr_num == 0) {
|
||||
BT_ERR("%s, Remove address list is NULL", __func__);
|
||||
BT_ERR("Empty proxy addr list to remove");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
alloc_len = sizeof(cfg->opcode) + (cfg->remove.addr_num << 1);
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown Proxy Configuration opcode 0x%02x", __func__, cfg->opcode);
|
||||
BT_ERR("Unknown Proxy Configuration opcode 0x%02x", cfg->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -913,25 +913,26 @@ static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_me
|
|||
break;
|
||||
}
|
||||
|
||||
BT_DBG("%s, len %u bytes: %s", __func__, buf->len, bt_hex(buf->data, buf->len));
|
||||
BT_DBG("len %u bytes: %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
err = bt_mesh_net_encode(&tx, buf, true);
|
||||
if (err) {
|
||||
BT_ERR("%s, Encoding Proxy message failed (err %d)", __func__, err);
|
||||
BT_ERR("Encoding proxy message failed (err %d)", err);
|
||||
bt_mesh_free_buf(buf);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = bt_mesh_proxy_prov_client_send(conn, BLE_MESH_PROXY_CONFIG, buf);
|
||||
err = bt_mesh_proxy_client_send(conn, BLE_MESH_PROXY_CONFIG, buf);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send proxy cfg message (err %d)", __func__, err);
|
||||
BT_ERR("Failed to send proxy cfg message (err %d)", err);
|
||||
}
|
||||
|
||||
bt_mesh_free_buf(buf);
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_proxy_client_send_cfg(u8_t conn_handle, u16_t net_idx, struct bt_mesh_proxy_cfg_pdu *pdu)
|
||||
int bt_mesh_proxy_client_cfg_send(u8_t conn_handle, u16_t net_idx,
|
||||
struct bt_mesh_proxy_cfg_pdu *pdu)
|
||||
{
|
||||
struct bt_mesh_conn *conn = NULL;
|
||||
|
||||
|
@ -944,7 +945,7 @@ int bt_mesh_proxy_client_send_cfg(u8_t conn_handle, u16_t net_idx, struct bt_mes
|
|||
|
||||
conn = servers[conn_handle].conn;
|
||||
if (!conn) {
|
||||
BT_ERR("%s, Not connected, conn_handle %d", __func__, conn_handle);
|
||||
BT_ERR("Not connected, conn handle %d", conn_handle);
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
|
@ -953,8 +954,8 @@ int bt_mesh_proxy_client_send_cfg(u8_t conn_handle, u16_t net_idx, struct bt_mes
|
|||
* with the one added when creating proxy connection.
|
||||
*/
|
||||
if (servers[conn_handle].net_idx != net_idx) {
|
||||
BT_ERR("%s, NetKey Index 0x%04x mismatch, expect 0x%04x",
|
||||
__func__, net_idx, servers[conn_handle].net_idx);
|
||||
BT_ERR("NetKeyIndex 0x%04x mismatch, expect 0x%04x",
|
||||
net_idx, servers[conn_handle].net_idx);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -962,7 +963,7 @@ int bt_mesh_proxy_client_send_cfg(u8_t conn_handle, u16_t net_idx, struct bt_mes
|
|||
}
|
||||
#endif /* CONFIG_BLE_MESH_GATT_PROXY_CLIENT */
|
||||
|
||||
int bt_mesh_proxy_prov_client_init(void)
|
||||
int bt_mesh_proxy_client_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -988,7 +989,7 @@ int bt_mesh_proxy_prov_client_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_proxy_prov_client_deinit(void)
|
||||
int bt_mesh_proxy_client_deinit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -74,35 +74,44 @@ typedef struct {
|
|||
};
|
||||
} bt_mesh_proxy_client_pdu_t;
|
||||
|
||||
int bt_mesh_proxy_prov_client_send(struct bt_mesh_conn *conn, u8_t type, struct net_buf_simple *msg);
|
||||
int bt_mesh_proxy_client_send(struct bt_mesh_conn *conn, u8_t type,
|
||||
struct net_buf_simple *msg);
|
||||
|
||||
int bt_mesh_provisioner_pb_gatt_enable(void);
|
||||
int bt_mesh_provisioner_pb_gatt_disable(void);
|
||||
int bt_mesh_proxy_client_prov_enable(void);
|
||||
int bt_mesh_proxy_client_prov_disable(void);
|
||||
|
||||
int bt_mesh_proxy_client_enable(void);
|
||||
int bt_mesh_proxy_client_disable(void);
|
||||
int bt_mesh_proxy_client_gatt_enable(void);
|
||||
int bt_mesh_proxy_client_gatt_disable(void);
|
||||
|
||||
typedef void (*proxy_client_recv_adv_cb_t)(const bt_mesh_addr_t *addr, u8_t type, bt_mesh_proxy_adv_ctx_t *ctx, s8_t rssi);
|
||||
typedef void (*proxy_client_connect_cb_t)(const bt_mesh_addr_t *addr, u8_t conn_handle, u16_t net_idx);
|
||||
typedef void (*proxy_client_disconnect_cb_t)(const bt_mesh_addr_t *addr, u8_t conn_handle, u16_t net_idx, u8_t reason);
|
||||
typedef void (*proxy_client_recv_filter_status_cb_t)(u8_t conn_handle, u16_t src, u16_t net_idx, u8_t filter_type, u16_t list_size);
|
||||
typedef void (*proxy_client_recv_adv_cb_t)(const bt_mesh_addr_t *addr, u8_t type,
|
||||
bt_mesh_proxy_adv_ctx_t *ctx, s8_t rssi);
|
||||
typedef void (*proxy_client_connect_cb_t)(const bt_mesh_addr_t *addr,
|
||||
u8_t conn_handle, u16_t net_idx);
|
||||
typedef void (*proxy_client_disconnect_cb_t)(const bt_mesh_addr_t *addr, u8_t conn_handle,
|
||||
u16_t net_idx, u8_t reason);
|
||||
typedef void (*proxy_client_recv_filter_status_cb_t)(u8_t conn_handle, u16_t src, u16_t net_idx,
|
||||
u8_t filter_type, u16_t list_size);
|
||||
|
||||
void bt_mesh_proxy_client_set_adv_recv_cb(proxy_client_recv_adv_cb_t cb);
|
||||
void bt_mesh_proxy_client_set_conn_cb(proxy_client_connect_cb_t cb);
|
||||
void bt_mesh_proxy_client_set_disconn_cb(proxy_client_disconnect_cb_t cb);
|
||||
void bt_mesh_proxy_client_set_filter_status_cb(proxy_client_recv_filter_status_cb_t cb);
|
||||
|
||||
void bt_mesh_proxy_client_adv_ind_recv(struct net_buf_simple *buf, const bt_mesh_addr_t *addr, s8_t rssi);
|
||||
void bt_mesh_proxy_client_gatt_adv_recv(struct net_buf_simple *buf,
|
||||
const bt_mesh_addr_t *addr, s8_t rssi);
|
||||
|
||||
int bt_mesh_proxy_client_connect(const u8_t addr[6], u8_t addr_type, u16_t net_idx);
|
||||
int bt_mesh_proxy_client_disconnect(u8_t conn_handle);
|
||||
|
||||
bool bt_mesh_proxy_client_beacon_send(struct bt_mesh_subnet *sub);
|
||||
bool bt_mesh_proxy_client_send(struct net_buf_simple *buf, u16_t dst);
|
||||
int bt_mesh_proxy_client_send_cfg(u8_t conn_handle, u16_t net_idx, struct bt_mesh_proxy_cfg_pdu *pdu);
|
||||
|
||||
int bt_mesh_proxy_prov_client_init(void);
|
||||
int bt_mesh_proxy_prov_client_deinit(void);
|
||||
bool bt_mesh_proxy_client_relay(struct net_buf_simple *buf, u16_t dst);
|
||||
|
||||
int bt_mesh_proxy_client_cfg_send(u8_t conn_handle, u16_t net_idx,
|
||||
struct bt_mesh_proxy_cfg_pdu *pdu);
|
||||
|
||||
int bt_mesh_proxy_client_init(void);
|
||||
int bt_mesh_proxy_client_deinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ int bt_mesh_set_device_name(const char *name)
|
|||
}
|
||||
|
||||
if (strlen(name) > DEVICE_NAME_SIZE) {
|
||||
BT_ERR("%s, Too long device name", __func__);
|
||||
BT_ERR("Too long device name (len %d)", strlen(name));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ static void proxy_sar_timeout(struct k_work *work)
|
|||
|
||||
client = CONTAINER_OF(work, struct bt_mesh_proxy_client, sar_timer.work);
|
||||
if (!client || !client->conn) {
|
||||
BT_ERR("%s, Invalid proxy client parameter", __func__);
|
||||
BT_ERR("Invalid proxy client parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ static int filter_set(struct bt_mesh_proxy_client *client,
|
|||
}
|
||||
|
||||
type = net_buf_simple_pull_u8(buf);
|
||||
BT_DBG("type 0x%02x", type);
|
||||
BT_INFO("Set filter type 0x%02x", type);
|
||||
|
||||
switch (type) {
|
||||
case 0x00:
|
||||
|
@ -214,9 +214,12 @@ static void filter_add(struct bt_mesh_proxy_client *client, u16_t addr)
|
|||
for (i = 0; i < ARRAY_SIZE(client->filter); i++) {
|
||||
if (client->filter[i] == BLE_MESH_ADDR_UNASSIGNED) {
|
||||
client->filter[i] = addr;
|
||||
BT_INFO("Add filter addr 0x%04x", addr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BT_WARN("Proxy filter is full!");
|
||||
}
|
||||
|
||||
static void filter_remove(struct bt_mesh_proxy_client *client, u16_t addr)
|
||||
|
@ -232,6 +235,7 @@ static void filter_remove(struct bt_mesh_proxy_client *client, u16_t addr)
|
|||
for (i = 0; i < ARRAY_SIZE(client->filter); i++) {
|
||||
if (client->filter[i] == addr) {
|
||||
client->filter[i] = BLE_MESH_ADDR_UNASSIGNED;
|
||||
BT_INFO("Remove filter addr 0x%04x", addr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -275,13 +279,13 @@ static void send_filter_status(struct bt_mesh_proxy_client *client,
|
|||
|
||||
err = bt_mesh_net_encode(&tx, buf, true);
|
||||
if (err) {
|
||||
BT_ERR("%s, Encoding Proxy cfg message failed (err %d)", __func__, err);
|
||||
BT_ERR("Encoding proxy cfg message failed (err %d)", err);
|
||||
return;
|
||||
}
|
||||
|
||||
err = proxy_segment_and_send(client->conn, BLE_MESH_PROXY_CONFIG, buf);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send proxy cfg message (err %d)", __func__, err);
|
||||
BT_ERR("Failed to send proxy cfg message (err %d)", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,7 +304,7 @@ static void proxy_cfg(struct bt_mesh_proxy_client *client)
|
|||
err = bt_mesh_net_decode(&client->buf, BLE_MESH_NET_IF_PROXY_CFG,
|
||||
&rx, &buf);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to decode Proxy Configuration (err %d)", __func__, err);
|
||||
BT_ERR("Failed to decode Proxy Configuration (err %d)", err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -370,7 +374,7 @@ static void proxy_send_beacons(struct k_work *work)
|
|||
}
|
||||
}
|
||||
|
||||
void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub)
|
||||
void bt_mesh_proxy_server_beacon_send(struct bt_mesh_subnet *sub)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -378,7 +382,7 @@ void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub)
|
|||
/* NULL means we send on all subnets */
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
|
||||
if (bt_mesh.sub[i].net_idx != BLE_MESH_KEY_UNUSED) {
|
||||
bt_mesh_proxy_beacon_send(&bt_mesh.sub[i]);
|
||||
bt_mesh_proxy_server_beacon_send(&bt_mesh.sub[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,7 +396,7 @@ void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub)
|
|||
}
|
||||
}
|
||||
|
||||
void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub)
|
||||
void bt_mesh_proxy_server_identity_start(struct bt_mesh_subnet *sub)
|
||||
{
|
||||
sub->node_id = BLE_MESH_NODE_IDENTITY_RUNNING;
|
||||
sub->node_id_start = k_uptime_get_32();
|
||||
|
@ -401,7 +405,7 @@ void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub)
|
|||
next_idx = sub - bt_mesh.sub;
|
||||
}
|
||||
|
||||
void bt_mesh_proxy_identity_stop(struct bt_mesh_subnet *sub)
|
||||
void bt_mesh_proxy_server_identity_stop(struct bt_mesh_subnet *sub)
|
||||
{
|
||||
sub->node_id = BLE_MESH_NODE_IDENTITY_STOPPED;
|
||||
sub->node_id_start = 0U;
|
||||
|
@ -428,7 +432,7 @@ int bt_mesh_proxy_identity_enable(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
bt_mesh_proxy_identity_start(sub);
|
||||
bt_mesh_proxy_server_identity_start(sub);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
@ -585,7 +589,7 @@ static void proxy_connected(struct bt_mesh_conn *conn, u8_t err)
|
|||
}
|
||||
|
||||
if (!client) {
|
||||
BT_ERR("%s, No free Proxy Client objects", __func__);
|
||||
BT_ERR("No free Proxy Client objects");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -624,7 +628,7 @@ static void proxy_disconnected(struct bt_mesh_conn *conn, u8_t reason)
|
|||
bt_mesh_adv_update();
|
||||
}
|
||||
|
||||
struct net_buf_simple *bt_mesh_proxy_get_buf(void)
|
||||
struct net_buf_simple *bt_mesh_proxy_server_get_buf(void)
|
||||
{
|
||||
struct net_buf_simple *buf = &clients[0].buf;
|
||||
|
||||
|
@ -697,7 +701,7 @@ static struct bt_mesh_gatt_attr prov_attrs[] = {
|
|||
|
||||
struct bt_mesh_gatt_service prov_svc = BLE_MESH_GATT_SERVICE(prov_attrs);
|
||||
|
||||
int bt_mesh_proxy_prov_enable(void)
|
||||
int bt_mesh_proxy_server_prov_enable(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -727,7 +731,7 @@ int bt_mesh_proxy_prov_enable(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_proxy_prov_disable(bool disconnect)
|
||||
int bt_mesh_proxy_server_prov_disable(bool disconnect)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -832,7 +836,7 @@ static struct bt_mesh_gatt_attr proxy_attrs[] = {
|
|||
|
||||
struct bt_mesh_gatt_service proxy_svc = BLE_MESH_GATT_SERVICE(proxy_attrs);
|
||||
|
||||
int bt_mesh_proxy_gatt_enable(void)
|
||||
int bt_mesh_proxy_server_gatt_enable(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -860,7 +864,7 @@ int bt_mesh_proxy_gatt_enable(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void bt_mesh_proxy_gatt_disconnect(void)
|
||||
void bt_mesh_proxy_server_gatt_disconnect(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -877,7 +881,7 @@ void bt_mesh_proxy_gatt_disconnect(void)
|
|||
}
|
||||
}
|
||||
|
||||
int bt_mesh_proxy_gatt_disable(void)
|
||||
int bt_mesh_proxy_server_gatt_disable(void)
|
||||
{
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
|
@ -891,7 +895,7 @@ int bt_mesh_proxy_gatt_disable(void)
|
|||
return -EBUSY;
|
||||
}
|
||||
|
||||
bt_mesh_proxy_gatt_disconnect();
|
||||
bt_mesh_proxy_server_gatt_disconnect();
|
||||
|
||||
bt_mesh_gatts_service_stop(&proxy_svc);
|
||||
gatt_svc = MESH_GATT_NONE;
|
||||
|
@ -899,12 +903,12 @@ int bt_mesh_proxy_gatt_disable(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void bt_mesh_proxy_addr_add(struct net_buf_simple *buf, u16_t addr)
|
||||
void bt_mesh_proxy_server_addr_add(struct net_buf_simple *buf, u16_t addr)
|
||||
{
|
||||
struct bt_mesh_proxy_client *client =
|
||||
CONTAINER_OF(buf, struct bt_mesh_proxy_client, buf);
|
||||
|
||||
BT_INFO("filter_type %u addr 0x%04x", client->filter_type, addr);
|
||||
BT_DBG("filter_type %u addr 0x%04x", client->filter_type, addr);
|
||||
|
||||
if (client->filter_type == WHITELIST) {
|
||||
filter_add(client, addr);
|
||||
|
@ -945,7 +949,7 @@ static bool client_filter_match(struct bt_mesh_proxy_client *client,
|
|||
return false;
|
||||
}
|
||||
|
||||
bool bt_mesh_proxy_relay(struct net_buf_simple *buf, u16_t dst)
|
||||
bool bt_mesh_proxy_server_relay(struct net_buf_simple *buf, u16_t dst)
|
||||
{
|
||||
bool relayed = false;
|
||||
int i;
|
||||
|
@ -970,7 +974,7 @@ bool bt_mesh_proxy_relay(struct net_buf_simple *buf, u16_t dst)
|
|||
net_buf_simple_reserve(&msg, 1);
|
||||
net_buf_simple_add_mem(&msg, buf->data, buf->len);
|
||||
|
||||
bt_mesh_proxy_send(client->conn, BLE_MESH_PROXY_NET_PDU, &msg);
|
||||
bt_mesh_proxy_server_send(client->conn, BLE_MESH_PROXY_NET_PDU, &msg);
|
||||
relayed = true;
|
||||
}
|
||||
|
||||
|
@ -1032,18 +1036,18 @@ static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_proxy_send(struct bt_mesh_conn *conn, u8_t type,
|
||||
int bt_mesh_proxy_server_send(struct bt_mesh_conn *conn, u8_t type,
|
||||
struct net_buf_simple *msg)
|
||||
{
|
||||
struct bt_mesh_proxy_client *client = find_client(conn);
|
||||
|
||||
if (!client) {
|
||||
BT_ERR("%s, No Proxy Client found", __func__);
|
||||
BT_ERR("No Proxy Client found");
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
if ((client->filter_type == PROV) != (type == BLE_MESH_PROXY_PROV)) {
|
||||
BT_ERR("%s, Invalid PDU type for Proxy Client", __func__);
|
||||
BT_ERR("Invalid PDU type for Proxy Client");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1251,7 +1255,7 @@ static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub)
|
|||
active, remaining);
|
||||
node_id_adv(sub);
|
||||
} else {
|
||||
bt_mesh_proxy_identity_stop(sub);
|
||||
bt_mesh_proxy_server_identity_stop(sub);
|
||||
BT_DBG("Node ID stopped");
|
||||
}
|
||||
}
|
||||
|
@ -1330,7 +1334,7 @@ static size_t gatt_prov_adv_create(struct bt_mesh_adv_data prov_sd[2])
|
|||
}
|
||||
#endif /* CONFIG_BLE_MESH_PB_GATT */
|
||||
|
||||
s32_t bt_mesh_proxy_adv_start(void)
|
||||
s32_t bt_mesh_proxy_server_adv_start(void)
|
||||
{
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
|
@ -1374,7 +1378,7 @@ s32_t bt_mesh_proxy_adv_start(void)
|
|||
return K_FOREVER;
|
||||
}
|
||||
|
||||
void bt_mesh_proxy_adv_stop(void)
|
||||
void bt_mesh_proxy_server_adv_stop(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
|
@ -1386,7 +1390,7 @@ void bt_mesh_proxy_adv_stop(void)
|
|||
|
||||
err = bt_le_adv_stop();
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to stop advertising (err %d)", __func__, err);
|
||||
BT_ERR("Failed to stop advertising (err %d)", err);
|
||||
} else {
|
||||
proxy_adv_enabled = false;
|
||||
}
|
||||
|
@ -1397,7 +1401,7 @@ static struct bt_mesh_conn_cb conn_callbacks = {
|
|||
.disconnected = proxy_disconnected,
|
||||
};
|
||||
|
||||
int bt_mesh_proxy_init(void)
|
||||
int bt_mesh_proxy_server_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1425,7 +1429,7 @@ int bt_mesh_proxy_init(void)
|
|||
return bt_mesh_gatts_set_local_device_name(device_name);
|
||||
}
|
||||
|
||||
int bt_mesh_proxy_deinit(void)
|
||||
int bt_mesh_proxy_server_deinit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -40,31 +40,32 @@ extern "C" {
|
|||
|
||||
int bt_mesh_set_device_name(const char *name);
|
||||
|
||||
int bt_mesh_proxy_send(struct bt_mesh_conn *conn, u8_t type,
|
||||
int bt_mesh_proxy_server_send(struct bt_mesh_conn *conn, u8_t type,
|
||||
struct net_buf_simple *msg);
|
||||
|
||||
int bt_mesh_proxy_prov_enable(void);
|
||||
int bt_mesh_proxy_prov_disable(bool disconnect);
|
||||
int bt_mesh_proxy_server_prov_enable(void);
|
||||
int bt_mesh_proxy_server_prov_disable(bool disconnect);
|
||||
|
||||
int bt_mesh_proxy_gatt_enable(void);
|
||||
int bt_mesh_proxy_gatt_disable(void);
|
||||
void bt_mesh_proxy_gatt_disconnect(void);
|
||||
int bt_mesh_proxy_server_gatt_enable(void);
|
||||
int bt_mesh_proxy_server_gatt_disable(void);
|
||||
|
||||
void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub);
|
||||
void bt_mesh_proxy_server_gatt_disconnect(void);
|
||||
|
||||
struct net_buf_simple *bt_mesh_proxy_get_buf(void);
|
||||
void bt_mesh_proxy_server_beacon_send(struct bt_mesh_subnet *sub);
|
||||
|
||||
s32_t bt_mesh_proxy_adv_start(void);
|
||||
void bt_mesh_proxy_adv_stop(void);
|
||||
struct net_buf_simple *bt_mesh_proxy_server_get_buf(void);
|
||||
|
||||
void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub);
|
||||
void bt_mesh_proxy_identity_stop(struct bt_mesh_subnet *sub);
|
||||
s32_t bt_mesh_proxy_server_adv_start(void);
|
||||
void bt_mesh_proxy_server_adv_stop(void);
|
||||
|
||||
bool bt_mesh_proxy_relay(struct net_buf_simple *buf, u16_t dst);
|
||||
void bt_mesh_proxy_addr_add(struct net_buf_simple *buf, u16_t addr);
|
||||
void bt_mesh_proxy_server_identity_start(struct bt_mesh_subnet *sub);
|
||||
void bt_mesh_proxy_server_identity_stop(struct bt_mesh_subnet *sub);
|
||||
|
||||
int bt_mesh_proxy_init(void);
|
||||
int bt_mesh_proxy_deinit(void);
|
||||
bool bt_mesh_proxy_server_relay(struct net_buf_simple *buf, u16_t dst);
|
||||
void bt_mesh_proxy_server_addr_add(struct net_buf_simple *buf, u16_t addr);
|
||||
|
||||
int bt_mesh_proxy_server_init(void);
|
||||
int bt_mesh_proxy_server_deinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -357,7 +357,7 @@ static int rpl_set(const char *name)
|
|||
if (!entry) {
|
||||
entry = rpl_alloc(src);
|
||||
if (!entry) {
|
||||
BT_ERR("%s, No space for a new RPL 0x%04x", __func__, src);
|
||||
BT_ERR("No space for a new RPL 0x%04x", src);
|
||||
err = -ENOMEM;
|
||||
goto free;
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ static int net_key_set(const char *name)
|
|||
|
||||
err = bt_mesh_load_core_settings(get, (u8_t *)&key, sizeof(key), &exist);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to load NetKey 0x%03x", __func__, net_idx);
|
||||
BT_ERR("Failed to load NetKey 0x%03x", net_idx);
|
||||
goto free;
|
||||
}
|
||||
|
||||
|
@ -426,7 +426,7 @@ static int net_key_set(const char *name)
|
|||
if (!sub) {
|
||||
sub = subnet_alloc(net_idx);
|
||||
if (!sub) {
|
||||
BT_ERR("%s, No space for a new subnet 0x%03x", __func__, net_idx);
|
||||
BT_ERR("No space for a new subnet 0x%03x", net_idx);
|
||||
err = -ENOMEM;
|
||||
goto free;
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ static int net_key_set(const char *name)
|
|||
memcpy(sub->keys[0].net, &key.val[0], 16);
|
||||
memcpy(sub->keys[1].net, &key.val[1], 16);
|
||||
|
||||
BT_INFO("Restored NetKey Index 0x%03x", sub->net_idx);
|
||||
BT_INFO("Restored NetKeyIndex 0x%03x", sub->net_idx);
|
||||
BT_INFO("Restored NetKey %s", bt_hex(sub->keys[0].net, 16));
|
||||
}
|
||||
|
||||
|
@ -474,7 +474,7 @@ static int app_key_set(const char *name)
|
|||
|
||||
err = bt_mesh_load_core_settings(get, (u8_t *)&key, sizeof(key), &exist);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to load AppKey 0x%03x", __func__, app_idx);
|
||||
BT_ERR("Failed to load AppKey 0x%03x", app_idx);
|
||||
goto free;
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ static int app_key_set(const char *name)
|
|||
|
||||
sub = bt_mesh_subnet_get(key.net_idx);
|
||||
if (!sub) {
|
||||
BT_ERR("%s, Failed to find subnet 0x%03x", __func__, key.net_idx);
|
||||
BT_ERR("Failed to find subnet 0x%03x", key.net_idx);
|
||||
err = -ENOENT;
|
||||
goto free;
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ static int app_key_set(const char *name)
|
|||
if (!app) {
|
||||
app = bt_mesh_app_key_alloc(app_idx);
|
||||
if (!app) {
|
||||
BT_ERR("%s, No space for a new app key 0x%03x", __func__, app_idx);
|
||||
BT_ERR("No space for a new appkey 0x%03x", app_idx);
|
||||
err = -ENOMEM;
|
||||
goto free;
|
||||
}
|
||||
|
@ -507,7 +507,7 @@ static int app_key_set(const char *name)
|
|||
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 AppKey Index 0x%03x, NetKey Index 0x%03x",
|
||||
BT_INFO("Restored AppKeyIndex 0x%03x, NetKeyIndex 0x%03x",
|
||||
app->app_idx, app->net_idx);
|
||||
BT_INFO("Restored AppKey %s", bt_hex(app->keys[0].val, 16));
|
||||
}
|
||||
|
@ -527,13 +527,13 @@ static int hb_pub_set(const char *name)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!hb_pub) {
|
||||
BT_ERR("%s, NULL cfg hb pub", __func__);
|
||||
BT_ERR("Invalid heartbeat pub");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = bt_mesh_load_core_settings(name, (u8_t *)&hb_val, sizeof(hb_val), &exist);
|
||||
if (err) {
|
||||
BT_ERR("Failed to load heartbeat publication");
|
||||
BT_ERR("Failed to load heartbeat pub");
|
||||
hb_pub->dst = BLE_MESH_ADDR_UNASSIGNED;
|
||||
hb_pub->count = 0U;
|
||||
hb_pub->ttl = 0U;
|
||||
|
@ -572,7 +572,7 @@ static int cfg_set(const char *name)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!cfg) {
|
||||
BT_ERR("%s, NULL cfg", __func__);
|
||||
BT_ERR("Invalid configuration");
|
||||
stored_cfg.valid = false;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -787,7 +787,7 @@ static int va_set(const char *name)
|
|||
|
||||
lab = get_label(index);
|
||||
if (lab == NULL) {
|
||||
BT_WARN("%s, Out of labels buffers", __func__);
|
||||
BT_WARN("Out of labels buffers");
|
||||
err = -ENOBUFS;
|
||||
goto free;
|
||||
}
|
||||
|
@ -826,7 +826,7 @@ static int p_prov_set(const char *name)
|
|||
|
||||
bt_mesh_provisioner_restore_prov_info(val.primary_addr, val.alloc_addr);
|
||||
|
||||
BT_INFO("Restored Primary Address 0x%04x, next address allocation 0x%04x",
|
||||
BT_INFO("Restored Primary Address 0x%04x, next address alloc 0x%04x",
|
||||
val.primary_addr, val.alloc_addr);
|
||||
|
||||
return 0;
|
||||
|
@ -842,7 +842,7 @@ static int p_net_idx_set(const char *name)
|
|||
|
||||
err = bt_mesh_load_core_settings(name, (u8_t *)&net_idx, sizeof(net_idx), &exist);
|
||||
if (err) {
|
||||
BT_ERR("Failed to load next net_idx allocation");
|
||||
BT_ERR("Failed to load next NetKeyIndex alloc");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -852,7 +852,7 @@ static int p_net_idx_set(const char *name)
|
|||
|
||||
bt_mesh.p_net_idx_next = net_idx;
|
||||
|
||||
BT_INFO("Restored next NetKey Index allocation 0x%03x", bt_mesh.p_net_idx_next);
|
||||
BT_INFO("Restored next NetKeyIndex alloc 0x%03x", bt_mesh.p_net_idx_next);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -867,7 +867,7 @@ static int p_app_idx_set(const char *name)
|
|||
|
||||
err = bt_mesh_load_core_settings(name, (u8_t *)&app_idx, sizeof(app_idx), &exist);
|
||||
if (err) {
|
||||
BT_ERR("Failed to load next app_idx allocation");
|
||||
BT_ERR("Failed to load next AppKeyIndex alloc");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -877,7 +877,7 @@ static int p_app_idx_set(const char *name)
|
|||
|
||||
bt_mesh.p_app_idx_next = app_idx;
|
||||
|
||||
BT_INFO("Restored next AppKey Index allocation 0x%03x", bt_mesh.p_app_idx_next);
|
||||
BT_INFO("Restored next AppKeyIndex alloc 0x%03x", bt_mesh.p_app_idx_next);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -890,7 +890,7 @@ static struct bt_mesh_subnet *p_subnet_alloc(void)
|
|||
if (bt_mesh.p_sub[i] == NULL) {
|
||||
bt_mesh.p_sub[i] = bt_mesh_calloc(sizeof(struct bt_mesh_subnet));
|
||||
if (!bt_mesh.p_sub[i]) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -909,7 +909,7 @@ static struct bt_mesh_app_key *p_appkey_alloc(void)
|
|||
if (bt_mesh.p_app_keys[i] == NULL) {
|
||||
bt_mesh.p_app_keys[i] = bt_mesh_calloc(sizeof(struct bt_mesh_app_key));
|
||||
if (!bt_mesh.p_app_keys[i]) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -946,7 +946,7 @@ static int p_net_key_set(const char *name)
|
|||
|
||||
err = bt_mesh_load_core_settings(get, (u8_t *)&key, sizeof(key), &exist);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to load NetKey 0x%03x", __func__, net_idx);
|
||||
BT_ERR("Failed to load NetKey 0x%03x", net_idx);
|
||||
goto free;
|
||||
}
|
||||
|
||||
|
@ -958,7 +958,7 @@ static int p_net_key_set(const char *name)
|
|||
if (!sub) {
|
||||
sub = p_subnet_alloc();
|
||||
if (!sub) {
|
||||
BT_ERR("%s, No space for a new subnet 0x%03x", __func__, net_idx);
|
||||
BT_ERR("No space for a new subnet 0x%03x", net_idx);
|
||||
err = -ENOMEM;
|
||||
goto free;
|
||||
}
|
||||
|
@ -970,7 +970,7 @@ static int p_net_key_set(const char *name)
|
|||
memcpy(sub->keys[0].net, &key.val[0], 16);
|
||||
memcpy(sub->keys[1].net, &key.val[1], 16);
|
||||
|
||||
BT_INFO("Restored NetKey Index 0x%03x", sub->net_idx);
|
||||
BT_INFO("Restored NetKeyIndex 0x%03x", sub->net_idx);
|
||||
BT_INFO("Restored NetKey %s", bt_hex(sub->keys[0].net, 16));
|
||||
}
|
||||
|
||||
|
@ -1006,7 +1006,7 @@ static int p_app_key_set(const char *name)
|
|||
|
||||
err = bt_mesh_load_core_settings(get, (u8_t *)&key, sizeof(key), &exist);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to load AppKey 0x%03x", __func__, app_idx);
|
||||
BT_ERR("Failed to load AppKey 0x%03x", app_idx);
|
||||
goto free;
|
||||
}
|
||||
|
||||
|
@ -1016,7 +1016,7 @@ static int p_app_key_set(const char *name)
|
|||
|
||||
sub = bt_mesh_provisioner_subnet_get(key.net_idx);
|
||||
if (!sub) {
|
||||
BT_ERR("%s, Failed to find subnet 0x%03x", __func__, key.net_idx);
|
||||
BT_ERR("Failed to find subnet 0x%03x", key.net_idx);
|
||||
err = -ENOENT;
|
||||
goto free;
|
||||
}
|
||||
|
@ -1025,7 +1025,7 @@ static int p_app_key_set(const char *name)
|
|||
if (!app) {
|
||||
app = p_appkey_alloc();
|
||||
if (!app) {
|
||||
BT_ERR("%s, No space for a new app key 0x%03x", __func__, app_idx);
|
||||
BT_ERR("No space for a new appkey 0x%03x", app_idx);
|
||||
err = -ENOMEM;
|
||||
goto free;
|
||||
}
|
||||
|
@ -1039,7 +1039,7 @@ static int p_app_key_set(const char *name)
|
|||
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 AppKey Index 0x%03x, NetKey Index 0x%03x",
|
||||
BT_INFO("Restored AppKeyIndex 0x%03x, NetKeyIndex 0x%03x",
|
||||
app->app_idx, app->net_idx);
|
||||
BT_INFO("Restored AppKey %s", bt_hex(app->keys[0].val, 16));
|
||||
}
|
||||
|
@ -1158,7 +1158,7 @@ static int p_node_set(const char *name)
|
|||
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);
|
||||
BT_ERR("Invalid unicast address 0x%04x", addr);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1284,14 +1284,14 @@ static int subnet_init(struct bt_mesh_subnet *sub)
|
|||
|
||||
err = bt_mesh_net_keys_create(&sub->keys[0], sub->keys[0].net);
|
||||
if (err) {
|
||||
BT_ERR("%s, Unable to generate keys for subnet", __func__);
|
||||
BT_ERR("Unable to generate keys for subnet");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (sub->kr_phase != BLE_MESH_KR_NORMAL) {
|
||||
err = bt_mesh_net_keys_create(&sub->keys[1], sub->keys[1].net);
|
||||
if (err) {
|
||||
BT_ERR("%s, Unable to generate keys for subnet", __func__);
|
||||
BT_ERR("Unable to generate keys for subnet");
|
||||
(void)memset(&sub->keys[0], 0, sizeof(sub->keys[0]));
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -1338,7 +1338,7 @@ int settings_core_commit(void)
|
|||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
|
||||
bt_mesh_proxy_prov_disable(true);
|
||||
bt_mesh_proxy_server_prov_disable(true);
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
|
||||
|
@ -1350,7 +1350,7 @@ int settings_core_commit(void)
|
|||
|
||||
err = subnet_init(sub);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to init subnet 0x%03x", __func__, sub->net_idx);
|
||||
BT_ERR("Failed to init subnet 0x%03x", sub->net_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1376,7 +1376,7 @@ int settings_core_commit(void)
|
|||
|
||||
err = subnet_init(sub);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to init subnet 0x%03x", __func__, sub->net_idx);
|
||||
BT_ERR("Failed to init subnet 0x%03x", sub->net_idx);
|
||||
}
|
||||
sub->node_id = BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED;
|
||||
}
|
||||
|
@ -1688,7 +1688,7 @@ static void clear_app_key(u16_t app_idx)
|
|||
|
||||
err = bt_mesh_remove_core_settings_item("mesh/appkey", app_idx);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to remove 0x%03x from mesh/appkey", __func__, app_idx);
|
||||
BT_ERR("Failed to remove 0x%03x from mesh/appkey", app_idx);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -1706,7 +1706,7 @@ static void clear_net_key(u16_t net_idx)
|
|||
|
||||
err = bt_mesh_remove_core_settings_item("mesh/netkey", net_idx);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to remove 0x%03x from mesh/netkey", __func__, net_idx);
|
||||
BT_ERR("Failed to remove 0x%03x from mesh/netkey", net_idx);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -1729,7 +1729,7 @@ static void store_net_key(struct bt_mesh_subnet *sub)
|
|||
sprintf(name, "mesh/nk/%04x", sub->net_idx);
|
||||
err = bt_mesh_save_core_settings(name, (const u8_t *)&key, sizeof(key));
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to store NetKey 0x%03x", __func__, sub->net_idx);
|
||||
BT_ERR("Failed to store NetKey 0x%03x", sub->net_idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1755,7 +1755,7 @@ static void store_app_key(struct bt_mesh_app_key *app)
|
|||
sprintf(name, "mesh/ak/%04x", app->app_idx);
|
||||
err = bt_mesh_save_core_settings(name, (const u8_t *)&key, sizeof(key));
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to store AppKey 0x%03x", __func__, app->app_idx);
|
||||
BT_ERR("Failed to store AppKey 0x%03x", app->app_idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2317,7 +2317,7 @@ static void store_p_net_key(struct bt_mesh_subnet *sub)
|
|||
sprintf(name, "mesh/pnk/%04x", sub->net_idx);
|
||||
err = bt_mesh_save_core_settings(name, (const u8_t *)&key, sizeof(key));
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to store NetKey 0x%03x", __func__, sub->net_idx);
|
||||
BT_ERR("Failed to store NetKey 0x%03x", sub->net_idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2341,7 +2341,7 @@ static void store_p_app_key(struct bt_mesh_app_key *app)
|
|||
sprintf(name, "mesh/pak/%04x", app->app_idx);
|
||||
err = bt_mesh_save_core_settings(name, (const u8_t *)&key, sizeof(key));
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to store AppKey 0x%03x", __func__, app->app_idx);
|
||||
BT_ERR("Failed to store AppKey 0x%03x", app->app_idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2380,7 +2380,7 @@ void bt_mesh_clear_p_app_idx(void)
|
|||
void bt_mesh_store_p_subnet(struct bt_mesh_subnet *sub)
|
||||
{
|
||||
if (sub == NULL) {
|
||||
BT_ERR("%s, Invalid subnet",__func__);
|
||||
BT_ERR("Invalid subnet");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2393,7 +2393,7 @@ void bt_mesh_store_p_subnet(struct bt_mesh_subnet *sub)
|
|||
void bt_mesh_store_p_app_key(struct bt_mesh_app_key *key)
|
||||
{
|
||||
if (key == NULL) {
|
||||
BT_ERR("%s, Invalid AppKey",__func__);
|
||||
BT_ERR("Invalid AppKey");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2406,7 +2406,7 @@ void bt_mesh_store_p_app_key(struct bt_mesh_app_key *key)
|
|||
void bt_mesh_clear_p_subnet(struct bt_mesh_subnet *sub)
|
||||
{
|
||||
if (sub == NULL) {
|
||||
BT_ERR("%s, Invalid subnet",__func__);
|
||||
BT_ERR("Invalid subnet");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2418,7 +2418,7 @@ void bt_mesh_clear_p_subnet(struct bt_mesh_subnet *sub)
|
|||
void bt_mesh_clear_p_app_key(struct bt_mesh_app_key *key)
|
||||
{
|
||||
if (key == NULL) {
|
||||
BT_ERR("%s, Invalid AppKey",__func__);
|
||||
BT_ERR("Invalid AppKey");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2433,7 +2433,7 @@ void bt_mesh_clear_rpl_single(u16_t src)
|
|||
int err = 0;
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(src)) {
|
||||
BT_ERR("%s, Invalid source address 0x%04x", __func__, src);
|
||||
BT_ERR("Invalid src 0x%04x", src);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2453,7 +2453,7 @@ void bt_mesh_store_node_info(struct bt_mesh_node *node)
|
|||
int err = 0;
|
||||
|
||||
if (node == NULL) {
|
||||
BT_ERR("%s, Invalid node", __func__);
|
||||
BT_ERR("Invalid node info");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2507,7 +2507,7 @@ static void clear_node(u16_t addr)
|
|||
void bt_mesh_clear_node_info(u16_t unicast_addr)
|
||||
{
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) {
|
||||
BT_ERR("%s, Invalid unicast address 0x%04x", __func__, unicast_addr);
|
||||
BT_ERR("Invalid unicast address 0x%04x", unicast_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2523,7 +2523,7 @@ void bt_mesh_store_node_name(struct bt_mesh_node *node)
|
|||
int err = 0;
|
||||
|
||||
if (node == NULL) {
|
||||
BT_ERR("%s, Invalid node", __func__);
|
||||
BT_ERR("Invalid node info");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2542,7 +2542,7 @@ void bt_mesh_store_node_comp_data(struct bt_mesh_node *node)
|
|||
int err = 0;
|
||||
|
||||
if (!node || !node->comp_data || node->comp_length == 0U) {
|
||||
BT_ERR("%s, Invalid node info", __func__);
|
||||
BT_ERR("Invalid node info");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,22 +80,22 @@ void bt_mesh_settings_foreach(void)
|
|||
err = nvs_open(ctx->nvs_name, NVS_READWRITE, &ctx->handle);
|
||||
#endif
|
||||
if (err != ESP_OK) {
|
||||
BT_ERR("%s, Open nvs failed, name %s, err %d", __func__, ctx->nvs_name, err);
|
||||
BT_ERR("Open nvs failed, name %s, err %d", ctx->nvs_name, err);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ctx->settings_init && ctx->settings_init()) {
|
||||
BT_ERR("%s, Init settings failed, name %s", __func__, ctx->nvs_name);
|
||||
BT_ERR("Init settings failed, name %s", ctx->nvs_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ctx->settings_load && ctx->settings_load()) {
|
||||
BT_ERR("%s, Load settings failed, name %s", __func__, ctx->nvs_name);
|
||||
BT_ERR("Load settings failed, name %s", ctx->nvs_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ctx->settings_commit && ctx->settings_commit()) {
|
||||
BT_ERR("%s, Commit settings failed, name %s", __func__, ctx->nvs_name);
|
||||
BT_ERR("Commit settings failed, name %s", ctx->nvs_name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ void bt_mesh_settings_deforeach(void)
|
|||
struct settings_context *ctx = &settings_ctx[i];
|
||||
|
||||
if (ctx->settings_deinit && ctx->settings_deinit()) {
|
||||
BT_ERR("%s, Deinit settings failed, name %s", __func__, ctx->nvs_name);
|
||||
BT_ERR("Deinit settings failed, name %s", ctx->nvs_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -139,26 +139,26 @@ static int settings_save(nvs_handle handle, const char *key, const u8_t *val, si
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
BT_DBG("%s, nvs %s, key %s", __func__, val ? "set" : "erase", key);
|
||||
BT_DBG("nvs %s, key %s", val ? "set" : "erase", key);
|
||||
|
||||
if (val) {
|
||||
err = nvs_set_blob(handle, key, val, len);
|
||||
} else {
|
||||
err = nvs_erase_key(handle, key);
|
||||
if (err == ESP_ERR_NVS_NOT_FOUND) {
|
||||
BT_DBG("%s, %s does not exist", __func__, key);
|
||||
BT_DBG("%s not exists", key);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (err != ESP_OK) {
|
||||
BT_ERR("%s, Failed to %s %s data (err %d)", __func__,
|
||||
BT_ERR("Failed to %s %s data (err %d)",
|
||||
val ? "set" : "erase", key, err);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
err = nvs_commit(handle);
|
||||
if (err != ESP_OK) {
|
||||
BT_ERR("%s, Failed to commit settings (err %d)", __func__, err);
|
||||
BT_ERR("Failed to commit settings (err %d)", err);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -186,12 +186,12 @@ static int settings_load(nvs_handle handle, const char *key,
|
|||
err = nvs_get_blob(handle, key, buf, &buf_len);
|
||||
if (err != ESP_OK) {
|
||||
if (err == ESP_ERR_NVS_NOT_FOUND) {
|
||||
BT_DBG("%s, Settings %s is not found", __func__, key);
|
||||
BT_DBG("Settings %s not found", key);
|
||||
*exist = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BT_ERR("%s, Failed to get %s data (err %d)", __func__, key, err);
|
||||
BT_ERR("Failed to get %s data (err %d)", key, err);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ static size_t settings_get_length(nvs_handle handle, const char *key)
|
|||
err = nvs_get_blob(handle, key, NULL, &len);
|
||||
if (err != ESP_OK) {
|
||||
if (err != ESP_ERR_NVS_NOT_FOUND) {
|
||||
BT_ERR("%s, Failed to get %s length (err %d)", __func__, key, err);
|
||||
BT_ERR("Failed to get %s length (err %d)", key, err);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -242,20 +242,20 @@ static struct net_buf_simple *settings_get_item(nvs_handle handle, const char *k
|
|||
|
||||
length = settings_get_length(handle, key);
|
||||
if (!length) {
|
||||
BT_DBG("%s, Empty %s", __func__, key);
|
||||
BT_DBG("Empty %s", key);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buf = bt_mesh_alloc_buf(length);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
/* TODO: in this case, erase all related settings? */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err = settings_load(handle, key, buf->data, length, &exist);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to load %s", __func__, key);
|
||||
BT_ERR("Failed to load %s", key);
|
||||
/* TODO: in this case, erase all related settings? */
|
||||
bt_mesh_free_buf(buf);
|
||||
return NULL;
|
||||
|
@ -316,7 +316,7 @@ static int settings_add_item(nvs_handle handle, const char *key, const u16_t val
|
|||
|
||||
/* Check if val already exists */
|
||||
if (is_settings_item_exist(buf, val) == true) {
|
||||
BT_DBG("%s, 0x%04x already exists", __func__, val);
|
||||
BT_DBG("0x%04x already exists", val);
|
||||
bt_mesh_free_buf(buf);
|
||||
return 0;
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ static int settings_add_item(nvs_handle handle, const char *key, const u16_t val
|
|||
|
||||
store = bt_mesh_alloc_buf(length);
|
||||
if (!store) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free_buf(buf);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ static int settings_remove_item(nvs_handle handle, const char *key, const u16_t
|
|||
|
||||
/* Check if val does exist */
|
||||
if (is_settings_item_exist(buf, val) == false) {
|
||||
BT_DBG("%s, 0x%04x does not exist", __func__, val);
|
||||
BT_DBG("0x%04x not exists", val);
|
||||
bt_mesh_free_buf(buf);
|
||||
return 0;
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ static int settings_remove_item(nvs_handle handle, const char *key, const u16_t
|
|||
|
||||
store = bt_mesh_alloc_buf(length);
|
||||
if (!store) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free_buf(buf);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
|
|
@ -46,14 +46,14 @@ int bt_mesh_device_auto_enter_network(struct bt_mesh_device_network_info *info)
|
|||
err = bt_mesh_provision(info->net_key, info->net_idx, info->flags, info->iv_index,
|
||||
info->unicast_addr, info->dev_key);
|
||||
if (err) {
|
||||
BT_ERR("%s, bt_mesh_provision() failed (err %d)", __func__, err);
|
||||
BT_ERR("bt_mesh_provision() failed (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Adds application key to device */
|
||||
sub = bt_mesh_subnet_get(info->net_idx);
|
||||
if (!sub) {
|
||||
BT_ERR("%s, Failed to find subnet 0x%04x", __func__, info->net_idx);
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", info->net_idx);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -64,14 +64,14 @@ int bt_mesh_device_auto_enter_network(struct bt_mesh_device_network_info *info)
|
|||
}
|
||||
}
|
||||
if (i == ARRAY_SIZE(bt_mesh.app_keys)) {
|
||||
BT_ERR("%s, Failed to allocate memory, AppKeyIndex 0x%04x", __func__, info->app_idx);
|
||||
BT_ERR("Failed to allocate AppKey, 0x%04x", info->app_idx);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
keys = sub->kr_flag ? &key->keys[1] : &key->keys[0];
|
||||
|
||||
if (bt_mesh_app_id(info->app_key, &keys->id)) {
|
||||
BT_ERR("%s, Failed to calculate AID, AppKeyIndex 0x%04x", __func__, info->app_idx);
|
||||
BT_ERR("Failed to calculate AID, 0x%04x", info->app_idx);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ int bt_mesh_device_auto_enter_network(struct bt_mesh_device_network_info *info)
|
|||
/* Binds AppKey with all non-config models, adds group address to all these models */
|
||||
comp = bt_mesh_comp_get();
|
||||
if (!comp) {
|
||||
BT_ERR("%s, Composition data is NULL", __func__);
|
||||
BT_ERR("Invalid composition data");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ static int send_unseg(struct bt_mesh_net_tx *tx, struct net_buf_simple *sdu,
|
|||
|
||||
buf = bt_mesh_adv_create(BLE_MESH_ADV_DATA, tx->xmit, BUF_TIMEOUT);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Out of network buffers", __func__);
|
||||
BT_ERR("Out of network buffers");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
|
@ -398,7 +398,7 @@ static void seg_tx_send_unacked(struct seg_tx *tx)
|
|||
err = bt_mesh_net_resend(tx->sub, seg, tx->new_key,
|
||||
&seg_sent_cb, tx);
|
||||
if (err) {
|
||||
BT_ERR("%s, Sending segment failed", __func__);
|
||||
BT_ERR("Sending segment failed");
|
||||
bt_mesh_tx_seg_unlock();
|
||||
seg_tx_complete(tx, -EIO);
|
||||
return;
|
||||
|
@ -428,12 +428,12 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu,
|
|||
net_tx->aszmic, sdu->len);
|
||||
|
||||
if (sdu->len < 1) {
|
||||
BT_ERR("%s, Zero-length SDU not allowed", __func__);
|
||||
BT_ERR("Zero-length SDU not allowed");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (sdu->len > BLE_MESH_TX_SDU_MAX) {
|
||||
BT_ERR("%s, Not enough segment buffers for length %u", __func__, sdu->len);
|
||||
BT_ERR("Not enough segment buffers for length %u", sdu->len);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu,
|
|||
}
|
||||
|
||||
if (!tx) {
|
||||
BT_ERR("%s, No multi-segment message contexts available", __func__);
|
||||
BT_ERR("No multi-segment message contexts available");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
|
@ -496,7 +496,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu,
|
|||
seg = bt_mesh_adv_create(BLE_MESH_ADV_DATA, net_tx->xmit,
|
||||
BUF_TIMEOUT);
|
||||
if (!seg) {
|
||||
BT_ERR("%s, Out of segment buffers", __func__);
|
||||
BT_ERR("Out of segment buffers");
|
||||
seg_tx_reset(tx);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu,
|
|||
seg_o ? &seg_sent_cb : &first_sent_cb,
|
||||
tx);
|
||||
if (err) {
|
||||
BT_ERR("%s, Sending segment failed", __func__);
|
||||
BT_ERR("Sending segment failed");
|
||||
seg_tx_reset(tx);
|
||||
return err;
|
||||
}
|
||||
|
@ -593,7 +593,7 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg,
|
|||
int err = 0;
|
||||
|
||||
if (net_buf_simple_tailroom(msg) < BLE_MESH_MIC_SHORT) {
|
||||
BT_ERR("%s, Insufficient tailroom for Transport MIC", __func__);
|
||||
BT_ERR("Insufficient tailroom for Transport MIC");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -607,7 +607,7 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg,
|
|||
|
||||
role = bt_mesh_get_device_role(tx->ctx->model, tx->ctx->srv_send);
|
||||
if (role == ROLE_NVAL) {
|
||||
BT_ERR("%s, Failed to get model role", __func__);
|
||||
BT_ERR("Failed to get model role");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -636,7 +636,7 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg,
|
|||
tx->ctx->addr, bt_mesh.seq,
|
||||
BLE_MESH_NET_IVI_TX);
|
||||
if (err) {
|
||||
BT_ERR("%s, Encrypt failed", __func__);
|
||||
BT_ERR("Encrypt failed (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -714,7 +714,7 @@ static bool is_replay(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match)
|
|||
}
|
||||
}
|
||||
|
||||
BT_ERR("%s, RPL is full!", __func__);
|
||||
BT_ERR("RPL is full!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -731,7 +731,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr,
|
|||
BT_DBG("len %u: %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
if (buf->len < 1 + APP_MIC_LEN(aszmic)) {
|
||||
BT_ERR("%s, Too short SDU + MIC", __func__);
|
||||
BT_ERR("Too short SDU + MIC (len %u)", buf->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -755,7 +755,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr,
|
|||
*/
|
||||
sdu = bt_mesh_alloc_buf(CONFIG_BLE_MESH_RX_SDU_MAX - BLE_MESH_MIC_SHORT);
|
||||
if (!sdu) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -767,7 +767,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr,
|
|||
|
||||
dev_key = bt_mesh_rx_devkey_get(i, rx->ctx.addr);
|
||||
if (!dev_key) {
|
||||
BT_DBG("%s, NULL Device Key", __func__);
|
||||
BT_DBG("DevKey not found");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -787,7 +787,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
BT_WARN("%s, Unable to decrypt with DevKey", __func__);
|
||||
BT_WARN("Unable to decrypt with DevKey");
|
||||
bt_mesh_free_buf(sdu);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
@ -800,7 +800,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr,
|
|||
|
||||
key = bt_mesh_rx_appkey_get(i);
|
||||
if (!key) {
|
||||
BT_DBG("%s, NULL AppKey", __func__);
|
||||
BT_DBG("AppKey not found");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -839,7 +839,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr,
|
|||
}
|
||||
|
||||
if (rx->local_match) {
|
||||
BT_WARN("%s, No matching AppKey", __func__);
|
||||
BT_WARN("No matching AppKey");
|
||||
}
|
||||
bt_mesh_free_buf(sdu);
|
||||
return 0;
|
||||
|
@ -885,7 +885,7 @@ static int trans_ack(struct bt_mesh_net_rx *rx, u8_t hdr,
|
|||
u8_t obo = 0U;
|
||||
|
||||
if (buf->len < 6) {
|
||||
BT_ERR("%s, Too short ack message", __func__);
|
||||
BT_ERR("Too short ack message (len %u)", buf->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -911,7 +911,7 @@ static int trans_ack(struct bt_mesh_net_rx *rx, u8_t hdr,
|
|||
}
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(tx->dst)) {
|
||||
BT_WARN("%s, Received ack for segments to group", __func__);
|
||||
BT_WARN("Received ack for segments to group");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -924,7 +924,7 @@ static int trans_ack(struct bt_mesh_net_rx *rx, u8_t hdr,
|
|||
}
|
||||
|
||||
if (find_msb_set(ack) - 1 > tx->seg_n) {
|
||||
BT_ERR("%s, Too large segment number in ack", __func__);
|
||||
BT_ERR("Too large segment number in ack");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -958,7 +958,7 @@ static int trans_heartbeat(struct bt_mesh_net_rx *rx,
|
|||
u16_t feat = 0U;
|
||||
|
||||
if (buf->len < 3) {
|
||||
BT_ERR("%s, Too short heartbeat message", __func__);
|
||||
BT_ERR("Too short heartbeat message (len %u)", buf->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1054,7 +1054,7 @@ static int trans_unseg(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx,
|
|||
BT_DBG("AFK %u AID 0x%02x", AKF(buf->data), AID(buf->data));
|
||||
|
||||
if (buf->len < 1) {
|
||||
BT_ERR("%s, Too small unsegmented PDU", __func__);
|
||||
BT_ERR("Too small unsegmented PDU");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1111,7 +1111,7 @@ static int ctl_send_unseg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data,
|
|||
|
||||
buf = bt_mesh_adv_create(BLE_MESH_ADV_DATA, tx->xmit, BUF_TIMEOUT);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Out of transport buffers", __func__);
|
||||
BT_ERR("Out of transport buffers");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
|
@ -1154,7 +1154,7 @@ static int ctl_send_seg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data,
|
|||
}
|
||||
|
||||
if (!tx_seg) {
|
||||
BT_ERR("%s, No multi-segment message contexts available", __func__);
|
||||
BT_ERR("No multi-segment message contexts available");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
|
@ -1187,7 +1187,7 @@ static int ctl_send_seg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data,
|
|||
seg = bt_mesh_adv_create(BLE_MESH_ADV_DATA, tx->xmit,
|
||||
BUF_TIMEOUT);
|
||||
if (!seg) {
|
||||
BT_ERR("%s, Out of segment buffers", __func__);
|
||||
BT_ERR("Out of segment buffers");
|
||||
seg_tx_reset(tx_seg);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
@ -1212,7 +1212,7 @@ static int ctl_send_seg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data,
|
|||
seg_o ? &seg_sent_cb : &first_sent_cb,
|
||||
tx_seg);
|
||||
if (err) {
|
||||
BT_ERR("%s, Sending segment failed", __func__);
|
||||
BT_ERR("Sending segment failed (err %d)", err);
|
||||
seg_tx_reset(tx_seg);
|
||||
return err;
|
||||
}
|
||||
|
@ -1418,17 +1418,17 @@ static bool seg_rx_is_valid(struct seg_rx *rx, struct bt_mesh_net_rx *net_rx,
|
|||
const u8_t *hdr, u8_t seg_n)
|
||||
{
|
||||
if (rx->hdr != *hdr || rx->seg_n != seg_n) {
|
||||
BT_ERR("%s, Invalid segment for ongoing session", __func__);
|
||||
BT_ERR("Invalid segment for ongoing session");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rx->src != net_rx->ctx.addr || rx->dst != net_rx->ctx.recv_dst) {
|
||||
BT_ERR("%s, Invalid source or destination for segment", __func__);
|
||||
BT_ERR("Invalid source or destination for segment");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rx->ctl != net_rx->ctl) {
|
||||
BT_ERR("%s, Inconsistent CTL in segment", __func__);
|
||||
BT_ERR("Inconsistent CTL in segment");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1482,7 +1482,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx,
|
|||
int err = 0;
|
||||
|
||||
if (buf->len < 5) {
|
||||
BT_ERR("%s, Too short segmented message (len %u)", __func__, buf->len);
|
||||
BT_ERR("Too short segmented message (len %u)", buf->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1506,7 +1506,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx,
|
|||
BT_DBG("SeqZero 0x%04x SegO %u SegN %u", seq_zero, seg_o, seg_n);
|
||||
|
||||
if (seg_o > seg_n) {
|
||||
BT_ERR("%s, SegO greater than SegN (%u > %u)", __func__, seg_o, seg_n);
|
||||
BT_ERR("SegO greater than SegN (%u > %u)", seg_o, seg_n);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1571,7 +1571,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx,
|
|||
|
||||
/* Bail out early if we're not ready to receive such a large SDU */
|
||||
if (!sdu_len_is_ok(net_rx->ctl, seg_n)) {
|
||||
BT_ERR("%s, Too big incoming SDU length", __func__);
|
||||
BT_ERR("Too big incoming SDU length");
|
||||
send_ack(net_rx->sub, net_rx->ctx.recv_dst, net_rx->ctx.addr,
|
||||
net_rx->ctx.send_ttl, seq_auth, 0,
|
||||
net_rx->friend_match);
|
||||
|
@ -1633,7 +1633,7 @@ found_rx:
|
|||
}
|
||||
} else {
|
||||
if (buf->len != seg_len(rx->ctl)) {
|
||||
BT_ERR("%s, Incorrect segment size for message type", __func__);
|
||||
BT_ERR("Incorrect segment size for message type");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1953,7 +1953,7 @@ int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, u16_t app_idx,
|
|||
if (app_idx == BLE_MESH_KEY_DEV) {
|
||||
*key = bt_mesh_tx_devkey_get(role, dst);
|
||||
if (!*key) {
|
||||
BT_ERR("%s, Failed to get Device Key", __func__);
|
||||
BT_ERR("DevKey not found");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1962,13 +1962,13 @@ int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, u16_t app_idx,
|
|||
}
|
||||
|
||||
if (!subnet) {
|
||||
BT_ERR("%s, Invalid subnet", __func__);
|
||||
BT_ERR("Invalid subnet");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
app_key = bt_mesh_tx_appkey_get(role, app_idx);
|
||||
if (!app_key) {
|
||||
BT_ERR("%s, AppKey 0x%04x not exists", __func__, app_idx);
|
||||
BT_ERR("Invalid AppKeyIndex 0x%04x", app_idx);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,7 @@ static bt_mesh_client_node_t *bt_mesh_client_pick_node(sys_slist_t *list, u16_t
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
||||
struct bt_mesh_model *model,
|
||||
bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf, bool need_pub)
|
||||
{
|
||||
|
@ -64,7 +63,7 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
|||
|
||||
cli = (bt_mesh_client_user_data_t *)model->user_data;
|
||||
if (!cli) {
|
||||
BT_ERR("%s, Clinet user_data is NULL", __func__);
|
||||
BT_ERR("Invalid client user data");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -73,7 +72,7 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
|||
* this message to the application layer.
|
||||
*/
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(ctx->recv_dst)) {
|
||||
BT_DBG("Unexpected status message 0x%x", ctx->recv_op);
|
||||
BT_DBG("Unexpected status message 0x%08x", ctx->recv_op);
|
||||
if (cli->publish_status && need_pub) {
|
||||
cli->publish_status(ctx->recv_op, model, ctx, buf);
|
||||
}
|
||||
|
@ -87,12 +86,12 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
|||
*/
|
||||
data = (bt_mesh_client_internal_data_t *)cli->internal_data;
|
||||
if (!data) {
|
||||
BT_ERR("%s, Client internal_data is NULL", __func__);
|
||||
BT_ERR("Invalid client internal data");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((node = bt_mesh_client_pick_node(&data->queue, ctx->addr)) == NULL) {
|
||||
BT_DBG("Unexpected status message 0x%x", ctx->recv_op);
|
||||
BT_DBG("Unexpected status message 0x%08x", ctx->recv_op);
|
||||
if (cli->publish_status && need_pub) {
|
||||
cli->publish_status(ctx->recv_op, model, ctx, buf);
|
||||
}
|
||||
|
@ -100,7 +99,7 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
|||
}
|
||||
|
||||
if (node->op_pending != ctx->recv_op) {
|
||||
BT_DBG("Unexpected status message 0x%x", ctx->recv_op);
|
||||
BT_DBG("Unexpected status message 0x%08x", ctx->recv_op);
|
||||
if (cli->publish_status && need_pub) {
|
||||
cli->publish_status(ctx->recv_op, model, ctx, buf);
|
||||
}
|
||||
|
@ -108,7 +107,7 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
|||
}
|
||||
|
||||
if (k_delayed_work_remaining_get(&node->timer) == 0) {
|
||||
BT_DBG("Unexpected status message 0x%x", ctx->recv_op);
|
||||
BT_DBG("Unexpected status message 0x%08x", ctx->recv_op);
|
||||
if (cli->publish_status && need_pub) {
|
||||
cli->publish_status(ctx->recv_op, model, ctx, buf);
|
||||
}
|
||||
|
@ -273,18 +272,18 @@ int bt_mesh_client_send_msg(struct bt_mesh_model *model,
|
|||
|
||||
client = (bt_mesh_client_user_data_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("%s, Invalid client user data", __func__);
|
||||
BT_ERR("Invalid client user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
internal = (bt_mesh_client_internal_data_t *)client->internal_data;
|
||||
if (!internal) {
|
||||
BT_ERR("%s, Invalid client internal data", __func__);
|
||||
BT_ERR("Invalid client internal data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (ctx->addr == BLE_MESH_ADDR_UNASSIGNED) {
|
||||
BT_ERR("%s, Invalid DST 0x%04x", __func__, ctx->addr);
|
||||
BT_ERR("Invalid DST 0x%04x", ctx->addr);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -303,19 +302,19 @@ int bt_mesh_client_send_msg(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
if (!timer_handler) {
|
||||
BT_ERR("%s, Invalid timeout handler", __func__);
|
||||
BT_ERR("Invalid timeout handler");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (bt_mesh_client_check_node_in_list(&internal->queue, ctx->addr)) {
|
||||
BT_ERR("%s, Busy sending message to DST 0x%04x", __func__, ctx->addr);
|
||||
BT_ERR("Busy sending message to DST 0x%04x", ctx->addr);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
/* Don't forget to free the node in the timeout (timer_handler) function. */
|
||||
node = (bt_mesh_client_node_t *)bt_mesh_calloc(sizeof(bt_mesh_client_node_t));
|
||||
if (!node) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -331,7 +330,7 @@ int bt_mesh_client_send_msg(struct bt_mesh_model *model,
|
|||
node->timeout = bt_mesh_client_calc_timeout(ctx, msg, opcode, timeout ? timeout : CONFIG_BLE_MESH_CLIENT_MSG_TIMEOUT);
|
||||
|
||||
if (k_delayed_work_init(&node->timer, timer_handler)) {
|
||||
BT_ERR("%s, Failed to create a timer", __func__);
|
||||
BT_ERR("Failed to create a timer");
|
||||
bt_mesh_free(node);
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -389,20 +388,20 @@ int bt_mesh_client_init(struct bt_mesh_model *model)
|
|||
}
|
||||
|
||||
if (!model->op) {
|
||||
BT_ERR("%s, Client model op is NULL", __func__);
|
||||
BT_ERR("Invalid vendor client model op");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cli = model->user_data;
|
||||
if (!cli) {
|
||||
BT_ERR("%s, Client user_data is NULL", __func__);
|
||||
BT_ERR("Invalid vendor client user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!cli->internal_data) {
|
||||
data = bt_mesh_calloc(sizeof(bt_mesh_client_internal_data_t));
|
||||
if (!data) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -431,7 +430,7 @@ int bt_mesh_client_deinit(struct bt_mesh_model *model)
|
|||
|
||||
client = (bt_mesh_client_user_data_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("%s, Client user_data is NULL", __func__);
|
||||
BT_ERR("Invalid vendor client user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -455,19 +454,19 @@ int bt_mesh_client_free_node(bt_mesh_client_node_t *node)
|
|||
bt_mesh_client_user_data_t *client = NULL;
|
||||
|
||||
if (!node || !node->ctx.model) {
|
||||
BT_ERR("%s, Client model list item is NULL", __func__);
|
||||
BT_ERR("Invalid client list item");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
client = (bt_mesh_client_user_data_t *)node->ctx.model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("%s, Client model user data is NULL", __func__);
|
||||
BT_ERR("Invalid client user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
internal = (bt_mesh_client_internal_data_t *)client->internal_data;
|
||||
if (!internal) {
|
||||
BT_ERR("%s, Client model internal data is NULL", __func__);
|
||||
BT_ERR("Invalid client internal data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -526,7 +525,7 @@ int bt_mesh_set_client_model_role(bt_mesh_role_param_t *common)
|
|||
case PROVISIONER:
|
||||
/* if provisioner is not enabled, provisioner role can't be used to send messages */
|
||||
if (!bt_mesh_is_provisioner_en()) {
|
||||
BT_ERR("%s, Provisioner is disabled", __func__);
|
||||
BT_ERR("Provisioner is disabled");
|
||||
return -EINVAL;
|
||||
}
|
||||
client->msg_role = PROVISIONER;
|
||||
|
@ -538,7 +537,7 @@ int bt_mesh_set_client_model_role(bt_mesh_role_param_t *common)
|
|||
break;
|
||||
#endif
|
||||
default:
|
||||
BT_WARN("%s, Unknown model role %x", __func__, common->role);
|
||||
BT_WARN("Unknown model role 0x%02x", common->role);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
#include "model_opcode.h"
|
||||
#include "generic_client.h"
|
||||
|
||||
/** The following are the macro definitions of generic client
|
||||
* model messages length, and a message is composed of three
|
||||
* parts: Opcode + msg_value + MIC
|
||||
/* The followings are the macro definitions of Generic client
|
||||
* model message length, and a message is composed of 3 parts:
|
||||
* Opcode + Payload + MIC
|
||||
*/
|
||||
/* Generic onoff client messages length */
|
||||
#define BLE_MESH_GEN_ONOFF_GET_MSG_LEN (2 + 0 + 4)
|
||||
|
@ -171,7 +171,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
u8_t evt = 0xFF;
|
||||
size_t len = 0U;
|
||||
|
||||
BT_DBG("%s, len %d, bytes %s", __func__, buf->len, bt_hex(buf->data, buf->len));
|
||||
BT_DBG("len %d, bytes %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
switch (ctx->recv_op) {
|
||||
case BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS: {
|
||||
|
@ -182,7 +182,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_onoff_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->present_onoff = net_buf_simple_pull_u8(buf);
|
||||
|
@ -203,7 +203,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_level_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->present_level = net_buf_simple_pull_le16(buf);
|
||||
|
@ -224,7 +224,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_def_trans_time_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->trans_time = net_buf_simple_pull_u8(buf);
|
||||
|
@ -240,7 +240,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_onpowerup_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->onpowerup = net_buf_simple_pull_u8(buf);
|
||||
|
@ -256,7 +256,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_power_level_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->present_power = net_buf_simple_pull_le16(buf);
|
||||
|
@ -277,7 +277,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_power_last_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->power = net_buf_simple_pull_le16(buf);
|
||||
|
@ -293,7 +293,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_power_default_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->power = net_buf_simple_pull_le16(buf);
|
||||
|
@ -309,7 +309,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_power_range_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->status_code = net_buf_simple_pull_u8(buf);
|
||||
|
@ -327,7 +327,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_battery_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
u32_t value = 0;
|
||||
|
@ -349,7 +349,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_loc_global_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->global_latitude = net_buf_simple_pull_le32(buf);
|
||||
|
@ -367,7 +367,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_loc_local_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->local_north = net_buf_simple_pull_le16(buf);
|
||||
|
@ -383,12 +383,12 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_user_properties_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_user_properties_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->user_property_ids = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->user_property_ids) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_user_property_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_user_property_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->user_property_id = net_buf_simple_pull_le16(buf);
|
||||
|
@ -410,7 +410,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
status->user_access = net_buf_simple_pull_u8(buf);
|
||||
status->user_property_value = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->user_property_value) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -424,12 +424,12 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_admin_properties_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_admin_properties_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->admin_property_ids = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->admin_property_ids) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_admin_property_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_admin_property_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->admin_property_id = net_buf_simple_pull_le16(buf);
|
||||
|
@ -451,7 +451,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
status->admin_user_access = net_buf_simple_pull_u8(buf);
|
||||
status->admin_property_value = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->admin_property_value) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -465,12 +465,12 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_manu_properties_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_manu_properties_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->manu_property_ids = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->manu_property_ids) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_manu_property_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_manu_property_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->manu_property_id = net_buf_simple_pull_le16(buf);
|
||||
|
@ -492,7 +492,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
status->manu_user_access = net_buf_simple_pull_u8(buf);
|
||||
status->manu_property_value = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->manu_property_value) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -506,12 +506,12 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_client_properties_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_client_properties_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->client_property_ids = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->client_property_ids) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Not a Generic Status message opcode", __func__);
|
||||
BT_ERR("Invalid Generic Status opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -532,7 +532,7 @@ static void generic_status(struct bt_mesh_model *model,
|
|||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true);
|
||||
if (!node) {
|
||||
BT_DBG("Unexpected generic status message 0x%x", ctx->recv_op);
|
||||
BT_DBG("Unexpected Generic Status 0x%04x", ctx->recv_op);
|
||||
} else {
|
||||
switch (node->opcode) {
|
||||
case BLE_MESH_MODEL_OP_GEN_ONOFF_GET:
|
||||
|
@ -720,7 +720,7 @@ static int gen_get_state(bt_mesh_client_common_param_t *common, void *value)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("This generic message should be sent with NULL get pointer");
|
||||
BT_DBG("No parameters for Generic Get 0x%04x", common->opcode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ static int gen_get_state(bt_mesh_client_common_param_t *common, void *value)
|
|||
timeout_handler, common->msg_timeout, true,
|
||||
common->cb, common->cb_data);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send Generic Get message (err %d)", __func__, err);
|
||||
BT_ERR("Failed to send Generic Get message (err %d)", err);
|
||||
}
|
||||
|
||||
return err;
|
||||
|
@ -743,7 +743,7 @@ static int gen_set_state(bt_mesh_client_common_param_t *common,
|
|||
|
||||
msg = bt_mesh_alloc_buf(value_len);
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -899,7 +899,7 @@ static int gen_set_state(bt_mesh_client_common_param_t *common,
|
|||
}
|
||||
|
||||
default:
|
||||
BT_ERR("%s, Not a Generic Client Set message opcode", __func__);
|
||||
BT_ERR("Invalid Generic Set opcode 0x%04x", common->opcode);
|
||||
err = -EINVAL;
|
||||
goto end;
|
||||
}
|
||||
|
@ -908,7 +908,7 @@ static int gen_set_state(bt_mesh_client_common_param_t *common,
|
|||
timeout_handler, common->msg_timeout, need_ack,
|
||||
common->cb, common->cb_data);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send Generic Set message (err %d)", __func__, err);
|
||||
BT_ERR("Failed to send Generic Set message (err %d)", err);
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -917,7 +917,8 @@ end:
|
|||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status)
|
||||
int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common,
|
||||
void *get, void *status)
|
||||
{
|
||||
bt_mesh_generic_client_t *client = NULL;
|
||||
|
||||
|
@ -928,7 +929,7 @@ int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void
|
|||
|
||||
client = (bt_mesh_generic_client_t *)common->model->user_data;
|
||||
if (!client || !client->internal_data) {
|
||||
BT_ERR("%s, Generic Client user data is NULL", __func__);
|
||||
BT_ERR("Invalid Generic client data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -950,37 +951,38 @@ int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void
|
|||
break;
|
||||
case BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET:
|
||||
if (!get) {
|
||||
BT_ERR("%s, Generic user_property_get is NULL", __func__);
|
||||
BT_ERR("Invalid Generic User Property Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
case BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET:
|
||||
if (!get) {
|
||||
BT_ERR("%s, Generic admin_property_get is NULL", __func__);
|
||||
BT_ERR("Invalid Generic Admin Property Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
case BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_GET:
|
||||
if (!get) {
|
||||
BT_ERR("%s, Generic manu_property_get is NULL", __func__);
|
||||
BT_ERR("Invalid Generic Manu Property Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
case BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET:
|
||||
if (!get) {
|
||||
BT_ERR("%s, Generic client_properties_get is NULL", __func__);
|
||||
BT_ERR("Invalid Generic Client Properties Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Not a Generic Client Get message opcode", __func__);
|
||||
BT_ERR("Invalid Generic Get opcode 0x%04x", common->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return gen_get_state(common, get);
|
||||
}
|
||||
|
||||
int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status)
|
||||
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 = 0U;
|
||||
|
@ -993,7 +995,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
|
||||
client = (bt_mesh_generic_client_t *)common->model->user_data;
|
||||
if (!client || !client->internal_data) {
|
||||
BT_ERR("%s, Generic Client user data is NULL", __func__);
|
||||
BT_ERR("Invalid Generic client data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1005,7 +1007,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
value = (struct bt_mesh_gen_onoff_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Generic OnOff Set transition time", __func__);
|
||||
BT_ERR("Invalid Generic OnOff Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1019,7 +1021,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
value = (struct bt_mesh_gen_level_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Generic Level Set transition time", __func__);
|
||||
BT_ERR("Invalid Generic Level Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1033,7 +1035,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
value = (struct bt_mesh_gen_delta_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Generic Delta Set transition time", __func__);
|
||||
BT_ERR("Invalid Generic Delta Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1047,7 +1049,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
value = (struct bt_mesh_gen_move_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Generic Move Set transition time", __func__);
|
||||
BT_ERR("Invalid Generic Move Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1059,7 +1061,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
case BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK: {
|
||||
u8_t value = *(u8_t *)set;
|
||||
if ((value & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Generic Default Trans Time Set transition time", __func__);
|
||||
BT_ERR("Invalid Generic Default Trans Time Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
length = BLE_MESH_GEN_DEF_TRANS_TIME_SET_MSG_LEN;
|
||||
|
@ -1077,7 +1079,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
value = (struct bt_mesh_gen_power_level_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Generic Power Level Set transition time", __func__);
|
||||
BT_ERR("Invalid Generic Power Level Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1095,7 +1097,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
struct bt_mesh_gen_power_range_set *value;
|
||||
value = (struct bt_mesh_gen_power_range_set *)set;
|
||||
if (value->range_min > value->range_max) {
|
||||
BT_ERR("%s, Generic Power Level Set range min is greater than range max", __func__);
|
||||
BT_ERR("Generic Power Level Set range min is greater than range max");
|
||||
return -EINVAL;
|
||||
}
|
||||
length = BLE_MESH_GEN_POWER_RANGE_SET_MSG_LEN;
|
||||
|
@ -1117,7 +1119,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
struct bt_mesh_gen_user_property_set *value;
|
||||
value = (struct bt_mesh_gen_user_property_set *)set;
|
||||
if (!value->user_property_value) {
|
||||
BT_ERR("%s, Generic user_property_value is NULL", __func__);
|
||||
BT_ERR("Invalid Generic User Property value");
|
||||
return -EINVAL;
|
||||
}
|
||||
length = (1 + 2 + value->user_property_value->len + 4);
|
||||
|
@ -1129,7 +1131,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
struct bt_mesh_gen_admin_property_set *value;
|
||||
value = (struct bt_mesh_gen_admin_property_set *)set;
|
||||
if (!value->admin_property_value) {
|
||||
BT_ERR("%s, Generic admin_property_value is NULL", __func__);
|
||||
BT_ERR("Invalid Generic Admin Property value");
|
||||
return -EINVAL;
|
||||
}
|
||||
length = (1 + 2 + 1 + value->admin_property_value->len + 4);
|
||||
|
@ -1141,7 +1143,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
length = BLE_MESH_GEN_MANU_PROPERTY_SET_MSG_LEN;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Not a Generic Client Set message opcode", __func__);
|
||||
BT_ERR("Invalid Generic Set opcode 0x%04x", common->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1162,14 +1164,14 @@ static int generic_client_init(struct bt_mesh_model *model, bool primary)
|
|||
|
||||
client = (bt_mesh_generic_client_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("%s, Generic Client user_data is NULL", __func__);
|
||||
BT_ERR("Invalid Generic client user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!client->internal_data) {
|
||||
internal = bt_mesh_calloc(sizeof(generic_internal_data_t));
|
||||
if (!internal) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -1239,7 +1241,7 @@ static int generic_client_deinit(struct bt_mesh_model *model, bool primary)
|
|||
|
||||
client = (bt_mesh_generic_client_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("%s, Generic Client user_data is NULL", __func__);
|
||||
BT_ERR("Invalid Generic client user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,8 +100,7 @@ int bt_mesh_client_deinit(struct bt_mesh_model *model);
|
|||
* @param need_pub Indicate if the msg sent to app layer as a publish msg
|
||||
* @return 0 on success, or (negative) error code on failure.
|
||||
*/
|
||||
bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
||||
struct bt_mesh_model *model,
|
||||
bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf, bool need_pub);
|
||||
|
||||
|
|
|
@ -557,7 +557,8 @@ int bt_mesh_gen_property_cli_deinit(struct bt_mesh_model *model, bool primary);
|
|||
*
|
||||
* @return Zero-success, other-fail
|
||||
*/
|
||||
int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status);
|
||||
int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common,
|
||||
void *get, void *status);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set generic states.
|
||||
|
@ -568,7 +569,8 @@ int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void
|
|||
*
|
||||
* @return Zero-success, other-fail
|
||||
*/
|
||||
int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status);
|
||||
int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common,
|
||||
void *set, void *status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -527,7 +527,8 @@ int bt_mesh_light_lc_cli_deinit(struct bt_mesh_model *model, bool primary);
|
|||
*
|
||||
* @return Zero-success, other-fail
|
||||
*/
|
||||
int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status);
|
||||
int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common,
|
||||
void *get, void *status);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set light states.
|
||||
|
@ -538,7 +539,8 @@ int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *
|
|||
*
|
||||
* @return Zero-success, other-fail
|
||||
*/
|
||||
int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status);
|
||||
int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common,
|
||||
void *set, void *status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -162,7 +162,8 @@ int bt_mesh_sensor_cli_deinit(struct bt_mesh_model *model, bool primary);
|
|||
*
|
||||
* @return Zero-success, other-fail
|
||||
*/
|
||||
int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status);
|
||||
int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common,
|
||||
void *get, void *status);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set sensor states.
|
||||
|
@ -173,7 +174,8 @@ int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void
|
|||
*
|
||||
* @return Zero-success, other-fail
|
||||
*/
|
||||
int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status);
|
||||
int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common,
|
||||
void *set, void *status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -272,7 +272,8 @@ int bt_mesh_scheduler_cli_deinit(struct bt_mesh_model *model, bool primary);
|
|||
*
|
||||
* @return Zero-success, other-fail
|
||||
*/
|
||||
int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status);
|
||||
int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common,
|
||||
void *get, void *status);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set scene states.
|
||||
|
@ -283,7 +284,8 @@ int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, v
|
|||
*
|
||||
* @return Zero-success, other-fail
|
||||
*/
|
||||
int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status);
|
||||
int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common,
|
||||
void *set, void *status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
#include "model_opcode.h"
|
||||
#include "lighting_client.h"
|
||||
|
||||
/** The following are the macro definitions of lighting client
|
||||
* model messages length, and a message is composed of three
|
||||
* parts: Opcode + msg_value + MIC
|
||||
/* The followings are the macro definitions of Lighting client
|
||||
* model message length, and a message is composed of 3 parts:
|
||||
* Opcode + Payload + MIC
|
||||
*/
|
||||
/* Light lightness client messages length */
|
||||
#define BLE_MESH_LIGHT_LIGHTNESS_GET_MSG_LEN (2 + 0 + 4)
|
||||
|
@ -180,18 +180,18 @@ static void light_status(struct bt_mesh_model *model,
|
|||
u8_t evt = 0xFF;
|
||||
size_t len = 0U;
|
||||
|
||||
BT_DBG("%s, len %d, bytes %s", __func__, buf->len, bt_hex(buf->data, buf->len));
|
||||
BT_DBG("len %d, bytes %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
switch (ctx->recv_op) {
|
||||
case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS: {
|
||||
struct bt_mesh_light_lightness_status *status = NULL;
|
||||
if (buf->len != 2 && buf->len != 5) {
|
||||
BT_ERR("%s, Invalid Light Lightness Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light Lightness Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lightness_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->present_lightness = net_buf_simple_pull_le16(buf);
|
||||
|
@ -207,12 +207,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS: {
|
||||
struct bt_mesh_light_lightness_linear_status *status = NULL;
|
||||
if (buf->len != 2 && buf->len != 5) {
|
||||
BT_ERR("%s, Invalid Light Lightness Linear Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light Lightness Linear Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lightness_linear_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->present_lightness = net_buf_simple_pull_le16(buf);
|
||||
|
@ -228,12 +228,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS: {
|
||||
struct bt_mesh_light_lightness_last_status *status = NULL;
|
||||
if (buf->len != 2) {
|
||||
BT_ERR("%s, Invalid Light Lightness Last Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light Lightness Last Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lightness_last_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->lightness = net_buf_simple_pull_le16(buf);
|
||||
|
@ -244,12 +244,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS: {
|
||||
struct bt_mesh_light_lightness_default_status *status = NULL;
|
||||
if (buf->len != 2) {
|
||||
BT_ERR("%s, Invalid Light Lightness Default Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light Lightness Default Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lightness_default_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->lightness = net_buf_simple_pull_le16(buf);
|
||||
|
@ -260,12 +260,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS: {
|
||||
struct bt_mesh_light_lightness_range_status *status = NULL;
|
||||
if (buf->len != 5) {
|
||||
BT_ERR("%s, Invalid Light Lightness Range Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light Lightness Range Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lightness_range_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->status_code = net_buf_simple_pull_u8(buf);
|
||||
|
@ -278,12 +278,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS: {
|
||||
struct bt_mesh_light_ctl_status *status = NULL;
|
||||
if (buf->len != 4 && buf->len != 9) {
|
||||
BT_ERR("%s, Invalid Light CTL Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light CTL Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_ctl_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->present_ctl_lightness = net_buf_simple_pull_le16(buf);
|
||||
|
@ -301,12 +301,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS: {
|
||||
struct bt_mesh_light_ctl_temperature_status *status = NULL;
|
||||
if (buf->len != 4 && buf->len != 9) {
|
||||
BT_ERR("%s, Invalid Light CTL Temperature Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light CTL Temperature Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_ctl_temperature_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->present_ctl_temperature = net_buf_simple_pull_le16(buf);
|
||||
|
@ -324,12 +324,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS: {
|
||||
struct bt_mesh_light_ctl_temperature_range_status *status = NULL;
|
||||
if (buf->len != 5) {
|
||||
BT_ERR("%s, Invalid Light CTL Temperature Range Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light CTL Temperature Range Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_ctl_temperature_range_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->status_code = net_buf_simple_pull_u8(buf);
|
||||
|
@ -342,12 +342,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS: {
|
||||
struct bt_mesh_light_ctl_default_status *status = NULL;
|
||||
if (buf->len != 6) {
|
||||
BT_ERR("%s, Invalid Light CTL Default Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light CTL Default Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_ctl_default_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->lightness = net_buf_simple_pull_le16(buf);
|
||||
|
@ -360,12 +360,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS: {
|
||||
struct bt_mesh_light_hsl_status *status = NULL;
|
||||
if (buf->len != 6 && buf->len != 7) {
|
||||
BT_ERR("%s, Invalid Light HSL Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light HSL Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_hsl_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->hsl_lightness = net_buf_simple_pull_le16(buf);
|
||||
|
@ -382,12 +382,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS: {
|
||||
struct bt_mesh_light_hsl_target_status *status = NULL;
|
||||
if (buf->len != 6 && buf->len != 7) {
|
||||
BT_ERR("%s, Invalid Light HSL Target Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light HSL Target Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_hsl_target_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->hsl_lightness_target = net_buf_simple_pull_le16(buf);
|
||||
|
@ -404,12 +404,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS: {
|
||||
struct bt_mesh_light_hsl_hue_status *status = NULL;
|
||||
if (buf->len != 2 && buf->len != 5) {
|
||||
BT_ERR("%s, Invalid Light HSL Hue Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light HSL Hue Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_hsl_hue_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->present_hue = net_buf_simple_pull_le16(buf);
|
||||
|
@ -425,12 +425,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS: {
|
||||
struct bt_mesh_light_hsl_saturation_status *status = NULL;
|
||||
if (buf->len != 2 && buf->len != 5) {
|
||||
BT_ERR("%s, Invalid Light HSL Saturation Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light HSL Saturation Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_hsl_saturation_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->present_saturation = net_buf_simple_pull_le16(buf);
|
||||
|
@ -446,12 +446,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS: {
|
||||
struct bt_mesh_light_hsl_default_status *status = NULL;
|
||||
if (buf->len != 6) {
|
||||
BT_ERR("%s, Invalid Light HSL Default Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light HSL Default Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_hsl_default_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->lightness = net_buf_simple_pull_le16(buf);
|
||||
|
@ -464,12 +464,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS: {
|
||||
struct bt_mesh_light_hsl_range_status *status = NULL;
|
||||
if (buf->len != 9) {
|
||||
BT_ERR("%s, Invalid Light HSL Range Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light HSL Range Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_hsl_range_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->status_code = net_buf_simple_pull_u8(buf);
|
||||
|
@ -484,12 +484,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS: {
|
||||
struct bt_mesh_light_xyl_status *status = NULL;
|
||||
if (buf->len != 6 && buf->len != 7) {
|
||||
BT_ERR("%s, Invalid Light xyL Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light xyL Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_xyl_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->xyl_lightness = net_buf_simple_pull_le16(buf);
|
||||
|
@ -506,12 +506,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS: {
|
||||
struct bt_mesh_light_xyl_target_status *status = NULL;
|
||||
if (buf->len != 6 && buf->len != 7) {
|
||||
BT_ERR("%s, Invalid Light xyL Target Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light xyL Target Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_xyl_target_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->target_xyl_lightness = net_buf_simple_pull_le16(buf);
|
||||
|
@ -528,12 +528,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS: {
|
||||
struct bt_mesh_light_xyl_default_status *status = NULL;
|
||||
if (buf->len != 6) {
|
||||
BT_ERR("%s, Invalid Light xyL Default Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light xyL Default Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_xyl_default_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->lightness = net_buf_simple_pull_le16(buf);
|
||||
|
@ -546,12 +546,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS: {
|
||||
struct bt_mesh_light_xyl_range_status *status = NULL;
|
||||
if (buf->len != 9) {
|
||||
BT_ERR("%s, Invalid Light xyL Range Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light xyL Range Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_xyl_range_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->status_code = net_buf_simple_pull_u8(buf);
|
||||
|
@ -566,12 +566,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS: {
|
||||
struct bt_mesh_light_lc_mode_status *status = NULL;
|
||||
if (buf->len != 1) {
|
||||
BT_ERR("%s, Invalid Light LC Mode Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light LC Mode Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lc_mode_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->mode = net_buf_simple_pull_u8(buf);
|
||||
|
@ -582,12 +582,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS: {
|
||||
struct bt_mesh_light_lc_om_status *status = NULL;
|
||||
if (buf->len != 1) {
|
||||
BT_ERR("%s, Invalid Light LC OM Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light LC OM Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lc_om_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->mode = net_buf_simple_pull_u8(buf);
|
||||
|
@ -598,12 +598,12 @@ static void light_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS: {
|
||||
struct bt_mesh_light_lc_light_onoff_status *status = NULL;
|
||||
if (buf->len != 1 && buf->len != 3) {
|
||||
BT_ERR("%s, Invalid Light LC Light OnOff Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Light LC Light OnOff Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lc_light_onoff_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->present_light_onoff = net_buf_simple_pull_u8(buf);
|
||||
|
@ -620,13 +620,13 @@ static void light_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_light_lc_property_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lc_property_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->light_lc_property_id = net_buf_simple_pull_le16(buf);
|
||||
status->light_lc_property_value = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->light_lc_property_value) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -636,7 +636,7 @@ static void light_status(struct bt_mesh_model *model,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Not a Lighting Status message opcode", __func__);
|
||||
BT_ERR("Invalid Lighting Status opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -647,7 +647,7 @@ static void light_status(struct bt_mesh_model *model,
|
|||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true);
|
||||
if (!node) {
|
||||
BT_DBG("Unexpected light status message 0x%x", ctx->recv_op);
|
||||
BT_DBG("Unexpected Lighting Status 0x%04x", ctx->recv_op);
|
||||
} else {
|
||||
switch (node->opcode) {
|
||||
case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_GET:
|
||||
|
@ -785,7 +785,7 @@ static int light_get_state(bt_mesh_client_common_param_t *common, void *value)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("This lighting message should be sent with NULL get pointer");
|
||||
BT_DBG("No parameters for Lighting Get 0x%04x", common->opcode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -794,7 +794,7 @@ static int light_get_state(bt_mesh_client_common_param_t *common, void *value)
|
|||
timeout_handler, common->msg_timeout, true,
|
||||
common->cb, common->cb_data);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send Lighting Client Get message (err %d)", __func__, err);
|
||||
BT_ERR("Failed to send Lighting Get message (err %d)", err);
|
||||
}
|
||||
|
||||
return err;
|
||||
|
@ -808,7 +808,7 @@ static int light_set_state(bt_mesh_client_common_param_t *common,
|
|||
|
||||
msg = bt_mesh_alloc_buf(value_len);
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -1023,7 +1023,7 @@ static int light_set_state(bt_mesh_client_common_param_t *common,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Not a Lighting Client Set message opcode", __func__);
|
||||
BT_ERR("Invalid Lighting Set opcode 0x%04x", common->opcode);
|
||||
err = -EINVAL;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1032,7 +1032,7 @@ static int light_set_state(bt_mesh_client_common_param_t *common,
|
|||
timeout_handler, common->msg_timeout, need_ack,
|
||||
common->cb, common->cb_data);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send Lighting Client Set message (err %d)", __func__, err);
|
||||
BT_ERR("Failed to send Lighting Set message (err %d)", err);
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -1041,7 +1041,8 @@ end:
|
|||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status)
|
||||
int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common,
|
||||
void *get, void *status)
|
||||
{
|
||||
bt_mesh_light_client_t *client = NULL;
|
||||
|
||||
|
@ -1052,7 +1053,7 @@ int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *
|
|||
|
||||
client = (bt_mesh_light_client_t *)common->model->user_data;
|
||||
if (!client || !client->internal_data) {
|
||||
BT_ERR("%s, Lighting Client user data is NULL", __func__);
|
||||
BT_ERR("Invalid Lighting client data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1082,19 +1083,20 @@ int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *
|
|||
break;
|
||||
case BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET:
|
||||
if (!get) {
|
||||
BT_ERR("%s, Lighting lc_property_get is NULL", __func__);
|
||||
BT_ERR("Invalid Lighting LC Property Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Not a Lighting Client Get message opcode", __func__);
|
||||
BT_ERR("Invalid Lighting Get opcode 0x%04x", common->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return light_get_state(common, get);
|
||||
}
|
||||
|
||||
int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status)
|
||||
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 = 0U;
|
||||
|
@ -1107,7 +1109,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
|
||||
client = (bt_mesh_light_client_t *)common->model->user_data;
|
||||
if (!client || !client->internal_data) {
|
||||
BT_ERR("%s, Lighting Client user data is NULL", __func__);
|
||||
BT_ERR("Invalid Lighting client data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1119,7 +1121,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
value = (struct bt_mesh_light_lightness_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Light Lightness Set transition time", __func__);
|
||||
BT_ERR("Invalid Light Lightness Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1133,7 +1135,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
value = (struct bt_mesh_light_lightness_linear_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Light Lightness Linear Set transition time", __func__);
|
||||
BT_ERR("Invalid Light Lightness Linear Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1151,7 +1153,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
struct bt_mesh_light_lightness_range_set *value;
|
||||
value = (struct bt_mesh_light_lightness_range_set *)set;
|
||||
if (value->range_min > value->range_max) {
|
||||
BT_ERR("%s, Light Lightness Range Set range min is greater than range max", __func__);
|
||||
BT_ERR("Light Lightness Range Set range min is greater than range max");
|
||||
return -EINVAL;
|
||||
}
|
||||
length = BLE_MESH_LIGHT_LIGHTNESS_RANGE_SET_MSG_LEN;
|
||||
|
@ -1164,7 +1166,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
value = (struct bt_mesh_light_ctl_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Light CTL Set transition time", __func__);
|
||||
BT_ERR("Invalid Light CTL Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1178,7 +1180,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
value = (struct bt_mesh_light_ctl_temperature_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Light CTL Temperature Set transition time", __func__);
|
||||
BT_ERR("Invalid Light CTL Temperature Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1191,7 +1193,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
struct bt_mesh_light_ctl_temperature_range_set *value;
|
||||
value = (struct bt_mesh_light_ctl_temperature_range_set *)set;
|
||||
if (value->range_min > value->range_max) {
|
||||
BT_ERR("%s, Light CTL Temperature Range Set range min is greater than range max", __func__);
|
||||
BT_ERR("Light CTL Temperature Range Set range min is greater than range max");
|
||||
return -EINVAL;
|
||||
}
|
||||
length = BLE_MESH_LIGHT_CTL_TEMPERATURE_RANGE_SET_MSG_LEN;
|
||||
|
@ -1209,7 +1211,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
value = (struct bt_mesh_light_hsl_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Light HSL Set transition time", __func__);
|
||||
BT_ERR("Invalid Light HSL Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1223,7 +1225,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
value = (struct bt_mesh_light_hsl_hue_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Light HSL Hue Set transition time", __func__);
|
||||
BT_ERR("Invalid Light HSL Hue Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1237,7 +1239,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
value = (struct bt_mesh_light_hsl_saturation_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Light HSL Saturation Set transition time", __func__);
|
||||
BT_ERR("Invalid Light HSL Saturation Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1256,7 +1258,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
value = (struct bt_mesh_light_hsl_range_set *)set;
|
||||
if (value->hue_range_min > value->hue_range_max ||
|
||||
value->saturation_range_min > value->saturation_range_max) {
|
||||
BT_ERR("%s, Light HSL Range Set range min is greater than range max", __func__);
|
||||
BT_ERR("Light HSL Range Set range min is greater than range max");
|
||||
return -EINVAL;
|
||||
}
|
||||
length = BLE_MESH_LIGHT_HSL_RANGE_SET_MSG_LEN;
|
||||
|
@ -1269,7 +1271,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
value = (struct bt_mesh_light_xyl_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Light xyL Set transition time", __func__);
|
||||
BT_ERR("Invalid Light xyL Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1288,7 +1290,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
value = (struct bt_mesh_light_xyl_range_set *)set;
|
||||
if (value->xyl_x_range_min > value->xyl_x_range_max ||
|
||||
value->xyl_y_range_min > value->xyl_y_range_max) {
|
||||
BT_ERR("%s, Light xyL Range Set range min is greater than range max", __func__);
|
||||
BT_ERR("Light xyL Range Set range min is greater than range max");
|
||||
return -EINVAL;
|
||||
}
|
||||
length = BLE_MESH_LIGHT_XYL_RANGE_SET_MSG_LEN;
|
||||
|
@ -1311,7 +1313,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
value = (struct bt_mesh_light_lc_light_onoff_set *)set;
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Light LC Light OnOff Set transition time", __func__);
|
||||
BT_ERR("Invalid Light LC Light OnOff Set transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1324,14 +1326,14 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
|
|||
struct bt_mesh_light_lc_property_set *value;
|
||||
value = (struct bt_mesh_light_lc_property_set *)set;
|
||||
if (!value->light_lc_property_value) {
|
||||
BT_ERR("%s, Lighting light_lc_property_value is NULL", __func__);
|
||||
BT_ERR("Invalid Lighting Light LC Property value");
|
||||
return -EINVAL;
|
||||
}
|
||||
length = (1 + 2 + value->light_lc_property_value->len + 4);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Not a Lighting Client Set message opcode", __func__);
|
||||
BT_ERR("Invalid Lighting Set opcode 0x%04x", common->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1352,14 +1354,14 @@ static int light_client_init(struct bt_mesh_model *model, bool primary)
|
|||
|
||||
client = (bt_mesh_light_client_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("%s, Lighting Client user_data is NULL", __func__);
|
||||
BT_ERR("Invalid Lighting client user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!client->internal_data) {
|
||||
internal = bt_mesh_calloc(sizeof(light_internal_data_t));
|
||||
if (!internal) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -1414,7 +1416,7 @@ static int light_client_deinit(struct bt_mesh_model *model, bool primary)
|
|||
|
||||
client = (bt_mesh_light_client_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("%s, Lighting Client user_data is NULL", __func__);
|
||||
BT_ERR("Invalid Lighting client user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
#include "model_opcode.h"
|
||||
#include "sensor_client.h"
|
||||
|
||||
/** The following are the macro definitions of sensor client
|
||||
* model messages length, and a message is composed of three
|
||||
* parts: Opcode + msg_value + MIC
|
||||
/* The followings are the macro definitions of Sensor client
|
||||
* model message length, and a message is composed of 3 parts:
|
||||
* Opcode + Payload + MIC
|
||||
*/
|
||||
/* Sensor client messages length */
|
||||
#define BLE_MESH_SENSOR_DESCRIPTOR_GET_MSG_LEN (2 + 2 + 4)
|
||||
|
@ -109,19 +109,19 @@ static void sensor_status(struct bt_mesh_model *model,
|
|||
u8_t evt = 0xFF;
|
||||
size_t len = 0U;
|
||||
|
||||
BT_DBG("%s, len %d, bytes %s", __func__, buf->len, bt_hex(buf->data, buf->len));
|
||||
BT_DBG("len %d, bytes %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
switch (ctx->recv_op) {
|
||||
case BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS: {
|
||||
struct bt_mesh_sensor_descriptor_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_descriptor_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->descriptor = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->descriptor) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -134,13 +134,13 @@ static void sensor_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_sensor_cadence_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_cadence_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->property_id = net_buf_simple_pull_le16(buf);
|
||||
status->sensor_cadence_value = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->sensor_cadence_value) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -153,13 +153,13 @@ static void sensor_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_sensor_settings_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_settings_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->sensor_property_id = net_buf_simple_pull_le16(buf);
|
||||
status->sensor_setting_property_ids = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->sensor_setting_property_ids) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ static void sensor_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_sensor_setting_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_setting_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->sensor_property_id = net_buf_simple_pull_le16(buf);
|
||||
|
@ -182,7 +182,7 @@ static void sensor_status(struct bt_mesh_model *model,
|
|||
status->sensor_setting_access = net_buf_simple_pull_u8(buf);
|
||||
status->sensor_setting_raw = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->sensor_setting_raw) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -196,12 +196,12 @@ static void sensor_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_sensor_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->marshalled_sensor_data = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->marshalled_sensor_data) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -214,13 +214,13 @@ static void sensor_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_sensor_column_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_column_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->property_id = net_buf_simple_pull_le16(buf);
|
||||
status->sensor_column_value = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->sensor_column_value) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -233,13 +233,13 @@ static void sensor_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_sensor_series_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_series_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->property_id = net_buf_simple_pull_le16(buf);
|
||||
status->sensor_series_value = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->sensor_series_value) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ static void sensor_status(struct bt_mesh_model *model,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Not a Sensor Status message opcode", __func__);
|
||||
BT_ERR("Invalid Sensor Status opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,7 @@ static void sensor_status(struct bt_mesh_model *model,
|
|||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true);
|
||||
if (!node) {
|
||||
BT_DBG("Unexpected sensor status message 0x%x", ctx->recv_op);
|
||||
BT_DBG("Unexpected Sensor Status 0x%04x", ctx->recv_op);
|
||||
} else {
|
||||
switch (node->opcode) {
|
||||
case BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET:
|
||||
|
@ -360,7 +360,7 @@ static int sensor_act_state(bt_mesh_client_common_param_t *common,
|
|||
|
||||
msg = bt_mesh_alloc_buf(value_len);
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,7 @@ static int sensor_act_state(bt_mesh_client_common_param_t *common,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Not a Sensor Client message opcode", __func__);
|
||||
BT_ERR("Invalid Sensor client opcode 0x%04x", common->opcode);
|
||||
err = -EINVAL;
|
||||
goto end;
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ static int sensor_act_state(bt_mesh_client_common_param_t *common,
|
|||
timeout_handler, common->msg_timeout, need_ack,
|
||||
common->cb, common->cb_data);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send Sensor Client message (err %d)", __func__, err);
|
||||
BT_ERR("Failed to send Sensor client message (err %d)", err);
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -460,7 +460,8 @@ end:
|
|||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status)
|
||||
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 = 0U;
|
||||
|
@ -472,7 +473,7 @@ int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void
|
|||
|
||||
client = (bt_mesh_sensor_client_t *)common->model->user_data;
|
||||
if (!client || !client->internal_data) {
|
||||
BT_ERR("%s, Sensor Client user data is NULL", __func__);
|
||||
BT_ERR("Invalid Sensor client data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -496,7 +497,7 @@ int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void
|
|||
struct bt_mesh_sensor_column_get *value;
|
||||
value = (struct bt_mesh_sensor_column_get *)get;
|
||||
if (!value->raw_value_x) {
|
||||
BT_ERR("%s, Sensor column_get is NULL", __func__);
|
||||
BT_ERR("Invalid Sensor Column Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
length = (2 + 2 + value->raw_value_x->len + 4);
|
||||
|
@ -507,7 +508,7 @@ int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void
|
|||
value = (struct bt_mesh_sensor_series_get *)get;
|
||||
if (value->op_en) {
|
||||
if (!value->raw_value_x1 || !value->raw_value_x2) {
|
||||
BT_ERR("%s, Sensor series_get is NULL", __func__);
|
||||
BT_ERR("Invalid Sensor Series Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -518,14 +519,15 @@ int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Not a Sensor Client Get message opcode", __func__);
|
||||
BT_ERR("Invalid Sensor Get opcode 0x%04x", common->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return sensor_act_state(common, get, length, true);
|
||||
}
|
||||
|
||||
int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status)
|
||||
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 = 0U;
|
||||
|
@ -538,7 +540,7 @@ int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
|
||||
client = (bt_mesh_sensor_client_t *)common->model->user_data;
|
||||
if (!client || !client->internal_data) {
|
||||
BT_ERR("%s, Sensor Client user data is NULL", __func__);
|
||||
BT_ERR("Invalid Sensor client data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -550,7 +552,7 @@ int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
value = (struct bt_mesh_sensor_cadence_set *)set;
|
||||
if (!value->status_trigger_delta_down || !value->status_trigger_delta_up ||
|
||||
!value->fast_cadence_low || !value->fast_cadence_high) {
|
||||
BT_ERR("%s, Sensor cadence_set is NULL", __func__);
|
||||
BT_ERR("Invalid Sensor Cadence Set");
|
||||
return -EINVAL;
|
||||
}
|
||||
length = value->status_trigger_delta_down->len + \
|
||||
|
@ -566,14 +568,14 @@ int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void
|
|||
struct bt_mesh_sensor_setting_set *value;
|
||||
value = (struct bt_mesh_sensor_setting_set *)set;
|
||||
if (!value->sensor_setting_raw) {
|
||||
BT_ERR("%s, Sensor setting_raw is NULL", __func__);
|
||||
BT_ERR("Invalid Sensor Setting Raw value");
|
||||
return -EINVAL;
|
||||
}
|
||||
length = (1 + 2 + 2 + value->sensor_setting_raw->len + 4);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Not a Sensor Client Set message opcode", __func__);
|
||||
BT_ERR("Invalid Sensor Set opcode 0x%04x", common->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -594,14 +596,14 @@ int bt_mesh_sensor_cli_init(struct bt_mesh_model *model, bool primary)
|
|||
|
||||
client = (bt_mesh_sensor_client_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("%s, Sensor Client user_data is NULL", __func__);
|
||||
BT_ERR("Invalid Sensor client user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!client->internal_data) {
|
||||
internal = bt_mesh_calloc(sizeof(sensor_internal_data_t));
|
||||
if (!internal) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -631,7 +633,7 @@ int bt_mesh_sensor_cli_deinit(struct bt_mesh_model *model, bool primary)
|
|||
|
||||
client = (bt_mesh_sensor_client_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("%s, Sensor Client user_data is NULL", __func__);
|
||||
BT_ERR("Invalid Sensor client user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
#include "model_opcode.h"
|
||||
#include "time_scene_client.h"
|
||||
|
||||
/** The following are the macro definitions of time and client
|
||||
* scene model messages length, and a message is composed of
|
||||
* three parts: Opcode + msg_value + MIC
|
||||
/* The followings are the macro definitions of Time Scene client
|
||||
* model message length, and a message is composed of 3 parts:
|
||||
* Opcode + Payload + MIC
|
||||
*/
|
||||
/* Time client messages length */
|
||||
#define BLE_MESH_TIME_SET_MSG_LEN (1 + 10 + 4)
|
||||
|
@ -125,18 +125,18 @@ static void time_scene_status(struct bt_mesh_model *model,
|
|||
u8_t evt = 0xFF;
|
||||
size_t len = 0U;
|
||||
|
||||
BT_DBG("%s, len %d, bytes %s", __func__, buf->len, bt_hex(buf->data, buf->len));
|
||||
BT_DBG("len %d, bytes %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
switch (ctx->recv_op) {
|
||||
case BLE_MESH_MODEL_OP_TIME_STATUS: {
|
||||
struct bt_mesh_time_status *status = NULL;
|
||||
if (buf->len != 5 && buf->len != 10) {
|
||||
BT_ERR("%s, Invalid Time Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Time Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_time_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
memcpy(status->tai_seconds, buf->data, 5);
|
||||
|
@ -154,12 +154,12 @@ static void time_scene_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_TIME_ZONE_STATUS: {
|
||||
struct bt_mesh_time_zone_status *status = NULL;
|
||||
if (buf->len != 7) {
|
||||
BT_ERR("%s, Invalid Time Zone Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Time Zone Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_time_zone_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->time_zone_offset_curr = net_buf_simple_pull_u8(buf);
|
||||
|
@ -173,12 +173,12 @@ static void time_scene_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS: {
|
||||
struct bt_mesh_tai_utc_delta_status *status = NULL;
|
||||
if (buf->len != 9) {
|
||||
BT_ERR("%s, Invalid TAI UTC Delta Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid TAI UTC Delta Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_tai_utc_delta_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
u16_t temp = net_buf_simple_pull_le16(buf);
|
||||
|
@ -196,12 +196,12 @@ static void time_scene_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_TIME_ROLE_STATUS: {
|
||||
struct bt_mesh_time_role_status *status = NULL;
|
||||
if (buf->len != 1) {
|
||||
BT_ERR("%s, Invalid Time Role Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Time Role Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_time_role_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->time_role = net_buf_simple_pull_u8(buf);
|
||||
|
@ -212,12 +212,12 @@ static void time_scene_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_SCENE_STATUS: {
|
||||
struct bt_mesh_scene_status *status = NULL;
|
||||
if (buf->len != 3 && buf->len != 6) {
|
||||
BT_ERR("%s, Invalid Scene Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Scene Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_scene_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->status_code = net_buf_simple_pull_u8(buf);
|
||||
|
@ -235,14 +235,14 @@ static void time_scene_status(struct bt_mesh_model *model,
|
|||
struct bt_mesh_scene_register_status *status = NULL;
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_scene_register_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->status_code = net_buf_simple_pull_u8(buf);
|
||||
status->current_scene = net_buf_simple_pull_le16(buf);
|
||||
status->scenes = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status->scenes) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
bt_mesh_free(status);
|
||||
return;
|
||||
}
|
||||
|
@ -254,12 +254,12 @@ static void time_scene_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_SCHEDULER_STATUS: {
|
||||
struct bt_mesh_scheduler_status *status = NULL;
|
||||
if (buf->len != 2) {
|
||||
BT_ERR("%s, Invalid Scheduler Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Scheduler Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_scheduler_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
status->schedules = net_buf_simple_pull_le16(buf);
|
||||
|
@ -270,12 +270,12 @@ static void time_scene_status(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS: {
|
||||
struct bt_mesh_scheduler_act_status *status = NULL;
|
||||
if (buf->len != 10) {
|
||||
BT_ERR("%s, Invalid Scheduler Action Status length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid Scheduler Action Status length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
status = bt_mesh_calloc(sizeof(struct bt_mesh_scheduler_act_status));
|
||||
if (!status) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
memcpy(status, buf->data, offsetof(struct bt_mesh_scheduler_act_status, scene_number));
|
||||
|
@ -286,7 +286,7 @@ static void time_scene_status(struct bt_mesh_model *model,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Not a Time Scene Status message opcode", __func__);
|
||||
BT_ERR("Invalid Time Scene Status opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ static void time_scene_status(struct bt_mesh_model *model,
|
|||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true);
|
||||
if (!node) {
|
||||
BT_DBG("Unexpected time scene status message 0x%x", ctx->recv_op);
|
||||
BT_DBG("Unexpected Time Scene Status 0x%04x", ctx->recv_op);
|
||||
} else {
|
||||
switch (node->opcode) {
|
||||
case BLE_MESH_MODEL_OP_TIME_GET:
|
||||
|
@ -385,7 +385,7 @@ static int time_scene_get_state(bt_mesh_client_common_param_t *common, void *val
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("This time scene message should be sent with NULL get pointer");
|
||||
BT_DBG("No parameters for Time Scene Get 0x%04x", common->opcode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ static int time_scene_get_state(bt_mesh_client_common_param_t *common, void *val
|
|||
timeout_handler, common->msg_timeout, true,
|
||||
common->cb, common->cb_data);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send Time Scene Get message (err %d)", __func__, err);
|
||||
BT_ERR("Failed to send Time Scene Get message (err %d)", err);
|
||||
}
|
||||
|
||||
return err;
|
||||
|
@ -408,7 +408,7 @@ static int time_scene_set_state(bt_mesh_client_common_param_t *common,
|
|||
|
||||
msg = bt_mesh_alloc_buf(value_len);
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -480,7 +480,7 @@ static int time_scene_set_state(bt_mesh_client_common_param_t *common,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Not a Time Scene Client set message opcode", __func__);
|
||||
BT_ERR("Invalid Time Scene Set opcode 0x%04x", common->opcode);
|
||||
err = -EINVAL;
|
||||
goto end;
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ static int time_scene_set_state(bt_mesh_client_common_param_t *common,
|
|||
timeout_handler, common->msg_timeout, need_ack,
|
||||
common->cb, common->cb_data);
|
||||
if (err) {
|
||||
BT_ERR("%s, Failed to send Time Scene Set message (err %d)", __func__, err);
|
||||
BT_ERR("Failed to send Time Scene Set message (err %d)", err);
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -497,7 +497,8 @@ end:
|
|||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status)
|
||||
int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common,
|
||||
void *get, void *status)
|
||||
{
|
||||
bt_mesh_time_scene_client_t *client = NULL;
|
||||
|
||||
|
@ -508,7 +509,7 @@ int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, v
|
|||
|
||||
client = (bt_mesh_time_scene_client_t *)common->model->user_data;
|
||||
if (!client || !client->internal_data) {
|
||||
BT_ERR("%s, Time Scene Client user data is NULL", __func__);
|
||||
BT_ERR("Invalid Time Scene client data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -523,19 +524,20 @@ int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, v
|
|||
break;
|
||||
case BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET:
|
||||
if (!get) {
|
||||
BT_ERR("%s, Scheduler action index is NULL", __func__);
|
||||
BT_ERR("Invalid Scheduler Action Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Not a Time Scene Client Get message opcode", __func__);
|
||||
BT_ERR("Invalid Time Scene Get opcode 0x%04x", common->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return time_scene_get_state(common, get);
|
||||
}
|
||||
|
||||
int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status)
|
||||
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 = 0U;
|
||||
|
@ -548,7 +550,7 @@ int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, v
|
|||
|
||||
client = (bt_mesh_time_scene_client_t *)common->model->user_data;
|
||||
if (!client || !client->internal_data) {
|
||||
BT_ERR("%s, Time Scene Client user data is NULL", __func__);
|
||||
BT_ERR("Invalid Time Scene client data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -565,7 +567,7 @@ int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, v
|
|||
struct bt_mesh_tai_utc_delta_set *value;
|
||||
value = (struct bt_mesh_tai_utc_delta_set *)set;
|
||||
if (value->padding) {
|
||||
BT_ERR("%s, Non-zero padding value is prohibited", __func__);
|
||||
BT_ERR("Non-zero padding value is prohibited");
|
||||
return -EINVAL;
|
||||
}
|
||||
need_ack = true;
|
||||
|
@ -576,7 +578,7 @@ int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, v
|
|||
struct bt_mesh_time_role_set *value;
|
||||
value = (struct bt_mesh_time_role_set *)set;
|
||||
if (value->time_role > 0x03) {
|
||||
BT_ERR("%s, Time role value is prohibited", __func__);
|
||||
BT_ERR("Time role 0x%02x is prohibited", value->time_role);
|
||||
return -EINVAL;
|
||||
}
|
||||
need_ack = true;
|
||||
|
@ -589,7 +591,7 @@ int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, v
|
|||
struct bt_mesh_scene_store *value;
|
||||
value = (struct bt_mesh_scene_store *)set;
|
||||
if (!value->scene_number) {
|
||||
BT_ERR("%s, Scene store scene_number 0x0000 is prohibited", __func__);
|
||||
BT_ERR("Scene Store scene number 0x0000 is prohibited");
|
||||
return -EINVAL;
|
||||
}
|
||||
length = BLE_MESH_SCENE_STORE_MSG_LEN;
|
||||
|
@ -601,12 +603,12 @@ int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, v
|
|||
struct bt_mesh_scene_recall *value;
|
||||
value = (struct bt_mesh_scene_recall *)set;
|
||||
if (!value->scene_number) {
|
||||
BT_ERR("%s, Scene recall scene_number 0x0000 is prohibited", __func__);
|
||||
BT_ERR("Scene Recall scene number 0x0000 is prohibited");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (value->op_en) {
|
||||
if ((value->trans_time & 0x3F) > 0x3E) {
|
||||
BT_ERR("%s, Invalid Scene Recall transition time", __func__);
|
||||
BT_ERR("Invalid Scene Recall transition time");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -625,18 +627,18 @@ int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, v
|
|||
struct bt_mesh_scheduler_act_set *value;
|
||||
value = (struct bt_mesh_scheduler_act_set *)set;
|
||||
if (value->year > 0x64) {
|
||||
BT_ERR("%s, Scheduler register year value is prohibited", __func__);
|
||||
BT_ERR("Scheduler Register year 0x%02x is prohibited", value->year);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (value->hour > 0x19) {
|
||||
BT_ERR("%s, Scheduler register hour value is prohibited", __func__);
|
||||
BT_ERR("Scheduler Register hour 0x%02x is prohibited", value->hour);
|
||||
return -EINVAL;
|
||||
}
|
||||
length = BLE_MESH_SCHEDULER_ACT_SET_MSG_LEN;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Not a Time Scene Set message opcode", __func__);
|
||||
BT_ERR("Invalid Time Scene Set opcode 0x%04x", common->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -657,14 +659,14 @@ static int time_scene_client_init(struct bt_mesh_model *model, bool primary)
|
|||
|
||||
client = (bt_mesh_time_scene_client_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("%s, Time Scene Client user_data is NULL", __func__);
|
||||
BT_ERR("Invalid Time Scene client user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!client->internal_data) {
|
||||
internal = bt_mesh_calloc(sizeof(time_scene_internal_data_t));
|
||||
if (!internal) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -709,7 +711,7 @@ static int time_scene_client_deinit(struct bt_mesh_model *model, bool primary)
|
|||
|
||||
client = (bt_mesh_time_scene_client_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("%s, Time Scene Client user_data is NULL", __func__);
|
||||
BT_ERR("Invalid Time Scene client user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ static struct bt_mesh_dev_prop {
|
|||
u8_t bt_mesh_get_dev_prop_len(u16_t prop_id)
|
||||
{
|
||||
if (prop_id > BLE_MESH_TOTAL_LUMINOUS_ENERGY) {
|
||||
BT_ERR("%s, Unknown Device Property ID 0x%04x", __func__, prop_id);
|
||||
BT_ERR("Unknown Device Property ID 0x%04x", prop_id);
|
||||
return UINT8_MAX;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ static void send_gen_onoff_status(struct bt_mesh_model *model,
|
|||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -93,7 +93,7 @@ static void gen_onoff_get(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_onoff_srv *srv = model->user_data;
|
||||
|
||||
if (srv == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ static void gen_onoff_get(struct bt_mesh_model *model,
|
|||
void gen_onoff_publish(struct bt_mesh_model *model)
|
||||
{
|
||||
if (model->user_data == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -129,13 +129,13 @@ static void gen_onoff_set(struct bt_mesh_model *model,
|
|||
s64_t now = 0;
|
||||
|
||||
if (srv == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
onoff = net_buf_simple_pull_u8(buf);
|
||||
if (onoff > BLE_MESH_STATE_ON) {
|
||||
BT_ERR("%s, Invalid OnOff value 0x%02x", __func__, onoff);
|
||||
BT_ERR("Invalid OnOff value 0x%02x", onoff);
|
||||
return;
|
||||
}
|
||||
tid = net_buf_simple_pull_u8(buf);
|
||||
|
@ -231,7 +231,7 @@ static void send_gen_level_status(struct bt_mesh_model *model,
|
|||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -274,7 +274,7 @@ static void gen_level_get(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_level_srv *srv = model->user_data;
|
||||
|
||||
if (srv == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ static void gen_level_get(struct bt_mesh_model *model,
|
|||
void gen_level_publish(struct bt_mesh_model *model)
|
||||
{
|
||||
if (model->user_data == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,7 @@ static void gen_level_set(struct bt_mesh_model *model,
|
|||
s64_t now = 0;
|
||||
|
||||
if (srv == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -407,7 +407,7 @@ static void gen_delta_set(struct bt_mesh_model *model,
|
|||
s64_t now = 0;
|
||||
|
||||
if (srv == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -529,7 +529,7 @@ static void gen_move_set(struct bt_mesh_model *model,
|
|||
s64_t now = 0;
|
||||
|
||||
if (srv == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -660,7 +660,7 @@ static void send_gen_def_trans_time_status(struct bt_mesh_model *model,
|
|||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -689,7 +689,7 @@ static void gen_def_trans_time_get(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_def_trans_time_srv *srv = model->user_data;
|
||||
|
||||
if (srv == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -712,13 +712,13 @@ static void gen_def_trans_time_set(struct bt_mesh_model *model,
|
|||
u8_t trans_time = 0U;
|
||||
|
||||
if (srv == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
trans_time = net_buf_simple_pull_u8(buf);
|
||||
if ((trans_time & 0x3F) == 0x3F) {
|
||||
BT_WARN("%s, Invalid Transaction Number of Steps 0x3F", __func__);
|
||||
BT_WARN("Invalid Transaction Number of Steps 0x3f");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -766,7 +766,7 @@ static void send_gen_onpowerup_status(struct bt_mesh_model *model,
|
|||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -789,7 +789,7 @@ static void send_gen_onpowerup_status(struct bt_mesh_model *model,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Invalid Generic Power OnOff Server 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Generic Power OnOff Server 0x%04x", model->id);
|
||||
if (publish == false) {
|
||||
bt_mesh_free_buf(msg);
|
||||
}
|
||||
|
@ -812,7 +812,7 @@ static void gen_onpowerup_get(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_power_onoff_srv *srv = model->user_data;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -831,7 +831,7 @@ static void gen_onpowerup_get(struct bt_mesh_model *model,
|
|||
void gen_onpowerup_publish(struct bt_mesh_model *model)
|
||||
{
|
||||
if (model->user_data == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -839,7 +839,7 @@ void gen_onpowerup_publish(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV: {
|
||||
struct bt_mesh_gen_power_onoff_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Generic Power OnOff Server state", __func__);
|
||||
BT_ERR("Invalid Generic Power OnOff Server state");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -847,13 +847,13 @@ void gen_onpowerup_publish(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV: {
|
||||
struct bt_mesh_gen_power_onoff_setup_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Generic Power OnOff Setup Server state", __func__);
|
||||
BT_ERR("Invalid Generic Power OnOff Setup Server state");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Invalid Generic Power OnOff Server 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Generic Power OnOff Server 0x%04x", model->id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -869,13 +869,13 @@ static void gen_onpowerup_set(struct bt_mesh_model *model,
|
|||
u8_t onpowerup = 0U;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
onpowerup = net_buf_simple_pull_u8(buf);
|
||||
if (onpowerup > BLE_MESH_STATE_RESTORE) {
|
||||
BT_WARN("%s, Invalid OnPowerUp value 0x%02x", __func__, onpowerup);
|
||||
BT_WARN("Invalid OnPowerUp value 0x%02x", onpowerup);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -923,7 +923,7 @@ static void send_gen_power_level_status(struct bt_mesh_model *model,
|
|||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -973,7 +973,7 @@ static void send_gen_power_level_status(struct bt_mesh_model *model,
|
|||
}
|
||||
break;
|
||||
default:
|
||||
BT_WARN("%s, Unknown Generic Power status opcode 0x%04x", __func__, opcode);
|
||||
BT_WARN("Unknown Generic Power status opcode 0x%04x", opcode);
|
||||
if (publish == false) {
|
||||
bt_mesh_free_buf(msg);
|
||||
}
|
||||
|
@ -997,7 +997,7 @@ static void gen_power_level_get(struct bt_mesh_model *model,
|
|||
u16_t opcode = 0U;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1022,7 +1022,7 @@ static void gen_power_level_get(struct bt_mesh_model *model,
|
|||
opcode = BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS;
|
||||
break;
|
||||
default:
|
||||
BT_WARN("%s, Unknown Generic Power Get opcode 0x%04x", __func__, ctx->recv_op);
|
||||
BT_WARN("Unknown Generic Power Get opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1033,7 +1033,7 @@ static void gen_power_level_get(struct bt_mesh_model *model,
|
|||
void gen_power_level_publish(struct bt_mesh_model *model, u16_t opcode)
|
||||
{
|
||||
if (model->user_data == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1041,7 +1041,7 @@ void gen_power_level_publish(struct bt_mesh_model *model, u16_t opcode)
|
|||
case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV: {
|
||||
struct bt_mesh_gen_power_level_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Generic Power Level Server state", __func__);
|
||||
BT_ERR("Invalid Generic Power Level Server state");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -1049,13 +1049,13 @@ void gen_power_level_publish(struct bt_mesh_model *model, u16_t opcode)
|
|||
case ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV: {
|
||||
struct bt_mesh_gen_power_level_setup_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Generic Power Level Setup Server state", __func__);
|
||||
BT_ERR("Invalid Generic Power Level Setup Server state");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Invalid Generic Power Level Server 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Generic Power Level Server 0x%04x", model->id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1074,7 +1074,7 @@ static void gen_power_level_set(struct bt_mesh_model *model,
|
|||
s64_t now = 0;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1182,7 +1182,7 @@ static void gen_power_default_set(struct bt_mesh_model *model,
|
|||
u16_t power = 0U;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1232,7 +1232,7 @@ static void gen_power_range_set(struct bt_mesh_model *model,
|
|||
u16_t range_min = 0U, range_max = 0U;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1240,8 +1240,8 @@ static void gen_power_range_set(struct bt_mesh_model *model,
|
|||
range_max = net_buf_simple_pull_le16(buf);
|
||||
|
||||
if (range_min > range_max) {
|
||||
BT_ERR("%s, Range Min 0x%04x is greater than Range Max 0x%04x",
|
||||
__func__, range_min, range_max);
|
||||
BT_ERR("Range min 0x%04x is greater than range max 0x%04x",
|
||||
range_min, range_max);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1296,7 +1296,7 @@ static void gen_battery_get(struct bt_mesh_model *model,
|
|||
NET_BUF_SIMPLE_DEFINE(msg, 2 + 8 + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
|
||||
if (srv == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1331,7 +1331,7 @@ static void send_gen_location_status(struct bt_mesh_model *model,
|
|||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -1374,7 +1374,7 @@ static void send_gen_location_status(struct bt_mesh_model *model,
|
|||
}
|
||||
break;
|
||||
default:
|
||||
BT_WARN("%s, Unknown Generic Location status opcode 0x%04x", __func__, opcode);
|
||||
BT_WARN("Unknown Generic Location status opcode 0x%04x", opcode);
|
||||
if (publish == false) {
|
||||
bt_mesh_free_buf(msg);
|
||||
}
|
||||
|
@ -1398,7 +1398,7 @@ static void gen_location_get(struct bt_mesh_model *model,
|
|||
u16_t opcode = 0U;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1417,7 +1417,7 @@ static void gen_location_get(struct bt_mesh_model *model,
|
|||
opcode = BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS;
|
||||
break;
|
||||
default:
|
||||
BT_WARN("%s, Unknown Generic Location Get opcode 0x%04x", __func__, ctx->recv_op);
|
||||
BT_WARN("Unknown Generic Location Get opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1434,7 +1434,7 @@ static void gen_location_set(struct bt_mesh_model *model,
|
|||
u16_t opcode = 0U;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1526,7 +1526,7 @@ static void gen_location_set(struct bt_mesh_model *model,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_WARN("%s, Unknown Generic Location Set opcode 0x%04x", __func__, ctx->recv_op);
|
||||
BT_WARN("Unknown Generic Location Set opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1540,7 +1540,7 @@ static void gen_location_set(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
/* Generic User Property Server message handlers */
|
||||
struct bt_mesh_generic_property *gen_get_user_property(struct bt_mesh_model *model,
|
||||
static struct bt_mesh_generic_property *gen_get_user_property(struct bt_mesh_model *model,
|
||||
u16_t property_id)
|
||||
{
|
||||
struct bt_mesh_gen_user_prop_srv *srv = model->user_data;
|
||||
|
@ -1564,13 +1564,13 @@ static void send_gen_user_prop_status(struct bt_mesh_model *model,
|
|||
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);
|
||||
BT_ERR("Invalid User Property ID 0x%04x", property_id);
|
||||
return;
|
||||
}
|
||||
|
||||
property = gen_get_user_property(model, property_id);
|
||||
if (property == NULL) {
|
||||
BT_WARN("%s, User property 0x%04x not exist", __func__, property_id);
|
||||
BT_WARN("User property 0x%04x not exists", property_id);
|
||||
length = sizeof(property_id);
|
||||
} else {
|
||||
length = sizeof(property->id) + sizeof(property->user_access) + property->val->len;
|
||||
|
@ -1579,7 +1579,7 @@ static void send_gen_user_prop_status(struct bt_mesh_model *model,
|
|||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -1622,7 +1622,7 @@ static void gen_user_prop_get(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_user_prop_srv *srv = model->user_data;
|
||||
|
||||
if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1651,7 +1651,7 @@ static void gen_user_prop_get(struct bt_mesh_model *model,
|
|||
u8_t i;
|
||||
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__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
bt_mesh_model_msg_init(msg, BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS);
|
||||
|
@ -1671,7 +1671,7 @@ static void gen_user_prop_get(struct bt_mesh_model *model,
|
|||
return;
|
||||
}
|
||||
default:
|
||||
BT_WARN("%s, Unknown Generic User Property Get opcode 0x%04x", __func__, ctx->recv_op);
|
||||
BT_WARN("Unknown Generic User Property Get opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1686,7 +1686,7 @@ static void gen_user_prop_set(struct bt_mesh_model *model,
|
|||
u8_t expect_len = 0U;
|
||||
|
||||
if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1720,8 +1720,8 @@ static void gen_user_prop_set(struct bt_mesh_model *model,
|
|||
*/
|
||||
expect_len = bt_mesh_get_dev_prop_len(property_id);
|
||||
if (buf->len != expect_len) {
|
||||
BT_ERR("%s, Invalid User Property length, ID 0x%04x, expect %d, actual %d",
|
||||
__func__, property_id, expect_len, buf->len);
|
||||
BT_ERR("Invalid User Property 0x%04x length, expect %d, actual %d",
|
||||
property_id, expect_len, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1744,7 +1744,7 @@ static void gen_user_prop_set(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
/* Generic Admin Property Server message handlers */
|
||||
struct bt_mesh_generic_property *gen_get_admin_property(struct bt_mesh_model *model,
|
||||
static struct bt_mesh_generic_property *gen_get_admin_property(struct bt_mesh_model *model,
|
||||
u16_t property_id)
|
||||
{
|
||||
struct bt_mesh_gen_admin_prop_srv *srv = model->user_data;
|
||||
|
@ -1768,13 +1768,13 @@ static void send_gen_admin_prop_status(struct bt_mesh_model *model,
|
|||
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);
|
||||
BT_ERR("Invalid Admin Property ID 0x%04x", property_id);
|
||||
return;
|
||||
}
|
||||
|
||||
property = gen_get_admin_property(model, property_id);
|
||||
if (property == NULL) {
|
||||
BT_WARN("%s, Admin property 0x%04x not exist", __func__, property_id);
|
||||
BT_WARN("Admin property 0x%04x not exists", property_id);
|
||||
length = sizeof(property_id);
|
||||
} else {
|
||||
length = sizeof(property->id) + sizeof(property->admin_access) + property->val->len;
|
||||
|
@ -1783,7 +1783,7 @@ static void send_gen_admin_prop_status(struct bt_mesh_model *model,
|
|||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -1821,7 +1821,7 @@ static void gen_admin_prop_get(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_admin_prop_srv *srv = model->user_data;
|
||||
|
||||
if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1846,7 +1846,7 @@ static void gen_admin_prop_get(struct bt_mesh_model *model,
|
|||
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__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
bt_mesh_model_msg_init(msg, BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS);
|
||||
|
@ -1863,7 +1863,7 @@ static void gen_admin_prop_get(struct bt_mesh_model *model,
|
|||
return;
|
||||
}
|
||||
default:
|
||||
BT_WARN("%s, Unknown Generic Admin Property Get opcode 0x%04x", __func__, ctx->recv_op);
|
||||
BT_WARN("Unknown Generic Admin Property Get opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1878,14 +1878,14 @@ static void gen_admin_prop_set(struct bt_mesh_model *model,
|
|||
u8_t access = 0U;
|
||||
|
||||
if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
property_id = net_buf_simple_pull_le16(buf);
|
||||
access = net_buf_simple_pull_u8(buf);
|
||||
if (access > ADMIN_ACCESS_READ_WRITE) {
|
||||
BT_ERR("%s, Invalid Admin Access 0x%02x", __func__, access);
|
||||
BT_ERR("Invalid Admin Access 0x%02x", access);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1932,7 +1932,7 @@ static void gen_admin_prop_set(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
/* Generic Manufacturer Property Server message handlers */
|
||||
struct bt_mesh_generic_property *gen_get_manu_property(struct bt_mesh_model *model,
|
||||
static struct bt_mesh_generic_property *gen_get_manu_property(struct bt_mesh_model *model,
|
||||
u16_t property_id)
|
||||
{
|
||||
struct bt_mesh_gen_manu_prop_srv *srv = model->user_data;
|
||||
|
@ -1956,13 +1956,13 @@ static void send_gen_manu_prop_status(struct bt_mesh_model *model,
|
|||
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);
|
||||
BT_ERR("Invalid Manu Property ID 0x%04x", property_id);
|
||||
return;
|
||||
}
|
||||
|
||||
property = gen_get_manu_property(model, property_id);
|
||||
if (property == NULL) {
|
||||
BT_WARN("%s, Manufacturer property 0x%04x not exist", __func__, property_id);
|
||||
BT_WARN("Manu property 0x%04x not exists", property_id);
|
||||
length = sizeof(property_id);
|
||||
} else {
|
||||
length = sizeof(property->id) + sizeof(property->manu_access) + property->val->len;
|
||||
|
@ -1971,7 +1971,7 @@ static void send_gen_manu_prop_status(struct bt_mesh_model *model,
|
|||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -2006,7 +2006,7 @@ static void gen_manu_prop_get(struct bt_mesh_model *model,
|
|||
struct bt_mesh_gen_manu_prop_srv *srv = model->user_data;
|
||||
|
||||
if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2031,7 +2031,7 @@ static void gen_manu_prop_get(struct bt_mesh_model *model,
|
|||
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__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
bt_mesh_model_msg_init(msg, BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_STATUS);
|
||||
|
@ -2048,7 +2048,7 @@ static void gen_manu_prop_get(struct bt_mesh_model *model,
|
|||
return;
|
||||
}
|
||||
default:
|
||||
BT_WARN("%s, Unknown Generic Manufacturer Property Get opcode 0x%04x", __func__, ctx->recv_op);
|
||||
BT_WARN("Unknown Generic Manu Property Get opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2063,14 +2063,14 @@ static void gen_manu_prop_set(struct bt_mesh_model *model,
|
|||
u8_t access = 0U;
|
||||
|
||||
if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
property_id = net_buf_simple_pull_le16(buf);
|
||||
access = net_buf_simple_pull_u8(buf);
|
||||
if (access > MANU_ACCESS_READ) {
|
||||
BT_ERR("%s, Invalid Manufacturer Access 0x%02x", __func__, access);
|
||||
BT_ERR("Invalid Manu Access 0x%02x", access);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2153,7 +2153,7 @@ static void gen_client_prop_get(struct bt_mesh_model *model,
|
|||
int i, index = 0;
|
||||
|
||||
if (srv == NULL || srv->id_count == 0U || srv->property_ids == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2184,7 +2184,7 @@ static void gen_client_prop_get(struct bt_mesh_model *model,
|
|||
|
||||
sdu = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN));
|
||||
if (sdu == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2336,7 +2336,7 @@ static inline int property_id_compare(const void *p1, const void *p2)
|
|||
static int generic_server_init(struct bt_mesh_model *model)
|
||||
{
|
||||
if (model->user_data == NULL) {
|
||||
BT_ERR("%s, No Generic Server context provided, model_id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Generic Server user data, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2367,7 +2367,7 @@ static int generic_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV: {
|
||||
struct bt_mesh_gen_power_onoff_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Generic OnPowerUp State", __func__);
|
||||
BT_ERR("Invalid Generic OnPowerUp State");
|
||||
return -EINVAL;
|
||||
}
|
||||
srv->model = model;
|
||||
|
@ -2376,7 +2376,7 @@ static int generic_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV: {
|
||||
struct bt_mesh_gen_power_onoff_setup_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Generic OnPowerUp State", __func__);
|
||||
BT_ERR("Invalid Generic OnPowerUp State");
|
||||
return -EINVAL;
|
||||
}
|
||||
srv->model = model;
|
||||
|
@ -2385,7 +2385,7 @@ static int generic_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV: {
|
||||
struct bt_mesh_gen_power_level_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Generic Power Level State", __func__);
|
||||
BT_ERR("Invalid Generic Power Level State");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) {
|
||||
|
@ -2398,7 +2398,7 @@ static int generic_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV: {
|
||||
struct bt_mesh_gen_power_level_setup_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Generic Power Level State", __func__);
|
||||
BT_ERR("Invalid Generic Power Level State");
|
||||
return -EINVAL;
|
||||
}
|
||||
srv->model = model;
|
||||
|
@ -2412,7 +2412,7 @@ static int generic_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_GEN_LOCATION_SRV: {
|
||||
struct bt_mesh_gen_location_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Generic Location State", __func__);
|
||||
BT_ERR("Invalid Generic Location State");
|
||||
return -EINVAL;
|
||||
}
|
||||
srv->model = model;
|
||||
|
@ -2421,7 +2421,7 @@ static int generic_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV: {
|
||||
struct bt_mesh_gen_location_setup_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Generic Location State", __func__);
|
||||
BT_ERR("Invalid Generic Location State");
|
||||
return -EINVAL;
|
||||
}
|
||||
srv->model = model;
|
||||
|
@ -2430,7 +2430,7 @@ static int generic_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV: {
|
||||
struct bt_mesh_gen_user_prop_srv *srv = model->user_data;
|
||||
if (srv->property_count == 0U || srv->properties == NULL) {
|
||||
BT_ERR("%s, NULL Generic User Property State", __func__);
|
||||
BT_ERR("Invalid Generic User Property State");
|
||||
return -EINVAL;
|
||||
}
|
||||
srv->model = model;
|
||||
|
@ -2439,7 +2439,7 @@ static int generic_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV: {
|
||||
struct bt_mesh_gen_admin_prop_srv *srv = model->user_data;
|
||||
if (srv->property_count == 0U || srv->properties == NULL) {
|
||||
BT_ERR("%s, NULL Generic Admin Property State", __func__);
|
||||
BT_ERR("Invalid Generic Admin Property State");
|
||||
return -EINVAL;
|
||||
}
|
||||
srv->model = model;
|
||||
|
@ -2448,7 +2448,7 @@ static int generic_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV: {
|
||||
struct bt_mesh_gen_manu_prop_srv *srv = model->user_data;
|
||||
if (srv->property_count == 0U || srv->properties == NULL) {
|
||||
BT_ERR("%s, NULL Generic Manufacturer Property State", __func__);
|
||||
BT_ERR("Invalid Generic Manufacturer Property State");
|
||||
return -EINVAL;
|
||||
}
|
||||
srv->model = model;
|
||||
|
@ -2457,7 +2457,7 @@ static int generic_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV: {
|
||||
struct bt_mesh_gen_client_prop_srv *srv = model->user_data;
|
||||
if (srv->id_count == 0U || srv->property_ids == NULL) {
|
||||
BT_ERR("%s, NULL Generic Client Property State", __func__);
|
||||
BT_ERR("Invalid Generic Client Property State");
|
||||
return -EINVAL;
|
||||
}
|
||||
/* Quick sort the Client Property IDs in ascending order */
|
||||
|
@ -2466,7 +2466,7 @@ static int generic_server_init(struct bt_mesh_model *model)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_WARN("%s, Unknown Generic Server Model, model_id 0x%04x", __func__, model->id);
|
||||
BT_WARN("Unknown Generic Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2478,7 +2478,7 @@ static int generic_server_init(struct bt_mesh_model *model)
|
|||
int bt_mesh_gen_onoff_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic OnOff Server has no publication support", __func__);
|
||||
BT_ERR("Generic OnOff Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2488,7 +2488,7 @@ int bt_mesh_gen_onoff_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_gen_level_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Level Server has no publication support", __func__);
|
||||
BT_ERR("Generic Level Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2498,7 +2498,7 @@ int bt_mesh_gen_level_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_gen_def_trans_time_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Default Trans Time Server has no publication support", __func__);
|
||||
BT_ERR("Generic Default Trans Time Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2508,7 +2508,7 @@ int bt_mesh_gen_def_trans_time_srv_init(struct bt_mesh_model *model, bool primar
|
|||
int bt_mesh_gen_power_onoff_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Power OnOff Server has no publication support", __func__);
|
||||
BT_ERR("Generic Power OnOff Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2517,7 +2517,7 @@ int bt_mesh_gen_power_onoff_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
*/
|
||||
struct bt_mesh_elem *element = bt_mesh_model_elem(model);
|
||||
if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV) == NULL) {
|
||||
BT_WARN("%s, Generic Power OnOff Setup Server is not present", __func__);
|
||||
BT_WARN("Generic Power OnOff Setup Server not present");
|
||||
/* Just give a warning here, continue with the initialization */
|
||||
}
|
||||
return generic_server_init(model);
|
||||
|
@ -2531,7 +2531,7 @@ int bt_mesh_gen_power_onoff_setup_srv_init(struct bt_mesh_model *model, bool pri
|
|||
int bt_mesh_gen_power_level_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Power Level Server has no publication support", __func__);
|
||||
BT_ERR("Generic Power Level Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2540,7 +2540,7 @@ int bt_mesh_gen_power_level_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
*/
|
||||
struct bt_mesh_elem *element = bt_mesh_model_elem(model);
|
||||
if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV) == NULL) {
|
||||
BT_WARN("%s, Generic Power Level Setup Server is not present", __func__);
|
||||
BT_WARN("Generic Power Level Setup Server not present");
|
||||
/* Just give a warning here, continue with the initialization */
|
||||
}
|
||||
return generic_server_init(model);
|
||||
|
@ -2554,7 +2554,7 @@ int bt_mesh_gen_power_level_setup_srv_init(struct bt_mesh_model *model, bool pri
|
|||
int bt_mesh_gen_battery_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Battery Server has no publication support", __func__);
|
||||
BT_ERR("Generic Battery Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2564,7 +2564,7 @@ int bt_mesh_gen_battery_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_gen_location_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Location Server has no publication support", __func__);
|
||||
BT_ERR("Generic Location Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2578,7 +2578,7 @@ int bt_mesh_gen_location_setup_srv_init(struct bt_mesh_model *model, bool primar
|
|||
*/
|
||||
struct bt_mesh_elem *element = bt_mesh_model_elem(model);
|
||||
if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV) == NULL) {
|
||||
BT_WARN("%s, Generic Location Setup Server is not present", __func__);
|
||||
BT_WARN("Generic Location Setup Server not present");
|
||||
/* Just give a warning here, continue with the initialization */
|
||||
}
|
||||
return generic_server_init(model);
|
||||
|
@ -2587,7 +2587,7 @@ int bt_mesh_gen_location_setup_srv_init(struct bt_mesh_model *model, bool primar
|
|||
int bt_mesh_gen_user_prop_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic User Property has no publication support", __func__);
|
||||
BT_ERR("Generic User Property Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2597,7 +2597,7 @@ int bt_mesh_gen_user_prop_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_gen_admin_prop_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Admin Property has no publication support", __func__);
|
||||
BT_ERR("Generic Admin Property Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2607,7 +2607,7 @@ int bt_mesh_gen_admin_prop_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_gen_manu_prop_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Manufacturer Property has no publication support", __func__);
|
||||
BT_ERR("Generic Manufacturer Property Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2617,7 +2617,7 @@ int bt_mesh_gen_manu_prop_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_gen_client_prop_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Client Property has no publication support", __func__);
|
||||
BT_ERR("Generic Client Property Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2627,7 +2627,7 @@ int bt_mesh_gen_client_prop_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
static int generic_server_deinit(struct bt_mesh_model *model)
|
||||
{
|
||||
if (model->user_data == NULL) {
|
||||
BT_ERR("%s, No Generic Server context provided, model_id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Generic Server user data, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2651,7 +2651,7 @@ static int generic_server_deinit(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV: {
|
||||
struct bt_mesh_gen_power_level_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Generic Power Level State", __func__);
|
||||
BT_ERR("Invalid Generic Power Level State");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) {
|
||||
|
@ -2661,7 +2661,7 @@ static int generic_server_deinit(struct bt_mesh_model *model)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_WARN("%s, Unknown Generic Server Model, model_id 0x%04x", __func__, model->id);
|
||||
BT_WARN("Unknown Generic Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2673,7 +2673,7 @@ static int generic_server_deinit(struct bt_mesh_model *model)
|
|||
int bt_mesh_gen_onoff_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic OnOff Server has no publication support", __func__);
|
||||
BT_ERR("Generic OnOff Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2683,7 +2683,7 @@ int bt_mesh_gen_onoff_srv_deinit(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_gen_level_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Level Server has no publication support", __func__);
|
||||
BT_ERR("Generic Level Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2693,7 +2693,7 @@ int bt_mesh_gen_level_srv_deinit(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_gen_def_trans_time_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Default Trans Time Server has no publication support", __func__);
|
||||
BT_ERR("Generic Default Trans Time Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2703,7 +2703,7 @@ int bt_mesh_gen_def_trans_time_srv_deinit(struct bt_mesh_model *model, bool prim
|
|||
int bt_mesh_gen_power_onoff_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Power OnOff Server has no publication support", __func__);
|
||||
BT_ERR("Generic Power OnOff Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2718,7 +2718,7 @@ int bt_mesh_gen_power_onoff_setup_srv_deinit(struct bt_mesh_model *model, bool p
|
|||
int bt_mesh_gen_power_level_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Power Level Server has no publication support", __func__);
|
||||
BT_ERR("Generic Power Level Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2733,7 +2733,7 @@ int bt_mesh_gen_power_level_setup_srv_deinit(struct bt_mesh_model *model, bool p
|
|||
int bt_mesh_gen_battery_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Battery Server has no publication support", __func__);
|
||||
BT_ERR("Generic Battery Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2743,7 +2743,7 @@ int bt_mesh_gen_battery_srv_deinit(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_gen_location_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Location Server has no publication support", __func__);
|
||||
BT_ERR("Generic Location Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2758,7 +2758,7 @@ int bt_mesh_gen_location_setup_srv_deinit(struct bt_mesh_model *model, bool prim
|
|||
int bt_mesh_gen_user_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic User Property has no publication support", __func__);
|
||||
BT_ERR("Generic User Property Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2768,7 +2768,7 @@ int bt_mesh_gen_user_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_gen_admin_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Admin Property has no publication support", __func__);
|
||||
BT_ERR("Generic Admin Property Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2778,7 +2778,7 @@ int bt_mesh_gen_admin_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_gen_manu_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Manufacturer Property has no publication support", __func__);
|
||||
BT_ERR("Generic Manufacturer Property Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2788,7 +2788,7 @@ int bt_mesh_gen_manu_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_gen_client_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Generic Client Property has no publication support", __func__);
|
||||
BT_ERR("Generic Client Property Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -39,7 +39,7 @@ static void send_sensor_descriptor_status(struct bt_mesh_model *model,
|
|||
|
||||
msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN));
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ static void send_sensor_descriptor_status(struct bt_mesh_model *model,
|
|||
}
|
||||
}
|
||||
if (i == srv->state_count) {
|
||||
BT_WARN("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id);
|
||||
BT_WARN("Sensor Property ID 0x%04x not exists", prop_id);
|
||||
net_buf_simple_add_le16(msg, prop_id);
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ static void send_sensor_data_status(struct bt_mesh_model *model,
|
|||
|
||||
msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN));
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ static void send_sensor_data_status(struct bt_mesh_model *model,
|
|||
}
|
||||
}
|
||||
if (i == srv->state_count) {
|
||||
BT_WARN("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id);
|
||||
BT_WARN("Sensor Property ID 0x%04x not exists", prop_id);
|
||||
u8_t mpid = (SENSOR_DATA_ZERO_LEN << 1) | SENSOR_DATA_FORMAT_B;
|
||||
net_buf_simple_add_u8(msg, mpid);
|
||||
net_buf_simple_add_le16(msg, prop_id);
|
||||
|
@ -222,14 +222,14 @@ static void send_sensor_cadence_status(struct bt_mesh_model *model,
|
|||
}
|
||||
}
|
||||
if (i == srv->state_count) {
|
||||
BT_WARN("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id);
|
||||
BT_WARN("Sensor Property ID 0x%04x not exists", prop_id);
|
||||
length = SENSOR_PROPERTY_ID_LEN;
|
||||
}
|
||||
|
||||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -297,7 +297,7 @@ static void send_sensor_settings_status(struct bt_mesh_model *model,
|
|||
|
||||
msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN));
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,7 @@ static void send_sensor_settings_status(struct bt_mesh_model *model,
|
|||
}
|
||||
}
|
||||
if (i == srv->state_count) {
|
||||
BT_WARN("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id);
|
||||
BT_WARN("Sensor Property ID 0x%04x not exists", prop_id);
|
||||
}
|
||||
|
||||
BLE_MESH_CHECK_SEND_STATUS(bt_mesh_model_send(model, ctx, msg, NULL, NULL));
|
||||
|
@ -377,14 +377,14 @@ static void send_sensor_setting_status(struct bt_mesh_model *model,
|
|||
* an unknown Sensor Setting Property ID field, the Sensor Setting Access
|
||||
* field and the Sensor Setting Raw field shall be omitted.
|
||||
*/
|
||||
BT_WARN("%s, Sensor Setting not found, 0x%04x, 0x%04x", __func__, prop_id, set_prop_id);
|
||||
BT_WARN("Sensor Setting not found, 0x%04x, 0x%04x", prop_id, set_prop_id);
|
||||
length = SENSOR_PROPERTY_ID_LEN + SENSOR_SETTING_PROPERTY_ID_LEN;
|
||||
}
|
||||
|
||||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -463,13 +463,13 @@ static void send_sensor_column_status(struct bt_mesh_model *model,
|
|||
}
|
||||
}
|
||||
if (i == srv->state_count) {
|
||||
BT_WARN("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id);
|
||||
BT_WARN("Sensor Property ID 0x%04x not exists", prop_id);
|
||||
length = SENSOR_PROPERTY_ID_LEN;
|
||||
}
|
||||
|
||||
msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -537,13 +537,13 @@ static void send_sensor_series_status(struct bt_mesh_model *model,
|
|||
}
|
||||
}
|
||||
if (i == srv->state_count) {
|
||||
BT_WARN("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id);
|
||||
BT_WARN("Sensor Property ID 0x%04x not exists", prop_id);
|
||||
length = SENSOR_PROPERTY_ID_LEN;
|
||||
}
|
||||
|
||||
msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -585,7 +585,7 @@ static void sensor_get(struct bt_mesh_model *model,
|
|||
u16_t prop_id = INVALID_SENSOR_PROPERTY_ID;
|
||||
|
||||
if (model->user_data == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -596,7 +596,7 @@ static void sensor_get(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_SENSOR_SERIES_GET: {
|
||||
struct bt_mesh_sensor_srv *srv = model->user_data;
|
||||
if (srv->state_count == 0U || srv->states == NULL) {
|
||||
BT_ERR("%s, Invalid Sensor Server state", __func__);
|
||||
BT_ERR("Invalid Sensor Server state");
|
||||
return;
|
||||
}
|
||||
if (ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET ||
|
||||
|
@ -605,7 +605,7 @@ static void sensor_get(struct bt_mesh_model *model,
|
|||
if (buf->len) {
|
||||
prop_id = net_buf_simple_pull_le16(buf);
|
||||
if (prop_id == INVALID_SENSOR_PROPERTY_ID) {
|
||||
BT_ERR("%s, Prohibited Sensor Property ID 0x0000", __func__);
|
||||
BT_ERR("Prohibited Sensor Property ID 0x0000");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -635,7 +635,7 @@ static void sensor_get(struct bt_mesh_model *model,
|
|||
} else {
|
||||
prop_id = net_buf_simple_pull_le16(buf);
|
||||
if (prop_id == INVALID_SENSOR_PROPERTY_ID) {
|
||||
BT_ERR("%s, Prohibited Sensor Property ID 0x0000", __func__);
|
||||
BT_ERR("Prohibited Sensor Property ID 0x0000");
|
||||
return;
|
||||
}
|
||||
if (ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET) {
|
||||
|
@ -669,14 +669,14 @@ static void sensor_get(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_SENSOR_SETTING_GET: {
|
||||
struct bt_mesh_sensor_setup_srv *srv = model->user_data;
|
||||
if (srv->state_count == 0U || srv->states == NULL) {
|
||||
BT_ERR("%s, Invalid Sensor Setup Server state", __func__);
|
||||
BT_ERR("Invalid Sensor Setup Server state");
|
||||
return;
|
||||
}
|
||||
if (ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET ||
|
||||
ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET) {
|
||||
prop_id = net_buf_simple_pull_le16(buf);
|
||||
if (prop_id == INVALID_SENSOR_PROPERTY_ID) {
|
||||
BT_ERR("%s, Prohibited Sensor Property ID 0x0000", __func__);
|
||||
BT_ERR("Prohibited Sensor Property ID 0x0000");
|
||||
return;
|
||||
}
|
||||
if (ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET) {
|
||||
|
@ -703,12 +703,12 @@ static void sensor_get(struct bt_mesh_model *model,
|
|||
} else {
|
||||
prop_id = net_buf_simple_pull_le16(buf);
|
||||
if (prop_id == INVALID_SENSOR_PROPERTY_ID) {
|
||||
BT_ERR("%s, Prohibited Sensor Property ID 0x0000", __func__);
|
||||
BT_ERR("Prohibited Sensor Property ID 0x0000");
|
||||
return;
|
||||
}
|
||||
set_prop_id = net_buf_simple_pull_le16(buf);
|
||||
if (set_prop_id == INVALID_SENSOR_PROPERTY_ID) {
|
||||
BT_ERR("%s, Prohibited Sensor Setting Property ID 0x0000", __func__);
|
||||
BT_ERR("Prohibited Sensor Setting Property ID 0x0000");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -726,7 +726,7 @@ static void sensor_get(struct bt_mesh_model *model,
|
|||
return;
|
||||
}
|
||||
default:
|
||||
BT_WARN("%s, Unknown Sensor Get opcode 0x%04x", __func__, ctx->recv_op);
|
||||
BT_WARN("Unknown Sensor Get opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -745,13 +745,13 @@ static void sensor_cadence_set(struct bt_mesh_model *model,
|
|||
int i;
|
||||
|
||||
if (srv == NULL || srv->state_count == 0U || srv->states == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
prop_id = net_buf_simple_pull_le16(buf);
|
||||
if (prop_id == INVALID_SENSOR_PROPERTY_ID) {
|
||||
BT_ERR("%s, Prohibited Sensor Property ID 0x0000", __func__);
|
||||
BT_ERR("Prohibited Sensor Property ID 0x0000");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -792,7 +792,7 @@ static void sensor_cadence_set(struct bt_mesh_model *model,
|
|||
val = net_buf_simple_pull_u8(buf);
|
||||
divisor = val & BIT_MASK(7);
|
||||
if (divisor > SENSOR_PERIOD_DIVISOR_MAX_VALUE) {
|
||||
BT_ERR("%s, Prohibited Fast Cadence Period Divisor 0x%02x", __func__, divisor);
|
||||
BT_ERR("Prohibited Fast Cadence Period Divisor 0x%02x", divisor);
|
||||
return;
|
||||
}
|
||||
state->cadence->period_divisor = divisor;
|
||||
|
@ -804,8 +804,8 @@ static void sensor_cadence_set(struct bt_mesh_model *model,
|
|||
trigger_len = SENSOR_STATUS_TRIGGER_UINT16_LEN;
|
||||
}
|
||||
if (buf->len < (trigger_len << 1) + SENSOR_STATUS_MIN_INTERVAL_LEN) {
|
||||
BT_ERR("%s, Invalid Sensor Cadence Set length %d, trigger type %d",
|
||||
__func__, buf->len + 3, state->cadence->trigger_type);
|
||||
BT_ERR("Invalid Sensor Cadence Set length %d, trigger type %d",
|
||||
buf->len + 3, state->cadence->trigger_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -823,13 +823,13 @@ static void sensor_cadence_set(struct bt_mesh_model *model,
|
|||
/* The valid range for the Status Min Interval is 0–26 and other values are Prohibited. */
|
||||
val = net_buf_simple_pull_u8(buf);
|
||||
if (val > SENSOR_STATUS_MIN_INTERVAL_MAX) {
|
||||
BT_ERR("%s, Invalid Status Min Interval %d", __func__, val);
|
||||
BT_ERR("Invalid Status Min Interval %d", val);
|
||||
return;
|
||||
}
|
||||
state->cadence->min_interval = val;
|
||||
|
||||
if (buf->len % 2) {
|
||||
BT_ERR("%s, Different length of Fast Cadence Low & High, length %d", __func__, buf->len);
|
||||
BT_ERR("Different length of Fast Cadence Low & High, length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
if (buf->len) {
|
||||
|
@ -866,7 +866,7 @@ static void sensor_cadence_set(struct bt_mesh_model *model,
|
|||
element = bt_mesh_model_elem(model);
|
||||
sensor_model = bt_mesh_model_find(element, BLE_MESH_MODEL_ID_SENSOR_SRV);
|
||||
if (sensor_model == NULL) {
|
||||
BT_WARN("%s, Sensor Server Model does not exist in the element", __func__);
|
||||
BT_WARN("Sensor Server model not exists in the element");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -885,13 +885,13 @@ static void update_sensor_periodic_pub(struct bt_mesh_model *model, u16_t prop_i
|
|||
int i;
|
||||
|
||||
if (model->id != BLE_MESH_MODEL_ID_SENSOR_SRV) {
|
||||
BT_ERR("%s, Not a Sensor Server Model", __func__);
|
||||
BT_ERR("Invalid Sensor Server model 0x%04x", model->id);
|
||||
return;
|
||||
}
|
||||
|
||||
srv = (struct bt_mesh_sensor_srv *)model->user_data;
|
||||
if (srv == NULL || srv->state_count == 0U || srv->states == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -903,12 +903,12 @@ static void update_sensor_periodic_pub(struct bt_mesh_model *model, u16_t prop_i
|
|||
}
|
||||
}
|
||||
if (i == srv->state_count) {
|
||||
BT_ERR("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id);
|
||||
BT_ERR("Sensor Property ID 0x%04x not exists", prop_id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state->cadence == NULL) {
|
||||
BT_WARN("%s, Sensor Cadence state does not exist", __func__);
|
||||
BT_WARN("Sensor Cadence state not exists");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -930,19 +930,19 @@ static void sensor_setting_set(struct bt_mesh_model *model,
|
|||
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__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
prop_id = net_buf_simple_pull_le16(buf);
|
||||
if (prop_id == INVALID_SENSOR_PROPERTY_ID) {
|
||||
BT_ERR("%s, Prohibited Sensor Property ID 0x0000", __func__);
|
||||
BT_ERR("Prohibited Sensor Property ID 0x0000");
|
||||
return;
|
||||
}
|
||||
|
||||
set_prop_id = net_buf_simple_pull_le16(buf);
|
||||
if (set_prop_id == INVALID_SENSOR_PROPERTY_ID) {
|
||||
BT_ERR("%s, Prohibited Sensor Setting Property ID 0x0000", __func__);
|
||||
BT_ERR("Prohibited Sensor Setting Property ID 0x0000");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1015,13 +1015,13 @@ static int check_sensor_server_init(struct bt_mesh_sensor_state *state_start,
|
|||
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);
|
||||
BT_ERR("Invalid Sensor Property ID 0x%04x", state->sensor_property_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* Check if the same Sensor Property ID exists */
|
||||
for (int k = i + 1; k < state_count; k++) {
|
||||
if (state->sensor_property_id == state_start[k].sensor_property_id) {
|
||||
BT_ERR("%s, Same Sensor Property ID 0x%04x exists", __func__, state->sensor_property_id);
|
||||
BT_ERR("Same Sensor Property ID 0x%04x exists", state->sensor_property_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1029,13 +1029,13 @@ static int check_sensor_server_init(struct bt_mesh_sensor_state *state_start,
|
|||
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", __func__);
|
||||
BT_ERR("Invalid Sensor Setting state");
|
||||
return -EINVAL;
|
||||
}
|
||||
/* Check if the same Sensor Setting Property ID exists */
|
||||
for (int k = j + 1; k < state->setting_count; k++) {
|
||||
if (setting->property_id == state->settings[k].property_id) {
|
||||
BT_ERR("%s, Same Sensor Setting Property ID 0x%04x exists", __func__, setting->property_id);
|
||||
BT_ERR("Same Sensor Setting Property ID 0x%04x exists", setting->property_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1046,12 +1046,12 @@ static int check_sensor_server_init(struct bt_mesh_sensor_state *state_start,
|
|||
state->cadence->trigger_delta_up == NULL ||
|
||||
state->cadence->fast_cadence_low == NULL ||
|
||||
state->cadence->fast_cadence_high == NULL) {
|
||||
BT_ERR("%s, Invalid Sensor Cadence state", __func__);
|
||||
BT_ERR("Invalid Sensor Cadence state");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
if (state->sensor_data.raw_value == NULL) {
|
||||
BT_ERR("%s, Invalid Sensor Data state", __func__);
|
||||
BT_ERR("Invalid Sensor Data state");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1062,7 +1062,7 @@ static int check_sensor_server_init(struct bt_mesh_sensor_state *state_start,
|
|||
static int sensor_server_init(struct bt_mesh_model *model)
|
||||
{
|
||||
if (model->user_data == NULL) {
|
||||
BT_ERR("%s, No Sensor Server context provided, model_id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Sensor Server user data, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1070,7 +1070,7 @@ static int sensor_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_SENSOR_SRV: {
|
||||
struct bt_mesh_sensor_srv *srv = model->user_data;
|
||||
if (srv->state_count == 0U || srv->states == NULL) {
|
||||
BT_ERR("%s, Invalid Sensor state, model_id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Sensor state, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (check_sensor_server_init(srv->states, srv->state_count)) {
|
||||
|
@ -1082,7 +1082,7 @@ static int sensor_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV: {
|
||||
struct bt_mesh_sensor_setup_srv *srv = model->user_data;
|
||||
if (srv->state_count == 0U || srv->states == NULL) {
|
||||
BT_ERR("%s, Invalid Sensor state, model_id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Sensor state, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (check_sensor_server_init(srv->states, srv->state_count)) {
|
||||
|
@ -1092,7 +1092,7 @@ static int sensor_server_init(struct bt_mesh_model *model)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_WARN("%s, Unknown Sensor Server Model, model_id 0x%04x", __func__, model->id);
|
||||
BT_WARN("Unknown Sensor Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1102,7 +1102,7 @@ static int sensor_server_init(struct bt_mesh_model *model)
|
|||
int bt_mesh_sensor_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Sensor Server has no publication support", __func__);
|
||||
BT_ERR("Sensor Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1111,7 +1111,7 @@ int bt_mesh_sensor_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
*/
|
||||
struct bt_mesh_elem *element = bt_mesh_model_elem(model);
|
||||
if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV) == NULL) {
|
||||
BT_WARN("%s, Sensor Setup Server is not present", __func__);
|
||||
BT_WARN("Sensor Setup Server not present");
|
||||
/* Just give a warning here, continue with the initialization */
|
||||
}
|
||||
return sensor_server_init(model);
|
||||
|
@ -1120,7 +1120,7 @@ int bt_mesh_sensor_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_sensor_setup_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Sensor Setup Server has no publication support", __func__);
|
||||
BT_ERR("Sensor Setup Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1130,7 +1130,7 @@ int bt_mesh_sensor_setup_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
static int sensor_server_deinit(struct bt_mesh_model *model)
|
||||
{
|
||||
if (model->user_data == NULL) {
|
||||
BT_ERR("%s, No Sensor Server context provided, model_id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Sensor Server user, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1140,7 +1140,7 @@ static int sensor_server_deinit(struct bt_mesh_model *model)
|
|||
int bt_mesh_sensor_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Sensor Server has no publication support", __func__);
|
||||
BT_ERR("Sensor Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1150,7 +1150,7 @@ int bt_mesh_sensor_srv_deinit(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_sensor_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Sensor Setup Server has no publication support", __func__);
|
||||
BT_ERR("Sensor Setup Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,13 +73,13 @@ int bt_mesh_get_light_lc_trans_time(struct bt_mesh_model *model, u8_t *trans_tim
|
|||
}
|
||||
|
||||
if (model->id != BLE_MESH_MODEL_ID_LIGHT_LC_SRV) {
|
||||
BT_ERR("%s, Not a Light LC Server", __func__);
|
||||
BT_ERR("Invalid a Light LC Server 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
srv = (struct bt_mesh_light_lc_srv *)model->user_data;
|
||||
if (srv == NULL) {
|
||||
BT_ERR("%s, Invalid Light LC Server user_data", __func__);
|
||||
BT_ERR("Invalid Light LC Server user data");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ int bt_mesh_server_get_optional(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
if (buf->len != 0x00 && buf->len != 0x02) {
|
||||
BT_ERR("%s, Invalid optional message length %d", __func__, buf->len);
|
||||
BT_ERR("Invalid optional message length %d", buf->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ int bt_mesh_server_get_optional(struct bt_mesh_model *model,
|
|||
* its appropriate transition times defined by the Light LC Property states.
|
||||
*/
|
||||
if (bt_mesh_get_light_lc_trans_time(model, trans_time)) {
|
||||
BT_ERR("%s, Failed to get Light LC transition time", __func__);
|
||||
BT_ERR("Failed to get Light LC transition time");
|
||||
return -EIO;
|
||||
}
|
||||
} else {
|
||||
|
@ -166,7 +166,7 @@ int bt_mesh_server_get_optional(struct bt_mesh_model *model,
|
|||
/* Optional fields are available */
|
||||
*trans_time = net_buf_simple_pull_u8(buf);
|
||||
if ((*trans_time & 0x3F) == 0x3F) {
|
||||
BT_ERR("%s, Invalid Transaction Number of Steps 0x3F", __func__);
|
||||
BT_ERR("Invalid Transaction Number of Steps 0x3f");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -183,16 +183,16 @@ void bt_mesh_server_alloc_ctx(struct k_work *work)
|
|||
* bt_mesh_msg_ctx" info to the application layer after a certain delay.
|
||||
* Here we use the allocated heap memory to store the "struct bt_mesh_msg_ctx".
|
||||
*/
|
||||
__ASSERT(work, "%s, Invalid parameter", __func__);
|
||||
__ASSERT(work, "Invalid parameter");
|
||||
if (!work->_reserved) {
|
||||
work->_reserved = bt_mesh_calloc(sizeof(struct bt_mesh_msg_ctx));
|
||||
__ASSERT(work->_reserved, "%s, Failed to allocate memory", __func__);
|
||||
__ASSERT(work->_reserved, "Out of memory");
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_server_free_ctx(struct k_work *work)
|
||||
{
|
||||
__ASSERT(work, "%s, Invalid parameter", __func__);
|
||||
__ASSERT(work, "Invalid parameter");
|
||||
if (work->_reserved) {
|
||||
bt_mesh_free(work->_reserved);
|
||||
work->_reserved = NULL;
|
||||
|
@ -243,14 +243,14 @@ struct net_buf_simple *bt_mesh_server_get_pub_msg(struct bt_mesh_model *model, u
|
|||
|
||||
if (model->pub == NULL || model->pub->msg == NULL ||
|
||||
model->pub->addr == BLE_MESH_ADDR_UNASSIGNED) {
|
||||
BT_DBG("%s, Model 0x%04x has no publication support", __func__, model->id);
|
||||
BT_DBG("No publication support, model id 0x%04x", model->id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buf = model->pub->msg;
|
||||
if (buf->size < msg_len) {
|
||||
BT_ERR("%s, Too small publication msg size %d, model 0x%04x",
|
||||
__func__, buf->size, model->id);
|
||||
BT_ERR("Too small publication msg size %d, model id 0x%04x",
|
||||
buf->size, model->id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
switch (type) {
|
||||
case GENERIC_ONOFF_STATE: {
|
||||
if (model->id != BLE_MESH_MODEL_ID_GEN_ONOFF_SRV) {
|
||||
BT_ERR("%s, Not a Generic OnOff Server Model, id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Generic OnOff Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
}
|
||||
case GENERIC_LEVEL_STATE: {
|
||||
if (model->id != BLE_MESH_MODEL_ID_GEN_LEVEL_SRV) {
|
||||
BT_ERR("%s, Not a Generic Level Server Model, id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Generic Level Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -128,13 +128,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
}
|
||||
case GENERIC_ONPOWERUP_STATE: {
|
||||
if (model->id != BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV) {
|
||||
BT_ERR("%s, Not a Generic Power OnOff Server Model, id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Generic Power OnOff Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct bt_mesh_gen_power_onoff_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Generic Power OnOff Server state", __func__);
|
||||
BT_ERR("Invalid Generic Power OnOff Server state");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -144,13 +144,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
}
|
||||
case GENERIC_POWER_ACTUAL_STATE: {
|
||||
if (model->id != BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV) {
|
||||
BT_ERR("%s, Not a Generic Power Level Server Model, id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Generic Power Level Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct bt_mesh_gen_power_level_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Generic Power Level Server state", __func__);
|
||||
BT_ERR("Invalid Generic Power Level Server state");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -170,13 +170,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
}
|
||||
case LIGHT_LIGHTNESS_ACTUAL_STATE: {
|
||||
if (model->id != BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV) {
|
||||
BT_ERR("%s, Not a Light Lightness Server Model, id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Light Lightness Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct bt_mesh_light_lightness_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Light Lightness Server state", __func__);
|
||||
BT_ERR("Invalid Light Lightness Server state");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -196,13 +196,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
}
|
||||
case LIGHT_LIGHTNESS_LINEAR_STATE: {
|
||||
if (model->id != BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV) {
|
||||
BT_ERR("%s, Not a Light Lightness Server Model, id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Light Lightness Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct bt_mesh_light_lightness_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Light Lightness Server state", __func__);
|
||||
BT_ERR("Invalid Light Lightness Server state");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -213,13 +213,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
}
|
||||
case LIGHT_CTL_LIGHTNESS_STATE: {
|
||||
if (model->id != BLE_MESH_MODEL_ID_LIGHT_CTL_SRV) {
|
||||
BT_ERR("%s, Not a Light CTL Server Model, id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Light CTL Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct bt_mesh_light_ctl_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Light CTL Server state", __func__);
|
||||
BT_ERR("Invalid Light CTL Server state");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -230,13 +230,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
}
|
||||
case LIGHT_CTL_TEMP_DELTA_UV_STATE: {
|
||||
if (model->id != BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV) {
|
||||
BT_ERR("%s, Not a Light CTL Temperature Server Model, id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Light CTL Temperature Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct bt_mesh_light_ctl_temp_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Light CTL Temperature Server state", __func__);
|
||||
BT_ERR("Invalid Light CTL Temperature Server state");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -248,13 +248,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
}
|
||||
case LIGHT_HSL_LIGHTNESS_STATE: {
|
||||
if (model->id != BLE_MESH_MODEL_ID_LIGHT_HSL_SRV) {
|
||||
BT_ERR("%s, Not a Light HSL Server Model, id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Light HSL Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct bt_mesh_light_hsl_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Light HSL Server state", __func__);
|
||||
BT_ERR("Invalid Light HSL Server state");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -265,13 +265,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
}
|
||||
case LIGHT_HSL_HUE_STATE: {
|
||||
if (model->id != BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV) {
|
||||
BT_ERR("%s, Not a Light HSL Hue Server Model, id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Light HSL Hue Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct bt_mesh_light_hsl_hue_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Light HSL Hue Server state", __func__);
|
||||
BT_ERR("Invalid Light HSL Hue Server state");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -282,13 +282,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
}
|
||||
case LIGHT_HSL_SATURATION_STATE: {
|
||||
if (model->id != BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV) {
|
||||
BT_ERR("%s, Not a Light HSL Saturation Server Model, id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Light HSL Saturation Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct bt_mesh_light_hsl_sat_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Light HSL Saturation Server state", __func__);
|
||||
BT_ERR("Invalid Light HSL Saturation Server state");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -299,13 +299,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
}
|
||||
case LIGHT_XYL_LIGHTNESS_STATE: {
|
||||
if (model->id != BLE_MESH_MODEL_ID_LIGHT_XYL_SRV) {
|
||||
BT_ERR("%s, Not a Light xyL Server Model, id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Light xyL Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct bt_mesh_light_xyl_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Light xyL Server state", __func__);
|
||||
BT_ERR("Invalid Light xyL Server state");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -316,13 +316,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
}
|
||||
case LIGHT_LC_LIGHT_ONOFF_STATE: {
|
||||
if (model->id != BLE_MESH_MODEL_ID_LIGHT_LC_SRV) {
|
||||
BT_ERR("%s, Not a Light LC Server Model, id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Light LC Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct bt_mesh_light_lc_srv *srv = model->user_data;
|
||||
if (srv->lc == NULL) {
|
||||
BT_ERR("%s, Invalid Light LC Server state", __func__);
|
||||
BT_ERR("Invalid Light LC Server state");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -332,7 +332,7 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_WARN("%s, Unknown binding state type 0x%02x", __func__, type);
|
||||
BT_WARN("Unknown binding state type 0x%02x", type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ static void send_time_status(struct bt_mesh_model *model,
|
|||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -138,7 +138,7 @@ static void send_time_status(struct bt_mesh_model *model,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_WARN("%s, Unknown Time status opcode 0x%04x", __func__, opcode);
|
||||
BT_WARN("Unknown Time status opcode 0x%04x", opcode);
|
||||
if (publish == false) {
|
||||
bt_mesh_free_buf(msg);
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ static void time_get(struct bt_mesh_model *model,
|
|||
u8_t prev_ttl = 0U;
|
||||
|
||||
if (model->user_data == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ static void time_get(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_ID_TIME_SRV: {
|
||||
struct bt_mesh_time_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Time Server state", __func__);
|
||||
BT_ERR("Invalid Time Server state");
|
||||
return;
|
||||
}
|
||||
rsp_ctrl = &srv->rsp_ctrl;
|
||||
|
@ -181,14 +181,14 @@ static void time_get(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_ID_TIME_SETUP_SRV: {
|
||||
struct bt_mesh_time_setup_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Time Setup Server state", __func__);
|
||||
BT_ERR("Invalid Time Setup Server state");
|
||||
return;
|
||||
}
|
||||
rsp_ctrl = &srv->rsp_ctrl;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Invalid Time Server 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Time Server, model id 0x%04x", model->id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ static void time_get(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_TIME_STATUS: {
|
||||
struct bt_mesh_time_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Time Server state", __func__);
|
||||
BT_ERR("Invalid Time Server state");
|
||||
return;
|
||||
}
|
||||
if (srv->state->time_role != TIME_RELAY &&
|
||||
|
@ -224,7 +224,7 @@ static void time_get(struct bt_mesh_model *model,
|
|||
net_buf_simple_pull(buf, TAI_SECONDS_LEN);
|
||||
if (memcmp(status.time_status.tai_seconds, zero, TAI_SECONDS_LEN)) {
|
||||
if (buf->len != TAI_SECONDS_LEN) {
|
||||
BT_ERR("%s, Invalid Time Status length %d", __func__, buf->len + TAI_SECONDS_LEN);
|
||||
BT_ERR("Invalid Time Status length %d", buf->len + TAI_SECONDS_LEN);
|
||||
return;
|
||||
}
|
||||
status.time_status.subsecond = net_buf_simple_pull_u8(buf);
|
||||
|
@ -247,7 +247,7 @@ static void time_get(struct bt_mesh_model *model,
|
|||
*/
|
||||
if (memcmp(srv->state->time.tai_seconds, zero, TAI_SECONDS_LEN)) {
|
||||
if (buf->len != TAI_SECONDS_LEN) {
|
||||
BT_ERR("%s, Invalid Time Status length %d", __func__, buf->len + TAI_SECONDS_LEN);
|
||||
BT_ERR("Invalid Time Status length %d", buf->len + TAI_SECONDS_LEN);
|
||||
return;
|
||||
}
|
||||
srv->state->time.subsecond = net_buf_simple_pull_u8(buf);
|
||||
|
@ -294,7 +294,7 @@ static void time_get(struct bt_mesh_model *model,
|
|||
opcode = BLE_MESH_MODEL_OP_TIME_ROLE_STATUS;
|
||||
break;
|
||||
default:
|
||||
BT_WARN("%s, Unknown Time Get opcode 0x%04x", __func__, ctx->recv_op);
|
||||
BT_WARN("Unknown Time Get opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ static void time_set(struct bt_mesh_model *model,
|
|||
u8_t role = 0U;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -360,7 +360,7 @@ static void time_set(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET:
|
||||
val = net_buf_simple_pull_le16(buf);
|
||||
if ((val >> 15) & BIT(0)) {
|
||||
BT_ERR("%s, Invalid Padding value 1", __func__);
|
||||
BT_ERR("Invalid Padding value 1");
|
||||
return;
|
||||
}
|
||||
if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_RSP_BY_APP) {
|
||||
|
@ -380,7 +380,7 @@ static void time_set(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_TIME_ROLE_SET:
|
||||
role = net_buf_simple_pull_u8(buf);
|
||||
if (role > TIME_CLINET) {
|
||||
BT_ERR("%s, Invalid Time Role 0x%02x", __func__, role);
|
||||
BT_ERR("Invalid Time Role 0x%02x", role);
|
||||
return;
|
||||
}
|
||||
if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_RSP_BY_APP) {
|
||||
|
@ -395,7 +395,7 @@ static void time_set(struct bt_mesh_model *model,
|
|||
opcode = BLE_MESH_MODEL_OP_TIME_ROLE_STATUS;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown Time Set opcode 0x%04x", __func__, ctx->recv_op);
|
||||
BT_ERR("Unknown Time Set opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,7 @@ static void send_scene_status(struct bt_mesh_model *model,
|
|||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -504,7 +504,7 @@ static void send_scene_register_status(struct bt_mesh_model *model,
|
|||
if (publish == false) {
|
||||
msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN));
|
||||
if (msg == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -548,7 +548,7 @@ static void scene_get(struct bt_mesh_model *model,
|
|||
struct bt_mesh_scene_srv *srv = model->user_data;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -571,7 +571,7 @@ static void scene_get(struct bt_mesh_model *model,
|
|||
send_scene_register_status(model, ctx, SCENE_SUCCESS, false);
|
||||
return;
|
||||
default:
|
||||
BT_WARN("%s, Unknown Scene Get opcode 0x%04x", __func__, ctx->recv_op);
|
||||
BT_WARN("Unknown Scene Get opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -581,7 +581,7 @@ void scene_publish(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, u16
|
|||
struct bt_mesh_scene_srv *srv = model->user_data;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -602,13 +602,13 @@ static void scene_recall(struct bt_mesh_model *model,
|
|||
int i;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
scene_number = net_buf_simple_pull_le16(buf);
|
||||
if (scene_number == INVALID_SCENE_NUMBER) {
|
||||
BT_ERR("%s, Invalid Scene Number 0x0000", __func__);
|
||||
BT_ERR("Invalid Scene Number 0x0000");
|
||||
return;
|
||||
}
|
||||
tid = net_buf_simple_pull_u8(buf);
|
||||
|
@ -637,7 +637,7 @@ static void scene_recall(struct bt_mesh_model *model,
|
|||
}
|
||||
}
|
||||
if (i == srv->state->scene_count) {
|
||||
BT_WARN("%s, Scene Number 0x%04x not exist", __func__, scene_number);
|
||||
BT_WARN("Scene Number 0x%04x not exists", scene_number);
|
||||
srv->state->status_code = SCENE_NOT_FOUND;
|
||||
if (ctx->recv_op == BLE_MESH_MODEL_OP_SCENE_RECALL) {
|
||||
send_scene_status(model, ctx, false);
|
||||
|
@ -731,13 +731,13 @@ static void scene_action(struct bt_mesh_model *model,
|
|||
int i;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
scene_number = net_buf_simple_pull_le16(buf);
|
||||
if (scene_number == INVALID_SCENE_NUMBER) {
|
||||
BT_ERR("%s, Invalid Scene number 0x0000", __func__);
|
||||
BT_ERR("Invalid Scene number 0x0000");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -763,7 +763,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);
|
||||
BT_DBG("No matching Scene Number 0x%04x found", scene_number);
|
||||
for (i = 0; i < srv->state->scene_count; i++) {
|
||||
scene = &srv->state->scenes[i];
|
||||
if (scene->scene_number == INVALID_SCENE_NUMBER) {
|
||||
|
@ -774,7 +774,7 @@ static void scene_action(struct bt_mesh_model *model,
|
|||
}
|
||||
}
|
||||
if (i == srv->state->scene_count) {
|
||||
BT_WARN("%s, Scene Register full", __func__);
|
||||
BT_WARN("Scene Register is full!");
|
||||
srv->state->status_code = SCENE_REG_FULL;
|
||||
/* Get the Scene Number of the currently active scene */
|
||||
for (i = 0; i < srv->state->scene_count; i++) {
|
||||
|
@ -826,7 +826,7 @@ static void scene_action(struct bt_mesh_model *model,
|
|||
}
|
||||
}
|
||||
if (i == srv->state->scene_count) {
|
||||
BT_WARN("%s, Scene Number 0x%04x not exist", __func__, scene_number);
|
||||
BT_WARN("Scene Number 0x%04x not exists", scene_number);
|
||||
/**
|
||||
* When a Scene Server receives a Scene Delete message with the Scene
|
||||
* Number value that does not match a Scene Number stored within the
|
||||
|
@ -881,13 +881,13 @@ static void scene_action(struct bt_mesh_model *model,
|
|||
|
||||
scene_model = bt_mesh_model_find(bt_mesh_model_elem(model), BLE_MESH_MODEL_ID_SCENE_SRV);
|
||||
if (scene_model == NULL) {
|
||||
BT_ERR("%s, Scene Server is not present in the element", __func__);
|
||||
BT_ERR("Scene Server not present in the element");
|
||||
break;
|
||||
}
|
||||
|
||||
scene_srv = scene_model->user_data;
|
||||
if (scene_srv == NULL || scene_srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid Scene Server parameter", __func__);
|
||||
BT_ERR("Invalid Scene Server user data");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -896,7 +896,7 @@ static void scene_action(struct bt_mesh_model *model,
|
|||
* Add this in case the Scene Setup Server is extending the Scene
|
||||
* Server in another element.
|
||||
*/
|
||||
BT_WARN("%s, Different Scene state in Scene Server & Scene Setup Server", __func__);
|
||||
BT_WARN("Different Scene state in Scene Server & Scene Setup Server");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -912,7 +912,7 @@ static void scene_action(struct bt_mesh_model *model,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Unknown Scene setup action opcode 0x%04x", __func__, ctx->recv_op);
|
||||
BT_ERR("Unknown Scene setup action opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -979,7 +979,7 @@ static void send_scheduler_act_status(struct bt_mesh_model *model,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_ERR("%s, Invalid Scheduler Server 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Scheduler Server, model id 0x%04x", model->id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -995,7 +995,7 @@ static void scheduler_get(struct bt_mesh_model *model,
|
|||
NET_BUF_SIMPLE_DEFINE(msg, 2 + 2 + BLE_MESH_SERVER_TRANS_MIC_SIZE);
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1015,7 +1015,7 @@ static void scheduler_get(struct bt_mesh_model *model,
|
|||
case BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET: {
|
||||
u8_t index = net_buf_simple_pull_u8(buf);
|
||||
if (index > SCHEDULE_ENTRY_MAX_INDEX) {
|
||||
BT_ERR("%s, Invalid Scheduler Register Entry index 0x%02x", __func__, index);
|
||||
BT_ERR("Invalid Scheduler Register Entry index 0x%02x", index);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1032,7 +1032,7 @@ static void scheduler_get(struct bt_mesh_model *model,
|
|||
return;
|
||||
}
|
||||
default:
|
||||
BT_WARN("%s, Unknown Scheduler Get opcode 0x%04x", __func__, ctx->recv_op);
|
||||
BT_WARN("Unknown Scheduler Get opcode 0x%04x", ctx->recv_op);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1058,7 +1058,7 @@ static void scheduler_act_set(struct bt_mesh_model *model,
|
|||
u64_t value = 0U;
|
||||
|
||||
if (srv == NULL || srv->state == NULL) {
|
||||
BT_ERR("%s, Invalid model user_data", __func__);
|
||||
BT_ERR("%s, Invalid model user data", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1077,22 +1077,22 @@ static void scheduler_act_set(struct bt_mesh_model *model,
|
|||
trans_time = (value >> 56) & BIT_MASK(8);
|
||||
|
||||
if (index > SCHEDULE_ENTRY_MAX_INDEX) {
|
||||
BT_ERR("%s, Invalid Scheduler Register Entry index 0x%02x", __func__, index);
|
||||
BT_ERR("Invalid Scheduler Register Entry index 0x%02x", index);
|
||||
return;
|
||||
}
|
||||
|
||||
if (year > SCHEDULE_YEAR_ANY_YEAR) {
|
||||
BT_ERR("%s, Invalid Scheduler Register year 0x%02x", __func__, year);
|
||||
BT_ERR("Invalid Scheduler Register year 0x%02x", year);
|
||||
return;
|
||||
}
|
||||
|
||||
if (hour > SCHEDULE_HOUR_ONCE_A_DAY) {
|
||||
BT_ERR("%s, Invalid Scheduler Register hour 0x%02x", __func__, hour);
|
||||
BT_ERR("Invalid Scheduler Register hour 0x%02x", hour);
|
||||
return;
|
||||
}
|
||||
|
||||
if (action > SCHEDULE_ACT_SCENE_RECALL && action != SCHEDULE_ACT_NO_ACTION) {
|
||||
BT_ERR("%s, Invalid Scheduler Register action 0x%02x", __func__, action);
|
||||
BT_ERR("Invalid Scheduler Register action 0x%02x", action);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1210,13 +1210,13 @@ static int check_scene_server_init(struct bt_mesh_scenes_state *state)
|
|||
int i;
|
||||
|
||||
if (state->scene_count == 0U || state->scenes == NULL) {
|
||||
BT_ERR("%s, Invalid Scene state", __func__);
|
||||
BT_ERR("Invalid Scene state");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
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);
|
||||
BT_ERR("Invalid Scene value, index %d", i);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1227,7 +1227,7 @@ static int check_scene_server_init(struct bt_mesh_scenes_state *state)
|
|||
static int time_scene_server_init(struct bt_mesh_model *model)
|
||||
{
|
||||
if (model->user_data == NULL) {
|
||||
BT_ERR("%s, No Time Scene Server context provided, model_id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Time Scene Server user data, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1235,7 +1235,7 @@ static int time_scene_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_TIME_SRV: {
|
||||
struct bt_mesh_time_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Time State", __func__);
|
||||
BT_ERR("Invalid Time State");
|
||||
return -EINVAL;
|
||||
}
|
||||
srv->model = model;
|
||||
|
@ -1244,7 +1244,7 @@ static int time_scene_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_TIME_SETUP_SRV: {
|
||||
struct bt_mesh_time_setup_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Time State", __func__);
|
||||
BT_ERR("Invalid Time State");
|
||||
return -EINVAL;
|
||||
}
|
||||
srv->model = model;
|
||||
|
@ -1253,7 +1253,7 @@ static int time_scene_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_SCENE_SRV: {
|
||||
struct bt_mesh_scene_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Scene State", __func__);
|
||||
BT_ERR("Invalid Scene State");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (check_scene_server_init(srv->state)) {
|
||||
|
@ -1269,7 +1269,7 @@ static int time_scene_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_SCENE_SETUP_SRV: {
|
||||
struct bt_mesh_scene_setup_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Scene State", __func__);
|
||||
BT_ERR("Invalid Scene State");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (check_scene_server_init(srv->state)) {
|
||||
|
@ -1281,11 +1281,11 @@ static int time_scene_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_SCHEDULER_SRV: {
|
||||
struct bt_mesh_scheduler_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Scheduler State", __func__);
|
||||
BT_ERR("Invalid Scheduler State");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (srv->state->schedule_count == 0U || srv->state->schedules == NULL) {
|
||||
BT_ERR("%s, NULL Register Schedule", __func__);
|
||||
BT_ERR("Invalid Register Schedule");
|
||||
return -EINVAL;
|
||||
}
|
||||
srv->model = model;
|
||||
|
@ -1294,18 +1294,18 @@ static int time_scene_server_init(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV: {
|
||||
struct bt_mesh_scheduler_setup_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Scheduler State", __func__);
|
||||
BT_ERR("Invalid Scheduler State");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (srv->state->schedule_count == 0U || srv->state->schedules == NULL) {
|
||||
BT_ERR("%s, NULL Register Schedule", __func__);
|
||||
BT_ERR("Invalid Register Schedule");
|
||||
return -EINVAL;
|
||||
}
|
||||
srv->model = model;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_WARN("%s, Unknown Time Scene Server Model, model_id 0x%04x", __func__, model->id);
|
||||
BT_WARN("Unknown Time Scene Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1317,7 +1317,7 @@ static int time_scene_server_init(struct bt_mesh_model *model)
|
|||
int bt_mesh_time_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Time Server has no publication support", __func__);
|
||||
BT_ERR("Time Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1327,7 +1327,7 @@ int bt_mesh_time_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
*/
|
||||
struct bt_mesh_elem *element = bt_mesh_model_elem(model);
|
||||
if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_TIME_SETUP_SRV) == NULL) {
|
||||
BT_WARN("%s, Time Setup Server is not present", __func__);
|
||||
BT_WARN("Time Setup Server not present");
|
||||
/* Just give a warning here, continue with the initialization */
|
||||
}
|
||||
return time_scene_server_init(model);
|
||||
|
@ -1337,7 +1337,7 @@ int bt_mesh_time_setup_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
{
|
||||
/* This model does not support subscribing nor publishing */
|
||||
if (model->pub) {
|
||||
BT_ERR("%s, Time Setup Server shall not support publication", __func__);
|
||||
BT_ERR("Time Setup Server shall not support publication");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1347,13 +1347,13 @@ int bt_mesh_time_setup_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_scene_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Scene Server has no publication support", __func__);
|
||||
BT_ERR("Scene Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* The model may be present only on the Primary element of a node. */
|
||||
if (primary == false) {
|
||||
BT_WARN("%s, Scene Server is not on the Primary element", __func__);
|
||||
BT_WARN("Scene Server not on the Primary element");
|
||||
/* Just give a warning here, continue with the initialization */
|
||||
}
|
||||
/**
|
||||
|
@ -1362,7 +1362,7 @@ int bt_mesh_scene_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
*/
|
||||
struct bt_mesh_elem *element = bt_mesh_model_elem(model);
|
||||
if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_SCENE_SETUP_SRV) == NULL) {
|
||||
BT_WARN("%s, Scene Setup Server is not present", __func__);
|
||||
BT_WARN("Scene Setup Server not present");
|
||||
/* Just give a warning here, continue with the initialization */
|
||||
}
|
||||
return time_scene_server_init(model);
|
||||
|
@ -1372,7 +1372,7 @@ int bt_mesh_scene_setup_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
{
|
||||
/* The model may be present only on the Primary element of a node. */
|
||||
if (primary == false) {
|
||||
BT_WARN("%s, Scene Setup Server is not on the Primary element", __func__);
|
||||
BT_WARN("Scene Setup Server not on the Primary element");
|
||||
/* Just give a warning here, continue with the initialization */
|
||||
}
|
||||
return time_scene_server_init(model);
|
||||
|
@ -1381,13 +1381,13 @@ int bt_mesh_scene_setup_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_scheduler_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Scheduler Server has no publication support", __func__);
|
||||
BT_ERR("Scheduler Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* The model may be present only on the Primary element of a node. */
|
||||
if (primary == false) {
|
||||
BT_WARN("%s, Scheduler Server is not on the Primary element", __func__);
|
||||
BT_WARN("Scheduler Server not on the Primary element");
|
||||
/* Just give a warning here, continue with the initialization */
|
||||
}
|
||||
/**
|
||||
|
@ -1397,11 +1397,11 @@ int bt_mesh_scheduler_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
*/
|
||||
struct bt_mesh_elem *element = bt_mesh_model_elem(model);
|
||||
if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV) == NULL) {
|
||||
BT_WARN("%s, Scheduler Setup Server is not present", __func__);
|
||||
BT_WARN("Scheduler Setup Server not present");
|
||||
/* Just give a warning here, continue with the initialization */
|
||||
}
|
||||
if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_TIME_SRV) == NULL) {
|
||||
BT_WARN("%s, Time Server is not present", __func__);
|
||||
BT_WARN("Time Server not present");
|
||||
/* Just give a warning here, continue with the initialization */
|
||||
}
|
||||
return time_scene_server_init(model);
|
||||
|
@ -1411,7 +1411,7 @@ int bt_mesh_scheduler_setup_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
{
|
||||
/* The model may be present only on the Primary element of a node. */
|
||||
if (primary == false) {
|
||||
BT_WARN("%s, Scheduler Setup Server is not on the Primary element", __func__);
|
||||
BT_WARN("Scheduler Setup Server not on the Primary element");
|
||||
/* Just give a warning here, continue with the initialization */
|
||||
}
|
||||
return time_scene_server_init(model);
|
||||
|
@ -1420,7 +1420,7 @@ int bt_mesh_scheduler_setup_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
static int time_scene_server_deinit(struct bt_mesh_model *model)
|
||||
{
|
||||
if (model->user_data == NULL) {
|
||||
BT_ERR("%s, No Time Scene Server context provided, model_id 0x%04x", __func__, model->id);
|
||||
BT_ERR("Invalid Time Scene Server user data, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1428,7 +1428,7 @@ static int time_scene_server_deinit(struct bt_mesh_model *model)
|
|||
case BLE_MESH_MODEL_ID_SCENE_SRV: {
|
||||
struct bt_mesh_scene_srv *srv = model->user_data;
|
||||
if (srv->state == NULL) {
|
||||
BT_ERR("%s, NULL Scene State", __func__);
|
||||
BT_ERR("Invalid Scene State");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (check_scene_server_init(srv->state)) {
|
||||
|
@ -1441,7 +1441,7 @@ static int time_scene_server_deinit(struct bt_mesh_model *model)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
BT_WARN("%s, Unknown Time Scene Server Model, model_id 0x%04x", __func__, model->id);
|
||||
BT_WARN("Unknown Time Scene Server, model id 0x%04x", model->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1453,7 +1453,7 @@ static int time_scene_server_deinit(struct bt_mesh_model *model)
|
|||
int bt_mesh_time_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Time Server has no publication support", __func__);
|
||||
BT_ERR("Time Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1463,7 +1463,7 @@ int bt_mesh_time_srv_deinit(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_time_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub) {
|
||||
BT_ERR("%s, Time Setup Server shall not support publication", __func__);
|
||||
BT_ERR("Time Setup Server shall not support publication");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1473,7 +1473,7 @@ int bt_mesh_time_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_scene_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Scene Server has no publication support", __func__);
|
||||
BT_ERR("Scene Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1488,7 +1488,7 @@ int bt_mesh_scene_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
|
|||
int bt_mesh_scheduler_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
if (model->pub == NULL) {
|
||||
BT_ERR("%s, Scheduler Server has no publication support", __func__);
|
||||
BT_ERR("Scheduler Server has no publication support");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,3 +11,4 @@ CONFIG_BT_BTU_TASK_STACK_SIZE=4512
|
|||
CONFIG_BLE_MESH=y
|
||||
CONFIG_BLE_MESH_NODE=y
|
||||
CONFIG_BLE_MESH_PB_GATT=y
|
||||
CONFIG_BLE_MESH_FRIEND=y
|
||||
|
|
|
@ -10,3 +10,4 @@ CONFIG_BT_NIMBLE_ENABLED=y
|
|||
CONFIG_BLE_MESH=y
|
||||
CONFIG_BLE_MESH_NODE=y
|
||||
CONFIG_BLE_MESH_PB_GATT=y
|
||||
CONFIG_BLE_MESH_LOW_POWER=y
|
||||
|
|
Loading…
Reference in a new issue