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
57
58#if defined(MAC_PROFILE_DECTNR) || defined(MAC_PROFILE_SUBG)
59// For SubGhz and 5G Mesh MAC profiles, joining network channel 4 is used
60#define JOINING_NETWORK_CHANNEL 4
61#endif
62
63#if defined(MAC_PROFILE_SUBG)
68#define JOINING_RX_TIMEOUT 5100
69#endif
70
71#if defined(MAC_PROFILE_SUBG)
73#define JOINING_TX_INTERVAL 5000
74#endif
75
80#if defined(MAC_PROFILE_ISM24) || defined(MAC_PROFILE_SUBG)
81// SubG and 2.4G
82#define JOINING_BEACON_TYPE 0x647650fb // "PROVIS"
83
84#endif
85
89#define PROV_START_FLAGS_NONE 0
90
94#define PROV_START_FLAGS_NW_PARAM_EQUAL_CHECK 1
95
109
117
125
126typedef struct __attribute__((__packed__))
127{
128 uint8_t type;
130 uint8_t session_id;
132
133typedef struct __attribute__((__packed__))
134{
136 uint8_t method;
138 uint8_t uid[PROV_PDU_SIZE -
141
142
143typedef struct __attribute__((__packed__))
144{
146 uint8_t key_index;
147 uint16_t counter;
149 /* Mic is added at the end of the data packet.
150 * uint8_t mic[PROV_MIC_SIZE];
151 */
153
154typedef struct __attribute__((__packed__))
155{
158
159typedef struct __attribute__((__packed__))
160{
162 uint8_t nack_type;
164
165typedef union __attribute__((__packed__))
166{
167 union __attribute__((__packed__))
168 {
169 pdu_prov_hdr_t pdu_header;
170 uint8_t pld[PROV_PDU_SIZE - sizeof(pdu_prov_hdr_t)];
171 };
176} pdu_prov_t;
177
194
202
217
223
234
245 bool dry_run);
246
261
269
279
288 const provisioning_failsafe_conf_t * conf);
289
297
305
315
323const app_lib_joining_received_beacon_t *
325 const app_lib_joining_received_beacon_t * beacons);
326
327#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