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

make AP password setable

This commit is contained in:
Harald Barth 2020-11-17 15:16:45 +01:00
parent 9ee5dc1600
commit 612cb95f85
2 changed files with 24 additions and 8 deletions

View File

@ -170,8 +170,9 @@ wifiSerialState WifiInterface::setup2(const __FlashStringHelper* SSid, const __F
// If the source code looks unconfigured, check if the
// ESP8266 is preconfigured. We check the first 13 chars
// of the password.
if (strncmp_P("Your network ",(const char*)password,13) == 0) {
// of the SSid.
char *yourNetwork = "Your network ";
if (strncmp_P(yourNetwork, (const char*)SSid, 13) == 0) {
delay(8000); // give a preconfigured ES8266 a chance to connect to a router
StringFormatter::send(wifiStream, F("AT+CIFSR\r\n"));
@ -243,8 +244,14 @@ wifiSerialState WifiInterface::setup2(const __FlashStringHelper* SSid, const __F
while (wifiStream->available()) StringFormatter::printEscape( wifiStream->read()); /// THIS IS A DIAG IN DISGUISE
int i=0;
do StringFormatter::send(wifiStream, F("AT+CWSAP=\"DCCEX_%s\",\"PASS_%s\",1,4\r\n"), macTail, macTail);
while (i++<2 && !checkForOK(16000, OK_SEARCH, true)); // do twice if necessary but ignore failure as AP mode may still be ok
do {
if (strncmp_P(yourNetwork, (const char*)password, 13) == 0) {
// unconfigured
StringFormatter::send(wifiStream, F("AT+CWSAP=\"DCCEX_%s\",\"PASS_%s\",1,4\r\n"), macTail, macTail);
} else {
// password configured by user
StringFormatter::send(wifiStream, F("AT+CWSAP=\"DCCEX_%s\",\"%s\",1,4\r\n"), macTail, password);
} while (i++<2 && !checkForOK(16000, OK_SEARCH, true)); // do twice if necessary but ignore failure as AP mode may still be ok
} else {

View File

@ -44,14 +44,23 @@ The configuration file for DCC++ EX Command Station
//
// DEFINE WiFi Parameters (only in effect if WIFI is on)
//
// If DONT_TOUCH_WIFI_CONF is set, all WIFI config will be done with
// the <+> commands and this sketch will not change anything over
// AT commands and the other WIFI_* defines below do not have any effect.
//#define DONT_TOUCH_WIFI_CONF
//
// if DONT_TOUCH_WIFI_CONF is set, all WIFI config will be done with
// the <+> commands and this sketch will not change anything over
// AT commands and the WIFI_* defines below do not have any effect.
//
// WIFI_SSID is the network name IF you want to use your home network.
// Do NOT change this if you want to use the WiFi in Access Point mode.
// Your SSID may not conain ``"'' (double quote, ASCII 0x22).
#define WIFI_SSID "Your network name"
//
// WIFI_PASSWORD is the network password for your home network or if
// you want to change the password from default AP mode password
// to the AP password you want.
// Your password may not conain ``"'' (double quote, ASCII 0x22).
#define WIFI_PASSWORD "Your network passwd"
//
// WIFI_HOSTNAME: You probably don't need to change this
#define WIFI_HOSTNAME "dccex"
/////////////////////////////////////////////////////////////////////////////////////