11#ifndef NETWORK_PROVISIONING_NETWORK_PROV_MGR_H_
12#define NETWORK_PROVISIONING_NETWORK_PROV_MGR_H_
80 int (*
start)(
struct protocomm *pc,
const char *service_name,
81 const char *service_key);
125 const uint8_t *inbuf,
size_t inlen,
126 uint8_t **outbuf,
size_t *outlen);
183 const char *
const *capabilities,
184 size_t capabilities_count);
211 const char *service_name,
212 const char *service_key);
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.
network_prov_cb_t event_cb
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.