Wirepas SDK
provisioning.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_H_
7 #define _PROVISIONING_H_
8 
9 #include <stdint.h>
10 #include "api.h"
11 #include "wms_joining.h"
12 #include "wms_settings.h"
13 #include "cbor.h"
14 
19 #define PROV_UUID_SIZE_BYTES 16
20 
24 #define PROV_KEY_SIZE_BYTES 16
25 
29 #define PROV_UID_MAX_SIZE_BYTES 79
30 
34 #define PROV_AUTH_UID_SIZE_BYTES 16
35 
37 typedef enum
38 {
46 
48 typedef enum
49 {
64 
68 typedef enum
69 {
74 
79 
84 
90 
94 #define PROV_METHOD_IS_UNSECURED(x) ((x) == PROV_METHOD_UNSECURED)
95 
99 #define PROV_METHOD_IS_SECURED(x) ((x) != PROV_METHOD_UNSECURED)
100 
104 #define PROV_METHOD_IS_EXTENDED_UID(x) ((x) == PROV_METHOD_EXTENDED_UID || x == PROV_METHOD_EXTENDED_UID_KEY_MGMT)
105 
109 #define PROV_METHOD_IS_KEY_MGMT(x) ((x) == PROV_METHOD_EXTENDED_UID_KEY_MGMT)
110 
120 
132 typedef void (*provisioning_user_data_cb_f)(uint32_t id,
133  CborType type,
134  uint8_t * data,
135  uint8_t len);
136 
147 typedef const app_lib_joining_received_beacon_t *
148  (*provisioning_joining_beacon_cb_f)
149  (const app_lib_joining_received_beacon_t * beacons);
150 
155 typedef struct
156 {
166 
186  const uint8_t * uid,
187  uint8_t uid_len,
188  provisioning_method_e method,
189  provisioning_proxy_net_param_t * net_param);
190 
191 typedef union
192 {
194  struct
195  {
197  uint8_t authenticator_uid_type;
199  uint8_t authenticator_uid[PROV_AUTH_UID_SIZE_BYTES];
201  uint8_t node_uid_type;
203  uint8_t node_uid[PROV_UUID_SIZE_BYTES];
204  };
206 
207 
212 typedef struct
213 {
217  uint8_t nb_retry;
219  uint16_t timeout_s;
223  uint8_t prov_uid_len;
224 
229  struct
230  {
231  uint8_t auth_key[PROV_KEY_SIZE_BYTES];
232  uint8_t enc_key[PROV_KEY_SIZE_BYTES];
233  } prov_keys;
235 
239 typedef struct
240 {
258 
266 typedef struct
267 {
269  uint8_t * payload;
271  uint8_t num_bytes;
273  int8_t tx_power;
282  const uint8_t * key;
284  uint8_t key_len;
288 
310 
317 
326 
340 
349 
357 
367 
377 
387 
388 #endif //_PROVISIONING_H_
PROV_RES_ERROR_JOINING
@ PROV_RES_ERROR_JOINING
Definition: provisioning.h:58
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:149
PROV_UUID_SIZE_BYTES
#define PROV_UUID_SIZE_BYTES
Definition: provisioning.h:19
provisioning_proxy_conf_t
This structure holds the joining proxy parameters.
Definition: provisioning.h:266
PROV_UID_MAX_SIZE_BYTES
#define PROV_UID_MAX_SIZE_BYTES
Maximum size of provisioning UID.
Definition: provisioning.h:29
PROV_RET_INVALID_PARAM
@ PROV_RET_INVALID_PARAM
Definition: provisioning.h:41
PROV_RES_SUCCESS
@ PROV_RES_SUCCESS
Definition: provisioning.h:50
provisioning_res_e
provisioning_res_e
Provisioning result.
Definition: provisioning.h:48
app_lib_settings_net_channel_t
uint8_t app_lib_settings_net_channel_t
Channel type definition.
Definition: wms_settings.h:58
wms_joining.h
provisioning_proxy_conf_t::num_bytes
uint8_t num_bytes
Definition: provisioning.h:271
PROV_RES_ERROR_SCANNING_BEACONS
@ PROV_RES_ERROR_SCANNING_BEACONS
Definition: provisioning.h:56
provisioning_settings_t::method
provisioning_method_e method
Definition: provisioning.h:215
PROV_RES_INVALID_PACKET
@ PROV_RES_INVALID_PACKET
Definition: provisioning.h:54
Provisioning_start
provisioning_ret_e Provisioning_start(void)
Start the provisioning process.
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:132
PROV_RET_OK
@ PROV_RET_OK
Definition: provisioning.h:39
Provisioning_Proxy_init
provisioning_ret_e Provisioning_Proxy_init(provisioning_proxy_conf_t *conf)
Initialize the provisioning proxy.
Provisioning_Proxy_start
provisioning_ret_e Provisioning_Proxy_start(void)
Start sending joining beacons. Provisioning packets will be forwarded to provisioning server or treat...
Provisioning_init
provisioning_ret_e Provisioning_init(provisioning_conf_t *conf)
Initialize the provisioning process.
provisioning_settings_t
This structure contains the provisioning settings stored in the secure storage.
Definition: provisioning.h:212
PROV_AUTH_UID_SIZE_BYTES
#define PROV_AUTH_UID_SIZE_BYTES
Authenticator UID size.
Definition: provisioning.h:34
cbor.h
PROV_RES_ERROR_SENDING_DATA
@ PROV_RES_ERROR_SENDING_DATA
Definition: provisioning.h:55
wms_settings.h
provisioning_conf_t
This structure contains all provisioning related parameters.
Definition: provisioning.h:239
provisioning_uid_t
Definition: provisioning.h:191
PROV_RET_INVALID_STATE
@ PROV_RET_INVALID_STATE
Definition: provisioning.h:40
PROV_METHOD_UNSECURED
@ PROV_METHOD_UNSECURED
Definition: provisioning.h:73
provisioning_settings_t::timeout_s
uint16_t timeout_s
Definition: provisioning.h:219
provisioning_proxy_conf_t::payload
uint8_t * payload
Definition: provisioning.h:269
PROV_RET_JOINING_LIB_ERROR
@ PROV_RET_JOINING_LIB_ERROR
Definition: provisioning.h:43
app_lib_settings_net_addr_t
uint32_t app_lib_settings_net_addr_t
Network address type definition.
Definition: wms_settings.h:53
PROV_METHOD_SECURED
@ PROV_METHOD_SECURED
Definition: provisioning.h:78
provisioning_proxy_net_param_t::net_chan
app_lib_settings_net_channel_t net_chan
Definition: provisioning.h:164
Provisioning_stop
provisioning_ret_e Provisioning_stop(void)
Stops the provisioning process.
PROV_RET_INTERNAL_ERROR
@ PROV_RET_INTERNAL_ERROR
Definition: provisioning.h:44
provisioning_method_e
provisioning_method_e
Provisioning methods.
Definition: provisioning.h:68
provisioning_proxy_conf_t::is_local_unsec_allowed
bool is_local_unsec_allowed
Definition: provisioning.h:275
PROV_RES_TIMEOUT
@ PROV_RES_TIMEOUT
Definition: provisioning.h:51
PROV_METHOD_EXTENDED_UID_KEY_MGMT
@ PROV_METHOD_EXTENDED_UID_KEY_MGMT
Definition: provisioning.h:88
PROV_RES_INVALID_DATA
@ PROV_RES_INVALID_DATA
Definition: provisioning.h:53
provisioning_ret_e
provisioning_ret_e
Return codes of provisioning functions.
Definition: provisioning.h:37
provisioning_conf_t::settings
provisioning_settings_t settings
Definition: provisioning.h:242
Provisioning_Proxy_stop
provisioning_ret_e Provisioning_Proxy_stop(void)
Stops the provisioning proxy.
CborType
CborType
Definition: cbor.h:82
provisioning_conf_t::beacon_joining_cb
provisioning_joining_beacon_cb_f beacon_joining_cb
Definition: provisioning.h:256
provisioning_proxy_conf_t::key
const uint8_t * key
Definition: provisioning.h:282
APP_LIB_SETTINGS_AES_KEY_NUM_BYTES
#define APP_LIB_SETTINGS_AES_KEY_NUM_BYTES
AES key size in bytes.
Definition: wms_settings.h:44
PROV_RES_STOPPED
@ PROV_RES_STOPPED
Definition: provisioning.h:60
Provisioning_settings_write
provisioning_ret_e Provisioning_settings_write(const provisioning_settings_t *settings)
Writes provisioning settings to the secure storage.
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:119
provisioning_proxy_conf_t::tx_power
int8_t tx_power
Definition: provisioning.h:273
PROV_KEY_SIZE_BYTES
#define PROV_KEY_SIZE_BYTES
All security keys are 16 bytes long.
Definition: provisioning.h:24
PROV_RET_INVALID_DATA
@ PROV_RET_INVALID_DATA
Definition: provisioning.h:42
provisioning_proxy_start_cb_f
bool(* provisioning_proxy_start_cb_f)(const uint8_t *uid, uint8_t uid_len, provisioning_method_e method, provisioning_proxy_net_param_t *net_param)
The proxy received START packet callback. This function is called when the proxy receives a valid STA...
Definition: provisioning.h:185
Provisioning_settings_read
provisioning_ret_e Provisioning_settings_read(provisioning_settings_t *settings)
Reads provisioning settings from the secure storage.
provisioning_settings_t::nb_retry
uint8_t nb_retry
Definition: provisioning.h:217
provisioning_conf_t::user_data_cb
provisioning_user_data_cb_f user_data_cb
Definition: provisioning.h:250
provisioning_proxy_conf_t::start_cb
provisioning_proxy_start_cb_f start_cb
Definition: provisioning.h:286
provisioning_settings_t::prov_uid_len
uint8_t prov_uid_len
Definition: provisioning.h:223
PROV_RES_ERROR_NO_ROUTE
@ PROV_RES_ERROR_NO_ROUTE
Definition: provisioning.h:59
PROV_RES_NACK
@ PROV_RES_NACK
Definition: provisioning.h:52
provisioning_settings_t::prov_uid
provisioning_uid_t prov_uid
Definition: provisioning.h:221
Provisioning_init_from_storage
provisioning_ret_e Provisioning_init_from_storage(provisioning_conf_t *conf)
Initialize the provisioning process with provisioning settings from the secure storage.
PROV_RES_ERROR_INTERNAL
@ PROV_RES_ERROR_INTERNAL
Definition: provisioning.h:61
provisioning_proxy_conf_t::is_local_sec_allowed
bool is_local_sec_allowed
Definition: provisioning.h:277
provisioning_proxy_conf_t::key_len
uint8_t key_len
Definition: provisioning.h:284
provisioning_proxy_net_param_t
This structure contains the network parameters sent by the provisioning proxy to the new node.
Definition: provisioning.h:155
PROV_METHOD_EXTENDED_UID
@ PROV_METHOD_EXTENDED_UID
Definition: provisioning.h:83
provisioning_conf_t::end_cb
provisioning_end_cb_f end_cb
Definition: provisioning.h:248
PROV_RES_ERROR_FAILSAFE
@ PROV_RES_ERROR_FAILSAFE
Definition: provisioning.h:62
provisioning_proxy_net_param_t::net_addr
app_lib_settings_net_addr_t net_addr
Definition: provisioning.h:162
api.h