diff --git a/WifiInterface.cpp b/WifiInterface.cpp index 8ce6715..709d7dd 100644 --- a/WifiInterface.cpp +++ b/WifiInterface.cpp @@ -230,8 +230,17 @@ wifiSerialState WifiInterface::setup2(const __FlashStringHelper* SSid, const __F if (!ipOK) { // If we have not managed to get this going in station mode, go for AP mode - StringFormatter::send(wifiStream, F("AT+CWMODE=2\r\n")); // configure as AccessPoint. - checkForOK(1000, OK_SEARCH, true); // Not always OK, sometimes "no change" +// StringFormatter::send(wifiStream, F("AT+RST\r\n")); +// checkForOK(1000, OK_SEARCH, true); // Not always OK, sometimes "no change" + + int i=0; + do { + // configure as AccessPoint. Try really hard as this is the + // last way out to get any Wifi connectivity. + StringFormatter::send(wifiStream, F("AT+CWMODE=2\r\n")); + } while (!checkForOK(1000+i*500, OK_SEARCH, true) && i++<10); + + while (wifiStream->available()) StringFormatter::printEscape( wifiStream->read()); /// THIS IS A DIAG IN DISGUISE // Figure out MAC addr StringFormatter::send(wifiStream, F("AT+CIFSR\r\n")); // not TOMATO @@ -245,15 +254,12 @@ wifiSerialState WifiInterface::setup2(const __FlashStringHelper* SSid, const __F } } else { memset(macAddress,'f',sizeof(macAddress)); - // run a GMR just for fun - StringFormatter::send(wifiStream, F("AT+GMR\r\n")); - checkForOK(2000, OK_SEARCH, true, false); // Makes this visible on the console } char macTail[]={macAddress[9],macAddress[10],macAddress[12],macAddress[13],macAddress[15],macAddress[16],'\0'}; while (wifiStream->available()) StringFormatter::printEscape( wifiStream->read()); /// THIS IS A DIAG IN DISGUISE - int i=0; + i=0; do { if (strncmp_P(yourNetwork, (const char*)password, 13) == 0) { // unconfigured diff --git a/config.example.h b/config.example.h index 488b3ce..666a354 100644 --- a/config.example.h +++ b/config.example.h @@ -58,7 +58,8 @@ The configuration file for DCC++ EX Command Station // The SSID of the AP will be automatically set to DCCEX_*. // If you DO set the WIFI_SSID then the WiFi chip will try to connect // to that (home) network in station (client) mode. If a WIFI_PASSWORD -// is set (recommended), that password will be used. +// is set (recommended), that password will be used for AP mode. +// The AP mode password must be at least 8 characters long. // // Your SSID may not conain ``"'' (double quote, ASCII 0x22). #define WIFI_SSID "Your network name"