nRF5 SDK for Mesh v1.0.1
config_messages.h
1 /* Copyright (c) 2010 - 2017, 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 CONFIG_MESSAGES_H__
39 #define CONFIG_MESSAGES_H__
40 
41 #include <stddef.h>
42 #include <stdint.h>
43 
44 #include "nrf_mesh_assert.h"
45 
54 #define CONFIG_RETRANSMIT_COUNT_MAX ((1 << 3) - 1)
55 
56 #define CONFIG_RETRANSMIT_INTERVAL_STEPS_MAX ((1 << 5) - 1)
57 
58 #define CONFIG_RETRANSMIT_INTERVAL_STEP_TO_MS(STEP) ((STEP) * 10)
59 
60 #define CONFIG_RETRANSMIT_INTERVAL_MS_TO_STEP(MS) ((MS) / 10)
61 
62 /*lint -align_max(push) -align_max(1) */
63 
70 typedef struct __attribute((packed))
71 {
72  uint8_t key_id_1_lsb;
73  uint8_t key_id_1_msb : 4;
74  uint8_t key_id_2_lsb : 4;
75  uint8_t key_id_2_msb;
77 
78 /* Ensure the size of the above type is correct: */
80 
87 static inline void config_msg_key_index_24_set(config_msg_key_index_24_t * p_idx24, uint16_t key_id_1, uint16_t key_id_2)
88 {
89  p_idx24->key_id_1_lsb = key_id_1 & 0xff;
90  p_idx24->key_id_1_msb = (key_id_1 >> 8) & 0xf;
91 
92  p_idx24->key_id_2_lsb = key_id_2 & 0xf;
93  p_idx24->key_id_2_msb = (key_id_2 >> 4) & 0xff;
94 }
95 
104 static inline void config_msg_key_index_24_get(const config_msg_key_index_24_t * p_idx24, uint16_t * p_key_id_1, uint16_t * p_key_id_2)
105 {
106  if (p_key_id_1 != NULL)
107  {
108  *p_key_id_1 = p_idx24->key_id_1_lsb | (p_idx24->key_id_1_msb << 8);
109  }
110 
111  if (p_key_id_2 != NULL)
112  {
113  *p_key_id_2 = p_idx24->key_id_2_lsb | (p_idx24->key_id_2_msb << 4);
114  }
115 }
116 
118 #define CONFIG_MSG_KEY_INDEX_12_MASK 0x0fff
119 
125 typedef uint16_t config_msg_key_index_12_t;
126 
132 typedef struct __attribute((packed))
133 {
134  uint16_t model_id;
135  uint16_t company_id;
137 NRF_MESH_STATIC_ASSERT(sizeof(config_model_id_t) == sizeof(uint32_t));
138 
140 typedef struct __attribute((packed))
141 {
143  uint8_t appkey[NRF_MESH_KEY_SIZE];
145 
147 typedef struct __attribute((packed))
148 {
150  uint8_t appkey[NRF_MESH_KEY_SIZE];
152 
154 typedef struct __attribute((packed))
155 {
158 
160 typedef struct __attribute((packed))
161 {
162  uint8_t status;
165 
167 typedef struct __attribute((packed))
168 {
169  config_msg_key_index_12_t netkey_index;
171 
173 typedef struct __attribute((packed))
174 {
175  uint8_t status;
176  config_msg_key_index_12_t netkey_index;
177  uint8_t packed_appkey_indexes[];
179 
181 typedef struct __attribute((packed))
182 {
183  uint8_t ttl;
185 
187 typedef enum
188 {
192 
194 typedef struct
195 {
196  uint8_t beacon_state;
198 
200 typedef struct __attribute((packed))
201 {
202  uint8_t beacon_state;
204 
206 typedef struct __attribute((packed))
207 {
208  uint16_t appkey_index : 12;
209  uint16_t credential_flag : 1;
210  uint16_t rfu : 3;
211  uint8_t publish_ttl;
212  uint8_t publish_period;
213  uint8_t retransmit_count : 3;
214  uint8_t retransmit_interval : 5;
217 
219 typedef struct __attribute((packed))
220 {
221  uint16_t element_address;
224 
226 typedef struct __attribute((packed))
227 {
228  uint16_t element_address;
229  uint16_t publish_address;
232 
234 typedef struct __attribute((packed))
235 {
236  uint16_t element_address;
237  uint8_t publish_uuid[NRF_MESH_UUID_SIZE];
240 
242 typedef struct __attribute((packed))
243 {
244  uint8_t status;
245  uint16_t element_address;
246  uint16_t publish_address;
249 
251 typedef struct __attribute((packed))
252 {
253  uint16_t element_address;
254  uint16_t address;
257 
259 typedef struct __attribute((packed))
260 {
261  uint16_t element_address;
262  uint8_t virtual_uuid[NRF_MESH_UUID_SIZE];
265 
267 typedef struct __attribute((packed))
268 {
269  uint16_t element_address;
272 
274 typedef struct __attribute((packed))
275 {
276  uint8_t status;
277  uint16_t element_address;
278  uint16_t address;
281 
283 typedef struct __attribute((packed))
284 {
285  config_msg_key_index_12_t netkey_index;
286  uint8_t netkey[NRF_MESH_KEY_SIZE];
288 
290 typedef struct __attribute((packed))
291 {
292  config_msg_key_index_12_t netkey_index;
294 
296 typedef struct __attribute((packed))
297 {
298  uint8_t status;
299  config_msg_key_index_12_t netkey_index;
301 
303 typedef enum
304 {
309 
311 typedef struct __attribute((packed))
312 {
313  uint8_t proxy_state;
315 
317 typedef struct __attribute((packed))
318 {
319  uint8_t proxy_state;
321 
323 typedef enum
324 {
329 
331 typedef struct __attribute((packed))
332 {
333  uint8_t friend_state;
335 
337 typedef struct __attribute((packed))
338 {
339  uint8_t friend_state;
341 
343 typedef struct __attribute((packed))
344 {
345  config_msg_key_index_12_t netkey_index;
347 
349 typedef struct __attribute((packed))
350 {
351  config_msg_key_index_12_t netkey_index;
352  uint8_t transition;
354 
356 typedef struct __attribute((packed))
357 {
358  uint8_t status;
359  config_msg_key_index_12_t netkey_index;
360  uint8_t phase;
362 
364 typedef struct __attribute((packed))
365 {
366  uint16_t destination;
367  uint8_t count_log;
368  uint8_t period_log;
369  uint8_t ttl;
370  uint16_t features;
371  config_msg_key_index_12_t netkey_index;
373 
375 typedef struct __attribute((packed))
376 {
377  uint8_t status;
378  uint16_t destination;
379  uint8_t count_log;
380  uint8_t period_log;
381  uint8_t ttl;
382  uint16_t features;
383  config_msg_key_index_12_t netkey_index;
385 
387 typedef struct __attribute((packed))
388 {
389  uint16_t source;
390  uint16_t destination;
391  uint8_t period_log;
393 
395 typedef struct __attribute((packed))
396 {
397  uint8_t status;
398  uint16_t source;
399  uint16_t destination;
400  uint8_t period_log;
401  uint8_t count_log;
402  uint8_t min_hops;
403  uint8_t max_hops;
405 
407 typedef struct __attribute((packed))
408 {
409  uint16_t element_address;
410  config_msg_key_index_12_t appkey_index;
413 
415 typedef struct __attribute((packed))
416 {
417  uint8_t status;
418  uint16_t element_address;
419  config_msg_key_index_12_t appkey_index;
422 
424 typedef enum
425 {
430 
432 typedef struct __attribute((packed))
433 {
434  config_msg_key_index_12_t netkey_index;
436 
438 typedef struct __attribute((packed))
439 {
440  config_msg_key_index_12_t netkey_index;
441  uint8_t identity_state;
443 
445 typedef struct __attribute((packed))
446 {
447  uint8_t status;
448  config_msg_key_index_12_t netkey_index;
449  uint8_t identity_state;
451 
453 typedef struct __attribute((packed))
454 {
455  uint8_t page_number;
457 
459 typedef struct __attribute((packed))
460 {
461  uint8_t page_number;
462  uint8_t data[];
464 
466 typedef enum
467 {
472 
474 typedef struct __attribute((packed))
475 {
476  uint8_t relay_state;
480 
482 typedef struct __attribute((packed))
483 {
484  uint8_t relay_state;
488 
490 typedef struct __attribute((packed))
491 {
495 
497 typedef struct __attribute((packed))
498 {
502 
504 typedef struct __attribute((packed))
505 {
506  uint16_t element_address;
509 
511 typedef struct __attribute((packed))
512 {
513  uint8_t status;
514  uint16_t element_address;
515  uint16_t sig_model_id;
516  uint8_t key_indexes[];
518 
520 typedef struct __attribute((packed))
521 {
522  uint8_t status;
523  uint16_t element_address;
524  uint16_t vendor_model_id;
525  uint16_t vendor_company_id;
526  uint8_t key_indexes[];
528 
530 typedef struct __attribute((packed))
531 {
532  uint16_t element_address;
535 
537 typedef struct __attribute((packed))
538 {
539  uint8_t status;
540  uint16_t element_address;
541  uint16_t sig_model_id;
542  uint16_t subscriptions[];
544 
546 typedef struct __attribute((packed))
547 {
548  uint8_t status;
549  uint16_t element_address;
550  uint16_t vendor_model_id;
551  uint16_t vendor_company_id;
552  uint16_t subscriptions[];
554 
555 /*lint -align_max(pop) */
558 #endif
559 
uint8_t network_transmit_count
Number of retransmissions per transmited packet.
uint8_t status
Status code.
uint16_t vendor_model_id
Vendor model ID.
Publication parameters.
Message format for the AppKey Status message.
uint16_t destination
Heartbeat publication destination.
uint16_t credential_flag
Friendship credentials flag.
uint8_t relay_retransmit_interval_steps
Number of 10 ms steps between retransmissions.
Message format for the Composition Data Get message.
uint8_t publish_ttl
TTL for outgoing messages.
Message format for the Model App Status message.
uint8_t identity_state
Current state of the node identity advertisement.
Friendship is supported, but disabled.
uint8_t page_number
Page-number for the composition data page to retrieve.
config_msg_key_index_12_t netkey_index
Subnet index.
config_model_id_t model_id
Model ID.
uint8_t proxy_state
The desired state of the GATT proxy service.
uint8_t proxy_state
The state of the GATT proxy service.
config_model_id_t model_id
Model ID.
uint8_t ttl
Default TTL value.
uint8_t count_log
Number of heartbeat messages received.
24-bit key index type.
#define NRF_MESH_KEY_SIZE
Size (in octets) of an encryption key.
Message format for the SIG/Vendor Model Subscription Get message.
uint8_t ttl
TTL for heartbeat message.
Message format for the Friend Set message.
Message format for the Friend Status message.
Message format for the Network Key Delete message.
config_gatt_proxy_state_t
Possible values for the GATT Proxy state.
config_net_beacon_state_t
Possible values for the network beacon state.
uint8_t relay_state
Desired state of the relaying feature.
uint8_t period_log
Period of heartbeat messages.
#define NRF_MESH_UUID_SIZE
Size (in octets) of a UUID.
config_msg_key_index_12_t netkey_index
Network key index.
Message format for the AppKey Add message.
config_friend_state_t
Possible values for the Friend state.
uint8_t key_id_1_lsb
8 LSB of the first key index.
Relaying is supported, but disabled.
uint8_t key_id_1_msb
4 MSB of the first key index.
uint16_t element_address
Address of the element.
The network beacon is disabled.
Message format for the Network Transmit Status message.
config_msg_key_index_12_t netkey_index
Index for the network key used to send heartbeats.
config_model_id_t model_id
ID of the model.
uint8_t relay_retransmit_count
Desired number of retransmissions per relayed packed.
Message format for the AppKey Get message.
uint16_t publish_address
Publish address.
#define NRF_MESH_STATIC_ASSERT(cond)
Compile-time assertion.
uint16_t source
Source of heartbeat messages.
config_model_id_t model_id
ID of the model.
The network beacon is enabled.
Message format for the Model Subscription Status message.
config_model_id_t model_id
ID of the model.
Message format for the Model Subscription Virtual Add/Delete/Overwrite messages.
uint16_t element_address
Unicast address of the element.
uint8_t publish_period
Period for periodic publishing.
config_msg_key_index_24_t key_indexes
Pair containing a netkey and an appkey index.
uint16_t appkey_index
Application key index.
Message format for the AppKey Delete message.
uint8_t key_id_2_lsb
4 LSB of the second key index.
uint8_t friend_state
The desired state of the friendship feature.
uint8_t friend_state
The state of the friendship feature.
The GATT proxy feature is not supported.
config_msg_key_index_12_t appkey_index
Application key index.
Message format for the Config Beacon Set message.
Message format for the Relay Status message.
Message format for the Default TTL Set and Get messages.
uint8_t status
Status code.
Message format for the Model Publication Get message.
Message format for the Network Key Add/Update messages.
config_identity_state_t
Possible values for the identity state.
uint8_t beacon_state
Beacon state.
Message format for the Heartbeat Subscription Status message.
Message format for the Node Identity Status message.
uint16_t element_address
Unicast address of the element.
uint16_t features
Features triggering heartbeat messages.
uint8_t page_number
Page-number for the composition data page contained in this response.
config_model_id_t model_id
Identifier of the model.
Message format for the Node Identity Get message.
uint8_t phase
Current key refresh phase for the subnet.
uint16_t element_address
Unicast address of the element.
uint16_t address
Address to subscribe to.
config_msg_key_index_12_t netkey_index
Index of the network the key refresh phase is reported for.
config_model_id_t model_id
Model ID.
Message format for the GATT Proxy Status message.
uint16_t element_address
Unicast address of the element.
Model ID type for configuration messages.
Message format for the Vendor Model App List message.
static void config_msg_key_index_24_set(config_msg_key_index_24_t *p_idx24, uint16_t key_id_1, uint16_t key_id_2)
Sets the value of the keys in a 24-bit index struct.
config_msg_key_index_12_t netkey_index
Network key index.
uint8_t period_log
Period of heartbeat messages.
uint16_t company_id
Vendor-specific company ID.
Message format for the Key Refresh Phase Get message.
uint16_t sig_model_id
SIG model ID.
uint8_t key_id_2_msb
8 MSB of the second key index.
The GATT proxy is running and enabled.
config_publication_params_t state
Current publication parameters.
config_msg_key_index_12_t netkey_index
Index of the network to set the key refresh phase for.
Friendship is not supported.
Message format for the Model Subscription Delete All message.
uint16_t element_address
Address of the element.
config_msg_key_index_12_t netkey_index
Network key to report application keys for.
uint16_t element_address
Address of the element.
uint8_t transition
ID of the phase to transition to.
Message format for the Key Refresh Phase Status message.
uint16_t destination
Destination of heartbeat messages.
Message format for the Model Publication Virtual Set message.
uint16_t model_id
Model ID.
The node identity advertisement is stopped.
config_msg_key_index_12_t netkey_index
Subnet index.
config_msg_key_index_12_t netkey_index
Network key index.
uint16_t element_address
Unicast address of the element.
config_relay_state_t
Values for the relay state.
uint16_t address
Address that the model was subscribed to.
Message format for the Config Beacon Status message.
Message format for the GATT Proxy Set message.
Message format for the Heartbeat Publication Status message.
Message format for the SIG Model App List message.
config_msg_key_index_12_t netkey_index
Index for the network key used to send heartbeats.
Relaying is not supported.
uint16_t element_address
Unicast address of the element.
config_msg_key_index_12_t netkey_index
Subnet index.
config_msg_key_index_24_t key_indexes
Pair containing a netkey and an appkey index.
uint8_t period_log
Period of transmitted heartbeat messages.
Friendship is supported and enabled.
static void config_msg_key_index_24_get(const config_msg_key_index_24_t *p_idx24, uint16_t *p_key_id_1, uint16_t *p_key_id_2)
Gets the value of one or both of the keys in a 24-bit index struct.
uint8_t min_hops
Least number of hops in received heartbeat messages.
uint16_t element_address
Unicast address of the element.
uint8_t ttl
TTL for heartbeat message.
uint8_t status
Status code.
uint8_t relay_retransmit_count
Number of retransmissions per relayed packet.
uint8_t retransmit_count
Number of retransmissions of each message.
uint8_t network_transmit_count
Desired number of retransmissions per packed.
Message format for the Model Publication Status message.
config_msg_key_index_24_t key_indexes
Pair containing a netkey and an appkey index.
Message format for the Composition Data Status message.
uint8_t retransmit_interval
Number of 50 ms steps between each retransmission.
config_model_id_t model_id
ID of the model.
uint8_t relay_state
Current state of the relaying feature.
config_msg_key_index_12_t appkey_index
Application key index.
Message format for the Heartbeat Publication Set message.
uint8_t relay_retransmit_interval_steps
Desired number of 10 ms steps between retransmissions.
Message format for the Model Subscription Add/Delete/Overwrite messages.
uint8_t count_log
Number of heartbeat messages to be sent.
Message format for the Heartbeat Subscription Set message.
uint16_t features
Features triggering heartbeat messages.
uint16_t source
Source of heartbeat messages.
config_msg_key_index_24_t key_indexes
Pair containing a netkey and an appkey index.
uint16_t vendor_company_id
Vendor company ID.
uint16_t vendor_company_id
Vendor company ID.
uint8_t max_hops
Largest number of hops in received heartbeat messages.
The node identity advertisement is running.
config_model_id_t model_id
Model identifier.
uint16_t element_address
Unicast address of the element.
Message format for the Vendor Model Subscription List message.
uint8_t network_transmit_interval_steps
Number of 10 ms steps between retransmissions.
Node identity advertising is not supported.
config_msg_key_index_12_t netkey_index
Index of the network to get the key refresh phase for.
Message format for the Node Identity Set message.
uint8_t status
Status code.
Message format for the Relay Set message.
uint16_t publish_address
Publish address.
Relaying is supported and enabled.
uint8_t count_log
Number of heartbeat messages to be sent.
uint8_t identity_state
Identity advertisement state.
Message format for the AppKey List message.
Message format for the Model App Bind/Unbind message.
config_model_id_t model_id
Model ID.
Message format for the Network Transmit Set message.
config_publication_params_t state
The publication parameters to set.
Message format for the Network Key Status message.
Message format for the Model Publication Set message.
uint16_t element_address
Address of the element.
uint8_t status
Status code.
uint16_t rfu
Reserved for future use, set to 0.
uint8_t period_log
Period of transmitted heartbeat messages.
Message format for the Key Refresh Phase Set message.
uint16_t destination
Heartbeat publication destination.
uint16_t element_address
Address of the element.
Message format for the AppKey Update message.
uint8_t beacon_state
Beacon state.
uint16_t element_address
Unicast address of the element.
uint8_t network_transmit_interval_steps
Desired number of 10 ms steps between retransmissions.
uint16_t element_address
Unicast address of the element.
uint16_t config_msg_key_index_12_t
12-bit key index type.
Message format for the SIG Model Subscription List message.
config_msg_key_index_12_t netkey_index
Network key index.
config_publication_params_t state
The publication parameters to set.
The GATT proxy is running, but disabled.
uint16_t destination
Destination of heartbeat messages.
Message format for the SIG/Vendor Model App Get message.
uint16_t element_address
Unicast address of the element.

Documentation feedback | Developer Zone | Subscribe | Updated