Created HomeSpan::setApPassword() and setAPTimeout()
Moved default values into Settings.h
This commit is contained in:
parent
7d8a91f13b
commit
2d8f36e735
|
|
@ -4,7 +4,6 @@
|
|||
#include <sodium.h>
|
||||
|
||||
#include "HAP.h"
|
||||
#include "Network.h"
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
|
|
@ -159,12 +158,11 @@ void Span::poll() {
|
|||
statusLED.start(500);
|
||||
}
|
||||
|
||||
if(controlButton.triggered(3000,10000)){
|
||||
if(controlButton.triggered(5000,10000)){
|
||||
if(controlButton.longPress()){
|
||||
statusLED.start(200);
|
||||
delay(2000);
|
||||
statusLED.off();
|
||||
ESP.restart();
|
||||
processSerialCommand("W"); // DELETE WiFi Data and Restart
|
||||
} else {
|
||||
statusLED.off();
|
||||
|
|
@ -191,7 +189,7 @@ int Span::getFreeSlot(){
|
|||
|
||||
void Span::initWifi(){
|
||||
|
||||
Network network; // initialization of WiFi credentials and Setup Code
|
||||
// Network network; // initialization of WiFi credentials and Setup Code
|
||||
|
||||
char id[18]; // create string version of Accessory ID for MDNS broadcast
|
||||
memcpy(id,HAPClient::accessory.ID,17); // copy ID bytes
|
||||
|
|
@ -424,7 +422,7 @@ void Span::processSerialCommand(char *c){
|
|||
|
||||
case 'S': {
|
||||
|
||||
Network network;
|
||||
// Network network;
|
||||
char buf[128];
|
||||
char setupCode[10];
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "Settings.h"
|
||||
#include "Utils.h"
|
||||
#include "Network.h"
|
||||
|
||||
using std::vector;
|
||||
using std::unordered_map;
|
||||
|
|
@ -55,6 +56,7 @@ struct Span{
|
|||
|
||||
Blinker statusLED; // indicates HomeSpan status
|
||||
PushButton controlButton; // controls HomeSpan configuration and resets
|
||||
Network network; // configures WiFi and Setup Code via either serial monitor or temporary Access Point
|
||||
|
||||
SpanConfig hapConfig; // track configuration changes to the HAP Accessory database; used to increment the configuration number (c#) when changes found
|
||||
vector<SpanAccessory *> Accessories; // vector of pointers to all Accessories
|
||||
|
|
@ -87,7 +89,8 @@ struct Span{
|
|||
|
||||
void setControlPin(uint8_t pin){controlPin=pin;} // sets Control Pin
|
||||
void setStatusPin(uint8_t pin){statusPin=pin;} // sets Status Pin
|
||||
|
||||
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)
|
||||
};
|
||||
|
||||
///////////////////////////////
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
#include <DNSServer.h>
|
||||
|
||||
#include "Network.h"
|
||||
#include "HAP.h"
|
||||
#include "HomeSpan.h"
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
|
|
@ -242,7 +241,7 @@ void Network::apConfigure(char *apName){
|
|||
|
||||
LOG2("\n");
|
||||
|
||||
} // process HAP Client
|
||||
} // process Client
|
||||
|
||||
if(client){
|
||||
Serial.print("*** Stopping Client ***\n");
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ using std::unordered_set;
|
|||
|
||||
struct Network {
|
||||
|
||||
const int MAX_HTTP=4095; // max number of bytes in HTTP message
|
||||
const char *apPassword="homespan"; // Access Point password (does not need to be secret - only used to ensure excrypted WiFi connection)
|
||||
const unsigned long lifetime=120000; // length of time (in milliseconds) to keep Access Point alive before shutting down and re-starting
|
||||
const int MAX_HTTP=4095; // max number of bytes in HTTP message
|
||||
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
|
||||
|
||||
char **ssidList=NULL;
|
||||
int numSSID;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
#define DEFAULT_SETUP_CODE "46637726" // changed during network setup or with 'S' command
|
||||
#define DEFAULT_CONTROL_PIN 21 // change with homeSpan.setControlPin(pin)
|
||||
#define DEFAULT_STATUS_PIN LED_BUILTIN // change with homeSpan.setStatusPin(pin)
|
||||
#define DEFAULT_AP_PASSWORD "homespan" // change with homeSpan.setApPassword(pwd)
|
||||
#define DEFAULT_AP_TIMEOUT 120 // change with homeSpan.setApTimeout(nSeconds)
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// Maximum number of simultaenous IP connections //
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
void setup() {
|
||||
|
||||
Serial.begin(115200);
|
||||
|
||||
|
||||
homeSpan.begin(Category::Lighting,"HomeSpan Benchmark");
|
||||
|
||||
new SpanAccessory(); // Begin by creating a new Accessory using SpanAccessory(), which takes no arguments
|
||||
|
|
|
|||
Loading…
Reference in New Issue