From 8988fb9b8d4b1ff9b742c8c2796001a29ba730ba Mon Sep 17 00:00:00 2001 From: lly Date: Fri, 29 May 2020 17:28:52 +0800 Subject: [PATCH] ble_mesh: Config and health client btc fixes Fix an issue which may cause no error code is returned when sending config client or health client messages with invalid parameters. --- .../btc/btc_ble_mesh_config_model.c | 229 ++++++++---------- .../btc/btc_ble_mesh_health_model.c | 52 ++-- 2 files changed, 127 insertions(+), 154 deletions(-) diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c index 837c38ed5b..c874454078 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c @@ -381,12 +381,11 @@ void btc_ble_mesh_config_client_publish_callback(u32_t opcode, } static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_cfg_client_get_state_t *get, - esp_ble_mesh_cfg_client_cb_param_t *cb) + esp_ble_mesh_cfg_client_get_state_t *get) { struct bt_mesh_msg_ctx ctx = {0}; - if (!params || !cb) { + if (params == NULL) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } @@ -421,68 +420,65 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param switch (params->opcode) { case ESP_BLE_MESH_MODEL_OP_BEACON_GET: - return (cb->error_code = bt_mesh_cfg_beacon_get(&ctx)); + return bt_mesh_cfg_beacon_get(&ctx); case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET: - return (cb->error_code = bt_mesh_cfg_ttl_get(&ctx)); + return bt_mesh_cfg_ttl_get(&ctx); case ESP_BLE_MESH_MODEL_OP_FRIEND_GET: - return (cb->error_code = bt_mesh_cfg_friend_get(&ctx)); + return bt_mesh_cfg_friend_get(&ctx); case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET: - return (cb->error_code = bt_mesh_cfg_gatt_proxy_get(&ctx)); + return bt_mesh_cfg_gatt_proxy_get(&ctx); case ESP_BLE_MESH_MODEL_OP_RELAY_GET: - return (cb->error_code = bt_mesh_cfg_relay_get(&ctx)); + return bt_mesh_cfg_relay_get(&ctx); case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET: - return (cb->error_code = - bt_mesh_cfg_mod_pub_get(&ctx, get->model_pub_get.element_addr, - get->model_pub_get.model_id, get->model_pub_get.company_id)); + return bt_mesh_cfg_mod_pub_get(&ctx, get->model_pub_get.element_addr, + get->model_pub_get.model_id, + get->model_pub_get.company_id); case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET: - return (cb->error_code = bt_mesh_cfg_hb_pub_get(&ctx)); + return bt_mesh_cfg_hb_pub_get(&ctx); case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET: - return (cb->error_code = bt_mesh_cfg_hb_sub_get(&ctx)); + return bt_mesh_cfg_hb_sub_get(&ctx); case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET: - return (cb->error_code = bt_mesh_cfg_comp_data_get(&ctx, get->comp_data_get.page)); + return bt_mesh_cfg_comp_data_get(&ctx, get->comp_data_get.page); case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET: - return (cb->error_code = - bt_mesh_cfg_mod_sub_get(&ctx, get->sig_model_sub_get.element_addr, - get->sig_model_sub_get.model_id)); + return bt_mesh_cfg_mod_sub_get(&ctx, get->sig_model_sub_get.element_addr, + get->sig_model_sub_get.model_id); case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET: - return (cb->error_code = - bt_mesh_cfg_mod_sub_get_vnd(&ctx, get->vnd_model_sub_get.element_addr, - get->vnd_model_sub_get.model_id, get->vnd_model_sub_get.company_id)); + return bt_mesh_cfg_mod_sub_get_vnd(&ctx, get->vnd_model_sub_get.element_addr, + get->vnd_model_sub_get.model_id, + get->vnd_model_sub_get.company_id); case ESP_BLE_MESH_MODEL_OP_NET_KEY_GET: - return (cb->error_code = bt_mesh_cfg_net_key_get(&ctx)); + return bt_mesh_cfg_net_key_get(&ctx); case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET: - return (cb->error_code = bt_mesh_cfg_app_key_get(&ctx, get->app_key_get.net_idx)); + return bt_mesh_cfg_app_key_get(&ctx, get->app_key_get.net_idx); case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET: - return (cb->error_code = bt_mesh_cfg_node_identity_get(&ctx, get->node_identity_get.net_idx)); + return bt_mesh_cfg_node_identity_get(&ctx, get->node_identity_get.net_idx); case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET: - return (cb->error_code = - bt_mesh_cfg_mod_app_get(&ctx, get->sig_model_app_get.element_addr, - get->sig_model_app_get.model_id)); + return bt_mesh_cfg_mod_app_get(&ctx, get->sig_model_app_get.element_addr, + get->sig_model_app_get.model_id); case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET: - return (cb->error_code = - bt_mesh_cfg_mod_app_get_vnd(&ctx, get->vnd_model_app_get.element_addr, - get->vnd_model_app_get.model_id, get->vnd_model_app_get.company_id)); + return bt_mesh_cfg_mod_app_get_vnd(&ctx, get->vnd_model_app_get.element_addr, + get->vnd_model_app_get.model_id, + get->vnd_model_app_get.company_id); case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET: - return (cb->error_code = bt_mesh_cfg_kr_phase_get(&ctx, get->kr_phase_get.net_idx)); + return bt_mesh_cfg_kr_phase_get(&ctx, get->kr_phase_get.net_idx); case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET: - return (cb->error_code = bt_mesh_cfg_lpn_timeout_get(&ctx, get->lpn_pollto_get.lpn_addr)); + return bt_mesh_cfg_lpn_timeout_get(&ctx, get->lpn_pollto_get.lpn_addr); case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET: - return (cb->error_code = bt_mesh_cfg_net_transmit_get(&ctx)); + return bt_mesh_cfg_net_transmit_get(&ctx); default: BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode); - return (cb->error_code = -EINVAL); + return -EINVAL; } return 0; } static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_cfg_client_set_state_t *set, - esp_ble_mesh_cfg_client_cb_param_t *cb) + esp_ble_mesh_cfg_client_set_state_t *set) { struct bt_mesh_msg_ctx ctx = {0}; - if (!params || !cb) { + if (params == NULL) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } @@ -502,29 +498,28 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param switch (params->opcode) { case ESP_BLE_MESH_MODEL_OP_BEACON_SET: - return (cb->error_code = bt_mesh_cfg_beacon_set(&ctx, set->beacon_set.beacon)); + return bt_mesh_cfg_beacon_set(&ctx, set->beacon_set.beacon); case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET: - return (cb->error_code = bt_mesh_cfg_ttl_set(&ctx, set->default_ttl_set.ttl)); + return bt_mesh_cfg_ttl_set(&ctx, set->default_ttl_set.ttl); case ESP_BLE_MESH_MODEL_OP_FRIEND_SET: - return (cb->error_code = bt_mesh_cfg_friend_set(&ctx, set->friend_set.friend_state)); + return bt_mesh_cfg_friend_set(&ctx, set->friend_set.friend_state); case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET: - return (cb->error_code = bt_mesh_cfg_gatt_proxy_set(&ctx, set->gatt_proxy_set.gatt_proxy)); + return bt_mesh_cfg_gatt_proxy_set(&ctx, set->gatt_proxy_set.gatt_proxy); case ESP_BLE_MESH_MODEL_OP_RELAY_SET: - return (cb->error_code = - bt_mesh_cfg_relay_set(&ctx, set->relay_set.relay, set->relay_set.relay_retransmit)); + return bt_mesh_cfg_relay_set(&ctx, set->relay_set.relay, + set->relay_set.relay_retransmit); case ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD: - return (cb->error_code = - bt_mesh_cfg_net_key_add(&ctx, set->net_key_add.net_idx, - &set->net_key_add.net_key[0])); + return bt_mesh_cfg_net_key_add(&ctx, set->net_key_add.net_idx, + &set->net_key_add.net_key[0]); case ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD: - return (cb->error_code = - bt_mesh_cfg_app_key_add(&ctx, set->app_key_add.net_idx, - set->app_key_add.app_idx, &set->app_key_add.app_key[0])); + return bt_mesh_cfg_app_key_add(&ctx, set->app_key_add.net_idx, + set->app_key_add.app_idx, + &set->app_key_add.app_key[0]); case ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND: - return (cb->error_code = - bt_mesh_cfg_mod_app_bind(&ctx, set->model_app_bind.element_addr, - set->model_app_bind.model_app_idx, set->model_app_bind.model_id, - set->model_app_bind.company_id)); + return bt_mesh_cfg_mod_app_bind(&ctx, set->model_app_bind.element_addr, + set->model_app_bind.model_app_idx, + set->model_app_bind.model_id, + set->model_app_bind.company_id); case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET: { struct bt_mesh_cfg_mod_pub model_pub = { .addr = set->model_pub_set.publish_addr, @@ -534,50 +529,46 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param .period = set->model_pub_set.publish_period, .transmit = set->model_pub_set.publish_retransmit, }; - return (cb->error_code = - bt_mesh_cfg_mod_pub_set(&ctx, set->model_pub_set.element_addr, - set->model_pub_set.model_id, set->model_pub_set.company_id, &model_pub)); + return bt_mesh_cfg_mod_pub_set(&ctx, set->model_pub_set.element_addr, + set->model_pub_set.model_id, + set->model_pub_set.company_id, &model_pub); } case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD: - return (cb->error_code = - bt_mesh_cfg_mod_sub_add(&ctx, set->model_sub_add.element_addr, - set->model_sub_add.sub_addr, set->model_sub_add.model_id, - set->model_sub_add.company_id)); + return bt_mesh_cfg_mod_sub_add(&ctx, set->model_sub_add.element_addr, + set->model_sub_add.sub_addr, + set->model_sub_add.model_id, + set->model_sub_add.company_id); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE: - return (cb->error_code = - bt_mesh_cfg_mod_sub_del(&ctx, set->model_sub_delete.element_addr, - set->model_sub_delete.sub_addr, set->model_sub_delete.model_id, - set->model_sub_delete.company_id)); + return bt_mesh_cfg_mod_sub_del(&ctx, set->model_sub_delete.element_addr, + set->model_sub_delete.sub_addr, + set->model_sub_delete.model_id, + set->model_sub_delete.company_id); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE: - return (cb->error_code = - bt_mesh_cfg_mod_sub_overwrite(&ctx, set->model_sub_overwrite.element_addr, - set->model_sub_overwrite.sub_addr, set->model_sub_overwrite.model_id, - set->model_sub_overwrite.company_id)); + return bt_mesh_cfg_mod_sub_overwrite(&ctx, set->model_sub_overwrite.element_addr, + set->model_sub_overwrite.sub_addr, + set->model_sub_overwrite.model_id, + set->model_sub_overwrite.company_id); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD: - return (cb->error_code = - bt_mesh_cfg_mod_sub_va_add(&ctx, set->model_sub_va_add.element_addr, - &set->model_sub_va_add.label_uuid[0], set->model_sub_va_add.model_id, - set->model_sub_va_add.company_id)); + return bt_mesh_cfg_mod_sub_va_add(&ctx, set->model_sub_va_add.element_addr, + &set->model_sub_va_add.label_uuid[0], + set->model_sub_va_add.model_id, + set->model_sub_va_add.company_id); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE: - return (cb->error_code = - bt_mesh_cfg_mod_sub_va_overwrite(&ctx, set->model_sub_va_overwrite.element_addr, - &set->model_sub_va_overwrite.label_uuid[0], set->model_sub_va_overwrite.model_id, - set->model_sub_va_overwrite.company_id)); + return bt_mesh_cfg_mod_sub_va_overwrite(&ctx, set->model_sub_va_overwrite.element_addr, + &set->model_sub_va_overwrite.label_uuid[0], + set->model_sub_va_overwrite.model_id, + set->model_sub_va_overwrite.company_id); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE: - return (cb->error_code = - bt_mesh_cfg_mod_sub_va_del(&ctx, set->model_sub_va_delete.element_addr, - &set->model_sub_va_delete.label_uuid[0], set->model_sub_va_delete.model_id, - set->model_sub_va_delete.company_id)); + return bt_mesh_cfg_mod_sub_va_del(&ctx, set->model_sub_va_delete.element_addr, + &set->model_sub_va_delete.label_uuid[0], + set->model_sub_va_delete.model_id, + set->model_sub_va_delete.company_id); case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET: - return (cb->error_code = - bt_mesh_cfg_hb_sub_set(&ctx, - (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set)); + return bt_mesh_cfg_hb_sub_set(&ctx, (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set); case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET: - return (cb->error_code = - bt_mesh_cfg_hb_pub_set(&ctx, - (const struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set)); + return bt_mesh_cfg_hb_pub_set(&ctx, (const struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set); case ESP_BLE_MESH_MODEL_OP_NODE_RESET: - return (cb->error_code = bt_mesh_cfg_node_reset(&ctx)); + return bt_mesh_cfg_node_reset(&ctx); case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET: { struct bt_mesh_cfg_mod_pub model_pub = { .app_idx = set->model_pub_va_set.publish_app_idx, @@ -586,49 +577,43 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param .period = set->model_pub_va_set.publish_period, .transmit = set->model_pub_va_set.publish_retransmit, }; - return (cb->error_code = - bt_mesh_cfg_mod_pub_va_set(&ctx, set->model_pub_va_set.element_addr, - set->model_pub_va_set.model_id, set->model_pub_va_set.company_id, - set->model_pub_va_set.label_uuid, &model_pub)); + return bt_mesh_cfg_mod_pub_va_set(&ctx, set->model_pub_va_set.element_addr, + set->model_pub_va_set.model_id, + set->model_pub_va_set.company_id, + set->model_pub_va_set.label_uuid, &model_pub); } case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL: - return (cb->error_code = - bt_mesh_cfg_mod_sub_del_all(&ctx, set->model_sub_delete_all.element_addr, - set->model_sub_delete_all.model_id, set->model_sub_delete_all.company_id)); + return bt_mesh_cfg_mod_sub_del_all(&ctx, set->model_sub_delete_all.element_addr, + set->model_sub_delete_all.model_id, + set->model_sub_delete_all.company_id); case ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE: - return (cb->error_code = - bt_mesh_cfg_net_key_update(&ctx, set->net_key_update.net_idx, - set->net_key_update.net_key)); + return bt_mesh_cfg_net_key_update(&ctx, set->net_key_update.net_idx, + set->net_key_update.net_key); case ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE: - return (cb->error_code = - bt_mesh_cfg_net_key_delete(&ctx, set->net_key_delete.net_idx)); + return bt_mesh_cfg_net_key_delete(&ctx, set->net_key_delete.net_idx); case ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE: - return (cb->error_code = - bt_mesh_cfg_app_key_update(&ctx, set->app_key_update.net_idx, - set->app_key_update.app_idx, set->app_key_update.app_key)); + return bt_mesh_cfg_app_key_update(&ctx, set->app_key_update.net_idx, + set->app_key_update.app_idx, + set->app_key_update.app_key); case ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE: - return (cb->error_code = - bt_mesh_cfg_app_key_delete(&ctx, set->app_key_delete.net_idx, - set->app_key_delete.app_idx)); + return bt_mesh_cfg_app_key_delete(&ctx, set->app_key_delete.net_idx, + set->app_key_delete.app_idx); case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET: - return (cb->error_code = - bt_mesh_cfg_node_identity_set(&ctx, set->node_identity_set.net_idx, - set->node_identity_set.identity)); + return bt_mesh_cfg_node_identity_set(&ctx, set->node_identity_set.net_idx, + set->node_identity_set.identity); case ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND: - return (cb->error_code = - bt_mesh_cfg_mod_app_unbind(&ctx, set->model_app_unbind.element_addr, - set->model_app_unbind.model_app_idx, set->model_app_unbind.model_id, - set->model_app_unbind.company_id)); + return bt_mesh_cfg_mod_app_unbind(&ctx, set->model_app_unbind.element_addr, + set->model_app_unbind.model_app_idx, + set->model_app_unbind.model_id, + set->model_app_unbind.company_id); case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET: - return (cb->error_code = - bt_mesh_cfg_kr_phase_set(&ctx, set->kr_phase_set.net_idx, - set->kr_phase_set.transition)); + return bt_mesh_cfg_kr_phase_set(&ctx, set->kr_phase_set.net_idx, + set->kr_phase_set.transition); case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET: - return (cb->error_code = - bt_mesh_cfg_net_transmit_set(&ctx, set->net_transmit_set.net_transmit)); + 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); - return (cb->error_code = -EINVAL); + return -EINVAL; } return 0; @@ -656,9 +641,8 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg) BT_ERR("%s, Failed to set model role", __func__); break; } - btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params, - arg->cfg_client_get_state.get_state, - &cb); + cb.error_code = btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params, + arg->cfg_client_get_state.get_state); if (cb.error_code) { btc_ble_mesh_config_client_callback(&cb, ESP_BLE_MESH_CFG_CLIENT_GET_STATE_EVT); } @@ -672,9 +656,8 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg) BT_ERR("%s, Failed to set model role", __func__); break; } - btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params, - arg->cfg_client_set_state.set_state, - &cb); + cb.error_code = btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params, + arg->cfg_client_set_state.set_state); if (cb.error_code) { btc_ble_mesh_config_client_callback(&cb, ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT); } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c index d94ff1e48a..e3be0c34c3 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c @@ -315,12 +315,11 @@ void btc_ble_mesh_health_publish_callback(u32_t opcode, } static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_health_client_get_state_t *get, - esp_ble_mesh_health_client_cb_param_t *cb) + esp_ble_mesh_health_client_get_state_t *get) { struct bt_mesh_msg_ctx ctx = {0}; - if (!params || !cb) { + if (params == NULL) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } @@ -340,26 +339,25 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param switch (params->opcode) { case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET: - return (cb->error_code = bt_mesh_health_attention_get(&ctx)); + return bt_mesh_health_attention_get(&ctx); case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET: - return (cb->error_code = bt_mesh_health_period_get(&ctx)); + return bt_mesh_health_period_get(&ctx); case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET: - return (cb->error_code = bt_mesh_health_fault_get(&ctx, get->fault_get.company_id)); + return bt_mesh_health_fault_get(&ctx, get->fault_get.company_id); default: BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode); - return (cb->error_code = -EINVAL); + return -EINVAL; } return 0; } static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_health_client_set_state_t *set, - esp_ble_mesh_health_client_cb_param_t *cb) + esp_ble_mesh_health_client_set_state_t *set) { struct bt_mesh_msg_ctx ctx = {0}; - if (!params || !set || !cb) { + if (params == NULL || set == NULL) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } @@ -374,32 +372,24 @@ static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param switch (params->opcode) { case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET: - return (cb->error_code = - bt_mesh_health_attention_set(&ctx, set->attention_set.attention, true)); + return bt_mesh_health_attention_set(&ctx, set->attention_set.attention, true); case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK: - return (cb->error_code = - bt_mesh_health_attention_set(&ctx, set->attention_set.attention, false)); + return bt_mesh_health_attention_set(&ctx, set->attention_set.attention, false); case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET: - return (cb->error_code = - bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, true)); + return bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, true); case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK: - return (cb->error_code = - bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, false)); + return bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, false); case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST: - return (cb->error_code = - bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, true)); + return bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, true); case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK: - return (cb->error_code = - bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, false)); + return bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, false); case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR: - return (cb->error_code = - bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, true)); + return bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, true); case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK: - return (cb->error_code = - bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, false)); + return bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, false); default: BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode); - return (cb->error_code = -EINVAL); + return -EINVAL; } return 0; @@ -427,8 +417,8 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg) BT_ERR("%s, Failed to set model role", __func__); break; } - btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params, - arg->health_client_get_state.get_state, &cb); + cb.error_code = btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params, + arg->health_client_get_state.get_state); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT); @@ -443,8 +433,8 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg) BT_ERR("%s, Failed to set model role", __func__); break; } - btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params, - arg->health_client_set_state.set_state, &cb); + cb.error_code = btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params, + arg->health_client_set_state.set_state); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT);