mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
AT passthrough from any HardwareSerial stream
IE cant passthrough from wifi!
This commit is contained in:
parent
65ce238bfb
commit
cbf9f39ea6
|
@ -550,7 +550,7 @@ void DCCEXParser::parse(Print *stream, byte *com, RingStream * ringStream)
|
||||||
if (atCommandCallback && !ringStream) {
|
if (atCommandCallback && !ringStream) {
|
||||||
DCCWaveform::mainTrack.setPowerMode(POWERMODE::OFF);
|
DCCWaveform::mainTrack.setPowerMode(POWERMODE::OFF);
|
||||||
DCCWaveform::progTrack.setPowerMode(POWERMODE::OFF);
|
DCCWaveform::progTrack.setPowerMode(POWERMODE::OFF);
|
||||||
atCommandCallback(com);
|
atCommandCallback(stream,com);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "RingStream.h"
|
#include "RingStream.h"
|
||||||
|
|
||||||
typedef void (*FILTER_CALLBACK)(Print * stream, byte & opcode, byte & paramCount, int16_t p[]);
|
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
|
struct DCCEXParser
|
||||||
{
|
{
|
||||||
|
|
|
@ -326,25 +326,25 @@ wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password,
|
||||||
// The sequence "!!!" returns the Arduino to the normal loop mode
|
// 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++;
|
command++;
|
||||||
if (*command=='\0') { // User gave <+> command
|
if (*command=='\0') { // User gave <+> command
|
||||||
DIAG(F("ES AT command passthrough mode, use ! to exit"));
|
stream->print(F("\nES AT command passthrough mode, use ! to exit\n"));
|
||||||
while(Serial.available()) Serial.read(); // Drain serial input first
|
while(stream->available()) stream->read(); // Drain serial input first
|
||||||
bool startOfLine=true;
|
bool startOfLine=true;
|
||||||
while(true) {
|
while(true) {
|
||||||
while (wifiStream->available()) Serial.write(wifiStream->read());
|
while (wifiStream->available()) stream->write(wifiStream->read());
|
||||||
if (Serial.available()) {
|
if (stream->available()) {
|
||||||
int cx=Serial.read();
|
int cx=stream->read();
|
||||||
// A newline followed by !!! is an exit
|
// A newline followed by !!! is an exit
|
||||||
if (cx=='\n' || cx=='\r') startOfLine=true;
|
if (cx=='\n' || cx=='\r') startOfLine=true;
|
||||||
else if (startOfLine && cx=='!') break;
|
else if (startOfLine && cx=='!') break;
|
||||||
else startOfLine=false;
|
else startOfLine=false;
|
||||||
Serial.write(cx);
|
stream->write(cx);
|
||||||
wifiStream->write(cx);
|
wifiStream->write(cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DIAG(F("Passthrough Ended"));
|
stream->print(F("Passthrough Ended"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
const int port,
|
const int port,
|
||||||
const byte channel);
|
const byte channel);
|
||||||
static void loop();
|
static void loop();
|
||||||
static void ATCommand(const byte *command);
|
static void ATCommand(HardwareSerial * stream,const byte *command);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static wifiSerialState setup(Stream &setupStream, const FSH *SSSid, const FSH *password,
|
static wifiSerialState setup(Stream &setupStream, const FSH *SSSid, const FSH *password,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user