|
|
|
|
|
|
|
|
#include "httpserver.h" |
|
|
#include "httpserver.h" |
|
|
#include "ota.h" |
|
|
#include "ota.h" |
|
|
#include "wifi_credentials.h" |
|
|
#include "wifi_credentials.h" |
|
|
|
|
|
#include <EEPROM.h> |
|
|
|
|
|
|
|
|
// BOARD |
|
|
// BOARD |
|
|
#define ESP12_LED 2 |
|
|
#define ESP12_LED 2 |
|
|
|
|
|
|
|
|
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("us") |
|
|
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("us") |
|
|
#define TIMEIF_US(_f, _l, _str) _t=micros(); _f; _t=micros()-_t; if(_t > (_l)) { SP_US(_str, _t); } |
|
|
#define TIMEIF_US(_f, _l, _str) _t=micros(); _f; _t=micros()-_t; if(_t > (_l)) { SP_US(_str, _t); } |
|
|
|
|
|
|
|
|
|
|
|
struct { // Struct for wifi-data, 40 Bytes each SSID and PW |
|
|
|
|
|
char SSID[40] = ""; |
|
|
|
|
|
char PW[40] = ""; |
|
|
|
|
|
} wifi_data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void timerCallback(void *pArg) |
|
|
void timerCallback(void *pArg) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
Serial.println("Booting ...."); |
|
|
Serial.println("Booting ...."); |
|
|
pinMode(ESP12_LED, OUTPUT); |
|
|
pinMode(ESP12_LED, OUTPUT); |
|
|
|
|
|
|
|
|
|
|
|
EEPROM.begin(512); // init virtual "EEPROM" with size 512 Bytes |
|
|
|
|
|
|
|
|
|
|
|
//strncpy(wifi_data.SSID, "donotconnect", 40); |
|
|
|
|
|
//strncpy(wifi_data.PW, "unsafe lol", 40); |
|
|
|
|
|
|
|
|
|
|
|
EEPROM.get(0, wifi_data); |
|
|
|
|
|
//EEPROM.commit(); |
|
|
|
|
|
|
|
|
Wire.begin(); // Wire must be started first |
|
|
Wire.begin(); // Wire must be started first |
|
|
Wire.setClock(1000000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz |
|
|
Wire.setClock(1000000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz |
|
|
stairs.setup(); |
|
|
stairs.setup(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
os_timer_setfn(&timer1, timerCallback, &timer_flag); |
|
|
os_timer_setfn(&timer1, timerCallback, &timer_flag); |
|
|
os_timer_arm(&timer1, 20, true); |
|
|
os_timer_arm(&timer1, 20, true); |
|
|
|
|
|
|
|
|
|
|
|
Serial.println("SSID: " + String(wifi_data.SSID) + " PW: " + String(wifi_data.PW)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint32_t c = 0; |
|
|
uint32_t c = 0; |