Skip to content

Commit 1ac90bf

Browse files
aurel32nashif
authored andcommitted
samples: mesh_badge: fix unknown sensor status message
When the value of an unknown sensor property ID is requested, the length field should represent the value of zero, as explain in the comment in sens_unknown_fill. However the marshalled representation of a zero length is wrong in the code. The format A uses a 1-based uint4 length value, so the range 0x0–0xF represents the range 1-16. The zero length is represented by format B using the 0x7F value. Signed-off-by: Aurelien Jarno <[email protected]>
1 parent 16d8a49 commit 1ac90bf

File tree

1 file changed

+7
-4
lines changed
  • samples/boards/reel_board/mesh_badge/src

1 file changed

+7
-4
lines changed

samples/boards/reel_board/mesh_badge/src/mesh.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,19 @@ static void sens_temperature_celsius_fill(struct net_buf_simple *msg)
223223

224224
static void sens_unknown_fill(u16_t id, struct net_buf_simple *msg)
225225
{
226-
struct sensor_hdr_a hdr;
226+
struct sensor_hdr_b hdr;
227227

228228
/*
229229
* When the message is a response to a Sensor Get message that
230230
* identifies a sensor property that does not exist on the element, the
231231
* Length field shall represent the value of zero and the Raw Value for
232-
* that property shall be omitted. (Mesh model spec 1.0, 4.2.14)
232+
* that property shall be omitted. (Mesh model spec 1.0, 4.2.14).
233+
*
234+
* The length zero is represented using the format B and the special
235+
* value 0x7F.
233236
*/
234-
hdr.format = SENSOR_HDR_A;
235-
hdr.length = 0U;
237+
hdr.format = SENSOR_HDR_B;
238+
hdr.length = 0x7FU;
236239
hdr.prop_id = id;
237240

238241
net_buf_simple_add_mem(msg, &hdr, sizeof(hdr));

0 commit comments

Comments
 (0)