Commit 67301e9e authored by Eric Duminil's avatar Eric Duminil
Browse files

Merge branch 'refactor/dependencies' into develop

parents 649d7fdf 6149cce2
Pipeline #5749 failed with stage
#ifndef WEB_SERVER_H_
#define WEB_SERVER_H_
#if defined(ESP8266)
# include <ESP8266WebServer.h>
#elif defined(ESP32)
# include <WebServer.h>
#endif
#include "config.h"
#include "util.h"
#include "wifi_util.h"
#include "co2_sensor.h"
#include "sensor_console.h"
#ifdef AMPEL_CSV
# include "csv_writer.h"
#endif
#ifdef AMPEL_MQTT
# include "mqtt.h"
#endif
#ifdef AMPEL_LORAWAN
# include "lorawan.h"
#endif
namespace web_server {
void initialize();
void update();
......
#include "wifi_util.h"
#include "config.h"
#include "util.h"
#include "ntp.h"
#include "led_effects.h"
#include "sensor_console.h"
#if defined(ESP8266)
# include <ESP8266WiFi.h>
#elif defined(ESP32)
# include <WiFi.h>
#endif
namespace config {
// WiFi config. See 'config.h' if you want to modify those values.
const char *wifi_ssid = WIFI_SSID;
......@@ -8,7 +20,7 @@ namespace config {
#ifdef WIFI_TIMEOUT
const uint8_t wifi_timeout = WIFI_TIMEOUT; // [s] Will try to connect during wifi_timeout seconds before failing.
#else
const uint8_t wifi_timeout = 60; // [s] Will try to connect during wifi_timeout seconds before failing.
const uint8_t wifi_timeout = 60; // [s] Will try to connect during wifi_timeout seconds before failing.
#endif
}
......@@ -40,6 +52,10 @@ namespace wifi {
Serial.println(WIFI_SSID);
}
bool connected() {
return WiFi.status() == WL_CONNECTED;
}
// Initialize Wi-Fi
void connect(const char *hostname) {
......@@ -64,7 +80,7 @@ namespace wifi {
led_effects::showRainbowWheel();
Serial.print(".");
}
if (WiFi.status() == WL_CONNECTED) {
if (connected()) {
led_effects::showKITTWheel(color::green);
Serial.println();
Serial.print(F("WiFi - Connected! IP address: "));
......@@ -74,7 +90,8 @@ namespace wifi {
} else {
//TODO: Allow sensor to work as an Access Point, in order to define SSID & password?
led_effects::showKITTWheel(color::red);
Serial.println(F("Connection to WiFi failed"));
Serial.print(F("Connection to WiFi failed! Status : "));
Serial.println(WiFi.status());
}
}
}
#ifndef WIFI_UTIL_H_INCLUDED
#define WIFI_UTIL_H_INCLUDED
#include "config.h"
#include "util.h"
#include "led_effects.h"
namespace wifi {
extern char local_ip[];
void connect(const char *hostname);
bool connected();
}
#endif
......@@ -24,8 +24,3 @@ monitor_speed = 115200
lib_deps =
MCCI LoRaWAN LMIC library
build_flags =
-D ARDUINO_LMIC_PROJECT_CONFIG_H_SUPPRESS
-D CFG_eu868=1
-D CFG_sx1276_radio=1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment