Wirepas SDK
provisioning_int.h
Go to the documentation of this file.
1/* Copyright 2019 Wirepas Ltd. All Rights Reserved.
2 *
3 * See file LICENSE.txt for full license details.
4 *
5 */
6#ifndef _PROVISIONING_INT_H_
7#define _PROVISIONING_INT_H_
8
9#include <stdint.h>
10#include "api.h"
11#include "aessw.h"
12
13#if defined(MAC_PROFILE_DECTNR)
14
15/* Wirepas Provisioning Protocol endpoints for 5GMesh
16 *
17 * - Downlink: Source: 0xA0 ; Destination: 0x28
18 * - Uplink: Source: 0xA0 ; Destination: 0x27
19 */
21#define PROV_DOWNLINK_SRC_EP 0xA0
22#define PROV_DOWNLINK_DST_EP 0x28
24#define PROV_UPLINK_SRC_EP 0xA0
25#define PROV_UPLINK_DST_EP 0x27
26#endif
27
28
29
31#define PROV_PDU_SIZE 135
32
34#define PROV_CTR_SIZE 2
35
37#define PROV_MIC_SIZE 5
38
40#define ENC_KEY_OFFSET 16
41
45#define PROV_DATA_OFFSET (sizeof(pdu_prov_hdr_t) + 1 + PROV_CTR_SIZE)
46
48#define PROV_DATA_MIN_USER_ID 128
49
51#define PROV_DATA_MAX_USER_ID 255
52
54#define JOINING_NETWORK_ADDRESS 0x9E4ADC // "JBTX"
55
56
57#if defined(MAC_PROFILE_DECTNR) || defined(MAC_PROFILE_SUBG)
58// For SubGhz and 5G Mesh MAC profiles, joining network channel 4 is used
59#define JOINING_NETWORK_CHANNEL 4
60#endif
61
62#if defined(MAC_PROFILE_DECTNR)
67#define JOINING_RX_TIMEOUT 2100
68#endif
69
70#if defined(MAC_PROFILE_DECTNR)
72#define JOINING_TX_INTERVAL 2000
73#endif
74
78#if defined(MAC_PROFILE_DECTNR)
79// For 5G Mesh the beacon type equals the provisioning data EP
80#define JOINING_BEACON_TYPE 0xA027
81#endif
82
83
87#define PROV_START_FLAGS_NONE 0
88
92#define PROV_START_FLAGS_NW_PARAM_EQUAL_CHECK 1
93
107
115
123
124typedef struct __attribute__((__packed__))
125{
126 uint8_t type;
128 uint8_t session_id;
130
131typedef struct __attribute__((__packed__))
132{
134 uint8_t method;
136 uint8_t uid[PROV_PDU_SIZE -
139
140
141typedef struct __attribute__((__packed__))
142{
144 uint8_t key_index;
145 uint16_t counter;
147 /* Mic is added at the end of the data packet.
148 * uint8_t mic[PROV_MIC_SIZE];
149 */
151
152typedef struct __attribute__((__packed__))
153{
156
157typedef struct __attribute__((__packed__))
158{
160 uint8_t nack_type;
162
163typedef union __attribute__((__packed__))
164{
165 union __attribute__((__packed__))
166 {
167 pdu_prov_hdr_t pdu_header;
168 uint8_t pld[PROV_PDU_SIZE - sizeof(pdu_prov_hdr_t)];
169 };
174} pdu_prov_t;
175
192
200
215
221
232
243 bool dry_run);
244
259
267
277
286 const provisioning_failsafe_conf_t * conf);
287
295
303
313
321const app_lib_joining_received_beacon_t *
323 const app_lib_joining_received_beacon_t * beacons);
324
325#endif //_PROVISIONING_INT_H_
#define AES_128_KEY_BLOCK_SIZE
AES 128 block size in bytes.
Definition aessw.h:13
provisioning_ret_e
Return codes of provisioning functions.
const app_lib_joining_received_beacon_t *(* provisioning_joining_beacon_cb_f)(const app_lib_joining_received_beacon_t *beacons)
Selects which joining beacon to connect to at the end of a scan.
provisioning_res_e
Provisioning result.
void(* provisioning_user_data_cb_f)(uint32_t id, CborType type, uint8_t *data, uint8_t len)
Received User provisioning data callback. Provisioning data is received as a map of id:data....
bool(* provisioning_end_cb_f)(provisioning_res_e result)
The end provisioning callback. This function is called at the end of the provisioning process.
bool Provisioning_Failsafe_callback_end(provisioning_res_e result)
Callback for ending provisioning.
#define PROV_PDU_SIZE
const app_lib_joining_received_beacon_t * Provisioning_Failsafe_callback_beacons(const app_lib_joining_received_beacon_t *beacons)
Callback for joining beacon filtering.
provisioning_ret_e Provisioning_Failsafe_start(void)
Start failsafe.
provisioning_ret_e Provisioning_Failsafe_stop(void)
Stop failsafe.
pdu_prov_hdr_t pdu_header
prov_nack_type_e
@ PROV_NACK_TYPE_INVALID_DATA
@ PROV_NACK_TYPE_NOT_AUTHORIZED
@ PROV_NACK_TYPE_INVALID_KEY_IDX
@ PROV_NACK_TYPE_METHOD_NOT_SUPPORTED
#define PROV_DATA_OFFSET
provisioning_start_cb_f start_cb
provisioning_ret_e Provisioning_Failsafe_init(const provisioning_failsafe_conf_t *conf)
Initialize the failsafe module.
pdu_prov_data_t data
provisioning_user_data_cb_f user_data_cb
provisioning_joining_end_cb_f end_cb
pdu_prov_nack_t nack
pdu_prov_data_ack_t data_ack
void(* provisioning_joining_end_cb_f)(provisioning_res_e result)
The end joining callback. This function is called at the end of the joining process.
provisioning_ret_e Provisioning_Data_decode(provisioning_data_conf_t *conf, bool dry_run)
Decode (and apply if valid) the received provisioning data.
provisioning_ret_e(* provisioning_start_cb_f)(void)
Provisioning start callback.
prov_packet_type_e
@ PROV_PACKET_TYPE_DATA
@ PROV_PACKET_TYPE_START
@ PROV_PACKET_TYPE_NACK
@ PROV_PACKET_TYPE_DATA_ACK
provisioning_end_cb_f end_cb
provisioning_ret_e Provisioning_Joining_start(void)
Start the joining process (listen to joining beacon and select a network to join).
provisioning_joining_beacon_cb_f joining_cb
#define PROV_MIC_SIZE
provisioning_ret_e Provisioning_Joining_stop(void)
Stops the joining process.
provisioning_ret_e Provisioning_Joining_init(provisioning_joining_conf_t *conf)
Initialize the Joining module.
pdu_prov_start_t start
provisioning_data_ids_e
List of Wirepas Ids for CBOR encoded provisioning data.
@ PROV_DATA_ID_NET_ADDR
@ PROV_DATA_ID_NET_KEY_SEQ
@ PROV_DATA_ID_MGMT_KEY_SEQ
@ PROV_DATA_ID_ENC_KEY
@ PROV_DATA_ID_MGMT_ENC_KEY
@ PROV_DATA_ID_NODE_ROLE
@ PROV_DATA_ID_AUTH_KEY
@ PROV_DATA_ID_NODE_ADDR
@ PROV_DATA_ID_NET_CHAN
@ PROV_DATA_ID_MGMT_AUTH_KEY
This structure holds the provisioning data parameters.
Structure to hold failsafe parameters.
This structure holds the joining node parameters.
uint32_t app_addr_t
Definition wms_app.h:228