2019-04-25 16:20:01 +02:00
|
|
|
/*
|
|
|
|
* productionMode.cpp
|
|
|
|
*
|
|
|
|
* Created on: Apr 05, 2019
|
|
|
|
* Author: wn
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-04-30 11:22:16 +00:00
|
|
|
#include <defines.h>
|
2019-04-25 16:20:01 +02:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <ESP8266WiFi.h>
|
|
|
|
#include <ESP8266WebServer.h>
|
|
|
|
|
2019-04-30 11:22:16 +00:00
|
|
|
#include <configuration.h>
|
2019-04-25 16:20:01 +02:00
|
|
|
|
|
|
|
void setup_wifi() {
|
|
|
|
delay(10);
|
|
|
|
WiFi.mode(WIFI_STA);
|
|
|
|
|
|
|
|
// We start by connecting to a WiFi network
|
|
|
|
#ifdef DEBUG
|
|
|
|
Serial.println();
|
|
|
|
Serial.print("Connecting to ");
|
|
|
|
Serial.println(configBlock.wifiSsid);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
WiFi.begin(configBlock.wifiSsid, configBlock.wifiKey);
|
|
|
|
|
|
|
|
while (WiFi.status() != WL_CONNECTED) {
|
|
|
|
delay(50);
|
|
|
|
#ifdef DEBUG
|
|
|
|
Serial.print(".");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
Serial.println("!");
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
Serial.println("");
|
|
|
|
Serial.println("WiFi connected");
|
|
|
|
Serial.println("IP address: ");
|
|
|
|
Serial.println(WiFi.localIP());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void __attribute__((weak)) setupApplication() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void __attribute__((weak)) loopApplication() {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void setupProduction() {
|
|
|
|
setup_wifi();
|
|
|
|
setupApplication();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loopProduction() {
|
2020-07-24 23:28:04 +02:00
|
|
|
if (WiFi.status() != WL_CONNECTED) {
|
|
|
|
ESP.reset();
|
|
|
|
}
|
2019-04-25 16:20:01 +02:00
|
|
|
loopApplication();
|
|
|
|
}
|
|
|
|
|
|
|
|
|