Commit 1f7a20c1 authored by Eric Duminil's avatar Eric Duminil
Browse files

Merge branch 'develop'

parents da1f41c0 34496cfe
#ifndef WEB_SERVER_H_ #ifndef WEB_SERVER_H_
#define 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 { namespace web_server {
void initialize(); void initialize();
void update(); void update();
......
#include "wifi_util.h" #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 { namespace config {
// WiFi config. See 'config.h' if you want to modify those values. // WiFi config. See 'config.h' if you want to modify those values.
const char *wifi_ssid = WIFI_SSID; const char *wifi_ssid = WIFI_SSID;
...@@ -8,7 +20,7 @@ namespace config { ...@@ -8,7 +20,7 @@ namespace config {
#ifdef WIFI_TIMEOUT #ifdef WIFI_TIMEOUT
const uint8_t wifi_timeout = WIFI_TIMEOUT; // [s] Will try to connect during wifi_timeout seconds before failing. const uint8_t wifi_timeout = WIFI_TIMEOUT; // [s] Will try to connect during wifi_timeout seconds before failing.
#else #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 #endif
} }
...@@ -40,6 +52,10 @@ namespace wifi { ...@@ -40,6 +52,10 @@ namespace wifi {
Serial.println(WIFI_SSID); Serial.println(WIFI_SSID);
} }
bool connected() {
return WiFi.status() == WL_CONNECTED;
}
// Initialize Wi-Fi // Initialize Wi-Fi
void connect(const char *hostname) { void connect(const char *hostname) {
...@@ -64,7 +80,7 @@ namespace wifi { ...@@ -64,7 +80,7 @@ namespace wifi {
led_effects::showRainbowWheel(); led_effects::showRainbowWheel();
Serial.print("."); Serial.print(".");
} }
if (WiFi.status() == WL_CONNECTED) { if (connected()) {
led_effects::showKITTWheel(color::green); led_effects::showKITTWheel(color::green);
Serial.println(); Serial.println();
Serial.print(F("WiFi - Connected! IP address: ")); Serial.print(F("WiFi - Connected! IP address: "));
...@@ -74,7 +90,8 @@ namespace wifi { ...@@ -74,7 +90,8 @@ namespace wifi {
} else { } else {
//TODO: Allow sensor to work as an Access Point, in order to define SSID & password? //TODO: Allow sensor to work as an Access Point, in order to define SSID & password?
led_effects::showKITTWheel(color::red); 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 #ifndef WIFI_UTIL_H_INCLUDED
#define WIFI_UTIL_H_INCLUDED #define WIFI_UTIL_H_INCLUDED
#include "config.h"
#include "util.h"
#include "led_effects.h"
namespace wifi { namespace wifi {
extern char local_ip[]; extern char local_ip[];
void connect(const char *hostname); void connect(const char *hostname);
bool connected();
} }
#endif #endif
...@@ -24,8 +24,3 @@ monitor_speed = 115200 ...@@ -24,8 +24,3 @@ monitor_speed = 115200
lib_deps = lib_deps =
MCCI LoRaWAN LMIC library 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