Functional prototype!
This commit is contained in:
+58
-5
@@ -1,6 +1,8 @@
|
||||
#include <cstring>
|
||||
|
||||
#include "peripherals/uart_serial.h"
|
||||
#include "peripherals/usb_serial.h"
|
||||
#include "peripherals/wireless_comms.h"
|
||||
|
||||
///
|
||||
/// So i lost all the code from the previous version of this due to messing with git.
|
||||
@@ -10,11 +12,62 @@
|
||||
/// Nicholas - 23/08/2026 @ 21:36
|
||||
///
|
||||
|
||||
const char* test = "amai zeg";
|
||||
const char *test = "amai zeg\n";
|
||||
|
||||
#define NODE_NUMBER 1
|
||||
#define TOTAL_NUMBER_OF_NODES 4
|
||||
|
||||
|
||||
extern "C" void app_main(void)
|
||||
{
|
||||
usb_serial::init();
|
||||
usb_serial::write(test,strlen(test));
|
||||
uint8_t node_mac[ESP_NOW_ETH_ALEN] = {0xDE, 0xD5, 0xEC, 0x00, 0x00, 0x02};
|
||||
|
||||
uint8_t peer_mac[ESP_NOW_ETH_ALEN] = {0xDE, 0xD5, 0xEC, 0x00, 0x00, 0x01};
|
||||
|
||||
uint8_t peer_list[TOTAL_NUMBER_OF_NODES][ESP_NOW_ETH_ALEN];
|
||||
|
||||
typedef struct communications {
|
||||
uart_serial uart;
|
||||
wireless_comms *wireless;
|
||||
} communications;
|
||||
|
||||
|
||||
void main_task(void *pvParameter) {
|
||||
auto comms = reinterpret_cast<communications *>(pvParameter);
|
||||
uart_serial uart = comms->uart;
|
||||
char data;
|
||||
while (true) {
|
||||
if (usb_serial::read_byte(&data)) {
|
||||
wireless_comms::send_byte(data);
|
||||
uart.write_byte(&data);
|
||||
}
|
||||
if (uart.read_byte(&data)) {
|
||||
ESP_LOGI("uart", "received data");
|
||||
wireless_comms::send_byte(data);
|
||||
usb_serial::write_byte(&data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void app_main(void) {
|
||||
esp_log_level_set("*", ESP_LOG_NONE);
|
||||
usb_serial::init();
|
||||
uart_serial uart(UART_NUM_0, GPIO_NUM_18, GPIO_NUM_19, 9600);
|
||||
wireless_comms wireless;
|
||||
|
||||
//usb_serial::write(test,strlen(test));
|
||||
communications comms = {.uart = uart, .wireless = &wireless};
|
||||
/*
|
||||
uint8_t peer_gen[ESP_NOW_ETH_ALEN] = {0xDE, 0xD5, 0xEC, 0x00, 0x00, 0x00};
|
||||
for(int i=2;i<TOTAL_NUMBER_OF_NODES;i++) {
|
||||
peer_gen[ESP_NOW_ETH_ALEN-1] = i;
|
||||
memcpy(peer_list[i],peer_gen,ESP_NOW_ETH_ALEN);
|
||||
test_comms.add_peer(peer_gen);
|
||||
}*/
|
||||
wireless_comms::add_peer(peer_mac);
|
||||
//test_comms.add_peer(peer_mac);
|
||||
wireless.create_rtos_task(uart);
|
||||
wireless_comms::send_byte('e');
|
||||
const char testchar = 'e';
|
||||
uart.write_byte(&testchar);
|
||||
|
||||
xTaskCreate(main_task, "main_task", 4096, &comms, 5,NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user