diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 94b7a66..38bac2f 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -550,7 +550,7 @@ void DCCEXParser::parse(Print *stream, byte *com, RingStream * ringStream) if (atCommandCallback && !ringStream) { DCCWaveform::mainTrack.setPowerMode(POWERMODE::OFF); DCCWaveform::progTrack.setPowerMode(POWERMODE::OFF); - atCommandCallback(com); + atCommandCallback(stream,com); return; } break; diff --git a/DCCEXParser.h b/DCCEXParser.h index 3bc94d4..6baeeaa 100644 --- a/DCCEXParser.h +++ b/DCCEXParser.h @@ -23,7 +23,7 @@ #include "RingStream.h" typedef void (*FILTER_CALLBACK)(Print * stream, byte & opcode, byte & paramCount, int16_t p[]); -typedef void (*AT_COMMAND_CALLBACK)(const byte * command); +typedef void (*AT_COMMAND_CALLBACK)(Print * stream,const byte * command); struct DCCEXParser { diff --git a/WifiInterface.cpp b/WifiInterface.cpp index 3f65cea..6b3e3b8 100644 --- a/WifiInterface.cpp +++ b/WifiInterface.cpp @@ -326,25 +326,25 @@ wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password, // The sequence "!!!" returns the Arduino to the normal loop mode -void WifiInterface::ATCommand(const byte * command) { +void WifiInterface::ATCommand(HardwareSerial * stream,const byte * command) { command++; if (*command=='\0') { // User gave <+> command - DIAG(F("ES AT command passthrough mode, use ! to exit")); - while(Serial.available()) Serial.read(); // Drain serial input first + stream->print(F("\nES AT command passthrough mode, use ! to exit\n")); + while(stream->available()) stream->read(); // Drain serial input first bool startOfLine=true; while(true) { - while (wifiStream->available()) Serial.write(wifiStream->read()); - if (Serial.available()) { - int cx=Serial.read(); + while (wifiStream->available()) stream->write(wifiStream->read()); + if (stream->available()) { + int cx=stream->read(); // A newline followed by !!! is an exit if (cx=='\n' || cx=='\r') startOfLine=true; else if (startOfLine && cx=='!') break; else startOfLine=false; - Serial.write(cx); + stream->write(cx); wifiStream->write(cx); } } - DIAG(F("Passthrough Ended")); + stream->print(F("Passthrough Ended")); return; } diff --git a/WifiInterface.h b/WifiInterface.h index 19f8a3a..8d77ab8 100644 --- a/WifiInterface.h +++ b/WifiInterface.h @@ -37,7 +37,7 @@ public: const int port, const byte channel); static void loop(); - static void ATCommand(const byte *command); + static void ATCommand(HardwareSerial * stream,const byte *command); private: static wifiSerialState setup(Stream &setupStream, const FSH *SSSid, const FSH *password,