diff --git a/WiThrottle.cpp b/WiThrottle.cpp index 4ad818a..7f2aadb 100644 --- a/WiThrottle.cpp +++ b/WiThrottle.cpp @@ -218,12 +218,12 @@ void WiThrottle::locoAction(Print & stream, byte* aval, char throttleChar, int c case 'q': if (aval[1]=='V') { //qV 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 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; @@ -271,3 +271,7 @@ void WiThrottle::checkHeartbeat() { // TODO Check if anything has changed on my locos since last notified! } } + +char WiThrottle::LorS(int cab) { + return (cab<127)?'S':'L'; +} diff --git a/WiThrottle.h b/WiThrottle.h index d0c3f4b..c04ba60 100644 --- a/WiThrottle.h +++ b/WiThrottle.h @@ -40,7 +40,7 @@ class WiThrottle { static WiThrottle* firstThrottle; static int getInt(byte * cmd); static int getLocoId(byte * cmd); - + static char LorS(int cab); WiThrottle* nextThrottle; int clientid; diff --git a/WifiInterface.cpp b/WifiInterface.cpp index fc96ee5..ee0fede 100644 --- a/WifiInterface.cpp +++ b/WifiInterface.cpp @@ -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,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" - // StringFormatter::send(wifiStream, F("AT+CWHOSTNAME=\"%S\"\r\n"), hostname); // Set Host name for Wifi Client - // checkForOK(wifiStream,5000, OK_SEARCH, true); - (void) hostname; // not currently in use + StringFormatter::send(wifiStream, F("AT+CWHOSTNAME=\"%S\"\r\n"), hostname); // Set Host name for Wifi Client + checkForOK(wifiStream,2000, OK_SEARCH, true); + + // 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); - 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 if (!checkForOK(wifiStream,10000,OK_SEARCH,true)) return false;