Proof of concept works. Nano can proxy requests to ESP32 via soft serial and then receives confirmation after event. Nano has a cleaner serial interface and will not throw junk into mcopy app serial listener.

This commit is contained in:
Matt McWilliams 2023-07-04 18:45:51 -04:00
parent 3feaea74bf
commit dd03583a27
3 changed files with 23 additions and 10 deletions

4
.gitignore vendored
View File

@ -5,4 +5,6 @@
node_modules
dist
*.svd
*.svd
*debug_custom.json
*debug.cfg

View File

@ -20,6 +20,7 @@ void loop () {
}
if (cmd == 'x') {
Serial2.print('x');
Serial2.print(cmd);
}
cmd = 'z';
}

View File

@ -5,26 +5,36 @@
SoftwareSerial softPort(SOFTWARE_RX, SOFTWARE_TX);
volatile char proxy = 'z';
volatile char cmd = 'z';
volatile long now;
volatile long start;
void setup () {
Serial.begin(57600);
softPort.begin(9600);
start = millis();
pinMode(LED_BUILTIN, OUTPUT);
}
//////
// Sending an x character to the nano over
// Serial will proxy it to the ESP32 over SoftSerial
// which will reflect it back to the Nano
// and will turn on the built-in LED. Proof of
// concept round trip
//////
void loop () {
now = millis();
if (Serial.available() > 0) {
proxy = Serial.read();
softPort.print(proxy);
}
if (softPort.available() > 0) {
cmd = softPort.read();
}
if (cmd != 'z') {
Serial.println(cmd);
}
if (cmd == 'x') {
digitalWrite(LED_BUILTIN, HIGH);
}
if (now >= start + 5000) {
softPort.print('x');
}
cmd = 'z';
}