mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-13 11:43:44 +02:00
Serial manager cleanup
This commit is contained in:
@@ -9,10 +9,7 @@
|
||||
#define ECHO_UART_BAUD_RATE (115200)
|
||||
#define ECHO_TASK_STACK_SIZE (3072)
|
||||
|
||||
static const char *TAG = "UART TEST";
|
||||
|
||||
#define BUF_SIZE (1024)
|
||||
uint8_t *data;
|
||||
|
||||
SerialManager::SerialManager(std::shared_ptr<CommandManager> commandManager) : commandManager(commandManager) {}
|
||||
|
||||
@@ -23,18 +20,17 @@ void SerialManager::setup()
|
||||
usb_serial_jtag_config.tx_buffer_size = BUF_SIZE;
|
||||
usb_serial_jtag_driver_install(&usb_serial_jtag_config);
|
||||
// Configure a temporary buffer for the incoming data
|
||||
data = (uint8_t *)malloc(BUF_SIZE);
|
||||
this->data = (uint8_t *)malloc(BUF_SIZE);
|
||||
}
|
||||
|
||||
// rewrite this to serial events or something
|
||||
void SerialManager::try_receive()
|
||||
{
|
||||
int len = usb_serial_jtag_read_bytes(data, (BUF_SIZE - 1), 20 / portTICK_PERIOD_MS);
|
||||
int len = usb_serial_jtag_read_bytes(this->data, (BUF_SIZE - 1), 10000);
|
||||
if (len)
|
||||
{
|
||||
auto result = this->commandManager->executeFromJson(std::string_view((const char *)data));
|
||||
auto result = this->commandManager->executeFromJson(std::string_view((const char *)this->data));
|
||||
auto resultMessage = result.getResult();
|
||||
usb_serial_jtag_write_bytes(resultMessage.c_str(), resultMessage.length(), 20 / portTICK_PERIOD_MS);
|
||||
usb_serial_jtag_write_bytes(resultMessage.c_str(), resultMessage.length(), 10000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
private:
|
||||
QueueHandle_t serialQueue;
|
||||
std::shared_ptr<CommandManager> commandManager;
|
||||
uint8_t *data;
|
||||
};
|
||||
|
||||
void HandleSerialManagerTask(void *pvParameters);
|
||||
|
||||
@@ -159,7 +159,7 @@ extern "C" void app_main(void)
|
||||
"HandleSerialManagerTask",
|
||||
1024 * 6,
|
||||
serialManager,
|
||||
3,
|
||||
1, // we only rely on the serial manager during provisioning, we can run it slower
|
||||
NULL);
|
||||
|
||||
wifiManager.Begin();
|
||||
|
||||
Reference in New Issue
Block a user