fixed-> cleanup
This commit is contained in:
parent
a21706f328
commit
6d57da3402
BIN
data/settings
BIN
data/settings
Binary file not shown.
Binary file not shown.
@ -20,12 +20,9 @@ public:
|
|||||||
~Config();
|
~Config();
|
||||||
const char *SSID = (char *)(buffer + OFFSET_SSID);
|
const char *SSID = (char *)(buffer + OFFSET_SSID);
|
||||||
const char *PASS = (char *)(buffer + OFFSET_PASS);
|
const char *PASS = (char *)(buffer + OFFSET_PASS);
|
||||||
uint32_t *ip_ptr = (uint32_t*)(buffer+OFFSET_IP);
|
uint32_t &ip = *((uint32_t*)(buffer+OFFSET_IP));
|
||||||
uint32_t &ip = *ip_ptr;
|
uint32_t &subnet = *((uint32_t*)(buffer+OFFSET_SUBNET));
|
||||||
uint32_t *subnet_ptr = (uint32_t*)(buffer+OFFSET_SUBNET);
|
uint32_t &gw = *((uint32_t*)(buffer+OFFSET_GW));
|
||||||
uint32_t &subnet = *subnet_ptr;
|
|
||||||
uint32_t *gw_ptr = (uint32_t*)(buffer+OFFSET_GW);
|
|
||||||
uint32_t &gw = *gw_ptr;
|
|
||||||
uint8_t &mode = *(buffer + OFFSET_MODE);
|
uint8_t &mode = *(buffer + OFFSET_MODE);
|
||||||
uint8_t &fail_timeout = *(buffer+OFFSET_FAIL_TIMEOUT);
|
uint8_t &fail_timeout = *(buffer+OFFSET_FAIL_TIMEOUT);
|
||||||
uint8_t &hold_time = *(buffer+OFFSET_HOLD_TIME);
|
uint8_t &hold_time = *(buffer+OFFSET_HOLD_TIME);
|
||||||
|
@ -15,30 +15,22 @@ bool WebConsole::init(Config *config, userdb::UserDb *userdb)
|
|||||||
this->userdb = userdb;
|
this->userdb = userdb;
|
||||||
this->_config = config;
|
this->_config = config;
|
||||||
this->userdb = userdb;
|
this->userdb = userdb;
|
||||||
|
// Wifi Setup
|
||||||
|
this->_dnsServer = new DNSServer;
|
||||||
|
WiFi.mode(WIFI_AP);
|
||||||
|
Serial.print("\t1. Network config... ");
|
||||||
|
Serial.println(WiFi.softAPConfig(_config->ip, _config->gw, _config->subnet) ? "Ready" : "Failed!");
|
||||||
|
Serial.print("\t2. DNS config... ");
|
||||||
|
Serial.println(_dnsServer->start(53, "*", _config->ip) ? "Ready" : "Failed!");
|
||||||
|
Serial.print("\t3 AP setup <SSID:\"" + String(_config->SSID) + "\"...");
|
||||||
|
if (strlen(_config->PASS) > 0)
|
||||||
|
Serial.println(WiFi.softAP(_config->SSID, _config->PASS) ? "Ready" : "Failed!");
|
||||||
|
else
|
||||||
|
Serial.println(WiFi.softAP(_config->SSID) ? "Ready" : "Failed!");
|
||||||
|
WiFi.hostname("Doorlock");
|
||||||
|
Serial.println("Please connect via http://" +WiFi.softAPIP().toString()+"/");
|
||||||
|
|
||||||
// this->_dnsServer = new DNSServer;
|
// Webserver Setup
|
||||||
// WiFi.mode(WIFI_AP);
|
|
||||||
//
|
|
||||||
// uint8_t *ipp = (uint8_t *)_config->ip_ptr;
|
|
||||||
// uint8_t *gwp = (uint8_t *)_config->gw_ptr;
|
|
||||||
// uint8_t *snp = (uint8_t *)_config->subnet_ptr;
|
|
||||||
//// IPAddress ip(*(ipp), *(ipp + 1), *(ipp + 2), *(ipp + 3));
|
|
||||||
//// IPAddress gw(*(gwp), *(gwp + 1), *(gwp + 2), *(gwp + 3));
|
|
||||||
//// IPAddress subnet(*(snp), *(snp + 1), *(snp + 2), *(snp + 3));
|
|
||||||
//
|
|
||||||
// Serial.print("\t1. Network config ->");
|
|
||||||
// Serial.println(WiFi.softAPConfig(ipp, gwp, snp) ? "Ready" : "Failed!");
|
|
||||||
// Serial.print("\t2. DNS config ->");
|
|
||||||
// //Serial.println(_dnsServer->start(53, "*", ip) ? "Ready" : "Failed!");
|
|
||||||
//
|
|
||||||
// Serial.print("\t3 AP setup " + String(_config->SSID) + " -> ");
|
|
||||||
// if (strlen(_config->PASS) > 0)
|
|
||||||
// Serial.println(WiFi.softAP(_config->SSID, _config->PASS) ? "Ready" : "Failed!");
|
|
||||||
// else
|
|
||||||
// Serial.println(WiFi.softAP(_config->SSID) ? "Ready" : "Failed!");
|
|
||||||
// WiFi.hostname("Doorlock");
|
|
||||||
// Serial.println(WiFi.softAPIP());
|
|
||||||
//
|
|
||||||
this->_server = new ESP8266WebServer(80);
|
this->_server = new ESP8266WebServer(80);
|
||||||
const char *headerkeys[] = {"Authentification"};
|
const char *headerkeys[] = {"Authentification"};
|
||||||
size_t headerkeyssize = sizeof(headerkeys) / sizeof(char *);
|
size_t headerkeyssize = sizeof(headerkeys) / sizeof(char *);
|
||||||
@ -54,7 +46,6 @@ bool WebConsole::init(Config *config, userdb::UserDb *userdb)
|
|||||||
_server->on(UriBraces("/api/user/{}"), HTTPMethod::HTTP_PUT, std::bind(&WebConsole::_createUser, this));
|
_server->on(UriBraces("/api/user/{}"), HTTPMethod::HTTP_PUT, std::bind(&WebConsole::_createUser, this));
|
||||||
_server->on(UriBraces("/api/user/{}"), HTTPMethod::HTTP_POST, std::bind(&WebConsole::_updateUser, this));
|
_server->on(UriBraces("/api/user/{}"), HTTPMethod::HTTP_POST, std::bind(&WebConsole::_updateUser, this));
|
||||||
_server->on(UriBraces("/api/config/{}"), std::bind(&WebConsole::_deleteUser, this));
|
_server->on(UriBraces("/api/config/{}"), std::bind(&WebConsole::_deleteUser, this));
|
||||||
//_server->on("/bypin",std::bind(&WebConsole::_findPin,this));
|
|
||||||
_server->serveStatic("/", LittleFS, "/s/");
|
_server->serveStatic("/", LittleFS, "/s/");
|
||||||
_server->onNotFound(std::bind(&WebConsole::_handleUnknown, this));
|
_server->onNotFound(std::bind(&WebConsole::_handleUnknown, this));
|
||||||
return true;
|
return true;
|
||||||
@ -65,7 +56,7 @@ void WebConsole::attachRfid(Rfid *rfid)
|
|||||||
}
|
}
|
||||||
void WebConsole::serve()
|
void WebConsole::serve()
|
||||||
{
|
{
|
||||||
//_dnsServer->processNextRequest();
|
_dnsServer->processNextRequest();
|
||||||
if (catch_rfid)
|
if (catch_rfid)
|
||||||
{
|
{
|
||||||
if (millis() - catch_rfid_millis > 2000)
|
if (millis() - catch_rfid_millis > 2000)
|
||||||
|
22
src/main.cpp
22
src/main.cpp
@ -8,8 +8,6 @@
|
|||||||
#include "WebConsole.h"
|
#include "WebConsole.h"
|
||||||
#include "UserDb.h"
|
#include "UserDb.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include <ESP8266mDNS.h>
|
|
||||||
#include <DNSServer.h>
|
|
||||||
|
|
||||||
// File config
|
// File config
|
||||||
Config config;
|
Config config;
|
||||||
@ -23,28 +21,11 @@ Rfid rfid;
|
|||||||
|
|
||||||
Keyboard keyboard(200);
|
Keyboard keyboard(200);
|
||||||
Interface iface;
|
Interface iface;
|
||||||
//DNSServer dnsServer;
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
config.loadBin();
|
config.loadBin();
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println("Starting System");
|
Serial.println("Starting System...");
|
||||||
IPAddress ip(192, 168, 80, 1);
|
|
||||||
IPAddress gw(192, 168, 80, 1);
|
|
||||||
IPAddress subnet(192, 168, 80, 255);
|
|
||||||
WiFi.mode(WIFI_AP);
|
|
||||||
Serial.print("\t1. Network config ->");
|
|
||||||
Serial.println(WiFi.softAPConfig(ip, gw, subnet) ? "Ready" : "Failed!");
|
|
||||||
Serial.print("\t2. DNS config ->");
|
|
||||||
//Serial.println(dnsServer.start(53, "*", ip) ? "Ready" : "Failed!");
|
|
||||||
Serial.print("\t3 AP setup " + String(config.SSID) + " -> ");
|
|
||||||
if (strlen(config.PASS) > 0)
|
|
||||||
Serial.println(WiFi.softAP(config.SSID, config.PASS) ? "Ready" : "Failed!");
|
|
||||||
else
|
|
||||||
Serial.println(WiFi.softAP(config.SSID) ? "Ready" : "Failed!");
|
|
||||||
WiFi.hostname("Doorlock");
|
|
||||||
delay(50);
|
|
||||||
Serial.println(WiFi.softAPIP());
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
userdatabase.print_to_serial();
|
userdatabase.print_to_serial();
|
||||||
#endif
|
#endif
|
||||||
@ -58,7 +39,6 @@ void setup()
|
|||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
//dnsServer.processNextRequest();
|
|
||||||
rfid.scan();
|
rfid.scan();
|
||||||
web.serve();
|
web.serve();
|
||||||
keyboard.scanAsync();
|
keyboard.scanAsync();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user