nRF5 SDK for Mesh v4.0.0
serial_evt.h
1 /* Copyright (c) 2010 - 2019, 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)
98 #define SERIAL_OPCODE_EVT_MESH_HEARTBEAT_RECEIVED (0xD8)
100 #define SERIAL_OPCODE_EVT_MODEL_SPECIFIC (0xF0)
103 /*lint -align_max(push) -align_max(1) */
104 
106 typedef struct __attribute((packed))
107 {
108  uint8_t operating_mode;
109  uint8_t hw_error;
112 
114 typedef struct __attribute((packed))
115 {
118 
120 typedef struct __attribute((packed))
121 {
122  uint8_t event_type;
123  uint8_t state;
124  uint8_t packet_size;
125  uint8_t packet[BLE_ADV_PACKET_PAYLOAD_MAX_LENGTH];
127 
129 typedef union __attribute((packed))
130 {
135 
137 typedef struct __attribute((packed))
138 {
139  uint8_t uuid[NRF_MESH_UUID_SIZE];
140  int8_t rssi;
141  uint8_t gatt_supported;
142  uint8_t adv_addr_type;
143  uint8_t adv_addr[BLE_GAP_ADDR_LEN];
145 
147 typedef struct __attribute((packed))
148 {
149  uint8_t context_id;
151 
153 typedef struct __attribute((packed))
154 {
155  uint8_t context_id;
156  uint8_t close_reason;
158 
160 typedef struct __attribute((packed))
161 {
162  uint8_t context_id;
164  uint8_t num_elements;
165  uint8_t public_key_type;
168  uint8_t output_oob_size;
171  uint8_t input_oob_size;
172  uint16_t input_oob_actions;
174 
176 typedef struct __attribute((packed))
177 {
178  uint8_t context_id;
181 
183 typedef struct __attribute((packed))
184 {
185  uint8_t context_id;
187 
189 typedef struct __attribute((packed))
190 {
191  uint8_t context_id;
192  uint32_t iv_index;
193  uint16_t net_key_index;
194  uint16_t address;
195  uint8_t iv_update_flag;
197  uint8_t device_key[NRF_MESH_KEY_SIZE];
198  uint8_t net_key[NRF_MESH_KEY_SIZE];
200 
202 typedef struct __attribute((packed))
203 {
204  uint8_t context_id;
205  uint8_t method;
206  uint8_t action;
207  uint8_t size;
209 
211 typedef struct __attribute((packed))
212 {
213  uint8_t context_id;
214  uint8_t peer_public[NRF_MESH_ECDH_PUBLIC_KEY_SIZE];
215  uint8_t node_private[NRF_MESH_ECDH_PRIVATE_KEY_SIZE];
217 
219 typedef struct __attribute((packed))
220 {
221  uint8_t context_id;
222  uint8_t output_action;
223  uint8_t data[16];
225 
227 typedef struct __attribute((packed))
228 {
229  uint8_t context_id;
230  uint8_t error_code;
233 typedef union __attribute((packed))
234 {
247 
249 typedef struct __attribute((packed))
250 {
252  uint8_t evt_type;
254 
256 typedef struct __attribute((packed))
257 {
263 
265 typedef struct __attribute((packed))
266 {
269 
271 typedef struct __attribute((packed))
272 {
274  uint16_t src;
276  uint16_t dst;
278  uint16_t appkey_handle;
280  uint16_t subnet_handle;
282  uint8_t ttl;
284  uint8_t adv_addr_type;
286  uint8_t adv_addr[BLE_GAP_ADDR_LEN];
288  int8_t rssi;
291  uint16_t actual_length;
295 
297 typedef struct __attribute((packed))
298 {
301 
303 typedef struct __attribute((packed))
304 {
305  uint32_t iv_index;
307 
309 typedef struct __attribute((packed))
310 {
311  uint16_t netkey_index;
312  uint8_t phase;
314 
316 typedef struct __attribute((packed))
317 {
319  uint8_t init_ttl;
321  uint8_t hops;
323  uint16_t features;
325  uint16_t src;
327 
329 typedef union __attribute((packed))
330 {
337 
338 /********* DFU parameters *********/
339 
341 typedef struct __attribute((packed))
342 {
343  uint8_t dfu_type;
345  uint8_t authority;
347 
349 typedef struct __attribute((packed))
350 {
351  uint8_t dfu_type;
353 
355 typedef struct __attribute((packed))
356 {
357  uint8_t role;
358  uint8_t dfu_type;
361 
363 typedef struct __attribute((packed))
364 {
365  uint8_t role;
366  uint8_t dfu_type;
368  uint8_t end_reason;
370 
372 typedef struct __attribute((packed))
373 {
374  uint8_t dfu_type;
376  uint32_t start_addr;
377  uint32_t length;
378  uint8_t is_signed;
380 
382 typedef struct __attribute((packed))
383 {
384  uint8_t dfu_type;
388 
390 typedef union __attribute((packed))
391 {
399 
401 typedef union __attribute((packed))
402 {
410 } serial_evt_t;
411 
412 /*lint -align_max(pop) */
415 #endif
416 
uint8_t gatt_supported
Whether the unprovisioned device supports GATT provisioning.
Definition: serial_evt.h:141
Union of all serial event parameters.
Definition: serial_evt.h:401
Application data event parameters.
Definition: serial_evt.h:265
Provisioning invite event.
Definition: serial_evt.h:176
serial_evt_mesh_iv_update_t iv_update
IV update parameters.
Definition: serial_evt.h:333
uint8_t iv_update_flag
IV update in progress flag.
Definition: serial_evt.h:195
serial_evt_device_internal_event_t internal_event
Internal event data.
Definition: serial_evt.h:133
serial_evt_mesh_tx_complete_t tx_complete
TX complete parameters.
Definition: serial_evt.h:332
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:343
uint8_t role
The device&#39;s role in the transfer.
Definition: serial_evt.h:365
uint16_t input_oob_actions
Available OOB input actions.
Definition: serial_evt.h:172
int8_t rssi
RSSI value of the message when received.
Definition: serial_evt.h:288
uint16_t net_key_index
Network key index.
Definition: serial_evt.h:193
#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:396
serial_evt_prov_invite_received_t invite_received
Invite received event params.
Definition: serial_evt.h:239
#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:166
int8_t rssi
RSSI of the received unprovisioned beacon.
Definition: serial_evt.h:140
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:291
uint8_t adv_addr_type
Advertisement address type of the last hop sender.
Definition: serial_evt.h:284
DFU firmware outdated event parameters.
Definition: serial_evt.h:382
#define NRF_MESH_UUID_SIZE
Size (in octets) of a UUID.
uint8_t init_ttl
Initial TTL value used for sending this heartbeat message.
Definition: serial_evt.h:319
serial_evt_device_started_t started
Device started parameters.
Definition: serial_evt.h:131
uint8_t context_id
Context ID of the provisioning link.
Definition: serial_evt.h:185
nrf_mesh_fwid_t fwid
Firmware ID of the transfer.
Definition: serial_evt.h:375
ECDH request packet.
Definition: serial_evt.h:211
DFU bank available event parameters.
Definition: serial_evt.h:372
Mesh heartbeat event parameters.
Definition: serial_evt.h:316
serial_evt_cmd_rsp_t cmd_rsp
Command response parameters.
Definition: serial_evt.h:403
uint8_t adv_addr_type
The advertisement address type of the sender of the unprovisioned beacon.
Definition: serial_evt.h:142
nrf_mesh_fwid_t available_fwid
Firmware ID of the newest firmware available.
Definition: serial_evt.h:385
Mesh key refresh event parameters.
Definition: serial_evt.h:309
uint8_t context_id
Context ID of the provisioning link.
Definition: serial_evt.h:178
Provisioning event parameters.
Definition: serial_evt.h:233
uint8_t hops
Number of hops equals: (Initial TTL - Received message TTL + 1).
Definition: serial_evt.h:321
#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:256
uint16_t dst
Destination unicast address or subscription handle.
Definition: serial_evt.h:276
serial_evt_dfu_t dfu
DFU parameters.
Definition: serial_evt.h:408
nrf_mesh_tx_token_t token
TX token for the completed packet.
Definition: serial_evt.h:299
DFU event parameters.
Definition: serial_evt.h:390
serial_evt_prov_output_request_t output_request
Output request event parameters.
Definition: serial_evt.h:244
uint8_t phase
Current key refresh phase for the network key being updated.
Definition: serial_evt.h:312
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:384
serial_evt_prov_caps_received_t caps_received
Capabilities received parameters.
Definition: serial_evt.h:238
uint8_t is_signed
Whether the bank is signed or not.
Definition: serial_evt.h:378
Device started event packet.
Definition: serial_evt.h:106
uint16_t src
Source address for the received heartbeat message.
Definition: serial_evt.h:325
DFU start event parameters.
Definition: serial_evt.h:355
Command response packet.
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:351
serial_evt_device_echo_t echo
Echo parameters.
Definition: serial_evt.h:132
uint8_t role
The device&#39;s role in the transfer.
Definition: serial_evt.h:357
serial_evt_prov_t prov
Provisioning parameters.
Definition: serial_evt.h:405
Mesh IV update event parameters.
Definition: serial_evt.h:303
uint8_t size
Authentication size.
Definition: serial_evt.h:207
serial_evt_model_specific_t model
Event generated by one of the models.
Definition: serial_evt.h:409
uint8_t key_refresh_flag
Key refresh in progress flag.
Definition: serial_evt.h:196
Unprovisioned beacon received.
Definition: serial_evt.h:137
uint16_t appkey_handle
Handle of the application the message was received on.
Definition: serial_evt.h:278
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:366
Provisioning start event.
Definition: serial_evt.h:183
uint8_t context_id
Context ID of the completed provisioning link.
Definition: serial_evt.h:191
uint8_t public_key_type
The public key type used for the provisioning session.
Definition: serial_evt.h:165
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:259
serial_evt_dfu_req_source_t req_source
DFU source request parameters.
Definition: serial_evt.h:393
uint16_t features
State bitmap of the feature.
Definition: serial_evt.h:323
uint8_t action
Authentication action.
Definition: serial_evt.h:206
uint32_t iv_index
IV index for the network.
Definition: serial_evt.h:192
uint8_t context_id
Context ID of the link the ECDH request appeared on.
Definition: serial_evt.h:213
Provisioning authentication data request event packet.
Definition: serial_evt.h:202
serial_evt_mesh_t mesh
Mesh parameters.
Definition: serial_evt.h:407
uint16_t netkey_index
Network key index of the network key being updated.
Definition: serial_evt.h:311
uint8_t evt_type
Type of the event generated.
Definition: serial_evt.h:252
uint8_t error_code
Provisioning error code.
Definition: serial_evt.h:230
uint8_t authority
Authority level of the transfer.
Definition: serial_evt.h:345
uint8_t method
Method of authentication requested.
Definition: serial_evt.h:205
uint8_t context_id
Context ID of the link the output request appeared on.
Definition: serial_evt.h:221
uint8_t input_oob_size
Maximum size of the input OOB supported.
Definition: serial_evt.h:171
serial_evt_prov_auth_request_t auth_request
Authorization request event parameters.
Definition: serial_evt.h:242
uint8_t packet_size
Size (in bytes) of the packet.
Definition: serial_evt.h:124
serial_evt_prov_start_received_t start_received
Start received event params.
Definition: serial_evt.h:240
serial_evt_prov_ecdh_request_t ecdh_request
ECDH request event parameters.
Definition: serial_evt.h:243
serial_evt_dfu_req_relay_t req_relay
DFU relay request parameters.
Definition: serial_evt.h:392
Output request packet.
Definition: serial_evt.h:219
nrf_mesh_fwid_t fwid
Firmware ID of the transfer.
Definition: serial_evt.h:367
uint8_t output_oob_size
Maximum size of the output OOB supported.
Definition: serial_evt.h:168
Provisioning capabilities received event.
Definition: serial_evt.h:160
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:374
access_model_id_t model_id
ID of the model generating the event.
Definition: serial_evt.h:251
uint32_t nrf_mesh_tx_token_t
TX Token type, used as a context parameter to notify the application of ended transmissions.
Definition: nrf_mesh.h:105
uint16_t src
Source address of the received packet.
Definition: serial_evt.h:274
serial_evt_dfu_start_t start
DFU start parameters.
Definition: serial_evt.h:394
DFU end event parameters.
Definition: serial_evt.h:363
#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:164
uint8_t data_credit_available
The number of bytes available in each of the tx and rx buffers.
Definition: serial_evt.h:110
Device event parameters.
Definition: serial_evt.h:129
uint8_t ttl
Packet time to live value when first received.
Definition: serial_evt.h:282
DFU relay request event parameters.
Definition: serial_evt.h:341
uint8_t end_reason
Reason for ending the transfer.
Definition: serial_evt.h:368
uint16_t output_oob_actions
Available OOB output actions.
Definition: serial_evt.h:169
serial_evt_application_t application
Application parameters.
Definition: serial_evt.h:406
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:358
Union of all serial event parameters.
Definition: serial_evt.h:329
serial_evt_dfu_firmware_outdated_t firmware_outdated
Firmware outdated parameters.
Definition: serial_evt.h:397
uint8_t event_type
Reported event.
Definition: serial_evt.h:122
uint8_t context_id
Context ID of the link the authorization request appeared on.
Definition: serial_evt.h:204
serial_evt_dfu_end_t end
DFU end parameters.
Definition: serial_evt.h:395
Provisioning complete event packet.
Definition: serial_evt.h:189
uint32_t length
Length of the banked firmware.
Definition: serial_evt.h:377
uint8_t context_id
Context ID of the link the capabilities were received on.
Definition: serial_evt.h:162
serial_evt_mesh_hb_message_t heartbeat
Heartbeat message parameters.
Definition: serial_evt.h:335
serial_evt_prov_unprov_t unprov
Unprovisioned event parameters.
Definition: serial_evt.h:235
nrf_mesh_fwid_t current_fwid
Firmware ID of the current version of the outdated firmware.
Definition: serial_evt.h:386
nrf_mesh_fwid_t fwid
Firmware ID of the transfer.
Definition: serial_evt.h:359
Mesh message received event parameters.
Definition: serial_evt.h:271
uint32_t start_addr
Start address of the bank.
Definition: serial_evt.h:376
Access layer model ID.
Definition: access.h:151
uint32_t iv_index
IV index updated to.
Definition: serial_evt.h:305
uint8_t state
State information about the event type reported.
Definition: serial_evt.h:123
serial_evt_mesh_key_refresh_t key_refresh
Key refresh parameters.
Definition: serial_evt.h:334
uint8_t context_id
Context ID of the link the error happened on.
Definition: serial_evt.h:229
Mesh TX complete event.
Definition: serial_evt.h:297
serial_evt_prov_link_closed_t link_closed
Link closed event parameters.
Definition: serial_evt.h:237
uint8_t output_action
Output action requested.
Definition: serial_evt.h:222
ID of a standalone firmware segment.
uint8_t hw_error
Hardware error code, or 0 if no error occurred.
Definition: serial_evt.h:109
Header for the model specific events.
Definition: serial_evt.h:249
DFU source request event parameters.
Definition: serial_evt.h:349
Provisioning failed packet.
Definition: serial_evt.h:227
serial_evt_prov_failed_t failed
Provisioning failed event parameters.
Definition: serial_evt.h:245
nrf_mesh_fwid_t fwid
Firmware ID of the requested transfer.
Definition: serial_evt.h:344
uint8_t operating_mode
Operating mode of the device.
Definition: serial_evt.h:108
serial_evt_mesh_message_received_t message_received
Message received parameters.
Definition: serial_evt.h:331
uint16_t subnet_handle
Handle of the subnetwork the message was received on.
Definition: serial_evt.h:280
uint16_t address
Unicast address for the device.
Definition: serial_evt.h:194
serial_evt_device_t device
Device parameters.
Definition: serial_evt.h:404
serial_evt_prov_link_established_t link_established
Link established event parameters.
Definition: serial_evt.h:236
serial_evt_prov_complete_t complete
Provisioning complete event parameters.
Definition: serial_evt.h:241
uint8_t attention_duration_s
Time in seconds during which the device will identify itself using any means it can.
Definition: serial_evt.h:179
#define NRF_MESH_SERIAL_PAYLOAD_MAXLEN
Maximum length of a serial packet&#39;s payload.

Documentation feedback | Developer Zone | Subscribe | Updated