Merge pull request #16 from lorow/fix/wifi-serial-manager

Revert stopping serial manager in wifi mode
This commit is contained in:
Lorow
2025-10-18 19:15:59 +02:00
committed by GitHub
3 changed files with 6 additions and 26 deletions
@@ -20,12 +20,6 @@ void SerialManager::setup()
usb_serial_jtag_driver_install(&usb_serial_jtag_config); usb_serial_jtag_driver_install(&usb_serial_jtag_config);
} }
bool SerialManager::isConnected()
{
// in preparation for handling uart as well
return usb_serial_jtag_is_connected();
}
void SerialManager::try_receive() void SerialManager::try_receive()
{ {
static auto current_position = 0; static auto current_position = 0;
@@ -34,7 +34,6 @@ class SerialManager
public: public:
explicit SerialManager(std::shared_ptr<CommandManager> commandManager, esp_timer_handle_t *timerHandle, std::shared_ptr<ProjectConfig> deviceConfig); explicit SerialManager(std::shared_ptr<CommandManager> commandManager, esp_timer_handle_t *timerHandle, std::shared_ptr<ProjectConfig> deviceConfig);
void setup(); void setup();
bool isConnected();
void try_receive(); void try_receive();
void send_heartbeat(); void send_heartbeat();
bool should_send_heartbeat(); bool should_send_heartbeat();
+6 -19
View File
@@ -67,7 +67,7 @@ auto ledManager = std::make_shared<LEDManager>(BLINK_GPIO, CONFIG_LED_C_PIN_GPIO
auto *serialManager = new SerialManager(commandManager, &timerHandle, deviceConfig); auto *serialManager = new SerialManager(commandManager, &timerHandle, deviceConfig);
std::shared_ptr<MonitoringManager> monitoringManager = std::make_shared<MonitoringManager>(); std::shared_ptr<MonitoringManager> monitoringManager = std::make_shared<MonitoringManager>();
void startWiFiMode(bool shouldCloseSerialManager); void startWiFiMode();
void startWiredMode(bool shouldCloseSerialManager); void startWiredMode(bool shouldCloseSerialManager);
static void initNVSStorage() static void initNVSStorage()
@@ -100,7 +100,7 @@ void launch_streaming()
// either the API endpoints or CDC will take care of further configuration // either the API endpoints or CDC will take care of further configuration
if (deviceMode == StreamingMode::WIFI) if (deviceMode == StreamingMode::WIFI)
{ {
startWiFiMode(true); startWiFiMode();
} }
else if (deviceMode == StreamingMode::UVC) else if (deviceMode == StreamingMode::UVC)
{ {
@@ -204,21 +204,9 @@ void startWiredMode(bool shouldCloseSerialManager)
#endif #endif
} }
void startWiFiMode(bool shouldCloseSerialManager) void startWiFiMode()
{ {
ESP_LOGI("[MAIN]", "Starting WiFi streaming mode."); ESP_LOGI("[MAIN]", "Starting WiFi streaming mode.");
if (shouldCloseSerialManager)
{
if (!serialManager->isConnected())
{
ESP_LOGI("[MAIN]", "We're not connected to serial. Closing serial manager task.");
vTaskDelete(serialManagerHandle);
}
else
{
ESP_LOGI("[MAIN]", "We're still connected to serial. Serial manager task will remain running.");
}
}
#ifdef CONFIG_GENERAL_ENABLE_WIRELESS #ifdef CONFIG_GENERAL_ENABLE_WIRELESS
wifiManager->Begin(); wifiManager->Begin();
mdnsManager.start(); mdnsManager.start();
@@ -327,15 +315,14 @@ extern "C" void app_main(void)
} }
else if (mode == StreamingMode::WIFI) else if (mode == StreamingMode::WIFI)
{ {
// in Wifi mode we only need the wireless communication stuff, nothing else got started // in Wifi mode we only need the wireless communication stuff, but the serial manager has to remain alive
startWiFiMode(true); startWiFiMode();
} }
else else
{ {
// since we're in setup mode, we have to have wireless functionality on, // since we're in setup mode, we have to have wireless functionality on,
// so we can do wifi scanning, test connection etc // so we can do wifi scanning, test connection etc
// if wireless is disabled by configuration, we will not start WiFi services here startWiFiMode();
startWiFiMode(false);
startSetupMode(); startSetupMode();
} }
} }