#ifndef NL_WIFI_H #define NL_WIFI_H #include #include #include "config/nl_settings.h" typedef struct { const char *mode; /* "sta" | "ap" | "apsta" */ char ssid[NL_SSID_LEN]; /* configured station SSID */ int rssi; /* dBm, 0 when not connected */ char ip[16]; /* station IP, else the AP IP when the AP is up, else "" */ char sta_ip[16]; /* "" when the station has no IP */ const char *error; /* result of the last onboarding test or NULL */ } nl_wifi_status_t; /* Incremented once per net_task loop iteration; app_main's watchdog feed checks it to make * sure the network task is still alive, not just the light task. */ extern volatile uint32_t nl_net_beat; /* Starts the network task. An empty ssid starts the onboarding AP. Strings are copied. */ void nl_wifi_start(const char *ssid, const char *pass, const char *ap_pass); /* Switches the SDK's own auto-connect off and drops any connection it may already have brought * up on its own. nl_wifi_start() does this too, but the boot recovery path runs before that and * must not have the SDK joining its stored AP in parallel (I3, final review). Safe to call any * number of times; only writes the SDK parameter when it is actually set. */ void nl_wifi_disable_sdk_auto_connect(void); /* Joins a station directly (no nl_wifi_sm) and blocks until it gets an IP or timeout_ms * elapses; returns true on success. For use before nl_wifi_start() only - e.g. the boot * recovery path in nl_recovery.c - since it drives the SDK Wi-Fi calls itself instead of * going through the state machine, and must not race nl_wifi_start()'s own netif status * event registration and s_lock/s_queue setup. Feeds the watchdog itself while it waits. */ bool nl_wifi_join_blocking(const char *ssid, const char *pass, uint32_t timeout_ms); /* Starts an onboarding test with new credentials (from the HTTP task). 0 = queued. */ int nl_wifi_request_onboard(const char *ssid, const char *pass); /* True while the unconfigured onboarding AP is open (API without token). */ bool nl_wifi_open_access(void); void nl_wifi_status(nl_wifi_status_t *out); /* "ninlight-", valid after nl_wifi_start(). */ const char *nl_wifi_hostname(void); void nl_wifi_mac(uint8_t mac[6]); #endif