nRF5 SDK for Mesh v2.1.1
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_COMPLETE (0xC5)
85 #define SERIAL_OPCODE_EVT_PROV_AUTH_REQUEST (0xC6)
86 #define SERIAL_OPCODE_EVT_PROV_ECDH_REQUEST (0xC7)
87 #define SERIAL_OPCODE_EVT_PROV_OUTPUT_REQUEST (0xC8)
88 #define SERIAL_OPCODE_EVT_PROV_FAILED (0xC9)
90 #define SERIAL_OPCODE_EVT_MESH_MESSAGE_RECEIVED_UNICAST (0xD0)
91 #define SERIAL_OPCODE_EVT_MESH_MESSAGE_RECEIVED_SUBSCRIPTION (0xD1)
92 #define SERIAL_OPCODE_EVT_MESH_TX_COMPLETE (0xD2)
93 #define SERIAL_OPCODE_EVT_MESH_IV_UPDATE_NOTIFICATION (0xD3)
94 #define SERIAL_OPCODE_EVT_MESH_KEY_REFRESH_NOTIFICATION (0xD4)
95 #define SERIAL_OPCODE_EVT_MESH_SAR_FAILED (0xD7)
97 #define SERIAL_OPCODE_EVT_MODEL_SPECIFIC (0xF0)
100 /*lint -align_max(push) -align_max(1) */
101 
103 typedef struct __attribute((packed))
104 {
105  uint8_t operating_mode;
106  uint8_t hw_error;
109 
111 typedef struct __attribute((packed))
112 {
115 
117 typedef struct __attribute((packed))
118 {
119  uint8_t event_type;
120  uint8_t state;
121  uint8_t packet_size;
122  uint8_t packet[BLE_ADV_PACKET_PAYLOAD_MAX_LENGTH];
124 
126 typedef union __attribute((packed))
127 {
132 
134 typedef struct __attribute((packed))
135 {
136  uint8_t uuid[NRF_MESH_UUID_SIZE];
137  int8_t rssi;
138  uint8_t gatt_supported;
139  uint8_t adv_addr_type;
140  uint8_t adv_addr[BLE_GAP_ADDR_LEN];
142 
144 typedef struct __attribute((packed))
145 {
146  uint8_t context_id;
148 
150 typedef struct __attribute((packed))
151 {
152  uint8_t context_id;
153  uint8_t close_reason;
155 
157 typedef struct __attribute((packed))
158 {
159  uint8_t context_id;
161  uint8_t num_elements;
162  uint8_t public_key_type;
165  uint8_t output_oob_size;
168  uint8_t input_oob_size;
169  uint16_t input_oob_actions;
171 
173 typedef struct __attribute((packed))
174 {
175  uint8_t context_id;
176  uint32_t iv_index;
177  uint16_t net_key_index;
178  uint16_t address;
179  uint8_t iv_update_flag;
181  uint8_t device_key[NRF_MESH_KEY_SIZE];
182  uint8_t net_key[NRF_MESH_KEY_SIZE];
184 
186 typedef struct __attribute((packed))
187 {
188  uint8_t context_id;
189  uint8_t method;
190  uint8_t action;
191  uint8_t size;
193 
195 typedef struct __attribute((packed))
196 {
197  uint8_t context_id;
198  uint8_t peer_public[NRF_MESH_ECDH_PUBLIC_KEY_SIZE];
199  uint8_t node_private[NRF_MESH_ECDH_PRIVATE_KEY_SIZE];
201 
203 typedef struct __attribute((packed))
204 {
205  uint8_t context_id;
206  uint8_t output_action;
207  uint8_t data[16];
209 
211 typedef struct __attribute((packed))
212 {
213  uint8_t context_id;
214  uint8_t error_code;
217 typedef union __attribute((packed))
218 {
229 
231 typedef struct __attribute((packed))
232 {
234  uint8_t evt_type;
236 
238 typedef struct __attribute((packed))
239 {
245 
247 typedef struct __attribute((packed))
248 {
251 
253 typedef struct __attribute((packed))
254 {
256  uint16_t src;
258  uint16_t dst;
260  uint16_t appkey_handle;
262  uint16_t subnet_handle;
264  uint8_t ttl;
266  uint8_t adv_addr_type;
268  uint8_t adv_addr[BLE_GAP_ADDR_LEN];
270  int8_t rssi;
273  uint16_t actual_length;
277 
279 typedef struct __attribute((packed))
280 {
281  uint32_t iv_index;
283 
285 typedef struct __attribute((packed))
286 {
287  uint16_t netkey_index;
288  uint8_t phase;
290 
292 typedef union __attribute((packed))
293 {
298 
299 /********* DFU parameters *********/
300 
302 typedef struct __attribute((packed))
303 {
304  uint8_t dfu_type;
306  uint8_t authority;
308 
310 typedef struct __attribute((packed))
311 {
312  uint8_t dfu_type;
314 
316 typedef struct __attribute((packed))
317 {
318  uint8_t role;
319  uint8_t dfu_type;
322 
324 typedef struct __attribute((packed))
325 {
326  uint8_t role;
327  uint8_t dfu_type;
329  uint8_t end_reason;
331 
333 typedef struct __attribute((packed))
334 {
335  uint8_t dfu_type;
337  uint32_t start_addr;
338  uint32_t length;
339  uint8_t is_signed;
341 
343 typedef struct __attribute((packed))
344 {
345  uint8_t dfu_type;
349 
351 typedef union __attribute((packed))
352 {
360 
362 typedef union __attribute((packed))
363 {
371 } serial_evt_t;
372 
373 /*lint -align_max(pop) */
376 #endif
377 
uint8_t gatt_supported
Whether the unprovisioned device supports GATT provisioning.
Definition: serial_evt.h:138
Union of all serial event parameters.
Definition: serial_evt.h:362
Application data event parameters.
Definition: serial_evt.h:247
serial_evt_mesh_iv_update_t iv_update
IV update parameters.
Definition: serial_evt.h:295
uint8_t iv_update_flag
IV update in progress flag.
Definition: serial_evt.h:179
serial_evt_device_internal_event_t internal_event
Internal event data.
Definition: serial_evt.h:130
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:304
uint8_t role
The device&#39;s role in the transfer.
Definition: serial_evt.h:326
uint16_t input_oob_actions
Available OOB input actions.
Definition: serial_evt.h:169
int8_t rssi
RSSI value of the message when received.
Definition: serial_evt.h:270
uint16_t net_key_index
Network key index.
Definition: serial_evt.h:177
#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:357
#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:163
int8_t rssi
RSSI of the received unprovisioned beacon.
Definition: serial_evt.h:137
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:273
uint8_t adv_addr_type
Advertisement address type of the last hop sender.
Definition: serial_evt.h:266
DFU firmware outdated event parameters.
Definition: serial_evt.h:343
#define NRF_MESH_UUID_SIZE
Size (in octets) of a UUID.
serial_evt_device_started_t started
Device started parameters.
Definition: serial_evt.h:128
nrf_mesh_fwid_t fwid
Firmware ID of the transfer.
Definition: serial_evt.h:336
ECDH request packet.
Definition: serial_evt.h:195
DFU bank available event parameters.
Definition: serial_evt.h:333
serial_evt_cmd_rsp_t cmd_rsp
Command response parameters.
Definition: serial_evt.h:364
uint8_t adv_addr_type
The advertisement address type of the sender of the unprovisioned beacon.
Definition: serial_evt.h:139
nrf_mesh_fwid_t available_fwid
Firmware ID of the newest firmware available.
Definition: serial_evt.h:346
Mesh key refresh event parameters.
Definition: serial_evt.h:285
Provisioning event parameters.
Definition: serial_evt.h:217
#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:238
uint16_t dst
Destination unicast address or subscription handle.
Definition: serial_evt.h:258
serial_evt_dfu_t dfu
DFU parameters.
Definition: serial_evt.h:369
DFU event parameters.
Definition: serial_evt.h:351
serial_evt_prov_output_request_t output_request
Output request event parameters.
Definition: serial_evt.h:226
uint8_t phase
Current key refresh phase for the network key being updated.
Definition: serial_evt.h:288
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:345
serial_evt_prov_caps_received_t caps_received
Capabilities received parameters.
Definition: serial_evt.h:222
uint8_t is_signed
Whether the bank is signed or not.
Definition: serial_evt.h:339
Device started event packet.
Definition: serial_evt.h:103
DFU start event parameters.
Definition: serial_evt.h:316
Command response packet.
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:312
serial_evt_device_echo_t echo
Echo parameters.
Definition: serial_evt.h:129
uint8_t role
The device&#39;s role in the transfer.
Definition: serial_evt.h:318
serial_evt_prov_t prov
Provisioning parameters.
Definition: serial_evt.h:366
Mesh IV update event parameters.
Definition: serial_evt.h:279
uint8_t size
Authentication size.
Definition: serial_evt.h:191
serial_evt_model_specific_t model
Event generated by one of the models.
Definition: serial_evt.h:370
uint8_t key_refresh_flag
Key refresh in progress flag.
Definition: serial_evt.h:180
Unprovisioned beacon received.
Definition: serial_evt.h:134
uint16_t appkey_handle
Handle of the application the message was received on.
Definition: serial_evt.h:260
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:327
uint8_t context_id
Context ID of the completed provisioning link.
Definition: serial_evt.h:175
uint8_t public_key_type
The public key type used for the provisioning session.
Definition: serial_evt.h:162
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:241
serial_evt_dfu_req_source_t req_source
DFU source request parameters.
Definition: serial_evt.h:354
uint8_t action
Authentication action.
Definition: serial_evt.h:190
uint32_t iv_index
IV index for the network.
Definition: serial_evt.h:176
uint8_t context_id
Context ID of the link the ECDH request appeared on.
Definition: serial_evt.h:197
Provisioning authentication data request event packet.
Definition: serial_evt.h:186
serial_evt_mesh_t mesh
Mesh parameters.
Definition: serial_evt.h:368
uint16_t netkey_index
Network key index of the network key being updated.
Definition: serial_evt.h:287
uint8_t evt_type
Type of the event generated.
Definition: serial_evt.h:234
uint8_t error_code
Provisioning error code.
Definition: serial_evt.h:214
uint8_t authority
Authority level of the transfer.
Definition: serial_evt.h:306
uint8_t method
Method of authentication requested.
Definition: serial_evt.h:189
uint8_t context_id
Context ID of the link the output request appeared on.
Definition: serial_evt.h:205
uint8_t input_oob_size
Maximum size of the input OOB supported.
Definition: serial_evt.h:168
serial_evt_prov_auth_request_t auth_request
Authorization request event parameters.
Definition: serial_evt.h:224
uint8_t packet_size
Size (in bytes) of the packet.
Definition: serial_evt.h:121
serial_evt_prov_ecdh_request_t ecdh_request
ECDH request event parameters.
Definition: serial_evt.h:225
serial_evt_dfu_req_relay_t req_relay
DFU relay request parameters.
Definition: serial_evt.h:353
Output request packet.
Definition: serial_evt.h:203
nrf_mesh_fwid_t fwid
Firmware ID of the transfer.
Definition: serial_evt.h:328
uint8_t output_oob_size
Maximum size of the output OOB supported.
Definition: serial_evt.h:165
Provisioning capabilities received event.
Definition: serial_evt.h:157
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:335
access_model_id_t model_id
ID of the model generating the event.
Definition: serial_evt.h:233
uint16_t src
Source address of the received packet.
Definition: serial_evt.h:256
serial_evt_dfu_start_t start
DFU start parameters.
Definition: serial_evt.h:355
DFU end event parameters.
Definition: serial_evt.h:324
#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:161
uint8_t data_credit_available
The number of bytes available in each of the tx and rx buffers.
Definition: serial_evt.h:107
Device event parameters.
Definition: serial_evt.h:126
uint8_t ttl
Packet time to live value when first received.
Definition: serial_evt.h:264
DFU relay request event parameters.
Definition: serial_evt.h:302
uint8_t end_reason
Reason for ending the transfer.
Definition: serial_evt.h:329
uint16_t output_oob_actions
Available OOB output actions.
Definition: serial_evt.h:166
serial_evt_application_t application
Application parameters.
Definition: serial_evt.h:367
uint8_t dfu_type
DFU type of the transfer.
Definition: serial_evt.h:319
Union of all serial event parameters.
Definition: serial_evt.h:292
serial_evt_dfu_firmware_outdated_t firmware_outdated
Firmware outdated parameters.
Definition: serial_evt.h:358
uint8_t event_type
Reported event.
Definition: serial_evt.h:119
uint8_t context_id
Context ID of the link the authorization request appeared on.
Definition: serial_evt.h:188
serial_evt_dfu_end_t end
DFU end parameters.
Definition: serial_evt.h:356
Provisioning complete event packet.
Definition: serial_evt.h:173
uint32_t length
Length of the banked firmware.
Definition: serial_evt.h:338
uint8_t context_id
Context ID of the link the capabilities were received on.
Definition: serial_evt.h:159
serial_evt_prov_unprov_t unprov
Unprovisioned event parameters.
Definition: serial_evt.h:219
nrf_mesh_fwid_t current_fwid
Firmware ID of the current version of the outdated firmware.
Definition: serial_evt.h:347
nrf_mesh_fwid_t fwid
Firmware ID of the transfer.
Definition: serial_evt.h:320
Mesh message received event parameters.
Definition: serial_evt.h:253
uint32_t start_addr
Start address of the bank.
Definition: serial_evt.h:337
Access layer model ID.
Definition: access.h:151
uint32_t iv_index
IV index updated to.
Definition: serial_evt.h:281
uint8_t state
State information about the event type reported.
Definition: serial_evt.h:120
serial_evt_mesh_key_refresh_t key_refresh
Key refresh parameters.
Definition: serial_evt.h:296
uint8_t context_id
Context ID of the link the error happened on.
Definition: serial_evt.h:213
serial_evt_prov_link_closed_t link_closed
Link closed event parameters.
Definition: serial_evt.h:221
uint8_t output_action
Output action requested.
Definition: serial_evt.h:206
ID of a standalone firmware segment.
uint8_t hw_error
Hardware error code, or 0 if no error occurred.
Definition: serial_evt.h:106
Header for the model specific events.
Definition: serial_evt.h:231
DFU source request event parameters.
Definition: serial_evt.h:310
Provisioning failed packet.
Definition: serial_evt.h:211
serial_evt_prov_failed_t failed
Provisioning failed event parameters.
Definition: serial_evt.h:227
nrf_mesh_fwid_t fwid
Firmware ID of the requested transfer.
Definition: serial_evt.h:305
uint8_t operating_mode
Operating mode of the device.
Definition: serial_evt.h:105
serial_evt_mesh_message_received_t message_received
Message received parameters.
Definition: serial_evt.h:294
uint16_t subnet_handle
Handle of the subnetwork the message was received on.
Definition: serial_evt.h:262
uint16_t address
Unicast address for the device.
Definition: serial_evt.h:178
serial_evt_device_t device
Device parameters.
Definition: serial_evt.h:365
serial_evt_prov_link_established_t link_established
Link established event parameters.
Definition: serial_evt.h:220
serial_evt_prov_complete_t complete
Provisioning complete event parameters.
Definition: serial_evt.h:223
#define NRF_MESH_SERIAL_PAYLOAD_MAXLEN
Maximum length of a serial packet&#39;s payload.

Documentation feedback | Developer Zone | Subscribe | Updated