diff --git a/faa_osc/faa_osc.ino b/faa_osc/faa_osc.ino index b9ad1cd..7f99757 100644 --- a/faa_osc/faa_osc.ino +++ b/faa_osc/faa_osc.ino @@ -26,6 +26,18 @@ #define WIFI_CHANNEL 1 //======================= +//======================== +// +// 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.) +// +//======================== +// #define MONITORING_ACTIVE + //arduino #include @@ -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();