bug fix
monitoring messages must go different Serial= Serial1
This commit is contained in:
parent
b50946cabd
commit
fff7c85c71
1 changed files with 30 additions and 6 deletions
|
|
@ -26,6 +26,18 @@
|
|||
#define WIFI_CHANNEL 1
|
||||
//============</parameters>===========
|
||||
|
||||
//============<configurations>============
|
||||
//
|
||||
// MONITORING_ACTIVE
|
||||
// : activate serial communication monitoring @ TX1, if defined.
|
||||
// since 'Serial' is occupied by 'SLIPSerial',
|
||||
// alternativly 'Serial1' will send out messages.
|
||||
//
|
||||
// 'Serial1' - D4/GPIO2/TDX1 @ nodemcu (this is TX only.)
|
||||
//
|
||||
//============</configurations>============
|
||||
// #define MONITORING_ACTIVE
|
||||
|
||||
//arduino
|
||||
#include <Arduino.h>
|
||||
|
||||
|
|
@ -96,8 +108,10 @@ void route_note(OSCMessage& msg, int offset) {
|
|||
//
|
||||
esp_now_send(NULL, frm, frm_size); // to all peers in the list.
|
||||
//
|
||||
Serial.write(frm, frm_size);
|
||||
Serial.println(" ==(esp_now_send/0)==> ");
|
||||
#if defined(MONITORING_ACTIVE)
|
||||
Serial1.write(frm, frm_size);
|
||||
Serial1.println(" ==(esp_now_send/0)==> ");
|
||||
#endif
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
@ -159,15 +173,18 @@ Task blink_task(0, TASK_FOREVER, &blink, &runner, true); // -> ENABLED, at start
|
|||
// on 'receive'
|
||||
void onDataReceive(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
|
||||
|
||||
//
|
||||
Serial.write(incomingData, len);
|
||||
#if defined(MONITORING_ACTIVE)
|
||||
Serial1.write(incomingData, len);
|
||||
#endif
|
||||
|
||||
// open => identify => use.
|
||||
if (incomingData[0] == '{' && incomingData[len - 1] == '}' && len == (sizeof(Hello) + 2)) {
|
||||
Hello hello("");
|
||||
memcpy((uint8_t *) &hello, incomingData + 1, sizeof(Hello));
|
||||
//
|
||||
Serial.println(hello.to_string());
|
||||
#if defined(MONITORING_ACTIVE)
|
||||
Serial1.println(hello.to_string());
|
||||
#endif
|
||||
//
|
||||
OSCMessage osc("/hello");
|
||||
osc.add(hello.id);
|
||||
|
|
@ -188,7 +205,9 @@ void onDataReceive(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
|
|||
Note note;
|
||||
memcpy((uint8_t *) ¬e, incomingData + 1, sizeof(Note));
|
||||
//
|
||||
Serial.println(note.to_string());
|
||||
#if defined(MONITORING_ACTIVE)
|
||||
Serial1.println(note.to_string());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -249,6 +268,11 @@ void setup() {
|
|||
// start SLIPSerial on Serial
|
||||
SLIPSerial.begin(57600);
|
||||
|
||||
// start Serial1 as an alternative
|
||||
#if defined(MONITORING_ACTIVE)
|
||||
Serial1.begin(115200);
|
||||
#endif
|
||||
|
||||
// clear out any leftover debris. (this will let LED blinking works from initialization.)
|
||||
while(SLIPSerial.available() > 0) {
|
||||
SLIPSerial.read();
|
||||
|
|
|
|||
Loading…
Reference in a new issue