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 /* Wirepas Provisioning Protocol endpoints :
14  * - Downlink: Source: 255 ; Destination: 246
15  * - Uplink: Source: 246 ; Destination: 255
16  */
18 #define PROV_DOWNLINK_EP 255
19 
20 #define PROV_UPLINK_EP 246
21 
23 #define PROV_PDU_SIZE 102
24 
26 #define PROV_CTR_SIZE 2
27 
29 #define PROV_MIC_SIZE 5
30 
32 #define ENC_KEY_OFFSET 16
33 
37 #define PROV_DATA_OFFSET (sizeof(pdu_prov_hdr_t) + 1 + PROV_CTR_SIZE)
38 
40 #define PROV_DATA_MIN_USER_ID 128
41 
43 #define PROV_DATA_MAX_USER_ID 255
44 
46 #define JOINING_NETWORK_ADDRESS 0x9E4ADC // "JBTX"
47 
49 // For Massive, joining network channel is 36
50 #ifdef MAC_PROFILE_ISM24
51 #define JOINING_NETWORK_CHANNEL 36
52 // For other mac profile (SubGhz and 5G Mesh), channel 4 is used
53 #else
54 #define JOINING_NETWORK_CHANNEL 4
55 #endif
56 
61 #define JOINING_RX_TIMEOUT 600
62 
64 #define JOINING_TX_INTERVAL 500
65 
69 #define JOINING_BEACON_TYPE 0x647650fb // "PROVIS"
70 
72 typedef enum
73 {
81 
82 typedef enum
83 {
89 
90 typedef enum
91 {
97 
98 typedef struct __attribute__((__packed__))
99 {
100  uint8_t type;
102  uint8_t session_id;
104 
105 typedef struct __attribute__((__packed__))
106 {
108  uint8_t method;
110  uint8_t uid[PROV_PDU_SIZE -
113 
114 typedef struct __attribute__((__packed__))
115 {
117  uint8_t key_index;
118  uint16_t counter;
120  /* Mic is added at the end of the data packet.
121  * uint8_t mic[PROV_MIC_SIZE];
122  */
124 
125 typedef struct __attribute__((__packed__))
126 {
129 
130 typedef struct __attribute__((__packed__))
131 {
133  uint8_t nack_type;
135 
136 typedef union __attribute__((__packed__))
137 {
138  union __attribute__((__packed__))
139  {
140  pdu_prov_hdr_t pdu_header;
141  uint8_t pld[PROV_PDU_SIZE - sizeof(pdu_prov_hdr_t)];
142  };
147 } pdu_prov_t;
148 
152 typedef struct
153 {
159  uint8_t * buffer;
161  uint8_t length;
163 
171 
175 typedef struct
176 {
182  uint8_t nb_retry;
184 
195  bool dry_run);
196 
211 
219 
229 
230 #endif //_PROVISIONING_INT_H_
provisioning_joining_beacon_cb_f
const typedef 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.
Definition: provisioning.h:88
prov_nack_type_e
prov_nack_type_e
Definition: provisioning_int.h:90
PROV_PACKET_TYPE_NACK
@ PROV_PACKET_TYPE_NACK
Definition: provisioning_int.h:87
pdu_prov_data_t::key_index
uint8_t key_index
Definition: provisioning_int.h:117
provisioning_res_e
provisioning_res_e
Provisioning result.
Definition: provisioning.h:26
pdu_prov_t
Definition: provisioning_int.h:136
PROV_DATA_OFFSET
#define PROV_DATA_OFFSET
Definition: provisioning_int.h:37
PROV_DATA_ID_NODE_ROLE
@ PROV_DATA_ID_NODE_ROLE
Definition: provisioning_int.h:79
provisioning_joining_end_cb_f
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.
Definition: provisioning_int.h:170
provisioning_joining_conf_t::joining_cb
provisioning_joining_beacon_cb_f joining_cb
Definition: provisioning_int.h:178
provisioning_joining_conf_t::nb_retry
uint8_t nb_retry
Definition: provisioning_int.h:182
provisioning_user_data_cb_f
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....
Definition: provisioning.h:71
pdu_prov_data_t
Definition: provisioning_int.h:114
Provisioning_Joining_init
provisioning_ret_e Provisioning_Joining_init(provisioning_joining_conf_t *conf)
Initialize the Joining module.
pdu_prov_t::start
pdu_prov_start_t start
Definition: provisioning_int.h:143
pdu_prov_data_t::counter
uint16_t counter
Definition: provisioning_int.h:118
pdu_prov_hdr_t
Definition: provisioning_int.h:98
pdu_prov_start_t::pdu_header
pdu_prov_hdr_t pdu_header
Definition: provisioning_int.h:107
pdu_prov_t::data
pdu_prov_data_t data
Definition: provisioning_int.h:144
PROV_NACK_TYPE_INVALID_DATA
@ PROV_NACK_TYPE_INVALID_DATA
Definition: provisioning_int.h:94
AES_128_KEY_BLOCK_SIZE
#define AES_128_KEY_BLOCK_SIZE
AES 128 block size in bytes.
Definition: aessw.h:13
pdu_prov_t::data_ack
pdu_prov_data_ack_t data_ack
Definition: provisioning_int.h:145
PROV_PDU_SIZE
#define PROV_PDU_SIZE
Definition: provisioning_int.h:23
PROV_DATA_ID_AUTH_KEY
@ PROV_DATA_ID_AUTH_KEY
Definition: provisioning_int.h:75
pdu_prov_hdr_t::type
uint8_t type
Definition: provisioning_int.h:100
pdu_prov_start_t::method
uint8_t method
Definition: provisioning_int.h:108
pdu_prov_t::nack
pdu_prov_nack_t nack
Definition: provisioning_int.h:146
provisioning_data_conf_t::buffer
uint8_t * buffer
Definition: provisioning_int.h:159
PROV_MIC_SIZE
#define PROV_MIC_SIZE
Definition: provisioning_int.h:29
provisioning_data_ids_e
provisioning_data_ids_e
List of Wirepas Ids for CBOR encoded provisioning data.
Definition: provisioning_int.h:72
provisioning_data_conf_t::user_data_cb
provisioning_user_data_cb_f user_data_cb
Definition: provisioning_int.h:157
PROV_NACK_TYPE_METHOD_NOT_SUPPORTED
@ PROV_NACK_TYPE_METHOD_NOT_SUPPORTED
Definition: provisioning_int.h:93
provisioning_data_conf_t::end_cb
provisioning_end_cb_f end_cb
Definition: provisioning_int.h:155
pdu_prov_hdr_t::address
app_addr_t address
Definition: provisioning_int.h:101
provisioning_ret_e
provisioning_ret_e
Return codes of provisioning functions.
Definition: provisioning.h:15
pdu_prov_nack_t::nack_type
uint8_t nack_type
Definition: provisioning_int.h:133
pdu_prov_data_ack_t
Definition: provisioning_int.h:125
prov_packet_type_e
prov_packet_type_e
Definition: provisioning_int.h:82
provisioning_joining_conf_t::end_cb
provisioning_joining_end_cb_f end_cb
Definition: provisioning_int.h:180
Provisioning_Joining_start
provisioning_ret_e Provisioning_Joining_start(void)
Start the joining process (listen to joining beacon and select a network to join).
PROV_DATA_ID_NET_CHAN
@ PROV_DATA_ID_NET_CHAN
Definition: provisioning_int.h:77
PROV_NACK_TYPE_INVALID_KEY_IDX
@ PROV_NACK_TYPE_INVALID_KEY_IDX
Definition: provisioning_int.h:95
pdu_prov_start_t
Definition: provisioning_int.h:105
app_addr_t
uint32_t app_addr_t
Definition: wms_app.h:228
provisioning_end_cb_f
bool(* provisioning_end_cb_f)(provisioning_res_e result)
The end provisioning callback. This function is called at the end of the provisioning process.
Definition: provisioning.h:58
Provisioning_Joining_stop
provisioning_ret_e Provisioning_Joining_stop(void)
Stops the joining process.
PROV_PACKET_TYPE_DATA
@ PROV_PACKET_TYPE_DATA
Definition: provisioning_int.h:85
provisioning_joining_conf_t
This structure holds the joining node parameters.
Definition: provisioning_int.h:175
PROV_NACK_TYPE_NOT_AUTHORIZED
@ PROV_NACK_TYPE_NOT_AUTHORIZED
Definition: provisioning_int.h:92
PROV_PACKET_TYPE_START
@ PROV_PACKET_TYPE_START
Definition: provisioning_int.h:84
provisioning_data_conf_t::length
uint8_t length
Definition: provisioning_int.h:161
pdu_prov_hdr_t::session_id
uint8_t session_id
Definition: provisioning_int.h:102
pdu_prov_nack_t
Definition: provisioning_int.h:130
aessw.h
PROV_DATA_ID_NET_ADDR
@ PROV_DATA_ID_NET_ADDR
Definition: provisioning_int.h:76
PROV_DATA_ID_ENC_KEY
@ PROV_DATA_ID_ENC_KEY
Definition: provisioning_int.h:74
PROV_DATA_ID_NODE_ADDR
@ PROV_DATA_ID_NODE_ADDR
Definition: provisioning_int.h:78
Provisioning_Data_decode
provisioning_ret_e Provisioning_Data_decode(provisioning_data_conf_t *conf, bool dry_run)
Decode (and apply if valid) the received provisioning data.
provisioning_data_conf_t
This structure holds the provisioning data parameters.
Definition: provisioning_int.h:152
PROV_PACKET_TYPE_DATA_ACK
@ PROV_PACKET_TYPE_DATA_ACK
Definition: provisioning_int.h:86
api.h