mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ble_mesh: stack: Update client model msg send
This commit is contained in:
parent
91cf59981c
commit
dfd0cd5f3e
@ -20,8 +20,6 @@
|
||||
#include "cfg_cli.h"
|
||||
#include "esp_ble_mesh_config_model_api.h"
|
||||
|
||||
extern s32_t config_msg_timeout;
|
||||
|
||||
/* Configuration Client Model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_config_client_cb_to_app(esp_ble_mesh_cfg_client_cb_event_t event,
|
||||
@ -383,7 +381,7 @@ void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_mo
|
||||
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)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@ -410,63 +408,64 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
|
||||
break;
|
||||
}
|
||||
|
||||
ctx.net_idx = params->ctx.net_idx;
|
||||
ctx.app_idx = BLE_MESH_KEY_DEV;
|
||||
ctx.addr = params->ctx.addr;
|
||||
ctx.send_rel = params->ctx.send_rel;
|
||||
ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = BLE_MESH_KEY_DEV;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
|
||||
config_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BEACON_GET:
|
||||
return bt_mesh_cfg_beacon_get(&ctx);
|
||||
return bt_mesh_cfg_beacon_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET:
|
||||
return bt_mesh_cfg_ttl_get(&ctx);
|
||||
return bt_mesh_cfg_ttl_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_FRIEND_GET:
|
||||
return bt_mesh_cfg_friend_get(&ctx);
|
||||
return bt_mesh_cfg_friend_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET:
|
||||
return bt_mesh_cfg_gatt_proxy_get(&ctx);
|
||||
return bt_mesh_cfg_gatt_proxy_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_RELAY_GET:
|
||||
return bt_mesh_cfg_relay_get(&ctx);
|
||||
return bt_mesh_cfg_relay_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
|
||||
return bt_mesh_cfg_mod_pub_get(&ctx, get->model_pub_get.element_addr,
|
||||
return bt_mesh_cfg_mod_pub_get(¶m, 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 bt_mesh_cfg_hb_pub_get(&ctx);
|
||||
return bt_mesh_cfg_hb_pub_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET:
|
||||
return bt_mesh_cfg_hb_sub_get(&ctx);
|
||||
return bt_mesh_cfg_hb_sub_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
|
||||
return bt_mesh_cfg_comp_data_get(&ctx, get->comp_data_get.page);
|
||||
return bt_mesh_cfg_comp_data_get(¶m, get->comp_data_get.page);
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
|
||||
return bt_mesh_cfg_mod_sub_get(&ctx, get->sig_model_sub_get.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_get(¶m, 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 bt_mesh_cfg_mod_sub_get_vnd(&ctx, get->vnd_model_sub_get.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_get_vnd(¶m, 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 bt_mesh_cfg_net_key_get(&ctx);
|
||||
return bt_mesh_cfg_net_key_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
|
||||
return bt_mesh_cfg_app_key_get(&ctx, get->app_key_get.net_idx);
|
||||
return bt_mesh_cfg_app_key_get(¶m, get->app_key_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET:
|
||||
return bt_mesh_cfg_node_identity_get(&ctx, get->node_identity_get.net_idx);
|
||||
return bt_mesh_cfg_node_identity_get(¶m, get->node_identity_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
|
||||
return bt_mesh_cfg_mod_app_get(&ctx, get->sig_model_app_get.element_addr,
|
||||
return bt_mesh_cfg_mod_app_get(¶m, 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 bt_mesh_cfg_mod_app_get_vnd(&ctx, get->vnd_model_app_get.element_addr,
|
||||
return bt_mesh_cfg_mod_app_get_vnd(¶m, 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 bt_mesh_cfg_kr_phase_get(&ctx, get->kr_phase_get.net_idx);
|
||||
return bt_mesh_cfg_kr_phase_get(¶m, get->kr_phase_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
|
||||
return bt_mesh_cfg_lpn_timeout_get(&ctx, get->lpn_pollto_get.lpn_addr);
|
||||
return bt_mesh_cfg_lpn_timeout_get(¶m, get->lpn_pollto_get.lpn_addr);
|
||||
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET:
|
||||
return bt_mesh_cfg_net_transmit_get(&ctx);
|
||||
return bt_mesh_cfg_net_transmit_get(¶m);
|
||||
default:
|
||||
BT_ERR("Invalid Configuration Get opcode 0x%04x", params->opcode);
|
||||
BT_ERR("Invalid Configuration Get opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -476,7 +475,7 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
|
||||
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)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@ -488,35 +487,36 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx.net_idx = params->ctx.net_idx;
|
||||
ctx.app_idx = BLE_MESH_KEY_DEV;
|
||||
ctx.addr = params->ctx.addr;
|
||||
ctx.send_rel = params->ctx.send_rel;
|
||||
ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = BLE_MESH_KEY_DEV;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
|
||||
config_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BEACON_SET:
|
||||
return bt_mesh_cfg_beacon_set(&ctx, set->beacon_set.beacon);
|
||||
return bt_mesh_cfg_beacon_set(¶m, set->beacon_set.beacon);
|
||||
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET:
|
||||
return bt_mesh_cfg_ttl_set(&ctx, set->default_ttl_set.ttl);
|
||||
return bt_mesh_cfg_ttl_set(¶m, set->default_ttl_set.ttl);
|
||||
case ESP_BLE_MESH_MODEL_OP_FRIEND_SET:
|
||||
return bt_mesh_cfg_friend_set(&ctx, set->friend_set.friend_state);
|
||||
return bt_mesh_cfg_friend_set(¶m, set->friend_set.friend_state);
|
||||
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET:
|
||||
return bt_mesh_cfg_gatt_proxy_set(&ctx, set->gatt_proxy_set.gatt_proxy);
|
||||
return bt_mesh_cfg_gatt_proxy_set(¶m, set->gatt_proxy_set.gatt_proxy);
|
||||
case ESP_BLE_MESH_MODEL_OP_RELAY_SET:
|
||||
return bt_mesh_cfg_relay_set(&ctx, set->relay_set.relay,
|
||||
return bt_mesh_cfg_relay_set(¶m, set->relay_set.relay,
|
||||
set->relay_set.relay_retransmit);
|
||||
case ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD:
|
||||
return bt_mesh_cfg_net_key_add(&ctx, set->net_key_add.net_idx,
|
||||
return bt_mesh_cfg_net_key_add(¶m, set->net_key_add.net_idx,
|
||||
&set->net_key_add.net_key[0]);
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD:
|
||||
return bt_mesh_cfg_app_key_add(&ctx, set->app_key_add.net_idx,
|
||||
return bt_mesh_cfg_app_key_add(¶m, 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 bt_mesh_cfg_mod_app_bind(&ctx, set->model_app_bind.element_addr,
|
||||
return bt_mesh_cfg_mod_app_bind(¶m, 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);
|
||||
@ -529,46 +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 bt_mesh_cfg_mod_pub_set(&ctx, set->model_pub_set.element_addr,
|
||||
return bt_mesh_cfg_mod_pub_set(¶m, 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 bt_mesh_cfg_mod_sub_add(&ctx, set->model_sub_add.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_add(¶m, 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 bt_mesh_cfg_mod_sub_del(&ctx, set->model_sub_delete.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_del(¶m, 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 bt_mesh_cfg_mod_sub_overwrite(&ctx, set->model_sub_overwrite.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_overwrite(¶m, 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 bt_mesh_cfg_mod_sub_va_add(&ctx, set->model_sub_va_add.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_va_add(¶m, 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 bt_mesh_cfg_mod_sub_va_overwrite(&ctx, set->model_sub_va_overwrite.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_va_overwrite(¶m, 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 bt_mesh_cfg_mod_sub_va_del(&ctx, set->model_sub_va_delete.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_va_del(¶m, 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 bt_mesh_cfg_hb_sub_set(&ctx, (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set);
|
||||
return bt_mesh_cfg_hb_sub_set(¶m, (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET:
|
||||
return 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(¶m, (struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set);
|
||||
case ESP_BLE_MESH_MODEL_OP_NODE_RESET:
|
||||
return bt_mesh_cfg_node_reset(&ctx);
|
||||
return bt_mesh_cfg_node_reset(¶m);
|
||||
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,
|
||||
@ -577,42 +577,42 @@ 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 bt_mesh_cfg_mod_pub_va_set(&ctx, set->model_pub_va_set.element_addr,
|
||||
return bt_mesh_cfg_mod_pub_va_set(¶m, 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 bt_mesh_cfg_mod_sub_del_all(&ctx, set->model_sub_delete_all.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_del_all(¶m, 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 bt_mesh_cfg_net_key_update(&ctx, set->net_key_update.net_idx,
|
||||
return bt_mesh_cfg_net_key_update(¶m, set->net_key_update.net_idx,
|
||||
set->net_key_update.net_key);
|
||||
case ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE:
|
||||
return bt_mesh_cfg_net_key_delete(&ctx, set->net_key_delete.net_idx);
|
||||
return bt_mesh_cfg_net_key_delete(¶m, set->net_key_delete.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE:
|
||||
return bt_mesh_cfg_app_key_update(&ctx, set->app_key_update.net_idx,
|
||||
return bt_mesh_cfg_app_key_update(¶m, 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 bt_mesh_cfg_app_key_delete(&ctx, set->app_key_delete.net_idx,
|
||||
return bt_mesh_cfg_app_key_delete(¶m, set->app_key_delete.net_idx,
|
||||
set->app_key_delete.app_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET:
|
||||
return bt_mesh_cfg_node_identity_set(&ctx, set->node_identity_set.net_idx,
|
||||
return bt_mesh_cfg_node_identity_set(¶m, set->node_identity_set.net_idx,
|
||||
set->node_identity_set.identity);
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND:
|
||||
return bt_mesh_cfg_mod_app_unbind(&ctx, set->model_app_unbind.element_addr,
|
||||
return bt_mesh_cfg_mod_app_unbind(¶m, 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 bt_mesh_cfg_kr_phase_set(&ctx, set->kr_phase_set.net_idx,
|
||||
return bt_mesh_cfg_kr_phase_set(¶m, set->kr_phase_set.net_idx,
|
||||
set->kr_phase_set.transition);
|
||||
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET:
|
||||
return bt_mesh_cfg_net_transmit_set(&ctx, set->net_transmit_set.net_transmit);
|
||||
return bt_mesh_cfg_net_transmit_set(¶m, set->net_transmit_set.net_transmit);
|
||||
default:
|
||||
BT_ERR("Invalid Configuration Set opcode 0x%04x", params->opcode);
|
||||
BT_ERR("Invalid Configuration Set opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,6 @@
|
||||
#include "health_cli.h"
|
||||
#include "esp_ble_mesh_health_model_api.h"
|
||||
|
||||
extern s32_t health_msg_timeout;
|
||||
|
||||
/* Health Client Model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_health_client_cb_to_app(esp_ble_mesh_health_client_cb_event_t event,
|
||||
@ -317,7 +315,7 @@ void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *mo
|
||||
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)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@ -329,23 +327,24 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx.net_idx = params->ctx.net_idx;
|
||||
ctx.app_idx = params->ctx.app_idx;
|
||||
ctx.addr = params->ctx.addr;
|
||||
ctx.send_rel = params->ctx.send_rel;
|
||||
ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = params->ctx.app_idx;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
|
||||
health_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
|
||||
return bt_mesh_health_attention_get(&ctx);
|
||||
return bt_mesh_health_attention_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
|
||||
return bt_mesh_health_period_get(&ctx);
|
||||
return bt_mesh_health_period_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
|
||||
return bt_mesh_health_fault_get(&ctx, get->fault_get.company_id);
|
||||
return bt_mesh_health_fault_get(¶m, get->fault_get.company_id);
|
||||
default:
|
||||
BT_ERR("Invalid Health Get opcode 0x%04x", params->opcode);
|
||||
BT_ERR("Invalid Health Get opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -355,40 +354,41 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param
|
||||
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)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL || set == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx.net_idx = params->ctx.net_idx;
|
||||
ctx.app_idx = params->ctx.app_idx;
|
||||
ctx.addr = params->ctx.addr;
|
||||
ctx.send_rel = params->ctx.send_rel;
|
||||
ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = params->ctx.app_idx;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
|
||||
health_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
|
||||
return bt_mesh_health_attention_set(&ctx, set->attention_set.attention, true);
|
||||
return bt_mesh_health_attention_set(¶m, set->attention_set.attention, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
|
||||
return bt_mesh_health_attention_set(&ctx, set->attention_set.attention, false);
|
||||
return bt_mesh_health_attention_set(¶m, set->attention_set.attention, false);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
|
||||
return bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, true);
|
||||
return bt_mesh_health_period_set(¶m, set->period_set.fast_period_divisor, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
|
||||
return bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, false);
|
||||
return bt_mesh_health_period_set(¶m, set->period_set.fast_period_divisor, false);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
|
||||
return bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, true);
|
||||
return bt_mesh_health_fault_test(¶m, set->fault_test.company_id, set->fault_test.test_id, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK:
|
||||
return bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, false);
|
||||
return bt_mesh_health_fault_test(¶m, set->fault_test.company_id, set->fault_test.test_id, false);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
|
||||
return bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, true);
|
||||
return bt_mesh_health_fault_clear(¶m, set->fault_clear.company_id, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
|
||||
return bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, false);
|
||||
return bt_mesh_health_fault_clear(¶m, set->fault_clear.company_id, false);
|
||||
default:
|
||||
BT_ERR("Invalid Health Set opcode 0x%04x", params->opcode);
|
||||
BT_ERR("Invalid Health Set opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2016,18 +2016,25 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
net_buf_simple_add_mem(buf, arg->model_send.data, arg->model_send.length);
|
||||
arg->model_send.ctx->srv_send = false;
|
||||
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("Failed to set model role");
|
||||
break;
|
||||
}
|
||||
err = bt_mesh_client_send_msg((struct bt_mesh_model *)arg->model_send.model,
|
||||
arg->model_send.opcode,
|
||||
(struct bt_mesh_msg_ctx *)arg->model_send.ctx, buf,
|
||||
btc_ble_mesh_client_model_timeout_cb, arg->model_send.msg_timeout,
|
||||
arg->model_send.need_rsp, NULL, NULL);
|
||||
bt_mesh_client_common_param_t param = {
|
||||
.opcode = arg->model_send.opcode,
|
||||
.model = (struct bt_mesh_model *)arg->model_send.model,
|
||||
.ctx.net_idx = arg->model_send.ctx->net_idx,
|
||||
.ctx.app_idx = arg->model_send.ctx->app_idx,
|
||||
.ctx.addr = arg->model_send.ctx->addr,
|
||||
.ctx.send_rel = arg->model_send.ctx->send_rel,
|
||||
.ctx.send_ttl = arg->model_send.ctx->send_ttl,
|
||||
.ctx.srv_send = false,
|
||||
.msg_timeout = arg->model_send.msg_timeout,
|
||||
};
|
||||
err = bt_mesh_client_send_msg(¶m, buf, arg->model_send.need_rsp,
|
||||
btc_ble_mesh_client_model_timeout_cb);
|
||||
bt_mesh_free_buf(buf);
|
||||
btc_ble_mesh_model_send_comp_cb(arg->model_send.model, arg->model_send.ctx,
|
||||
arg->model_send.opcode, err);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -235,20 +235,14 @@ const struct bt_mesh_model_op bt_mesh_health_cli_op[] = {
|
||||
BLE_MESH_MODEL_OP_END,
|
||||
};
|
||||
|
||||
int bt_mesh_health_attention_get(struct bt_mesh_msg_ctx *ctx)
|
||||
int bt_mesh_health_attention_get(bt_mesh_client_common_param_t *param)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_ATTENTION_GET, 0);
|
||||
int err = 0;
|
||||
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bt_mesh_model_msg_init(&msg, OP_ATTENTION_GET);
|
||||
|
||||
err = bt_mesh_client_send_msg(health_cli->model, OP_ATTENTION_GET, ctx,
|
||||
&msg, timeout_handler, health_msg_timeout,
|
||||
true, NULL, NULL);
|
||||
err = bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
@ -256,28 +250,16 @@ int bt_mesh_health_attention_get(struct bt_mesh_msg_ctx *ctx)
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_health_attention_set(struct bt_mesh_msg_ctx *ctx,
|
||||
int bt_mesh_health_attention_set(bt_mesh_client_common_param_t *param,
|
||||
u8_t attention, bool need_ack)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_ATTENTION_SET, 1);
|
||||
u32_t opcode = 0U;
|
||||
int err = 0;
|
||||
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (need_ack) {
|
||||
opcode = OP_ATTENTION_SET;
|
||||
} else {
|
||||
opcode = OP_ATTENTION_SET_UNREL;
|
||||
}
|
||||
bt_mesh_model_msg_init(&msg, opcode);
|
||||
bt_mesh_model_msg_init(&msg, need_ack ? OP_ATTENTION_SET : OP_ATTENTION_SET_UNREL);
|
||||
net_buf_simple_add_u8(&msg, attention);
|
||||
|
||||
err = bt_mesh_client_send_msg(health_cli->model, opcode, ctx, &msg,
|
||||
timeout_handler, health_msg_timeout,
|
||||
need_ack, NULL, NULL);
|
||||
err = bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
@ -285,20 +267,14 @@ int bt_mesh_health_attention_set(struct bt_mesh_msg_ctx *ctx,
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_health_period_get(struct bt_mesh_msg_ctx *ctx)
|
||||
int bt_mesh_health_period_get(bt_mesh_client_common_param_t *param)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_PERIOD_GET, 0);
|
||||
int err = 0;
|
||||
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bt_mesh_model_msg_init(&msg, OP_HEALTH_PERIOD_GET);
|
||||
|
||||
err = bt_mesh_client_send_msg(health_cli->model, OP_HEALTH_PERIOD_GET,
|
||||
ctx, &msg, timeout_handler, health_msg_timeout,
|
||||
true, NULL, NULL);
|
||||
err = bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
@ -306,28 +282,16 @@ int bt_mesh_health_period_get(struct bt_mesh_msg_ctx *ctx)
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_health_period_set(struct bt_mesh_msg_ctx *ctx,
|
||||
int bt_mesh_health_period_set(bt_mesh_client_common_param_t *param,
|
||||
u8_t divisor, bool need_ack)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_PERIOD_SET, 1);
|
||||
u32_t opcode = 0U;
|
||||
int err = 0;
|
||||
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (need_ack) {
|
||||
opcode = OP_HEALTH_PERIOD_SET;
|
||||
} else {
|
||||
opcode = OP_HEALTH_PERIOD_SET_UNREL;
|
||||
}
|
||||
bt_mesh_model_msg_init(&msg, opcode);
|
||||
bt_mesh_model_msg_init(&msg, need_ack ? OP_HEALTH_PERIOD_SET : OP_HEALTH_PERIOD_SET_UNREL);
|
||||
net_buf_simple_add_u8(&msg, divisor);
|
||||
|
||||
err = bt_mesh_client_send_msg(health_cli->model, opcode, ctx, &msg,
|
||||
timeout_handler, health_msg_timeout,
|
||||
need_ack, NULL, NULL);
|
||||
err = bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
@ -335,29 +299,17 @@ int bt_mesh_health_period_set(struct bt_mesh_msg_ctx *ctx,
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_health_fault_test(struct bt_mesh_msg_ctx *ctx,
|
||||
int bt_mesh_health_fault_test(bt_mesh_client_common_param_t *param,
|
||||
u16_t cid, u8_t test_id, bool need_ack)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_TEST, 3);
|
||||
u32_t opcode = 0U;
|
||||
int err = 0;
|
||||
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (need_ack) {
|
||||
opcode = OP_HEALTH_FAULT_TEST;
|
||||
} else {
|
||||
opcode = OP_HEALTH_FAULT_TEST_UNREL;
|
||||
}
|
||||
bt_mesh_model_msg_init(&msg, opcode);
|
||||
bt_mesh_model_msg_init(&msg, need_ack ? OP_HEALTH_FAULT_TEST : OP_HEALTH_FAULT_TEST_UNREL);
|
||||
net_buf_simple_add_u8(&msg, test_id);
|
||||
net_buf_simple_add_le16(&msg, cid);
|
||||
|
||||
err = bt_mesh_client_send_msg(health_cli->model, opcode, ctx, &msg,
|
||||
timeout_handler, health_msg_timeout,
|
||||
need_ack, NULL, NULL);
|
||||
err = bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
@ -365,28 +317,16 @@ int bt_mesh_health_fault_test(struct bt_mesh_msg_ctx *ctx,
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_health_fault_clear(struct bt_mesh_msg_ctx *ctx,
|
||||
int bt_mesh_health_fault_clear(bt_mesh_client_common_param_t *param,
|
||||
u16_t cid, bool need_ack)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_CLEAR, 2);
|
||||
u32_t opcode = 0U;
|
||||
int err = 0;
|
||||
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (need_ack) {
|
||||
opcode = OP_HEALTH_FAULT_CLEAR;
|
||||
} else {
|
||||
opcode = OP_HEALTH_FAULT_CLEAR_UNREL;
|
||||
}
|
||||
bt_mesh_model_msg_init(&msg, opcode);
|
||||
bt_mesh_model_msg_init(&msg, need_ack ? OP_HEALTH_FAULT_CLEAR : OP_HEALTH_FAULT_CLEAR_UNREL);
|
||||
net_buf_simple_add_le16(&msg, cid);
|
||||
|
||||
err = bt_mesh_client_send_msg(health_cli->model, opcode, ctx, &msg,
|
||||
timeout_handler, health_msg_timeout,
|
||||
need_ack, NULL, NULL);
|
||||
err = bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
@ -394,21 +334,15 @@ int bt_mesh_health_fault_clear(struct bt_mesh_msg_ctx *ctx,
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_health_fault_get(struct bt_mesh_msg_ctx *ctx, u16_t cid)
|
||||
int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, u16_t cid)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_GET, 2);
|
||||
int err = 0;
|
||||
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bt_mesh_model_msg_init(&msg, OP_HEALTH_FAULT_GET);
|
||||
net_buf_simple_add_le16(&msg, cid);
|
||||
|
||||
err = bt_mesh_client_send_msg(health_cli->model, OP_HEALTH_FAULT_GET, ctx,
|
||||
&msg, timeout_handler, health_msg_timeout,
|
||||
true, NULL, NULL);
|
||||
err = bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
|
@ -34,36 +34,39 @@ extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[];
|
||||
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_CFG_CLI, \
|
||||
bt_mesh_cfg_cli_op, NULL, cli_data)
|
||||
|
||||
int bt_mesh_cfg_comp_data_get(struct bt_mesh_msg_ctx *ctx, u8_t page);
|
||||
int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, u8_t page);
|
||||
|
||||
int bt_mesh_cfg_beacon_get(struct bt_mesh_msg_ctx *ctx);
|
||||
int bt_mesh_cfg_beacon_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_beacon_set(struct bt_mesh_msg_ctx *ctx, u8_t val);
|
||||
int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, u8_t val);
|
||||
|
||||
int bt_mesh_cfg_ttl_get(struct bt_mesh_msg_ctx *ctx);
|
||||
int bt_mesh_cfg_ttl_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_ttl_set(struct bt_mesh_msg_ctx *ctx, u8_t val);
|
||||
int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, u8_t val);
|
||||
|
||||
int bt_mesh_cfg_friend_get(struct bt_mesh_msg_ctx *ctx);
|
||||
int bt_mesh_cfg_friend_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_friend_set(struct bt_mesh_msg_ctx *ctx, u8_t val);
|
||||
int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, u8_t val);
|
||||
|
||||
int bt_mesh_cfg_gatt_proxy_get(struct bt_mesh_msg_ctx *ctx);
|
||||
int bt_mesh_cfg_gatt_proxy_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_gatt_proxy_set(struct bt_mesh_msg_ctx *ctx, u8_t val);
|
||||
int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, u8_t val);
|
||||
|
||||
int bt_mesh_cfg_relay_get(struct bt_mesh_msg_ctx *ctx);
|
||||
int bt_mesh_cfg_relay_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_relay_set(struct bt_mesh_msg_ctx *ctx, u8_t new_relay, u8_t new_transmit);
|
||||
int bt_mesh_cfg_relay_set(bt_mesh_client_common_param_t *param,
|
||||
u8_t relay, u8_t retransmit);
|
||||
|
||||
int bt_mesh_cfg_net_key_add(struct bt_mesh_msg_ctx *ctx, u16_t key_net_idx,
|
||||
const u8_t net_key[16]);
|
||||
int bt_mesh_cfg_net_key_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, const u8_t net_key[16]);
|
||||
|
||||
int bt_mesh_cfg_app_key_add(struct bt_mesh_msg_ctx *ctx, u16_t key_net_idx,
|
||||
u16_t key_app_idx, const u8_t app_key[16]);
|
||||
int bt_mesh_cfg_app_key_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u16_t app_idx,
|
||||
const u8_t app_key[16]);
|
||||
|
||||
int bt_mesh_cfg_mod_app_bind(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_app_idx, u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_app_bind(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t app_idx,
|
||||
u16_t mod_id, u16_t cid);
|
||||
|
||||
struct bt_mesh_cfg_mod_pub {
|
||||
u16_t addr;
|
||||
@ -74,30 +77,36 @@ struct bt_mesh_cfg_mod_pub {
|
||||
u8_t transmit;
|
||||
};
|
||||
|
||||
int bt_mesh_cfg_mod_pub_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_pub_get(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_pub_set(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_id, u16_t cid,
|
||||
int bt_mesh_cfg_mod_pub_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid,
|
||||
struct bt_mesh_cfg_mod_pub *pub);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_add(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t sub_addr, u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_del(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t sub_addr, u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_del(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_overwrite(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t sub_addr, u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_overwrite(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_va_add(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
const u8_t label[16], u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_va_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, const u8_t label[16],
|
||||
u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_va_del(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
const u8_t label[16], u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_va_del(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, const u8_t label[16],
|
||||
u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_va_overwrite(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
const u8_t label[16], u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_va_overwrite(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, const u8_t label[16],
|
||||
u16_t mod_id, u16_t cid);
|
||||
|
||||
struct bt_mesh_cfg_hb_sub {
|
||||
u16_t src;
|
||||
@ -105,10 +114,10 @@ struct bt_mesh_cfg_hb_sub {
|
||||
u8_t period;
|
||||
};
|
||||
|
||||
int bt_mesh_cfg_hb_sub_set(struct bt_mesh_msg_ctx *ctx,
|
||||
int bt_mesh_cfg_hb_sub_set(bt_mesh_client_common_param_t *param,
|
||||
struct bt_mesh_cfg_hb_sub *sub);
|
||||
|
||||
int bt_mesh_cfg_hb_sub_get(struct bt_mesh_msg_ctx *ctx);
|
||||
int bt_mesh_cfg_hb_sub_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
struct bt_mesh_cfg_hb_pub {
|
||||
u16_t dst;
|
||||
@ -119,12 +128,12 @@ struct bt_mesh_cfg_hb_pub {
|
||||
u16_t net_idx;
|
||||
};
|
||||
|
||||
int bt_mesh_cfg_hb_pub_set(struct bt_mesh_msg_ctx *ctx,
|
||||
const struct bt_mesh_cfg_hb_pub *pub);
|
||||
int bt_mesh_cfg_hb_pub_set(bt_mesh_client_common_param_t *param,
|
||||
struct bt_mesh_cfg_hb_pub *pub);
|
||||
|
||||
int bt_mesh_cfg_hb_pub_get(struct bt_mesh_msg_ctx *ctx);
|
||||
int bt_mesh_cfg_hb_pub_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_node_reset(struct bt_mesh_msg_ctx *ctx);
|
||||
int bt_mesh_cfg_node_reset(bt_mesh_client_common_param_t *param);
|
||||
|
||||
s32_t bt_mesh_cfg_cli_timeout_get(void);
|
||||
void bt_mesh_cfg_cli_timeout_set(s32_t timeout);
|
||||
@ -244,53 +253,61 @@ struct bt_mesh_cfg_lpn_pollto_status {
|
||||
s32_t timeout;
|
||||
};
|
||||
|
||||
int bt_mesh_cfg_mod_pub_va_set(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_id, u16_t cid, const u8_t label[16],
|
||||
int bt_mesh_cfg_mod_pub_va_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id,
|
||||
u16_t cid, const u8_t label[16],
|
||||
struct bt_mesh_cfg_mod_pub *pub);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_del_all(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_del_all(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, u16_t mod_id);
|
||||
int bt_mesh_cfg_mod_sub_get(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_get_vnd(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_get_vnd(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_net_key_update(struct bt_mesh_msg_ctx *ctx, u16_t net_idx,
|
||||
const u8_t net_key[16]);
|
||||
int bt_mesh_cfg_net_key_update(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, const u8_t net_key[16]);
|
||||
|
||||
int bt_mesh_cfg_net_key_delete(struct bt_mesh_msg_ctx *ctx, u16_t net_idx);
|
||||
int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, u16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_net_key_get(struct bt_mesh_msg_ctx *ctx);
|
||||
int bt_mesh_cfg_net_key_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_app_key_update(struct bt_mesh_msg_ctx *ctx, u16_t net_idx,
|
||||
u16_t app_idx, const u8_t app_key[16]);
|
||||
int bt_mesh_cfg_app_key_update(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u16_t app_idx,
|
||||
const u8_t app_key[16]);
|
||||
|
||||
int bt_mesh_cfg_app_key_delete(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u16_t app_idx);
|
||||
int bt_mesh_cfg_app_key_delete(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u16_t app_idx);
|
||||
|
||||
int bt_mesh_cfg_app_key_get(struct bt_mesh_msg_ctx *ctx, u16_t net_idx);
|
||||
int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, u16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_node_identity_get(struct bt_mesh_msg_ctx *ctx, u16_t net_idx);
|
||||
int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, u16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_node_identity_set(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u8_t identity);
|
||||
int bt_mesh_cfg_node_identity_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u8_t identity);
|
||||
|
||||
int bt_mesh_cfg_mod_app_unbind(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t app_idx, u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_app_unbind(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t app_idx,
|
||||
u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_app_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, u16_t mod_id);
|
||||
int bt_mesh_cfg_mod_app_get(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id);
|
||||
|
||||
int bt_mesh_cfg_mod_app_get_vnd(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_app_get_vnd(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_kr_phase_get(struct bt_mesh_msg_ctx *ctx, u16_t net_idx);
|
||||
int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, u16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_kr_phase_set(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u8_t transition);
|
||||
int bt_mesh_cfg_kr_phase_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u8_t transition);
|
||||
|
||||
int bt_mesh_cfg_lpn_timeout_get(struct bt_mesh_msg_ctx *ctx, u16_t lpn_addr);
|
||||
int bt_mesh_cfg_lpn_timeout_get(bt_mesh_client_common_param_t *param, u16_t lpn_addr);
|
||||
|
||||
int bt_mesh_cfg_net_transmit_get(struct bt_mesh_msg_ctx *ctx);
|
||||
int bt_mesh_cfg_net_transmit_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_net_transmit_set(struct bt_mesh_msg_ctx *ctx, u8_t transmit);
|
||||
int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, u8_t transmit);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -36,22 +36,22 @@ extern const struct bt_mesh_model_op bt_mesh_health_cli_op[];
|
||||
|
||||
int bt_mesh_health_cli_set(struct bt_mesh_model *model);
|
||||
|
||||
int bt_mesh_health_fault_get(struct bt_mesh_msg_ctx *ctx, u16_t cid);
|
||||
int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, u16_t cid);
|
||||
|
||||
int bt_mesh_health_fault_clear(struct bt_mesh_msg_ctx *ctx, u16_t cid,
|
||||
bool need_ack);
|
||||
int bt_mesh_health_fault_clear(bt_mesh_client_common_param_t *param,
|
||||
u16_t cid, bool need_ack);
|
||||
|
||||
int bt_mesh_health_fault_test(struct bt_mesh_msg_ctx *ctx,
|
||||
int bt_mesh_health_fault_test(bt_mesh_client_common_param_t *param,
|
||||
u16_t cid, u8_t test_id, bool need_ack);
|
||||
|
||||
int bt_mesh_health_period_get(struct bt_mesh_msg_ctx *ctx);
|
||||
int bt_mesh_health_period_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_health_period_set(struct bt_mesh_msg_ctx *ctx,
|
||||
int bt_mesh_health_period_set(bt_mesh_client_common_param_t *param,
|
||||
u8_t divisor, bool need_ack);
|
||||
|
||||
int bt_mesh_health_attention_get(struct bt_mesh_msg_ctx *ctx);
|
||||
int bt_mesh_health_attention_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_health_attention_set(struct bt_mesh_msg_ctx *ctx,
|
||||
int bt_mesh_health_attention_set(bt_mesh_client_common_param_t *param,
|
||||
u8_t attention, bool need_ack);
|
||||
|
||||
s32_t bt_mesh_health_cli_timeout_get(void);
|
||||
|
@ -251,26 +251,21 @@ static const struct bt_mesh_send_cb send_cb = {
|
||||
.end = NULL,
|
||||
};
|
||||
|
||||
int bt_mesh_client_send_msg(struct bt_mesh_model *model,
|
||||
u32_t opcode,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *msg,
|
||||
k_work_handler_t timer_handler,
|
||||
s32_t timeout, bool need_ack,
|
||||
const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data)
|
||||
int bt_mesh_client_send_msg(bt_mesh_client_common_param_t *param,
|
||||
struct net_buf_simple *msg, bool need_ack,
|
||||
k_work_handler_t timer_handler)
|
||||
{
|
||||
bt_mesh_client_internal_data_t *internal = NULL;
|
||||
bt_mesh_client_user_data_t *client = NULL;
|
||||
bt_mesh_client_node_t *node = NULL;
|
||||
int err = 0;
|
||||
|
||||
if (!model || !ctx || !msg) {
|
||||
if (!param || !param->model || !msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
client = (bt_mesh_client_user_data_t *)model->user_data;
|
||||
client = (bt_mesh_client_user_data_t *)param->model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("Invalid client user data");
|
||||
return -EINVAL;
|
||||
@ -282,23 +277,23 @@ int bt_mesh_client_send_msg(struct bt_mesh_model *model,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (ctx->addr == BLE_MESH_ADDR_UNASSIGNED) {
|
||||
BT_ERR("Invalid DST 0x%04x", ctx->addr);
|
||||
if (param->ctx.addr == BLE_MESH_ADDR_UNASSIGNED) {
|
||||
BT_ERR("Invalid DST 0x%04x", param->ctx.addr);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!need_ack) {
|
||||
/* If this is an unack message, send it directly. */
|
||||
return bt_mesh_model_send(model, ctx, msg, cb, cb_data);
|
||||
return bt_mesh_model_send(param->model, ¶m->ctx, msg, param->cb, param->cb_data);
|
||||
}
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(ctx->addr)) {
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(param->ctx.addr)) {
|
||||
/* If an acknowledged message is not sent to a unicast address,
|
||||
* for example to a group/virtual address, then all the
|
||||
* corresponding responses will be treated as publish messages.
|
||||
* And no timeout will be used for the message.
|
||||
*/
|
||||
return bt_mesh_model_send(model, ctx, msg, cb, cb_data);
|
||||
return bt_mesh_model_send(param->model, ¶m->ctx, msg, param->cb, param->cb_data);
|
||||
}
|
||||
|
||||
if (!timer_handler) {
|
||||
@ -306,8 +301,8 @@ int bt_mesh_client_send_msg(struct bt_mesh_model *model,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (bt_mesh_client_check_node_in_list(&internal->queue, ctx->addr)) {
|
||||
BT_ERR("Busy sending message to DST 0x%04x", ctx->addr);
|
||||
if (bt_mesh_client_check_node_in_list(&internal->queue, param->ctx.addr)) {
|
||||
BT_ERR("Busy sending message to DST 0x%04x", param->ctx.addr);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
@ -318,16 +313,17 @@ int bt_mesh_client_send_msg(struct bt_mesh_model *model,
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memcpy(&node->ctx, ctx, sizeof(struct bt_mesh_msg_ctx));
|
||||
node->ctx.model = model;
|
||||
node->opcode = opcode;
|
||||
node->op_pending = bt_mesh_client_get_status_op(client->op_pair, client->op_pair_size, opcode);
|
||||
memcpy(&node->ctx, ¶m->ctx, sizeof(struct bt_mesh_msg_ctx));
|
||||
node->ctx.model = param->model;
|
||||
node->opcode = param->opcode;
|
||||
node->op_pending = bt_mesh_client_get_status_op(client->op_pair, client->op_pair_size, param->opcode);
|
||||
if (node->op_pending == 0U) {
|
||||
BT_ERR("Not found the status opcode in op_pair list");
|
||||
bt_mesh_free(node);
|
||||
return -EINVAL;
|
||||
}
|
||||
node->timeout = bt_mesh_client_calc_timeout(ctx, msg, opcode, timeout ? timeout : CONFIG_BLE_MESH_CLIENT_MSG_TIMEOUT);
|
||||
node->timeout = bt_mesh_client_calc_timeout(¶m->ctx, msg, param->opcode,
|
||||
param->msg_timeout ? param->msg_timeout : CONFIG_BLE_MESH_CLIENT_MSG_TIMEOUT);
|
||||
|
||||
if (k_delayed_work_init(&node->timer, timer_handler)) {
|
||||
BT_ERR("Failed to create a timer");
|
||||
@ -343,7 +339,7 @@ int bt_mesh_client_send_msg(struct bt_mesh_model *model,
|
||||
* Due to the higher priority of adv_thread (than btc task), we need to
|
||||
* send the packet after the list item "node" is initialized properly.
|
||||
*/
|
||||
err = bt_mesh_model_send(model, ctx, msg, &send_cb, node);
|
||||
err = bt_mesh_model_send(param->model, ¶m->ctx, msg, &send_cb, node);
|
||||
if (err) {
|
||||
BT_ERR("Failed to send client message 0x%08x", node->opcode);
|
||||
k_delayed_work_free(&node->timer);
|
||||
|
@ -725,9 +725,7 @@ static int gen_get_state(bt_mesh_client_common_param_t *common, void *value)
|
||||
}
|
||||
}
|
||||
|
||||
err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, &msg,
|
||||
timeout_handler, common->msg_timeout, true,
|
||||
common->cb, common->cb_data);
|
||||
err = bt_mesh_client_send_msg(common, &msg, true, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("Failed to send Generic Get message (err %d)", err);
|
||||
}
|
||||
@ -904,9 +902,7 @@ static int gen_set_state(bt_mesh_client_common_param_t *common,
|
||||
goto end;
|
||||
}
|
||||
|
||||
err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, msg,
|
||||
timeout_handler, common->msg_timeout, need_ack,
|
||||
common->cb, common->cb_data);
|
||||
err = bt_mesh_client_send_msg(common, msg, need_ack, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("Failed to send Generic Set message (err %d)", err);
|
||||
}
|
||||
|
@ -104,13 +104,9 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(struct bt_mesh_model *
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf, bool need_pub);
|
||||
|
||||
int bt_mesh_client_send_msg(struct bt_mesh_model *model,
|
||||
u32_t opcode,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *msg,
|
||||
k_work_handler_t timer_handler,
|
||||
s32_t timeout, bool need_ack,
|
||||
const struct bt_mesh_send_cb *cb, void *cb_data);
|
||||
int bt_mesh_client_send_msg(bt_mesh_client_common_param_t *param,
|
||||
struct net_buf_simple *msg, bool need_ack,
|
||||
k_work_handler_t timer_handler);
|
||||
|
||||
int bt_mesh_client_free_node(bt_mesh_client_node_t *node);
|
||||
|
||||
|
@ -790,9 +790,7 @@ static int light_get_state(bt_mesh_client_common_param_t *common, void *value)
|
||||
}
|
||||
}
|
||||
|
||||
err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, &msg,
|
||||
timeout_handler, common->msg_timeout, true,
|
||||
common->cb, common->cb_data);
|
||||
err = bt_mesh_client_send_msg(common, &msg, true, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("Failed to send Lighting Get message (err %d)", err);
|
||||
}
|
||||
@ -1028,9 +1026,7 @@ static int light_set_state(bt_mesh_client_common_param_t *common,
|
||||
goto end;
|
||||
}
|
||||
|
||||
err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, msg,
|
||||
timeout_handler, common->msg_timeout, need_ack,
|
||||
common->cb, common->cb_data);
|
||||
err = bt_mesh_client_send_msg(common, msg, need_ack, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("Failed to send Lighting Set message (err %d)", err);
|
||||
}
|
||||
|
@ -447,9 +447,7 @@ static int sensor_act_state(bt_mesh_client_common_param_t *common,
|
||||
goto end;
|
||||
}
|
||||
|
||||
err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, msg,
|
||||
timeout_handler, common->msg_timeout, need_ack,
|
||||
common->cb, common->cb_data);
|
||||
err = bt_mesh_client_send_msg(common, msg, need_ack, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("Failed to send Sensor client message (err %d)", err);
|
||||
}
|
||||
|
@ -390,9 +390,7 @@ static int time_scene_get_state(bt_mesh_client_common_param_t *common, void *val
|
||||
}
|
||||
}
|
||||
|
||||
err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, &msg,
|
||||
timeout_handler, common->msg_timeout, true,
|
||||
common->cb, common->cb_data);
|
||||
err = bt_mesh_client_send_msg(common, &msg, true, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("Failed to send Time Scene Get message (err %d)", err);
|
||||
}
|
||||
@ -485,9 +483,7 @@ static int time_scene_set_state(bt_mesh_client_common_param_t *common,
|
||||
goto end;
|
||||
}
|
||||
|
||||
err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, msg,
|
||||
timeout_handler, common->msg_timeout, need_ack,
|
||||
common->cb, common->cb_data);
|
||||
err = bt_mesh_client_send_msg(common, msg, need_ack, timeout_handler);
|
||||
if (err) {
|
||||
BT_ERR("Failed to send Time Scene Set message (err %d)", err);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user