Files
mimiclaw/main/proxy/http_proxy.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

49 lines
1.2 KiB
C

#pragma once
#include "esp_err.h"
#include <stddef.h>
#include <stdbool.h>
/**
* Initialize proxy module.
*/
esp_err_t http_proxy_init(void);
/**
* Returns true if a proxy host:port is configured.
*/
bool http_proxy_is_enabled(void);
/**
* Save proxy host and port to NVS.
*/
esp_err_t http_proxy_set(const char *host, uint16_t port);
/**
* Remove proxy config from NVS.
*/
esp_err_t http_proxy_clear(void);
/* ── Proxied HTTPS connection ─────────────────────────────────── */
typedef struct proxy_conn proxy_conn_t;
/**
* Open an HTTPS connection through the configured proxy.
* 1) TCP connect to proxy
* 2) Send HTTP CONNECT to target host:port
* 3) TLS handshake over the tunnel
*
* Returns NULL on failure.
*/
proxy_conn_t *proxy_conn_open(const char *host, int port, int timeout_ms);
/** Write raw bytes through the TLS tunnel. Returns bytes written or -1. */
int proxy_conn_write(proxy_conn_t *conn, const char *data, int len);
/** Read raw bytes from the TLS tunnel. Returns bytes read or -1. */
int proxy_conn_read(proxy_conn_t *conn, char *buf, int len, int timeout_ms);
/** Close and free the connection. */
void proxy_conn_close(proxy_conn_t *conn);