nRF5 SDK for Mesh v2.2.0
serial_evt.h
1 /* Copyright (c) 2010 - 2018, 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 
39 
40 #ifndef SERIAL_EVT_H
41 #define SERIAL_EVT_H
42 
43 #include <stdint.h>
44 #include "serial_cmd_rsp.h"
45 #include "nrf_mesh_serial.h"
46 #include "serial_types.h"
47 #include "internal_event.h"
48 #include "packet.h"
49 
56 #define SERIAL_OPCODE_EVT_CMD_RSP (0x84)
58 #define SERIAL_OPCODE_EVT_DEVICE_STARTED (0x81)
59 #define SERIAL_OPCODE_EVT_DEVICE_ECHO_RSP (0x82)
60 #define SERIAL_OPCODE_EVT_DEVICE_INTERNAL_EVENT (0x83)
62 #define SERIAL_OPCODE_EVT_APPLICATION (0x8A)
64 #define SERIAL_OPCODE_EVT_SAR_START (0x8B)
65 #define SERIAL_OPCODE_EVT_SAR_CONTINUE (0x8C)
67 #define SERIAL_OPCODE_EVT_DFU_REQ_RELAY (0xA0)
68 #define SERIAL_OPCODE_EVT_DFU_REQ_SOURCE (0xA1)
69 #define SERIAL_OPCODE_EVT_DFU_START (0xA2)
70 #define SERIAL_OPCODE_EVT_DFU_END (0xA3)
71 #define SERIAL_OPCODE_EVT_DFU_BANK_AVAILABLE (0xA4)
72 #define SERIAL_OPCODE_EVT_DFU_FIRMWARE_OUTDATED (0xA5)
73 #define SERIAL_OPCODE_EVT_DFU_FIRMWARE_OUTDATED_NO_AUTH (0xA6)
75 #define SERIAL_OPCODE_EVT_OPENMESH_NEW (0xB3)
76 #define SERIAL_OPCODE_EVT_OPENMESH_UPDATE (0xB4)
77 #define SERIAL_OPCODE_EVT_OPENMESH_CONFLICTING (0xB5)
78 #define SERIAL_OPCODE_EVT_OPENMESH_TX (0xB6)
80 #define SERIAL_OPCODE_EVT_PROV_UNPROVISIONED_RECEIVED (0xC0)
81 #define SERIAL_OPCODE_EVT_PROV_LINK_ESTABLISHED (0xC1)
82 #define SERIAL_OPCODE_EVT_PROV_LINK_CLOSED (0xC2)
83 #define SERIAL_OPCODE_EVT_PROV_CAPS_RECEIVED (0xC3)
84 #define SERIAL_OPCODE_EVT_PROV_INVITE_RECEIVED (0xC4)
85 #define SERIAL_OPCODE_EVT_PROV_COMPLETE (0xC5)
86 #define SERIAL_OPCODE_EVT_PROV_AUTH_REQUEST (0xC6)
87 #define SERIAL_OPCODE_EVT_PROV_ECDH_REQUEST (0xC7)
88 #define SERIAL_OPCODE_EVT_PROV_OUTPUT_REQUEST (0xC8)
89 #define SERIAL_OPCODE_EVT_PROV_FAILED (0xC9)
90 #define SERIAL_OPCODE_EVT_PROV_START_RECEIVED (0xCA)
92 #define SERIAL_OPCODE_EVT_MESH_MESSAGE_RECEIVED_UNICAST (0xD0)
93 #define SERIAL_OPCODE_EVT_MESH_MESSAGE_RECEIVED_SUBSCRIPTION (0xD1)
94 #define SERIAL_OPCODE_EVT_MESH_TX_COMPLETE (0xD2)
95 #define SERIAL_OPCODE_EVT_MESH_IV_UPDATE_NOTIFICATION (0xD3)
96 #define SERIAL_OPCODE_EVT_MESH_KEY_REFRESH_NOTIFICATION (0xD4)
97 #define SERIAL_OPCODE_EVT_MESH_SAR_FAILED (0xD7)
99 #define SERIAL_OPCODE_EVT_MODEL_SPECIFIC (0xF0)
102 /*lint -align_max(push) -align_max(1) */
103 
105 typedef struct __attribute((packed))
106 {
107  uint8_t operating_mode;
108  uint8_t hw_error;
111 
113 typedef struct __attribute((packed))
114 {
117 
119 typedef struct __attribute((packed))
120 {
121  uint8_t event_type;
122  uint8_t state;
123  uint8_t packet_size;
124  uint8_t packet[BLE_ADV_PACKET_PAYLOAD_MAX_LENGTH];
126 
128 typedef union __attribute((packed))
129 {
134 
136 typedef struct __attribute((packed))
137 {
138  uint8_t uuid[NRF_MESH_UUID_SIZE];
139  int8_t rssi;
140  uint8_t gatt_supported;
141  uint8_t adv_addr_type;
142  uint8_t adv_addr[BLE_GAP_ADDR_LEN];
144 
146 typedef struct __attribute((packed))
147 {
148  uint8_t context_id;
150 
152 typedef struct __attribute((packed))
153 {
154  uint8_t context_id;
155  uint8_t close_reason;
157 
159 typedef struct __attribute((packed))
160 {
161  uint8_t context_id;
163  uint8_t num_elements;
164  uint8_t public_key_type;
167  uint8_t output_oob_size;
170  uint8_t input_oob_size;
171  uint16_t input_oob_actions;
173 
175 typedef struct __attribute((packed))
176 {
177  uint8_t context_id;
180 
182 typedef struct __attribute((packed))
183 {
184  uint8_t context_id;
186 
188 typedef struct __attribute((packed))
189 {
190  uint8_t context_id;
191  uint32_t iv_index;
192  uint16_t net_key_index;
193  uint16_t address;
194  uint8_t iv_update_flag;
196  uint8_t device_key[NRF_MESH_KEY_SIZE];
197  uint8_t net_key[NRF_MESH_KEY_SIZE];
199 
201 typedef struct __attribute((packed))
202 {
203  uint8_t context_id;
204  uint8_t method;
205  uint8_t action;
206  uint8_t size;
208 
210 typedef struct __attribute((packed))
211 {
212  uint8_t context_id;
213  uint8_t peer_public[NRF_MESH_ECDH_PUBLIC_KEY_SIZE];
214  uint8_t node_private[NRF_MESH_ECDH_PRIVATE_KEY_SIZE];
216 
218 typedef struct __attribute((packed))
219 {
220  uint8_t context_id;
221  uint8_t output_action;
222  uint8_t data[16];
224 
226 typedef struct __attribute((packed))
227 {
228  uint8_t context_id;
229  uint8_t error_code;
232 typedef union __attribute((packed))
233 {
246 
248 typedef struct __attribute((packed))
249 {
251  uint8_t evt_type;
253 
255 typedef struct __attribute((packed))
256 {
262 
264 typedef struct __attribute((packed))
265 {
268 
270 typedef struct __attribute((packed))
271 {
273  uint16_t src;
275  uint16_t dst;
277  uint16_t appkey_handle;
279  uint16_t subnet_handle;
281  uint8_t ttl;
283  uint8_t adv_addr_type;
285  uint8_t adv_addr[BLE_GAP_ADDR_LEN];
287  int8_t rssi;
290  uint16_t actual_length;
294 
296 typedef struct __attribute((packed))
297 {
298  uint32_t iv_index;
300 
302 typedef struct __attribute((packed))
303 {
304  uint16_t netkey_index;
305  uint8_t phase;
307 
309 typedef union __attribute((packed))
310 {
315 
316 /********* DFU parameters *********/
317 
319 typedef struct __attribute((packed))
320 {
321  uint8_t dfu_type;
323  uint8_t authority;
325 
327 typedef struct __attribute((packed))
328 {
329  uint8_t dfu_type;
331 
333 typedef struct __attribute((packed))
334 {
335  uint8_t role;
336  uint8_t dfu_type;
339 
341 typedef struct __attribute((packed))
342 {
343  uint8_t role;
344  uint8_t dfu_type;
346  uint8_t end_reason;
348 
350 typedef struct __attribute((packed))
351 {
352  uint8_t dfu_type;
354  uint32_t start_addr;
355  uint32_t length;
356  uint8_t is_signed;
358 
360 typedef struct __attribute((packed))
361 {
362  uint8_t dfu_type;
366 
368 typedef union __attribute((packed))
369 {
377 
379 typedef union __attribute((packed))
380 {
388 } serial_evt_t;
389 
390 /*lint -align_max(pop) */
393 #endif
394 
uint8_t gatt_supported
Whether the unprovisioned device supports GATT provisioning.
Definition: serial_evt.h:140
Union of all serial event parameters.
Definition: serial_evt.h:379
Application data event parameters.
Definition: serial_evt.h:264
Provisioning invite event.
Definition: serial_evt.h:175
serial_evt_mesh_iv_update_t iv_update
IV update parameters.
Definition: serial_evt.h:312
uint8_t iv_update_flag
IV update in progress flag.
Definition: serial_evt.h:194
serial_evt_device_internal_event_t internal_event
Internal event data.
Definition: serial_evt.h:132
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:321
uint8_t role
The device&#39;s role in the transfer.
Definition: serial_evt.h:343
uint16_t input_oob_actions
Available OOB input actions.
Definition: serial_evt.h:171
int8_t rssi
RSSI value of the message when received.
Definition: serial_evt.h:287
uint16_t net_key_index
Network key index.
Definition: serial_evt.h:192
#define SERIAL_EVT_MESH_MESSAGE_RECEIVED_DATA_MAXLEN
Message received event data max length.
Definition: serial_types.h:53
serial_evt_dfu_bank_t bank
DFU bank available parameters.
Definition: serial_evt.h:374
serial_evt_prov_invite_received_t invite_received
Invite received event params.
Definition: serial_evt.h:238
#define NRF_MESH_KEY_SIZE
Size (in octets) of an encryption key.
uint8_t static_oob_types
The available static OOB authentication methods.
Definition: serial_evt.h:165
int8_t rssi
RSSI of the received unprovisioned beacon.
Definition: serial_evt.h:139
uint16_t actual_length
Length of the received message, may be larger than the data reported if SERIAL_EVT_MESH_MESSAGE_RECEI...
Definition: serial_evt.h:290
uint8_t adv_addr_type
Advertisement address type of the last hop sender.
Definition: serial_evt.h:283
DFU firmware outdated event parameters.
Definition: serial_evt.h:360
#define NRF_MESH_UUID_SIZE
Size (in octets) of a UUID.
serial_evt_device_started_t started
Device started parameters.
Definition: serial_evt.h:130
uint8_t context_id
Context ID of the provisioning link.
Definition: serial_evt.h:184
nrf_mesh_fwid_t fwid
Firmware ID of the transfer.
Definition: serial_evt.h:353
ECDH request packet.
Definition: serial_evt.h:210
DFU bank available event parameters.
Definition: serial_evt.h:350
serial_evt_cmd_rsp_t cmd_rsp
Command response parameters.
Definition: serial_evt.h:381
uint8_t adv_addr_type
The advertisement address type of the sender of the unprovisioned beacon.
Definition: serial_evt.h:141
nrf_mesh_fwid_t available_fwid
Firmware ID of the newest firmware available.
Definition: serial_evt.h:363
Mesh key refresh event parameters.
Definition: serial_evt.h:302
uint8_t context_id
Context ID of the provisioning link.
Definition: serial_evt.h:177
Provisioning event parameters.
Definition: serial_evt.h:232
#define NRF_MESH_ECDH_PUBLIC_KEY_SIZE
Size of an ECDH public key.
Event generated by one of the initialized models.
Definition: serial_evt.h:255
uint16_t dst
Destination unicast address or subscription handle.
Definition: serial_evt.h:275
serial_evt_dfu_t dfu
DFU parameters.
Definition: serial_evt.h:386
DFU event parameters.
Definition: serial_evt.h:368
serial_evt_prov_output_request_t output_request
Output request event parameters.
Definition: serial_evt.h:243
uint8_t phase
Current key refresh phase for the network key being updated.
Definition: serial_evt.h:305
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:362
serial_evt_prov_caps_received_t caps_received
Capabilities received parameters.
Definition: serial_evt.h:237
uint8_t is_signed
Whether the bank is signed or not.
Definition: serial_evt.h:356
Device started event packet.
Definition: serial_evt.h:105
DFU start event parameters.
Definition: serial_evt.h:333
Command response packet.
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:329
serial_evt_device_echo_t echo
Echo parameters.
Definition: serial_evt.h:131
uint8_t role
The device&#39;s role in the transfer.
Definition: serial_evt.h:335
serial_evt_prov_t prov
Provisioning parameters.
Definition: serial_evt.h:383
Mesh IV update event parameters.
Definition: serial_evt.h:296
uint8_t size
Authentication size.
Definition: serial_evt.h:206
serial_evt_model_specific_t model
Event generated by one of the models.
Definition: serial_evt.h:387
uint8_t key_refresh_flag
Key refresh in progress flag.
Definition: serial_evt.h:195
Unprovisioned beacon received.
Definition: serial_evt.h:136
uint16_t appkey_handle
Handle of the application the message was received on.
Definition: serial_evt.h:277
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:344
Provisioning start event.
Definition: serial_evt.h:182
uint8_t context_id
Context ID of the completed provisioning link.
Definition: serial_evt.h:190
uint8_t public_key_type
The public key type used for the provisioning session.
Definition: serial_evt.h:164
serial_evt_model_specific_header_t model_evt_info
Contains the model id the event generates from and the model specific event type. ...
Definition: serial_evt.h:258
serial_evt_dfu_req_source_t req_source
DFU source request parameters.
Definition: serial_evt.h:371
uint8_t action
Authentication action.
Definition: serial_evt.h:205
uint32_t iv_index
IV index for the network.
Definition: serial_evt.h:191
uint8_t context_id
Context ID of the link the ECDH request appeared on.
Definition: serial_evt.h:212
Provisioning authentication data request event packet.
Definition: serial_evt.h:201
serial_evt_mesh_t mesh
Mesh parameters.
Definition: serial_evt.h:385
uint16_t netkey_index
Network key index of the network key being updated.
Definition: serial_evt.h:304
uint8_t evt_type
Type of the event generated.
Definition: serial_evt.h:251
uint8_t error_code
Provisioning error code.
Definition: serial_evt.h:229
uint8_t authority
Authority level of the transfer.
Definition: serial_evt.h:323
uint8_t method
Method of authentication requested.
Definition: serial_evt.h:204
uint8_t context_id
Context ID of the link the output request appeared on.
Definition: serial_evt.h:220
uint8_t input_oob_size
Maximum size of the input OOB supported.
Definition: serial_evt.h:170
serial_evt_prov_auth_request_t auth_request
Authorization request event parameters.
Definition: serial_evt.h:241
uint8_t packet_size
Size (in bytes) of the packet.
Definition: serial_evt.h:123
serial_evt_prov_start_received_t start_received
Start received event params.
Definition: serial_evt.h:239
serial_evt_prov_ecdh_request_t ecdh_request
ECDH request event parameters.
Definition: serial_evt.h:242
serial_evt_dfu_req_relay_t req_relay
DFU relay request parameters.
Definition: serial_evt.h:370
Output request packet.
Definition: serial_evt.h:218
nrf_mesh_fwid_t fwid
Firmware ID of the transfer.
Definition: serial_evt.h:345
uint8_t output_oob_size
Maximum size of the output OOB supported.
Definition: serial_evt.h:167
Provisioning capabilities received event.
Definition: serial_evt.h:159
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:352
access_model_id_t model_id
ID of the model generating the event.
Definition: serial_evt.h:250
uint16_t src
Source address of the received packet.
Definition: serial_evt.h:273
serial_evt_dfu_start_t start
DFU start parameters.
Definition: serial_evt.h:372
DFU end event parameters.
Definition: serial_evt.h:341
#define NRF_MESH_ECDH_PRIVATE_KEY_SIZE
Size of an ECDH private key.
uint8_t num_elements
The number of elements on the unprovisoined device.
Definition: serial_evt.h:163
uint8_t data_credit_available
The number of bytes available in each of the tx and rx buffers.
Definition: serial_evt.h:109
Device event parameters.
Definition: serial_evt.h:128
uint8_t ttl
Packet time to live value when first received.
Definition: serial_evt.h:281
DFU relay request event parameters.
Definition: serial_evt.h:319
uint8_t end_reason
Reason for ending the transfer.
Definition: serial_evt.h:346
uint16_t output_oob_actions
Available OOB output actions.
Definition: serial_evt.h:168
serial_evt_application_t application
Application parameters.
Definition: serial_evt.h:384
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:336
Union of all serial event parameters.
Definition: serial_evt.h:309
serial_evt_dfu_firmware_outdated_t firmware_outdated
Firmware outdated parameters.
Definition: serial_evt.h:375
uint8_t event_type
Reported event.
Definition: serial_evt.h:121
uint8_t context_id
Context ID of the link the authorization request appeared on.
Definition: serial_evt.h:203
serial_evt_dfu_end_t end
DFU end parameters.
Definition: serial_evt.h:373
Provisioning complete event packet.
Definition: serial_evt.h:188
uint32_t length
Length of the banked firmware.
Definition: serial_evt.h:355
uint8_t context_id
Context ID of the link the capabilities were received on.
Definition: serial_evt.h:161
serial_evt_prov_unprov_t unprov
Unprovisioned event parameters.
Definition: serial_evt.h:234
nrf_mesh_fwid_t current_fwid
Firmware ID of the current version of the outdated firmware.
Definition: serial_evt.h:364
nrf_mesh_fwid_t fwid
Firmware ID of the transfer.
Definition: serial_evt.h:337
Mesh message received event parameters.
Definition: serial_evt.h:270
uint32_t start_addr
Start address of the bank.
Definition: serial_evt.h:354
Access layer model ID.
Definition: access.h:151
uint32_t iv_index
IV index updated to.
Definition: serial_evt.h:298
uint8_t state
State information about the event type reported.
Definition: serial_evt.h:122
serial_evt_mesh_key_refresh_t key_refresh
Key refresh parameters.
Definition: serial_evt.h:313
uint8_t context_id
Context ID of the link the error happened on.
Definition: serial_evt.h:228
serial_evt_prov_link_closed_t link_closed
Link closed event parameters.
Definition: serial_evt.h:236
uint8_t output_action
Output action requested.
Definition: serial_evt.h:221
ID of a standalone firmware segment.
uint8_t hw_error
Hardware error code, or 0 if no error occurred.
Definition: serial_evt.h:108
Header for the model specific events.
Definition: serial_evt.h:248
DFU source request event parameters.
Definition: serial_evt.h:327
Provisioning failed packet.
Definition: serial_evt.h:226
serial_evt_prov_failed_t failed
Provisioning failed event parameters.
Definition: serial_evt.h:244
nrf_mesh_fwid_t fwid
Firmware ID of the requested transfer.
Definition: serial_evt.h:322
uint8_t operating_mode
Operating mode of the device.
Definition: serial_evt.h:107
serial_evt_mesh_message_received_t message_received
Message received parameters.
Definition: serial_evt.h:311
uint16_t subnet_handle
Handle of the subnetwork the message was received on.
Definition: serial_evt.h:279
uint16_t address
Unicast address for the device.
Definition: serial_evt.h:193
serial_evt_device_t device
Device parameters.
Definition: serial_evt.h:382
serial_evt_prov_link_established_t link_established
Link established event parameters.
Definition: serial_evt.h:235
serial_evt_prov_complete_t complete
Provisioning complete event parameters.
Definition: serial_evt.h:240
uint8_t attention_duration_s
How long the primary element of the device identifies itself using the Attention Timer in seconds...
Definition: serial_evt.h:178
#define NRF_MESH_SERIAL_PAYLOAD_MAXLEN
Maximum length of a serial packet&#39;s payload.

Documentation feedback | Developer Zone | Subscribe | Updated