Changed apConfig() to use fixed SSID of "HomeSpan-Configuration"
This commit is contained in:
parent
8cfd9afa63
commit
f3b1de2f6b
|
|
@ -515,7 +515,7 @@ void Span::processSerialCommand(char *c){
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
network.apConfigure(hostName);
|
network.apConfigure();
|
||||||
nvs_set_blob(HAPClient::wifiNVS,"WIFIDATA",&network.wifiData,sizeof(network.wifiData)); // update data
|
nvs_set_blob(HAPClient::wifiNVS,"WIFIDATA",&network.wifiData,sizeof(network.wifiData)); // update data
|
||||||
nvs_commit(HAPClient::wifiNVS); // commit to NVS
|
nvs_commit(HAPClient::wifiNVS); // commit to NVS
|
||||||
Serial.print("\n*** Credentials saved!\n\n");
|
Serial.print("\n*** Credentials saved!\n\n");
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ struct Span{
|
||||||
|
|
||||||
void setControlPin(uint8_t pin){controlPin=pin;} // sets Control Pin
|
void setControlPin(uint8_t pin){controlPin=pin;} // sets Control Pin
|
||||||
void setStatusPin(uint8_t pin){statusPin=pin;} // sets Status Pin
|
void setStatusPin(uint8_t pin){statusPin=pin;} // sets Status Pin
|
||||||
|
void setApSSID(char *ssid){network.apSSID=ssid;} // sets Access Point SSID
|
||||||
void setApPassword(char *pwd){network.apPassword=pwd;} // sets Access Point Password
|
void setApPassword(char *pwd){network.apPassword=pwd;} // sets Access Point Password
|
||||||
void setApTimeout(uint16_t nSec){network.lifetime=nSec*1000;} // sets Access Point Timeout (seconds)
|
void setApTimeout(uint16_t nSec){network.lifetime=nSec*1000;} // sets Access Point Timeout (seconds)
|
||||||
void setCommandTimeout(uint16_t nSec){comModeLife=nSec*1000;} // sets Command Mode Timeout (seconds)
|
void setCommandTimeout(uint16_t nSec){comModeLife=nSec*1000;} // sets Command Mode Timeout (seconds)
|
||||||
|
|
|
||||||
|
|
@ -82,10 +82,10 @@ boolean Network::allowedCode(char *s){
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
void Network::apConfigure(char *apName){
|
void Network::apConfigure(){
|
||||||
|
|
||||||
Serial.print("*** Starting Access Point: ");
|
Serial.print("*** Starting Access Point: ");
|
||||||
Serial.print(apName);
|
Serial.print(apSSID);
|
||||||
Serial.print(" / ");
|
Serial.print(" / ");
|
||||||
Serial.print(apPassword);
|
Serial.print(apPassword);
|
||||||
Serial.print("\n");
|
Serial.print("\n");
|
||||||
|
|
@ -114,7 +114,7 @@ void Network::apConfigure(char *apName){
|
||||||
IPAddress apIP(192, 168, 4, 1);
|
IPAddress apIP(192, 168, 4, 1);
|
||||||
|
|
||||||
WiFi.mode(WIFI_AP);
|
WiFi.mode(WIFI_AP);
|
||||||
WiFi.softAP(apName,apPassword); // start access point
|
WiFi.softAP(apSSID,apPassword); // start access point
|
||||||
dnsServer.start(DNS_PORT, "*", apIP); // start DNS server that resolves every request to the address of this device
|
dnsServer.start(DNS_PORT, "*", apIP); // start DNS server that resolves every request to the address of this device
|
||||||
apServer.begin();
|
apServer.begin();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ struct Network {
|
||||||
|
|
||||||
const int MAX_HTTP=4095; // max number of bytes in HTTP message
|
const int MAX_HTTP=4095; // max number of bytes in HTTP message
|
||||||
|
|
||||||
|
char *apSSID=DEFAULT_AP_SSID; // Access Point SSID
|
||||||
char *apPassword=DEFAULT_AP_PASSWORD; // Access Point password (does not need to be secret - only used to ensure excrypted WiFi connection)
|
char *apPassword=DEFAULT_AP_PASSWORD; // Access Point password (does not need to be secret - only used to ensure excrypted WiFi connection)
|
||||||
unsigned long lifetime=DEFAULT_AP_TIMEOUT*1000; // length of time (in milliseconds) to keep Access Point alive before shutting down and re-starting
|
unsigned long lifetime=DEFAULT_AP_TIMEOUT*1000; // length of time (in milliseconds) to keep Access Point alive before shutting down and re-starting
|
||||||
|
|
||||||
|
|
@ -38,7 +39,7 @@ struct Network {
|
||||||
void scan(); // scan for WiFi networks and save only those with unique SSIDs
|
void scan(); // scan for WiFi networks and save only those with unique SSIDs
|
||||||
void serialConfigure(); // configure homeSpan WiFi from serial monitor
|
void serialConfigure(); // configure homeSpan WiFi from serial monitor
|
||||||
boolean allowedCode(char *s); // checks if Setup Code is allowed (HAP defines a list of disallowed codes)
|
boolean allowedCode(char *s); // checks if Setup Code is allowed (HAP defines a list of disallowed codes)
|
||||||
void apConfigure(char *hostName); // configure homeSpan WiFi and Setup Code using temporary Captive Access Point 'hostName'; only returns if sucessful, else ESP restarts
|
void apConfigure(); // configure homeSpan WiFi and Setup Code using temporary Captive Access Point; only returns if sucessful, else ESP restarts
|
||||||
void processRequest(char *body, char *formData); // process the HTTP request
|
void processRequest(char *body, char *formData); // process the HTTP request
|
||||||
int getFormValue(char *formData, char *tag, char *value, int maxSize); // search for 'tag' in 'formData' and copy result into 'value' up to 'maxSize' characters; returns number of characters, else -1 if 'tag' not found
|
int getFormValue(char *formData, char *tag, char *value, int maxSize); // search for 'tag' in 'formData' and copy result into 'value' up to 'maxSize' characters; returns number of characters, else -1 if 'tag' not found
|
||||||
int badRequestError(); // return 400 error
|
int badRequestError(); // return 400 error
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#define DEFAULT_CONTROL_PIN 21 // change with homeSpan.setControlPin(pin)
|
#define DEFAULT_CONTROL_PIN 21 // change with homeSpan.setControlPin(pin)
|
||||||
#define DEFAULT_STATUS_PIN LED_BUILTIN // change with homeSpan.setStatusPin(pin)
|
#define DEFAULT_STATUS_PIN LED_BUILTIN // change with homeSpan.setStatusPin(pin)
|
||||||
|
|
||||||
|
#define DEFAULT_AP_SSID "HomeSpan-Configuration" // change with homeSpan.setApSSID(pwd)
|
||||||
#define DEFAULT_AP_PASSWORD "homespan" // change with homeSpan.setApPassword(pwd)
|
#define DEFAULT_AP_PASSWORD "homespan" // change with homeSpan.setApPassword(pwd)
|
||||||
|
|
||||||
#define DEFAULT_AP_TIMEOUT 300 // change with homeSpan.setApTimeout(nSeconds)
|
#define DEFAULT_AP_TIMEOUT 300 // change with homeSpan.setApTimeout(nSeconds)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue