network-provisioning-zephyr
Zephyr port of Espressif's network provisioning protocol (Wi-Fi over BLE / SoftAP / console)
Loading...
Searching...
No Matches
fake_wifi.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <zephyr/net/wifi.h>
#include <zephyr/net/wifi_mgmt.h>
Include dependency graph for fake_wifi.h:

Go to the source code of this file.

Data Structures

struct  fake_wifi_ap
 A canned access point the fake backend reports from a scan. More...
 

Functions

void fake_wifi_set_scan_aps (const struct fake_wifi_ap *aps, size_t count)
 Replace the canned AP list returned by subsequent NET_REQUEST_WIFI_SCAN requests.
 
void fake_wifi_set_next_connect_result (enum wifi_conn_status status)
 Program the conn_status reported for the next NET_REQUEST_WIFI_CONNECT.
 
void fake_wifi_set_next_connect_sync_error (int errnum)
 Make the next NET_REQUEST_WIFI_CONNECT fail synchronously with -errnum (e.g.
 
void fake_wifi_set_expected_credentials (const char *ssid, const char *pass)
 Switch the backend to credential-matching mode: the outcome of each connect is derived from the requested credentials rather than a pre-programmed status.
 
void fake_wifi_reset (void)
 Reset all programmed state: empty scan list, connect succeeds, no sync error.
 

Function Documentation

◆ fake_wifi_reset()

void fake_wifi_reset ( void  )

Reset all programmed state: empty scan list, connect succeeds, no sync error.

◆ fake_wifi_set_expected_credentials()

void fake_wifi_set_expected_credentials ( const char *  ssid,
const char *  pass 
)

Switch the backend to credential-matching mode: the outcome of each connect is derived from the requested credentials rather than a pre-programmed status.

With ssid / pass configured as the one "real" network:

  • requested SSID not among the canned scan APs -> AP_NOT_FOUND;
  • SSID matches a canned AP but the passphrase differs -> WRONG_PASSWORD;
  • SSID and passphrase both match -> SUCCESS. This lets a host-side client (esp_prov) drive every outcome purely through the credentials it sends. Pass NULL/empty ssid to leave this mode.

◆ fake_wifi_set_next_connect_result()

void fake_wifi_set_next_connect_result ( enum wifi_conn_status  status)

Program the conn_status reported for the next NET_REQUEST_WIFI_CONNECT.

Use WIFI_STATUS_CONN_SUCCESS, WIFI_STATUS_CONN_WRONG_PASSWORD, WIFI_STATUS_CONN_AP_NOT_FOUND, etc. The setting persists across attempts until changed (so the manager's retry loop sees a consistent failure).

◆ fake_wifi_set_next_connect_sync_error()

void fake_wifi_set_next_connect_sync_error ( int  errnum)

Make the next NET_REQUEST_WIFI_CONNECT fail synchronously with -errnum (e.g.

EINVAL) instead of raising an async result, to exercise the config handler's synchronous-rejection path. One-shot: cleared after it fires.

◆ fake_wifi_set_scan_aps()

void fake_wifi_set_scan_aps ( const struct fake_wifi_ap *  aps,
size_t  count 
)

Replace the canned AP list returned by subsequent NET_REQUEST_WIFI_SCAN requests.

aps is copied (up to CONFIG_NETWORK_PROV_FAKE_WIFI_MAX_AP).