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
14#if defined(MAC_PROFILE_ISM24) || defined(MAC_PROFILE_SUBG)
15
16/* Wirepas Provisioning Protocol endpoints for 2.4G and SubGHz
17 * - Downlink: Source: 255 ; Destination: 246
18 * - Uplink: Source: 246 ; Destination: 255
19 */
20
22#define PROV_DOWNLINK_SRC_EP 255
23#define PROV_DOWNLINK_DST_EP 246
25#define PROV_UPLINK_SRC_EP 246
26#define PROV_UPLINK_DST_EP 255
27
28#endif
29
30
32#define PROV_PDU_SIZE 135
33
35#define PROV_CTR_SIZE 2
36
38#define PROV_MIC_SIZE 5
39
41#define ENC_KEY_OFFSET 16
42
46#define PROV_DATA_OFFSET (sizeof(pdu_prov_hdr_t) + 1 + PROV_CTR_SIZE)
47
49#define PROV_DATA_MIN_USER_ID 128
50
52#define PROV_DATA_MAX_USER_ID 255
53
55#define JOINING_NETWORK_ADDRESS 0x9E4ADC // "JBTX"
56
58#if defined(MAC_PROFILE_ISM24)
59// For 2.4G MAC profiles, joining network channel is 36
60#define JOINING_NETWORK_CHANNEL 36
61#endif
62
63
64#if defined(MAC_PROFILE_ISM24)
69#define JOINING_RX_TIMEOUT 600
70#endif
71
72#if defined(MAC_PROFILE_ISM24)
74#define JOINING_TX_INTERVAL 500
75#endif
76
81#if defined(MAC_PROFILE_ISM24) || defined(MAC_PROFILE_SUBG)
82// SubG and 2.4G
83#define JOINING_BEACON_TYPE 0x647650fb // "PROVIS"
84
85#endif
86
90#define PROV_START_FLAGS_NONE 0
91
95#define PROV_START_FLAGS_NW_PARAM_EQUAL_CHECK 1
96
110
118
126
127typedef struct __attribute__((__packed__))
128{
129 uint8_t type;
131 uint8_t session_id;
133
134typedef struct __attribute__((__packed__))
135{
137 uint8_t method;
139 uint8_t uid[PROV_PDU_SIZE -
142
143
144typedef struct __attribute__((__packed__))
145{
147 uint8_t key_index;
148 uint16_t counter;
150 /* Mic is added at the end of the data packet.
151 * uint8_t mic[PROV_MIC_SIZE];
152 */
154
155typedef struct __attribute__((__packed__))
156{
159
160typedef struct __attribute__((__packed__))
161{
163 uint8_t nack_type;
165
166typedef union __attribute__((__packed__))
167{
168 union __attribute__((__packed__))
169 {
170 pdu_prov_hdr_t pdu_header;
171 uint8_t pld[PROV_PDU_SIZE - sizeof(pdu_prov_hdr_t)];
172 };
177} pdu_prov_t;
178
195
203
218
224
235
246 bool dry_run);
247
262
270
280
289 const provisioning_failsafe_conf_t * conf);
290
298
306
316
324const app_lib_joining_received_beacon_t *
326 const app_lib_joining_received_beacon_t * beacons);
327
328#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