Moved platform-specific code related to WiFi and services to my_wifi.h. Also, made the HTTP server stuff compatible to ESP32.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ea4898daa6
commit
291a3be623
@ -2,9 +2,14 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef HTTP_SERVER_ENABLE
|
#ifdef HTTP_SERVER_ENABLE
|
||||||
#include <ESP8266WebServer.h>
|
|
||||||
|
|
||||||
|
#include "my_wifi.h"
|
||||||
|
|
||||||
|
#if defined ( ESP8266 )
|
||||||
extern ESP8266WebServer http_server;
|
extern ESP8266WebServer http_server;
|
||||||
|
#elif defined ( ESP32 )
|
||||||
|
extern ESP32WebServer http_server;
|
||||||
|
#endif
|
||||||
|
|
||||||
void http_server_setup();
|
void http_server_setup();
|
||||||
void http_server_loop();
|
void http_server_loop();
|
||||||
|
19
include/my_wifi.h
Normal file
19
include/my_wifi.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#if defined( ESP8266 )
|
||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <ESP8266mDNS.h>
|
||||||
|
#include <ESP8266WebServer.h>
|
||||||
|
#elif defined( ESP32 )
|
||||||
|
#include <WiFi.h>
|
||||||
|
#include <ESPmDNS.h>
|
||||||
|
#include <WiFiClient.h>
|
||||||
|
#include <WiFiServer.h>
|
||||||
|
#include <ESP32WebServer.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <WiFiUdp.h>
|
||||||
|
|
||||||
|
void wifi_setup();
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <NTPClient.h>
|
#include <NTPClient.h>
|
||||||
#include <WiFiUdp.h>
|
#include "my_wifi.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
extern NTPClient ntpClient;
|
extern NTPClient ntpClient;
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
#ifndef ota_H
|
#pragma once
|
||||||
#define ota_H
|
|
||||||
|
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
|
|
||||||
void ota_setup();
|
void ota_setup();
|
||||||
void ota_loop();
|
void ota_loop();
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
#ifndef wifi_H
|
|
||||||
#define wifi_H
|
|
||||||
|
|
||||||
void wifi_setup();
|
|
||||||
|
|
||||||
#endif
|
|
@ -19,6 +19,7 @@ lib_deps =
|
|||||||
https://github.com/fabianonline/FastLED.git
|
https://github.com/fabianonline/FastLED.git
|
||||||
https://github.com/fabianonline/simplelist.git
|
https://github.com/fabianonline/simplelist.git
|
||||||
https://github.com/fabianonline/NTPClient.git
|
https://github.com/fabianonline/NTPClient.git
|
||||||
|
ESP8266WebServer
|
||||||
|
|
||||||
[env:ota]
|
[env:ota]
|
||||||
upload_port = 10.10.2.78
|
upload_port = 10.10.2.78
|
||||||
@ -39,4 +40,7 @@ lib_deps = ${extra.lib_deps}
|
|||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = ${extra.lib_deps}
|
lib_deps =
|
||||||
|
${extra.lib_deps}
|
||||||
|
ESP32WebServer
|
||||||
|
WiFiClient
|
||||||
|
@ -5,7 +5,11 @@
|
|||||||
#include "http_server.h"
|
#include "http_server.h"
|
||||||
#include "effects.h"
|
#include "effects.h"
|
||||||
|
|
||||||
|
#if defined( ESP8266 )
|
||||||
ESP8266WebServer http_server(HTTP_SERVER_PORT);
|
ESP8266WebServer http_server(HTTP_SERVER_PORT);
|
||||||
|
#elif defined( ESP32 )
|
||||||
|
ESP32WebServer http_server(HTTP_SERVER_PORT);
|
||||||
|
#endif
|
||||||
|
|
||||||
void http_server_400() {
|
void http_server_400() {
|
||||||
http_server.send(400);
|
http_server.send(400);
|
||||||
|
@ -5,13 +5,7 @@
|
|||||||
#pragma message "MQTT_ENABLE is false. Skipping MQTT."
|
#pragma message "MQTT_ENABLE is false. Skipping MQTT."
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#if defined( ESP8266 )
|
#include "my_wifi.h"
|
||||||
#include <ESP8266WiFi.h>
|
|
||||||
#elif defined( ESP32 )
|
|
||||||
#include <WiFi.h>
|
|
||||||
#else
|
|
||||||
#error "Neither ESP32 nor ESP8266 set..."
|
|
||||||
#endif
|
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
#include "EffectEntry.h"
|
#include "EffectEntry.h"
|
||||||
#include "Effect.h"
|
#include "Effect.h"
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
|
|
||||||
#if defined( ESP8266 )
|
#include "my_wifi.h"
|
||||||
#include <ESP8266mDNS.h>
|
|
||||||
#elif defined( ESP32 )
|
|
||||||
#include <ESPmDNS.h>
|
|
||||||
#else
|
|
||||||
#error Neither ESP32 nor ESP8266 set!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "ntp.h"
|
#include "ntp.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "animations.h"
|
#include "animations.h"
|
||||||
#include "wifi.h"
|
#include "my_wifi.h"
|
||||||
#include "ota.h"
|
#include "ota.h"
|
||||||
#include "my_fastled.h"
|
#include "my_fastled.h"
|
||||||
#include "EffectEntry.h"
|
#include "EffectEntry.h"
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#if defined( ESP8266 )
|
#include "my_wifi.h"
|
||||||
#include <ESP8266WiFi.h>
|
|
||||||
#elif defined( ESP32 )
|
|
||||||
#include <WiFi.h>
|
|
||||||
#endif
|
|
||||||
#include "wifi.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
void wifi_setup() {
|
void wifi_setup() {
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.begin(WIFI_SSID, WIFI_PASS);
|
WiFi.begin(WIFI_SSID, WIFI_PASS);
|
||||||
|
Loading…
Reference in New Issue
Block a user