1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-23 08:06:13 +01:00

AT command version

+ Withrottle minor fix
This commit is contained in:
Asbelos 2020-07-22 15:14:07 +01:00
parent 177e243507
commit 928a9d834a
3 changed files with 16 additions and 8 deletions

View File

@ -218,12 +218,12 @@ void WiThrottle::locoAction(Print & stream, byte* aval, char throttleChar, int c
case 'q': case 'q':
if (aval[1]=='V') { //qV if (aval[1]=='V') { //qV
LOOPLOCOS(throttleChar, cab) { LOOPLOCOS(throttleChar, cab) {
StringFormatter::send(stream,F("M%cAL%d<;>V%d\n"), throttleChar, myLocos[loco].cab, DCC::getThrottleSpeed(myLocos[loco].cab)); StringFormatter::send(stream,F("M%cA%c%d<;>V%d\n"), throttleChar, LorS(myLocos[loco].cab), myLocos[loco].cab, DCC::getThrottleSpeed(myLocos[loco].cab));
} }
} }
else if (aval[1]=='R') { // qR else if (aval[1]=='R') { // qR
LOOPLOCOS(throttleChar, cab) { LOOPLOCOS(throttleChar, cab) {
StringFormatter::send(stream,F("M%cAL%d<;>R%d\n"), throttleChar, myLocos[loco].cab, DCC::getThrottleDirection(myLocos[loco].cab)); StringFormatter::send(stream,F("M%cA%c%d<;>R%d\n"), throttleChar, LorS(myLocos[loco].cab), myLocos[loco].cab, DCC::getThrottleDirection(myLocos[loco].cab));
} }
} }
break; break;
@ -271,3 +271,7 @@ void WiThrottle::checkHeartbeat() {
// TODO Check if anything has changed on my locos since last notified! // TODO Check if anything has changed on my locos since last notified!
} }
} }
char WiThrottle::LorS(int cab) {
return (cab<127)?'S':'L';
}

View File

@ -40,7 +40,7 @@ class WiThrottle {
static WiThrottle* firstThrottle; static WiThrottle* firstThrottle;
static int getInt(byte * cmd); static int getInt(byte * cmd);
static int getLocoId(byte * cmd); static int getLocoId(byte * cmd);
static char LorS(int cab);
WiThrottle* nextThrottle; WiThrottle* nextThrottle;
int clientid; int clientid;

View File

@ -56,15 +56,19 @@ bool WifiInterface::setup2(Stream & wifiStream, const __FlashStringHelper* SSid,
//checkForOK(wifiStream,5000,END_DETAIL_SEARCH,true); // Show startup but ignore unreadable upto ready //checkForOK(wifiStream,5000,END_DETAIL_SEARCH,true); // Show startup but ignore unreadable upto ready
checkForOK(wifiStream,5000,READY_SEARCH,true); checkForOK(wifiStream,5000,READY_SEARCH,true);
StringFormatter::send(wifiStream,F("AT+CWMODE=1\r\n")); // configure as access point StringFormatter::send(wifiStream,F("AT+CWMODE=3\r\n")); // configure as server or access point
checkForOK(wifiStream,1000,OK_SEARCH,true); // Not always OK, sometimes "no change" checkForOK(wifiStream,1000,OK_SEARCH,true); // Not always OK, sometimes "no change"
// StringFormatter::send(wifiStream, F("AT+CWHOSTNAME=\"%S\"\r\n"), hostname); // Set Host name for Wifi Client StringFormatter::send(wifiStream, F("AT+CWHOSTNAME=\"%S\"\r\n"), hostname); // Set Host name for Wifi Client
// checkForOK(wifiStream,5000, OK_SEARCH, true); checkForOK(wifiStream,2000, OK_SEARCH, true);
(void) hostname; // not currently in use
// Older ES versions have AT+CWJAP, newer ones have AT+CWJAP_CUR and AT+CWHOSTNAME
StringFormatter::send(wifiStream,F("AT+CWJAP=\"%S\",\"%S\"\r\n"),SSid,password); StringFormatter::send(wifiStream,F("AT+CWJAP=\"%S\",\"%S\"\r\n"),SSid,password);
if (!checkForOK(wifiStream,20000,OK_SEARCH,true)) return false; if (!checkForOK(wifiStream,20000,OK_SEARCH,true)) {
StringFormatter::send(wifiStream,F("AT+CWJAP_CUR=\"%S\",\"%S\"\r\n"),SSid,password);
if (!checkForOK(wifiStream,20000,OK_SEARCH,true)) return false;
}
StringFormatter::send(wifiStream,F("AT+CIFSR\r\n")); // get ip address //192.168.4.1 StringFormatter::send(wifiStream,F("AT+CIFSR\r\n")); // get ip address //192.168.4.1
if (!checkForOK(wifiStream,10000,OK_SEARCH,true)) return false; if (!checkForOK(wifiStream,10000,OK_SEARCH,true)) return false;