mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-17 13:33:44 +02:00
Add Proof of concept switching between UVC and Wi-Fi streaming based on the presence of Wi-Fi creds, rewrite restart task to esp_timer
TODO: Think about letting people set the mode explicitly so the board comes online faster
This commit is contained in:
@@ -1,16 +1,8 @@
|
||||
#include "SerialManager.hpp"
|
||||
|
||||
#define ECHO_TEST_TXD (4)
|
||||
#define ECHO_TEST_RXD (5)
|
||||
#define ECHO_TEST_RTS (UART_PIN_NO_CHANGE)
|
||||
#define ECHO_TEST_CTS (UART_PIN_NO_CHANGE)
|
||||
|
||||
#define ECHO_UART_PORT_NUM (1)
|
||||
#define ECHO_UART_BAUD_RATE (115200)
|
||||
|
||||
#define BUF_SIZE (1024)
|
||||
|
||||
SerialManager::SerialManager(std::shared_ptr<CommandManager> commandManager) : commandManager(commandManager) {
|
||||
SerialManager::SerialManager(std::shared_ptr<CommandManager> commandManager, esp_timer_handle_t *timerHandle) : commandManager(commandManager), timerHandle(timerHandle) {
|
||||
this->data = static_cast<uint8_t *>(malloc(BUF_SIZE));
|
||||
this->temp_data = static_cast<uint8_t *>(malloc(256));
|
||||
}
|
||||
@@ -28,6 +20,9 @@ void SerialManager::try_receive()
|
||||
int current_position = 0;
|
||||
int len = usb_serial_jtag_read_bytes(this->temp_data, 256, 1000 / 20);
|
||||
|
||||
if (len) {
|
||||
esp_timer_stop(*timerHandle);
|
||||
}
|
||||
// since we've got something on the serial port
|
||||
// we gotta keep reading until we've got the whole message
|
||||
while (len)
|
||||
@@ -46,6 +41,7 @@ void SerialManager::try_receive()
|
||||
const auto result = this->commandManager->executeFromJson(std::string_view(reinterpret_cast<const char *>(this->data)));
|
||||
const auto resultMessage = result.getResult();
|
||||
usb_serial_jtag_write_bytes(resultMessage.c_str(), resultMessage.length(), 1000 / 20);
|
||||
esp_timer_start_once(*timerHandle, 30000000); // 30s
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
class SerialManager
|
||||
{
|
||||
public:
|
||||
explicit SerialManager(std::shared_ptr<CommandManager> commandManager);
|
||||
explicit SerialManager(std::shared_ptr<CommandManager> commandManager, esp_timer_handle_t *timerHandle);
|
||||
void setup();
|
||||
void try_receive();
|
||||
|
||||
private:
|
||||
// QueueHandle_t serialQueue;
|
||||
std::shared_ptr<CommandManager> commandManager;
|
||||
esp_timer_handle_t *timerHandle;
|
||||
uint8_t *data;
|
||||
uint8_t *temp_data;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user