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 
85 
89 typedef enum
90 {
95 
100 
106 
114 
118 #define PROV_METHOD_IS_UNSECURED(x) ((x) == 0)
119 
123 #define PROV_METHOD_IS_SECURED(x) (((x) & PROV_METHOD_FLAG_SECURED) != 0)
124 
128 #define PROV_METHOD_IS_EXTENDED_UID(x) (((x) & PROV_METHOD_FLAG_EXTENDED_UID) != 0)
129 
133 #define PROV_METHOD_IS_KEY_MGMT(x) (((x) & PROV_METHOD_FLAG_KEY_MGMT) != 0)
134 
144 
156 typedef void (*provisioning_user_data_cb_f)(uint32_t id,
157  CborType type,
158  uint8_t * data,
159  uint8_t len);
160 
171 typedef const app_lib_joining_received_beacon_t *
172  (*provisioning_joining_beacon_cb_f)
173  (const app_lib_joining_received_beacon_t * beacons);
174 
179 typedef struct
180 {
190 
210  const uint8_t * uid,
211  uint8_t uid_len,
212  provisioning_method_e method,
213  provisioning_proxy_net_param_t * net_param);
214 
215 typedef union
216 {
218  struct
219  {
221  uint8_t authenticator_uid_type;
223  uint8_t authenticator_uid[PROV_AUTH_UID_SIZE_BYTES];
225  uint8_t node_uid_type;
227  uint8_t node_uid[PROV_UUID_SIZE_BYTES];
228  };
230 
231 
236 typedef struct
237 {
241  uint8_t nb_retry;
243  uint16_t timeout_s;
247  uint8_t prov_uid_len;
248 
253  struct
254  {
255  uint8_t auth_key[PROV_KEY_SIZE_BYTES];
256  uint8_t enc_key[PROV_KEY_SIZE_BYTES];
257  } prov_keys;
259 
263 typedef struct
264 {
274 
282 typedef struct
283 {
285  uint8_t * payload;
287  uint8_t num_bytes;
289  int8_t tx_power;
298  const uint8_t * key;
300  uint8_t key_len;
304 
326 
333 
342 
356 
365 
373 
383 
393 
403 
404 #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:173
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:282
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:287
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:239
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:156
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:236
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:263
provisioning_uid_t
Definition: provisioning.h:215
PROV_RET_INVALID_STATE
@ PROV_RET_INVALID_STATE
Definition: provisioning.h:40
PROV_METHOD_UNSECURED
@ PROV_METHOD_UNSECURED
Definition: provisioning.h:94
provisioning_settings_t::timeout_s
uint16_t timeout_s
Definition: provisioning.h:243
provisioning_proxy_conf_t::payload
uint8_t * payload
Definition: provisioning.h:285
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_FLAG_SECURED
@ PROV_METHOD_FLAG_SECURED
Definition: provisioning.h:73
PROV_METHOD_SECURED
@ PROV_METHOD_SECURED
Definition: provisioning.h:99
provisioning_proxy_net_param_t::net_chan
app_lib_settings_net_channel_t net_chan
Definition: provisioning.h:188
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:89
provisioning_proxy_conf_t::is_local_unsec_allowed
bool is_local_unsec_allowed
Definition: provisioning.h:291
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:110
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:266
Provisioning_Proxy_stop
provisioning_ret_e Provisioning_Proxy_stop(void)
Stops the provisioning proxy.
CborType
CborType
Definition: cbor.h:82
PROV_METHOD_FLAG_EXTENDED_UID
@ PROV_METHOD_FLAG_EXTENDED_UID
Definition: provisioning.h:78
PROV_METHOD_FLAG_KEY_MGMT
@ PROV_METHOD_FLAG_KEY_MGMT
Definition: provisioning.h:83
provisioning_conf_t::beacon_joining_cb
provisioning_joining_beacon_cb_f beacon_joining_cb
Definition: provisioning.h:272
provisioning_proxy_conf_t::key
const uint8_t * key
Definition: provisioning.h:298
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:143
provisioning_proxy_conf_t::tx_power
int8_t tx_power
Definition: provisioning.h:289
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:209
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:241
provisioning_method_flag_e
provisioning_method_flag_e
Supported provisioning method bit flags.
Definition: provisioning.h:68
provisioning_conf_t::user_data_cb
provisioning_user_data_cb_f user_data_cb
Definition: provisioning.h:270
provisioning_proxy_conf_t::start_cb
provisioning_proxy_start_cb_f start_cb
Definition: provisioning.h:302
provisioning_settings_t::prov_uid_len
uint8_t prov_uid_len
Definition: provisioning.h:247
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:245
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:293
provisioning_proxy_conf_t::key_len
uint8_t key_len
Definition: provisioning.h:300
provisioning_proxy_net_param_t
This structure contains the network parameters sent by the provisioning proxy to the new node.
Definition: provisioning.h:179
PROV_METHOD_EXTENDED_UID
@ PROV_METHOD_EXTENDED_UID
Definition: provisioning.h:104
provisioning_conf_t::end_cb
provisioning_end_cb_f end_cb
Definition: provisioning.h:268
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:186
api.h