refactor: remove NVS/CLI config, use mimi_secrets.h as sole configuration method
All configuration is now done exclusively through mimi_secrets.h at build time. Removed NVS read/write logic, CLI config commands (wifi_set, set_tg_token, set_api_key, set_model, set_proxy, clear_proxy, set_search_key), and setter functions from all modules. CLI retains debug/maintenance commands only. Updated all documentation to reflect the change. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,8 +6,6 @@
|
||||
#include "esp_log.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_netif.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "nvs.h"
|
||||
|
||||
static const char *TAG = "wifi";
|
||||
|
||||
@@ -72,34 +70,15 @@ esp_err_t wifi_manager_init(void)
|
||||
|
||||
esp_err_t wifi_manager_start(void)
|
||||
{
|
||||
wifi_config_t wifi_cfg = {0};
|
||||
|
||||
/* Build-time secrets take highest priority */
|
||||
if (MIMI_SECRET_WIFI_SSID[0] != '\0') {
|
||||
strncpy((char *)wifi_cfg.sta.ssid, MIMI_SECRET_WIFI_SSID, sizeof(wifi_cfg.sta.ssid) - 1);
|
||||
strncpy((char *)wifi_cfg.sta.password, MIMI_SECRET_WIFI_PASS, sizeof(wifi_cfg.sta.password) - 1);
|
||||
} else {
|
||||
/* Fall back to NVS */
|
||||
nvs_handle_t nvs;
|
||||
esp_err_t err = nvs_open(MIMI_NVS_WIFI, NVS_READONLY, &nvs);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "No WiFi credentials. Use CLI: wifi_set <SSID> <PASS>");
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
size_t len = sizeof(wifi_cfg.sta.ssid);
|
||||
err = nvs_get_str(nvs, MIMI_NVS_KEY_SSID, (char *)wifi_cfg.sta.ssid, &len);
|
||||
if (err != ESP_OK) {
|
||||
nvs_close(nvs);
|
||||
ESP_LOGW(TAG, "SSID not found in NVS");
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
len = sizeof(wifi_cfg.sta.password);
|
||||
nvs_get_str(nvs, MIMI_NVS_KEY_PASS, (char *)wifi_cfg.sta.password, &len);
|
||||
nvs_close(nvs);
|
||||
if (MIMI_SECRET_WIFI_SSID[0] == '\0') {
|
||||
ESP_LOGW(TAG, "No WiFi credentials. Set MIMI_SECRET_WIFI_SSID in mimi_secrets.h");
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
wifi_config_t wifi_cfg = {0};
|
||||
strncpy((char *)wifi_cfg.sta.ssid, MIMI_SECRET_WIFI_SSID, sizeof(wifi_cfg.sta.ssid) - 1);
|
||||
strncpy((char *)wifi_cfg.sta.password, MIMI_SECRET_WIFI_PASS, sizeof(wifi_cfg.sta.password) - 1);
|
||||
|
||||
ESP_LOGI(TAG, "Connecting to SSID: %s", wifi_cfg.sta.ssid);
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_cfg));
|
||||
@@ -126,18 +105,6 @@ bool wifi_manager_is_connected(void)
|
||||
return s_connected;
|
||||
}
|
||||
|
||||
esp_err_t wifi_manager_set_credentials(const char *ssid, const char *password)
|
||||
{
|
||||
nvs_handle_t nvs;
|
||||
ESP_ERROR_CHECK(nvs_open(MIMI_NVS_WIFI, NVS_READWRITE, &nvs));
|
||||
ESP_ERROR_CHECK(nvs_set_str(nvs, MIMI_NVS_KEY_SSID, ssid));
|
||||
ESP_ERROR_CHECK(nvs_set_str(nvs, MIMI_NVS_KEY_PASS, password));
|
||||
ESP_ERROR_CHECK(nvs_commit(nvs));
|
||||
nvs_close(nvs);
|
||||
ESP_LOGI(TAG, "WiFi credentials saved for SSID: %s", ssid);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
const char *wifi_manager_get_ip(void)
|
||||
{
|
||||
return s_ip_str;
|
||||
|
||||
Reference in New Issue
Block a user