Streaming (main feature this session): - New WebRadioConfig/WebRadioJson core types, ISecureStore-backed persistence - New webradio::WebRadioService (thread-safe live config) + GET/POST /api/streaming - web_radio_stream task now runtime-toggleable (no reboot), no hardcoded URL - Content-Type diagnostic: warns clearly when a URL is a webpage, not an audio stream Boot cleanup: - Removed boot-time auto FM/DAB tune, auto-beep, and the (now-concluded) Si4684 crystal IBIAS/CTUN empirical sweep from main.cpp — tuning/beep are on-demand via the existing REST API only Web UI: - Modernized styling (cards, gradients, toggle switches, light/dark theme) - New Stream tab wired to /api/streaming Fixes found via real idf.py build (not just clangd): - Restored wrongly-removed si4684/Si4684Tuner.hpp include in main.cpp - Fixed MP3Decode() argument types in web_radio_stream.cpp (unsigned char**/int*) Quality-gate fixes: - Host-test stub headers (esp_log.h, freertos/*) so TunerService.cpp's scanForStation logging/pacing compiles for station_service_test / integration_service_test instead of running stale binaries - Added WifiScanner and WebRadioService manual sections; filled in missing Doxygen docs on BluetoothService, i2s_sdata_probe, test_firmware, Bt1035At - Ignore clangd's .cache/ index directory Also includes prior uncommitted work carried in the tree: Wi-Fi/Bluetooth device scan REST API and UI (WifiScanner, BT scan), SigmaStudio TCP bridge, and the current ADAU1701 SigmaStudio DSP program export. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
109 lines
2.6 KiB
C++
109 lines
2.6 KiB
C++
/**
|
|
* @file SoftApHost.cpp
|
|
* @brief SoftApHost implementation.
|
|
*
|
|
* DigiRadio firmware — https://github.com/manvalan/DigiRadio
|
|
*
|
|
* Copyright 2026 Michele Bigi
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* @author Michele Bigi
|
|
* @date 2026-07-06
|
|
*/
|
|
|
|
#include "net/SoftApHost.hpp"
|
|
|
|
#include "esp_netif.h"
|
|
#include "esp_wifi.h"
|
|
#include "esp_log.h"
|
|
|
|
#include <cstring>
|
|
|
|
namespace net {
|
|
|
|
namespace {
|
|
constexpr char kTag[] = "SoftApHost";
|
|
} // namespace
|
|
|
|
SoftApHost::SoftApHost(SoftApConfig config)
|
|
: config_(config)
|
|
, started_(false)
|
|
{
|
|
}
|
|
|
|
SoftApHost::~SoftApHost()
|
|
{
|
|
if (started_) {
|
|
esp_wifi_stop();
|
|
started_ = false;
|
|
}
|
|
}
|
|
|
|
SoftApHost::SoftApHost(SoftApHost&& other) noexcept
|
|
: config_(other.config_)
|
|
, started_(other.started_)
|
|
{
|
|
other.started_ = false;
|
|
}
|
|
|
|
SoftApHost& SoftApHost::operator=(SoftApHost&& other) noexcept
|
|
{
|
|
if (this != &other) {
|
|
if (started_) {
|
|
esp_wifi_stop();
|
|
}
|
|
config_ = other.config_;
|
|
started_ = other.started_;
|
|
other.started_ = false;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
std::expected<void, NetError> SoftApHost::start()
|
|
{
|
|
if (started_) {
|
|
return {};
|
|
}
|
|
|
|
if (esp_wifi_set_mode(WIFI_MODE_APSTA) != ESP_OK) {
|
|
ESP_LOGE(kTag, "esp_wifi_set_mode failed");
|
|
return std::unexpected(NetError::WifiConfigFailed);
|
|
}
|
|
|
|
wifi_config_t staCfg = {};
|
|
if (esp_wifi_set_config(WIFI_IF_STA, &staCfg) != ESP_OK) {
|
|
ESP_LOGE(kTag, "esp_wifi_set_config STA failed");
|
|
return std::unexpected(NetError::WifiConfigFailed);
|
|
}
|
|
|
|
wifi_config_t wifiCfg = {};
|
|
const std::string_view ssid = config_.ssid();
|
|
std::memcpy(wifiCfg.ap.ssid, ssid.data(), ssid.size());
|
|
wifiCfg.ap.ssid_len = static_cast<int>(ssid.size());
|
|
wifiCfg.ap.channel = config_.channel();
|
|
wifiCfg.ap.max_connection = config_.maxConnections();
|
|
wifiCfg.ap.authmode = WIFI_AUTH_OPEN;
|
|
|
|
if (esp_wifi_set_config(WIFI_IF_AP, &wifiCfg) != ESP_OK) {
|
|
ESP_LOGE(kTag, "esp_wifi_set_config failed");
|
|
return std::unexpected(NetError::WifiConfigFailed);
|
|
}
|
|
|
|
if (esp_wifi_start() != ESP_OK) {
|
|
ESP_LOGE(kTag, "esp_wifi_start failed");
|
|
return std::unexpected(NetError::WifiStartFailed);
|
|
}
|
|
|
|
started_ = true;
|
|
ESP_LOGI(kTag, "SoftAP started: %.*s", static_cast<int>(ssid.size()),
|
|
ssid.data());
|
|
return {};
|
|
}
|
|
|
|
} // namespace net
|