From 21c5be311c9a49b7dab8dc8cc756ff15ba25045f Mon Sep 17 00:00:00 2001 From: lly Date: Thu, 26 Mar 2020 11:19:17 +0800 Subject: [PATCH] ble_mesh: Add comment explaining use of byte order [Zephyr] Add comment that explains why a different byte order is used for the 3-byte opcode on the CID part of the opcode. --- components/bt/esp_ble_mesh/mesh_core/access.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/bt/esp_ble_mesh/mesh_core/access.c b/components/bt/esp_ble_mesh/mesh_core/access.c index acc48ed53..effc9d47c 100644 --- a/components/bt/esp_ble_mesh/mesh_core/access.c +++ b/components/bt/esp_ble_mesh/mesh_core/access.c @@ -797,6 +797,10 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode) } *opcode = net_buf_simple_pull_u8(buf) << 16; + /* Using LE for the CID since the model layer is defined as + * little-endian in the mesh spec and using BT_MESH_MODEL_OP_3 + * will declare the opcode in this way. + */ *opcode |= net_buf_simple_pull_le16(buf); return 0; } @@ -921,6 +925,10 @@ void bt_mesh_model_msg_init(struct net_buf_simple *msg, u32_t opcode) break; case 3: net_buf_simple_add_u8(msg, ((opcode >> 16) & 0xff)); + /* Using LE for the CID since the model layer is defined as + * little-endian in the mesh spec and using BT_MESH_MODEL_OP_3 + * will declare the opcode in this way. + */ net_buf_simple_add_le16(msg, opcode & 0xffff); break; default: