From: Abhay Agarwal Date: Tue, 1 Sep 2020 05:33:52 +0000 (+0530) Subject: Mesh: Fix model message execution X-Git-Tag: submit/tizen/20200901.064142~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F19%2F242819%2F1;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git Mesh: Fix model message execution Change-Id: I5ed5de49eb724357cbc3d2ccbedceaa7bfbeebac Signed-off-by: Abhay Agarwal --- diff --git a/bt-service/services/mesh/bt-service-mesh-model.c b/bt-service/services/mesh/bt-service-mesh-model.c index 1e191b37..f341f0c3 100644 --- a/bt-service/services/mesh/bt-service-mesh-model.c +++ b/bt-service/services/mesh/bt-service-mesh-model.c @@ -365,6 +365,7 @@ int _bt_mesh_model_execute_msg(const char *app_cred, const char *sender, uint16_t appkey_idx; oal_uuid_t net_uuid; uint16_t data_len; + uint16_t msg_hex_len = 0; uint32_t opcode = 0; uint8_t buffer[MESH_CONFIG_BUFFER_MAX_LEN]; uint8_t msg[BLUETOOTH_MESH_MODEL_MSG_LENGTH_MAX + 1]; @@ -395,17 +396,17 @@ int _bt_mesh_model_execute_msg(const char *app_cred, const char *sender, req->opcode, req->msg_len); if (req->msg_len > 0) { /* Convert Mesh msg to hex*/ - BT_DBG("Mesh: Model string msg opcode: 0x%2.2X msg_len: %zd, msg: %s", - req->opcode, strlen(req->msg), req->msg); - _bt_mesh_util_convert_string_to_hex(req->msg, strlen(req->msg), msg, (req->msg_len)/2); + BT_DBG("Mesh: Model string msg_len: %zd, msg: %s", strlen(req->msg), req->msg); + msg_hex_len = req->msg_len/2; + _bt_mesh_util_convert_string_to_hex(req->msg, strlen(req->msg), msg, msg_hex_len); - for (int msg_idx = 0; msg_idx < (req->msg_len)/2; msg_idx++) + for (int msg_idx = 0; msg_idx < msg_hex_len; msg_idx++) BT_DBG("Mesh: Model hex msg[%d]: msg: 0x%2.2X", msg_idx, msg[msg_idx]); /* Append model msg */ - if (req->msg_len > 0) { - memcpy(buffer + data_len, msg, req->msg_len); - data_len += req->msg_len; + if (msg_hex_len > 0) { + memcpy(buffer + data_len, msg, msg_hex_len); + data_len += msg_hex_len; } }