mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 13:21:23 +01:00
Update WifiInterface.cpp
Merge newer AT commands and freveal AT version at startup
This commit is contained in:
parent
95a5f7b9a4
commit
32b507248d
@ -53,21 +53,36 @@ bool WifiInterface::setup2(Stream & wifiStream, const __FlashStringHelper* SSid,
|
||||
delay(1000);
|
||||
|
||||
StringFormatter::send(wifiStream,F("AT+RST\r\n")); // reset module
|
||||
//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,false); // generally not interesting to DCC
|
||||
|
||||
StringFormatter::send(wifiStream,F("AT+GMR\r\n")); // request AT version
|
||||
checkForOK(wifiStream,2000,OK_SEARCH,true); // Makes this visible on the console
|
||||
|
||||
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,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?\r\n"));
|
||||
if (checkForOK(wifiStream,2000,OK_SEARCH,true)) {
|
||||
// early version supports CWJAP
|
||||
StringFormatter::send(wifiStream,F("AT+CWJAP=\"%S\",\"%S\"\r\n"),SSid,password);
|
||||
if (!checkForOK(wifiStream,20000,OK_SEARCH,true)) {
|
||||
checkForOK(wifiStream,20000,OK_SEARCH,true); // can ignore failure as AP mode may still be ok
|
||||
}
|
||||
else {
|
||||
// later version supports CWJAP_CUR
|
||||
StringFormatter::send(wifiStream, F("AT+CWHOSTNAME=\"%S\"\r\n"), hostname); // Set Host name for Wifi Client
|
||||
checkForOK(wifiStream,2000, OK_SEARCH, true); // dont care if not supported
|
||||
|
||||
StringFormatter::send(wifiStream,F("AT+CWJAP_CUR=\"%S\",\"%S\"\r\n"),SSid,password);
|
||||
if (!checkForOK(wifiStream,20000,OK_SEARCH,true)) return false;
|
||||
checkForOK(wifiStream,20000,OK_SEARCH,true); // can ignore failure as AP mode may still be ok
|
||||
|
||||
StringFormatter::send(wifiStream,F("AT+CIPRECVMODE=0\r\n"),port); // make sure transfer mode is correct
|
||||
checkForOK(wifiStream,2000,OK_SEARCH,true);
|
||||
|
||||
// StringFormatter::send(wifiStream, F("AT+MDNS=1,\"%S.local\",\"%S.local\",%d\r\n"), hostname, servername, port); // Setup mDNS for Server
|
||||
// if (!checkForOK(wifiStream,5000, OK_SEARCH, true)) return false;
|
||||
(void)servername; // avoid compiler warning from commented out AT_MDNS above
|
||||
|
||||
}
|
||||
|
||||
StringFormatter::send(wifiStream,F("AT+CIFSR\r\n")); // get ip address //192.168.4.1
|
||||
@ -77,12 +92,9 @@ bool WifiInterface::setup2(Stream & wifiStream, const __FlashStringHelper* SSid,
|
||||
StringFormatter::send(wifiStream,F("AT+CIPMUX=1\r\n")); // configure for multiple connections
|
||||
if (!checkForOK(wifiStream,10000,OK_SEARCH,true)) return false;
|
||||
|
||||
StringFormatter::send(wifiStream,F("AT+CIPSERVER=1,%d\r\n"),port); // turn on server on port 80
|
||||
StringFormatter::send(wifiStream,F("AT+CIPSERVER=1,%d\r\n"),port); // turn on server on port
|
||||
if (!checkForOK(wifiStream,10000,OK_SEARCH,true)) return false;
|
||||
|
||||
// StringFormatter::send(wifiStream, F("AT+MDNS=1,\"%S.local\",\"%S.local\",%d\r\n"), hostname, servername, port); // Setup mDNS for Server
|
||||
// if (!checkForOK(wifiStream,5000, OK_SEARCH, true)) return false;
|
||||
(void)servername; // not currently in use
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user