Wirepas SDK
local_provisioning.h File Reference

Detailed Description

Local provisioning library.

Definition in file local_provisioning.h.

Go to the source code of this file.

Typedefs

typedef void(* local_provisioning_proxy_enabled_cb) (bool enabled)
 Callback to be notified when proxy is enabled It is an information for app. It can be used to blink a led for example. More...
 
typedef bool(* local_provisioning_joining_done_cb) (bool success)
 Callback to be notified when local provisioning joining is finished It is an information for app. More...
 

Functions

Local_provisioning_res_e Local_provisioning_init (local_provisioning_psk_t *psk, local_provisioning_proxy_enabled_cb on_proxy_enabled_cb)
 Initialize the Local provisioning library. More...
 
bool Local_provisioning_is_provisioned ()
 Is the node provisioned A node is considered provisioned if it has a valid config with network security keys set. More...
 
Local_provisioning_res_e Local_provisioning_start_joining (local_provisioning_joining_beacon_selection_f cb_beacons, local_provisioning_joining_done_cb cb_end)
 Start a joining session Node will start a joining request. More...
 
void Local_provisioning_reset_node ()
 Reset all node settings. More...
 

Data Structures

struct  local_provisioning_psk_t
 Pre shared key structure. More...
 

Enumerations

enum  Local_provisioning_res_e {
  LOCAL_PROVISIONING_RES_SUCCESS = 0, LOCAL_PROVISIONING_RES_UNINTIALLIZED = 1, LOCAL_PROVISIONING_RES_WRONG_STATE = 2, LOCAL_PROVISIONING_RES_INTERNAL_ERROR = 3,
  LOCAL_PROVISIONING_RES_UNPROVISIONED = 4, LOCAL_PROVISIONING_RES_ALREADY_PROVISIONED = 5
}
 

Variables

const typedef app_lib_joining_received_beacon_t *(* local_provisioning_joining_beacon_selection_f )(const app_lib_joining_received_beacon_t *beacons)
 Selects which joining beacon to connect to at the end of a scan. More...
 

Typedef Documentation

◆ local_provisioning_joining_done_cb

typedef bool(* local_provisioning_joining_done_cb) (bool success)

Callback to be notified when local provisioning joining is finished It is an information for app.

Parameters
successTrue if provisioning session ended with a valid configuration, false otherwise
Returns
True if the stack must be stopped in case of unsuccessful provisioning. If it is successful, it will always be restarted
Note
As stack must be started to try to join a newtork, it must be stoped at the end in case provisioning fails, otherwise network will scan on a network that doesn't exist. But it will generate a reboot. If not desired and main powered, satck can stay started

Definition at line 70 of file local_provisioning.h.

◆ local_provisioning_proxy_enabled_cb

typedef void(* local_provisioning_proxy_enabled_cb) (bool enabled)

Callback to be notified when proxy is enabled It is an information for app. It can be used to blink a led for example.

Parameters
enabledTrue if joining beacons are currently sent, false otherwise

Definition at line 56 of file local_provisioning.h.

Function Documentation

◆ Local_provisioning_init()

Local_provisioning_res_e Local_provisioning_init ( local_provisioning_psk_t psk,
local_provisioning_proxy_enabled_cb  on_proxy_enabled_cb 
)

Initialize the Local provisioning library.

Parameters
pskPre Shared Key used between joining node and neighbor node. If set to NULL, secure method is still used but with a default key.
Returns
Result code of the operation
Note
If psk is not set, even if data exchange is encrypted, anyone could decrypt it thanks to the default key available on GitHub. It is highly recommended to define a personal secret key that will be the same in all the nodes that can interact.
Examples
dualmcu_app/app.c.

◆ Local_provisioning_is_provisioned()

bool Local_provisioning_is_provisioned ( )

Is the node provisioned A node is considered provisioned if it has a valid config with network security keys set.

Note
Once provisioned, a node will automatically wait on app config specific order to start sending its joining beacons
Returns
True if node is provisioned, false otherwise.

◆ Local_provisioning_reset_node()

void Local_provisioning_reset_node ( )

Reset all node settings.

Note
This call will genrate a reboot of node and will never return

◆ Local_provisioning_start_joining()

Start a joining session Node will start a joining request.

Parameters
cb_beaconsCallback to be called after a beacon scan to select the node to do the joining. If set to NULL, the beacon with the highest RSSI is selected
cb_endCallback to be called at the end of joining. If set to NULL, the stack is automatically stopped in case of failure
Returns
Result code of the operation

Data Structure Documentation

◆ local_provisioning_psk_t

struct local_provisioning_psk_t

Pre shared key structure.

Definition at line 31 of file local_provisioning.h.

Data Fields
uint32_t id
uint8_t psk[32]

Enumeration Type Documentation

◆ Local_provisioning_res_e

Enumerator
LOCAL_PROVISIONING_RES_SUCCESS 

Operation is a success.

LOCAL_PROVISIONING_RES_UNINTIALLIZED 
LOCAL_PROVISIONING_RES_WRONG_STATE 
LOCAL_PROVISIONING_RES_INTERNAL_ERROR 
LOCAL_PROVISIONING_RES_UNPROVISIONED 
LOCAL_PROVISIONING_RES_ALREADY_PROVISIONED 

Definition at line 19 of file local_provisioning.h.

Variable Documentation

◆ local_provisioning_joining_beacon_selection_f

const typedef app_lib_joining_received_beacon_t*(* local_provisioning_joining_beacon_selection_f) (const app_lib_joining_received_beacon_t *beacons)

Selects which joining beacon to connect to at the end of a scan.

Note
Joining network selection is up to the application. Any algorithm can be implemented for example by looking at the content of the beacon payload, or the network (address and channel) the node sending the beacons is connected to.
Parameters
beaconsA buffer of joining beacons.
Returns
The selected beacon.

Definition at line 48 of file local_provisioning.h.

Local_provisioning_res_e
Local_provisioning_res_e
Definition: local_provisioning.h:19
LOCAL_PROVISIONING_RES_WRONG_STATE
@ LOCAL_PROVISIONING_RES_WRONG_STATE
Definition: local_provisioning.h:22
LOCAL_PROVISIONING_RES_INTERNAL_ERROR
@ LOCAL_PROVISIONING_RES_INTERNAL_ERROR
Definition: local_provisioning.h:23
LOCAL_PROVISIONING_RES_UNPROVISIONED
@ LOCAL_PROVISIONING_RES_UNPROVISIONED
Definition: local_provisioning.h:24
LOCAL_PROVISIONING_RES_UNINTIALLIZED
@ LOCAL_PROVISIONING_RES_UNINTIALLIZED
Definition: local_provisioning.h:21
LOCAL_PROVISIONING_RES_SUCCESS
@ LOCAL_PROVISIONING_RES_SUCCESS
Definition: local_provisioning.h:20
LOCAL_PROVISIONING_RES_ALREADY_PROVISIONED
@ LOCAL_PROVISIONING_RES_ALREADY_PROVISIONED
Definition: local_provisioning.h:25