nRF5 SDK for Mesh v5.0.0
config_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 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 #include "access.h"
46 
55 #define CONFIG_RETRANSMIT_COUNT_MAX ((1 << 3) - 1)
56 
57 #define CONFIG_RETRANSMIT_INTERVAL_STEPS_MAX ((1 << 5) - 1)
58 
59 #define CONFIG_RETRANSMIT_INTERVAL_STEP_TO_MS(STEP) ((STEP) * 10)
60 
61 #define CONFIG_RETRANSMIT_INTERVAL_MS_TO_STEP(MS) ((MS) / 10)
62 
63 /*lint -align_max(push) -align_max(1) */
64 
71 typedef struct __attribute((packed))
72 {
73  uint8_t key_id_1_lsb;
74  uint8_t key_id_1_msb : 4;
75  uint8_t key_id_2_lsb : 4;
76  uint8_t key_id_2_msb;
78 
79 /* Ensure the size of the above type is correct: */
81 
88 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)
89 {
90  p_idx24->key_id_1_lsb = key_id_1 & 0xff;
91  p_idx24->key_id_1_msb = (key_id_1 >> 8) & 0xf;
92 
93  p_idx24->key_id_2_lsb = key_id_2 & 0xf;
94  p_idx24->key_id_2_msb = (key_id_2 >> 4) & 0xff;
95 }
96 
105 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)
106 {
107  if (p_key_id_1 != NULL)
108  {
109  *p_key_id_1 = p_idx24->key_id_1_lsb | (p_idx24->key_id_1_msb << 8);
110  }
111 
112  if (p_key_id_2 != NULL)
113  {
114  *p_key_id_2 = p_idx24->key_id_2_lsb | (p_idx24->key_id_2_msb << 4);
115  }
116 }
117 
119 #define CONFIG_MSG_KEY_INDEX_12_MASK 0x0fff
120 
126 typedef uint16_t config_msg_key_index_12_t;
127 
133 typedef union __attribute((packed))
134 {
135  struct __attribute((packed))
136  {
137  uint16_t model_id;
138  } sig;
139  struct __attribute((packed))
140  {
141  uint16_t company_id;
142  uint16_t model_id;
143  } vendor;
145 NRF_MESH_STATIC_ASSERT(sizeof(config_model_id_t) == sizeof(uint32_t));
146 
153 static inline void config_msg_model_id_set(config_model_id_t * p_dst, const access_model_id_t * p_src, bool is_sig)
154 {
155  if (is_sig)
156  {
157  p_dst->sig.model_id = p_src->model_id;
158  }
159  else
160  {
161  p_dst->vendor.model_id = p_src->model_id;
162  p_dst->vendor.company_id = p_src->company_id;
163  }
164 }
165 
167 typedef struct __attribute((packed))
168 {
170  uint8_t appkey[NRF_MESH_KEY_SIZE];
172 
174 typedef struct __attribute((packed))
175 {
177  uint8_t appkey[NRF_MESH_KEY_SIZE];
179 
181 typedef struct __attribute((packed))
182 {
185 
187 typedef struct __attribute((packed))
188 {
189  uint8_t status;
192 
194 typedef struct __attribute((packed))
195 {
196  config_msg_key_index_12_t netkey_index;
198 
200 typedef struct __attribute((packed))
201 {
202  uint8_t status;
203  config_msg_key_index_12_t netkey_index;
204  uint8_t packed_appkey_indexes[];
206 
208 typedef struct __attribute((packed))
209 {
210  uint8_t ttl;
212 
214 typedef struct __attribute((packed))
215 {
216  uint8_t ttl;
218 
220 typedef enum
221 {
225 
227 typedef struct __attribute((packed))
228 {
229  uint8_t beacon_state;
231 
233 typedef struct __attribute((packed))
234 {
235  uint8_t beacon_state;
237 
239 typedef struct __attribute((packed))
240 {
241  uint16_t appkey_index : 12;
242  uint16_t credential_flag : 1;
243  uint16_t rfu : 3;
244  uint8_t publish_ttl;
245  uint8_t publish_period;
246  uint8_t retransmit_count : 3;
247  uint8_t retransmit_interval : 5;
250 
252 typedef struct __attribute((packed))
253 {
254  uint16_t element_address;
257 
259 typedef struct __attribute((packed))
260 {
261  uint16_t element_address;
262  uint16_t publish_address;
265 
267 typedef struct __attribute((packed))
268 {
269  uint16_t element_address;
270  uint8_t publish_uuid[NRF_MESH_UUID_SIZE];
273 
275 typedef struct __attribute((packed))
276 {
277  uint8_t status;
278  uint16_t element_address;
279  uint16_t publish_address;
282 
284 typedef struct __attribute((packed))
285 {
286  uint16_t element_address;
287  uint16_t address;
290 
292 typedef struct __attribute((packed))
293 {
294  uint16_t element_address;
295  uint8_t virtual_uuid[NRF_MESH_UUID_SIZE];
298 
300 typedef struct __attribute((packed))
301 {
302  uint16_t element_address;
305 
307 typedef struct __attribute((packed))
308 {
309  uint8_t status;
310  uint16_t element_address;
311  uint16_t address;
314 
316 typedef struct __attribute((packed))
317 {
318  config_msg_key_index_12_t netkey_index;
319  uint8_t netkey[NRF_MESH_KEY_SIZE];
321 
323 typedef struct __attribute((packed))
324 {
325  config_msg_key_index_12_t netkey_index;
327 
329 typedef struct __attribute((packed))
330 {
331  uint8_t status;
332  config_msg_key_index_12_t netkey_index;
334 
336 typedef enum
337 {
342 
344 typedef struct __attribute((packed))
345 {
346  uint8_t proxy_state;
348 
350 typedef struct __attribute((packed))
351 {
352  uint8_t proxy_state;
354 
356 typedef enum
357 {
362 
364 typedef struct __attribute((packed))
365 {
366  uint8_t friend_state;
368 
370 typedef struct __attribute((packed))
371 {
372  uint8_t friend_state;
374 
376 typedef struct __attribute((packed))
377 {
378  config_msg_key_index_12_t netkey_index;
380 
382 typedef struct __attribute((packed))
383 {
384  config_msg_key_index_12_t netkey_index;
385  uint8_t transition;
387 
389 typedef struct __attribute((packed))
390 {
391  uint8_t status;
392  config_msg_key_index_12_t netkey_index;
393  uint8_t phase;
395 
397 typedef struct __attribute((packed))
398 {
399  uint16_t destination;
400  uint8_t count_log;
401  uint8_t period_log;
402  uint8_t ttl;
403  uint16_t features;
404  config_msg_key_index_12_t netkey_index;
406 
408 typedef struct __attribute((packed))
409 {
410  uint8_t status;
411  uint16_t destination;
412  uint8_t count_log;
413  uint8_t period_log;
414  uint8_t ttl;
415  uint16_t features;
416  config_msg_key_index_12_t netkey_index;
418 
420 typedef struct __attribute((packed))
421 {
422  uint16_t source;
423  uint16_t destination;
424  uint8_t period_log;
426 
428 typedef struct __attribute((packed))
429 {
430  uint8_t status;
431  uint16_t source;
432  uint16_t destination;
433  uint8_t period_log;
434  uint8_t count_log;
435  uint8_t min_hops;
436  uint8_t max_hops;
438 
440 typedef struct __attribute((packed))
441 {
442  uint16_t element_address;
443  config_msg_key_index_12_t appkey_index;
446 
448 typedef struct __attribute((packed))
449 {
450  uint8_t status;
451  uint16_t element_address;
452  config_msg_key_index_12_t appkey_index;
455 
457 typedef enum
458 {
463 
465 typedef struct __attribute((packed))
466 {
467  config_msg_key_index_12_t netkey_index;
469 
471 typedef struct __attribute((packed))
472 {
473  config_msg_key_index_12_t netkey_index;
474  uint8_t identity_state;
476 
478 typedef struct __attribute((packed))
479 {
480  uint8_t status;
481  config_msg_key_index_12_t netkey_index;
482  uint8_t identity_state;
484 
486 typedef struct __attribute((packed))
487 {
488  uint8_t page_number;
490 
492 typedef struct __attribute((packed))
493 {
494  uint8_t page_number;
495  uint8_t data[];
497 
499 typedef enum
500 {
505 
507 typedef struct __attribute((packed))
508 {
509  uint8_t relay_state;
513 
515 typedef struct __attribute((packed))
516 {
517  uint8_t relay_state;
521 
523 typedef struct __attribute((packed))
524 {
528 
530 typedef struct __attribute((packed))
531 {
535 
537 typedef struct __attribute((packed))
538 {
539  uint16_t element_address;
542 
544 typedef struct __attribute((packed))
545 {
546  uint8_t status;
547  uint16_t element_address;
548  uint16_t sig_model_id;
549  uint8_t key_indexes[];
551 
553 typedef struct __attribute((packed))
554 {
555  uint8_t status;
556  uint16_t element_address;
557  uint16_t vendor_company_id;
558  uint16_t vendor_model_id;
559  uint8_t key_indexes[];
561 
563 typedef struct __attribute((packed))
564 {
565  uint16_t element_address;
568 
570 typedef struct __attribute((packed))
571 {
572  uint8_t status;
573  uint16_t element_address;
574  uint16_t sig_model_id;
575  uint16_t subscriptions[];
577 
579 typedef struct __attribute((packed))
580 {
581  uint8_t status;
582  uint16_t element_address;
583  uint16_t vendor_company_id;
584  uint16_t vendor_model_id;
585  uint16_t subscriptions[];
587 
589 typedef struct __attribute((packed))
590 {
591  uint16_t lpn_address;
593 
595 typedef struct __attribute((packed))
596 {
597  uint16_t lpn_address;
598  uint8_t polltimeout[3];
600 
601 /*lint -align_max(pop) */
604 #endif
605 
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.
uint16_t company_id
Company ID.
Definition: access.h:154
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.
uint16_t company_id
Vendor-specific company 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 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.
Message format for the Default TTL Set message.
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.
static void config_msg_model_id_set(config_model_id_t *p_dst, const access_model_id_t *p_src, bool is_sig)
Sets the value of the model id for different kind of models (SIG or vendor).
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.
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.
uint16_t lpn_address
The unicast address of the Low Power node.
Message format for the Config Beacon Set message.
Message format for the Relay Status message.
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.
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.
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.
uint16_t model_id
Model ID.
Definition: access.h:156
uint8_t ttl
Default TTL value.
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.
uint8_t ttl
Default TTL value.
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.
Model ID type for configuration messages.
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.
Message format for the Low Power node PollTimeout Status message.
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.
uint16_t model_id
Model ID.
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.
Access layer model ID.
Definition: access.h:151
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.
Message format for the Default TTL Status 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.
uint16_t lpn_address
The unicast address of the Low Power node.
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.
#define NRF_MESH_STATIC_ASSERT(...)
Compile-time assertion.
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.
Message format for the Low Power node PollTimeout Get message.
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