network-provisioning-zephyr
Zephyr port of Espressif's network provisioning protocol (Wi-Fi over BLE / SoftAP / console)
Loading...
Searching...
No Matches
network_prov_mgr.h
Go to the documentation of this file.
1/*
2 * Network provisioning manager for Zephyr (Wi-Fi over BLE).
3 *
4 * Implements the Espressif "network provisioning" wire protocol so that the
5 * stock ESP BLE Provisioning apps (Android/iOS) can configure a Zephyr
6 * device's Wi-Fi credentials over a secure protocomm session.
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10
11#ifndef NETWORK_PROVISIONING_NETWORK_PROV_MGR_H_
12#define NETWORK_PROVISIONING_NETWORK_PROV_MGR_H_
13
14#include <stdbool.h>
15#include <stddef.h>
16#include <stdint.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
29
40
46
55typedef void (*network_prov_cb_t)(void *user_data,
56 enum network_prov_cb_event event,
57 void *event_data);
58
64
65struct protocomm; /* forward declaration — the scheme vtable only needs a pointer */
66
80 int (*start)(struct protocomm *pc, const char *service_name,
81 const char *service_key);
83 void (*stop)(void);
84};
85
103
113
116
124typedef int (*network_prov_endpoint_handler_t)(void *user_ctx,
125 const uint8_t *inbuf, size_t inlen,
126 uint8_t **outbuf, size_t *outlen);
127
143int network_prov_mgr_endpoint_create(const char *ep_name);
144
155 void *user_ctx);
156
164
182int network_prov_mgr_set_app_info(const char *label, const char *version,
183 const char *const *capabilities,
184 size_t capabilities_count);
185
192int network_prov_mgr_is_provisioned(bool *provisioned);
193
210 const char *pop,
211 const char *service_name,
212 const char *service_key);
213
216
232int network_prov_mgr_disable_auto_stop(uint32_t cleanup_delay_ms);
233
236
245
254
266int network_prov_mgr_configure_wifi_sta(const char *ssid, const char *psk);
267
277
280
291
292#ifdef __cplusplus
293}
294#endif
295
296#endif /* NETWORK_PROVISIONING_NETWORK_PROV_MGR_H_ */
void network_prov_mgr_wait(void)
Block until provisioning completes (NETWORK_PROV_CRED_SUCCESS).
int network_prov_mgr_configure_wifi_sta(const char *ssid, const char *psk)
Apply Wi-Fi credentials programmatically, as if received from a client.
int network_prov_mgr_reset_wifi_sm_state_for_reprovision(void)
Reset the Wi-Fi provisioning state machine to accept a new network while the service is still running...
int network_prov_mgr_set_app_info(const char *label, const char *version, const char *const *capabilities, size_t capabilities_count)
Advertise an application-specific section in the proto-ver capabilities JSON.
bool network_prov_mgr_is_sm_idle(void)
True when no provisioning session is active (state machine idle).
int network_prov_mgr_reset_wifi_provisioning(void)
Erase all stored Wi-Fi credentials; the device reverts to unprovisioned.
int network_prov_mgr_endpoint_create(const char *ep_name)
Create an application-specific protocomm endpoint.
network_prov_security
Security scheme used for the protocomm session.
@ NETWORK_PROV_SECURITY_1
Curve25519 key exchange + AES-256-CTR + optional proof-of-possession.
@ NETWORK_PROV_SECURITY_0
No security: payloads exchanged in plaintext (bring-up/testing only).
int network_prov_mgr_endpoint_unregister(const char *ep_name)
Detach a custom endpoint's handler; subsequent requests report unsupported until it is registered aga...
int network_prov_mgr_reset_wifi_sm_state_on_failure(void)
Reset the Wi-Fi provisioning state machine after a failed attempt so the app can supply fresh credent...
int network_prov_mgr_disable_auto_stop(uint32_t cleanup_delay_ms)
Disable the automatic teardown of the provisioning service after a successful connection.
int(* network_prov_endpoint_handler_t)(void *user_ctx, const uint8_t *inbuf, size_t inlen, uint8_t **outbuf, size_t *outlen)
Handler for an application-defined custom endpoint.
int network_prov_mgr_endpoint_register(const char *ep_name, network_prov_endpoint_handler_t handler, void *user_ctx)
Attach a handler to a created custom endpoint.
int network_prov_mgr_is_provisioned(bool *provisioned)
Report whether the device already has stored Wi-Fi credentials.
void network_prov_mgr_stop_provisioning(void)
Stop advertising and tear down the transport (keeps the manager init'd).
int network_prov_mgr_start_provisioning(enum network_prov_security security, const char *pop, const char *service_name, const char *service_key)
Start the provisioning service on the configured transport: BLE (register the GATT service and advert...
network_prov_cb_event
Events emitted by the manager over the application event handler.
@ NETWORK_PROV_DEINIT
Manager de-initialised.
@ NETWORK_PROV_CRED_SUCCESS
Connected successfully with the credentials.
@ NETWORK_PROV_START
Provisioning started, transport advertising.
@ NETWORK_PROV_CRED_RECV
Wi-Fi credentials received from the app.
@ NETWORK_PROV_INIT
Manager initialised.
@ NETWORK_PROV_CRED_FAIL
Failed to connect with the received credentials.
@ NETWORK_PROV_END
Provisioning stopped.
network_prov_cred_fail_reason
Reason reported alongside NETWORK_PROV_CRED_FAIL.
@ NETWORK_PROV_WIFI_NETWORK_NOT_FOUND
Requested SSID not found.
@ NETWORK_PROV_WIFI_AUTH_ERROR
Authentication failed (bad passphrase).
void(* network_prov_cb_t)(void *user_data, enum network_prov_cb_event event, void *event_data)
Application event callback.
void network_prov_mgr_deinit(void)
Tear down the manager and free its resources.
int network_prov_mgr_init(struct network_prov_mgr_config config)
Initialise the provisioning manager.
int network_prov_mgr_get_wifi_remaining_conn_attempts(uint32_t *attempts_remaining)
Number of Wi-Fi connection attempts left for the credentials currently being tried (wifi_conn_attempt...
Registration of an application event handler.
Manager configuration passed to network_prov_mgr_init.
struct network_prov_event_handler app_event_handler
Application event handler (may have a NULL callback).
const struct network_prov_scheme * scheme
Transport scheme object, e.g.
uint32_t wifi_conn_attempts
Maximum Wi-Fi connection attempts per provisioning try.
Provisioning transport (scheme) vtable.
int(* start)(struct protocomm *pc, const char *service_name, const char *service_key)
Start the transport for protocomm instance pc.
void(* stop)(void)
Tear the transport down.