mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
ble_mesh: stack: Only keep func pointer for very common log
Currently only keep func pointer for the followings: - Invalid parameter (mesh btc & mesh stack) - Out of memory (mesh btc & mesh stack) - Unknown act (mesh btc) - Invalid model user data (mesh stack) - BT_DBG("%s", __func__) (mesh btc & mesh stack) - A few other specific situations (buf ref debug, send status check)
This commit is contained in:
@@ -48,10 +48,9 @@ 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,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf, bool need_pub)
|
||||
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)
|
||||
{
|
||||
bt_mesh_client_internal_data_t *data = NULL;
|
||||
bt_mesh_client_user_data_t *cli = NULL;
|
||||
@@ -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,10 +100,9 @@ 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,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf, bool need_pub);
|
||||
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);
|
||||
|
||||
int bt_mesh_client_send_msg(struct bt_mesh_model *model,
|
||||
u32_t opcode,
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user