nRF5 SDK for Mesh v4.2.0
sensor_messages.h
1 /* Copyright (c) 2010 - 2020, Nordic Semiconductor ASA
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification,
5  * are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form, except as embedded into a Nordic
11  * Semiconductor ASA integrated circuit in a product or a software update for
12  * such product, must reproduce the above copyright notice, this list of
13  * conditions and the following disclaimer in the documentation and/or other
14  * materials provided with the distribution.
15  *
16  * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
17  * contributors may be used to endorse or promote products derived from this
18  * software without specific prior written permission.
19  *
20  * 4. This software, with or without modification, must only be used with a
21  * Nordic Semiconductor ASA integrated circuit.
22  *
23  * 5. Any software provided in binary form under this license must not be reverse
24  * engineered, decompiled, modified and/or disassembled.
25  *
26  * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28  * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
29  * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
30  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
35  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef SENSOR_MESSAGES_H__
39 #define SENSOR_MESSAGES_H__
40 
41 #include <stdint.h>
42 #include "sensor_common.h"
43 #include "nrf_mesh_assert.h"
44 
53 /* @tagMeshMdlSp - 4.1 "The number of sensors within a multisensor is
54  * limited by the size of the message payload for the Sensor
55  * Descriptor Status message" ... "up to 38 Sensor Descriptor states
56  * may be sent" */
57 #define MAX_NUM_SENSORS 38
58 
60 #define SENSOR_DESCRIPTOR_MINLEN 2
61 #define SENSOR_DESCRIPTOR_STATE_SIZE 8
62 #define SENSOR_DESCRIPTOR_MAXLEN (MAX_NUM_SENSORS * SENSOR_DESCRIPTOR_STATE_SIZE)
63 
65 #define SENSOR_SETTING_SET_MINLEN 5
66 
68 #define SENSOR_CADENCE_SET_MINLEN 8
69 
71 #define SENSOR_STATUS_MINLEN 3
72 #define SENSOR_STATUS_MAXLEN_SINGLE_SENSOR 130
73 #define SENSOR_STATUS_MAXLEN 379
74 
76 typedef enum
77 {
78  SENSOR_OPCODE_DESCRIPTOR_GET = 0x8230,
79  SENSOR_OPCODE_DESCRIPTOR_STATUS = 0x51,
80  SENSOR_OPCODE_GET = 0x8231,
81  SENSOR_OPCODE_STATUS = 0x52,
82  SENSOR_OPCODE_COLUMN_GET = 0x8232,
83  SENSOR_OPCODE_COLUMN_STATUS = 0x53,
84  SENSOR_OPCODE_SERIES_GET = 0X8233,
85  SENSOR_OPCODE_SERIES_STATUS = 0x54,
86  SENSOR_OPCODE_CADENCE_GET = 0x8234,
87  SENSOR_OPCODE_CADENCE_SET = 0x55,
88  SENSOR_OPCODE_CADENCE_SET_UNACKNOWLEDGED = 0x56,
89  SENSOR_OPCODE_CADENCE_STATUS = 0x57,
90  SENSOR_OPCODE_SETTINGS_GET = 0x8235,
91  SENSOR_OPCODE_SETTINGS_STATUS = 0x58,
92  SENSOR_OPCODE_SETTING_GET = 0x8236,
93  SENSOR_OPCODE_SETTING_SET = 0x59,
94  SENSOR_OPCODE_SETTING_SET_UNACKNOWLEDGED = 0x5A,
95  SENSOR_OPCODE_SETTING_STATUS = 0x5B,
96 } sensor_opcode_t;
97 
100 /* Note that the partial message types are assumed to be parsed as uint8_t buffers beyond the few
101  fields at the top that are defined in the structure. uint8_t is the straightforward way to handle
102  variably-sized fields.
103 */
104 
110 typedef struct __attribute((packed))
111 {
112  uint16_t property_id;
114 
115 typedef struct __attribute((packed))
116 {
117  uint64_t sensor_property_id : 16;
118  uint64_t sensor_positive_tolerance : 12;
119  uint64_t sensor_negative_tolerance : 12;
120  uint64_t sensor_sampling_function : 8;
121  uint64_t sensor_measurement_period : 8;
122  uint64_t sensor_update_interval : 8;
124 
125 STATIC_ASSERT(SENSOR_DESCRIPTOR_STATE_SIZE == sizeof(sensor_descriptor_pkt_t),
126  "Wrong packed sensor_descriptor_pkt_t.");
127 
146 typedef union __attribute((packed))
147 {
148  uint16_t property_id;
149  sensor_descriptor_pkt_t descriptors;
151 
157 typedef struct __attribute((packed))
158 {
159  uint16_t property_id;
161 
185 typedef uint8_t sensor_cadence_status_msg_pkt_t;
186 
207 typedef struct __attribute((packed))
208 {
209  uint16_t property_id;
211 
217 typedef struct __attribute((packed))
218 {
219  uint16_t property_id;
221 
238 typedef struct __attribute((packed))
239 {
240  uint16_t property_id;
241  uint16_t setting_property_ids[];
243 
257 typedef struct __attribute((packed))
258 {
259  uint16_t property_id;
262 
277 typedef struct __attribute((packed))
278 {
279  uint16_t property_id;
281  uint8_t setting_raw[];
283 
302 typedef struct __attribute((packed))
303 {
304  uint16_t property_id;
306  uint8_t setting_access;
307  uint8_t setting_raw[];
309 
321 typedef struct __attribute((packed))
322 {
323  uint16_t property_id;
325 
341 typedef uint8_t sensor_status_msg_pkt_t;
342 
354 typedef struct __attribute((packed))
355 {
356  uint16_t property_id;
357  uint8_t raw_value_x[];
360 
377 typedef struct __attribute((packed))
378 {
379  uint16_t property_id;
380  uint8_t raw_value_xwy[];
383 
400 typedef struct __attribute((packed))
401 {
402  uint16_t property_id;
403  uint8_t raw_value_x1x2[];
407 
432 typedef struct __attribute((packed))
433 {
434  uint16_t property_id;
435  uint8_t raw_value_xwy[];
440 
442 #endif /* SENSOR_MESSAGES_H__ */
Message format for the Sensor Descriptor Status message.
uint16_t property_id
Property ID for the sensor.
uint16_t setting_property_id
Setting Property ID identifying a setting within a sensor.
uint16_t property_id
Property ID for the sensor.
Message format for the Sensor Column Status message 4.2.16 Sensor Column Status Sensor Column Status ...
uint16_t property_id
Property ID for the sensor.
Message format for the Sensor Cadence Set/Set Unacknowledged message (partial) 4.2.4 Sensor Cadence Set Sensor Cadence Set is an acknowledged message used to set the Sensor Cadence state of an element (see Section 4.1.3).
Packed message structure typedefs are used for packing and unpacking byte stream. ...
uint16_t property_id
Property ID for the sensor.
Message format for the Sensor Setting Get message.
Message format for the Sensor Series Status message 4.2.18 Sensor Series Status Sensor Series Status ...
uint16_t property_id
Property ID for the sensor.
Message format for the Sensor Get message 4.2.13 Sensor Get Sensor Get is an acknowledged message use...
uint16_t property_id
Property ID for the sensor.
Message format for the Sensor Settings Get message.
uint16_t property_id
Property ID for the sensor.
uint16_t property_id
Property ID for the sensor.
uint16_t setting_property_id
Setting Property ID identifying a setting within a sensor.
uint16_t property_id
Property ID for the sensor.
uint16_t setting_property_id
Setting Property ID identifying a setting within a sensor.
Message format for the Sensor Setting Set/Set Unacknowledged message (partial) 4.2.10 Sensor Setting Set Sensor Setting Set is an acknowledged message used to set the Sensor Setting state of an element (see Section 4.1.2).
Message format for the Sensor Cadence Get message.
uint16_t property_id
Property ID for the sensor.
uint16_t property_id
Property ID for the sensor.
Message format for the Sensor Column Get message (partial) 4.2.15 Sensor Column Get Sensor Column Get...
uint16_t property_id
Property ID for the sensor.
uint16_t property_id
Property ID for the sensor.
Message format for the Sensor Settings Status message.
Message format for the Sensor Series Get message (partial) 4.2.17 Sensor Series Get Sensor Series Get...
Message format for the Sensor Setting Status message.

Documentation feedback | Developer Zone | Subscribe | Updated