Files
mimiclaw/main/wifi/wifi_manager.h
crispyberry da43c27003 feat: restore NVS runtime config with CLI commands (NVS > build-time priority)
Bring back two-layer configuration: build-time defaults from mimi_secrets.h
with runtime NVS overrides via serial CLI. NVS values take highest priority
so a pre-flashed board can be reconfigured anywhere with just a USB cable.

Restored CLI commands: wifi_set, set_tg_token, set_api_key, set_model,
set_proxy, clear_proxy, set_search_key. Added new commands: config_show
(displays all config with sensitive fields masked), config_reset (clears
all NVS overrides), and help (lists all commands).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 20:42:10 +08:00

47 lines
1.1 KiB
C

#pragma once
#include "esp_err.h"
#include "esp_event.h"
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#define WIFI_CONNECTED_BIT BIT0
#define WIFI_FAIL_BIT BIT1
/**
* Initialize WiFi subsystem (STA mode).
*/
esp_err_t wifi_manager_init(void);
/**
* Start WiFi connection. Non-blocking, fires events.
*/
esp_err_t wifi_manager_start(void);
/**
* Block until WiFi is connected or failed.
* @param timeout_ms Max time to wait (portMAX_DELAY for forever)
* @return ESP_OK if connected, ESP_ERR_TIMEOUT otherwise
*/
esp_err_t wifi_manager_wait_connected(uint32_t timeout_ms);
/**
* Check if WiFi is currently connected.
*/
bool wifi_manager_is_connected(void);
/**
* Get the current IP address string (or "0.0.0.0" if not connected).
*/
const char *wifi_manager_get_ip(void);
/**
* Save WiFi credentials to NVS.
*/
esp_err_t wifi_manager_set_credentials(const char *ssid, const char *password);
/**
* Get the event group for WiFi state (WIFI_CONNECTED_BIT / WIFI_FAIL_BIT).
*/
EventGroupHandle_t wifi_manager_get_event_group(void);