|
1 | 1 | #include <Arduino.h> |
2 | 2 | #include <ArduinoJson.h> |
| 3 | +#ifdef ESP8266 |
3 | 4 | #include <ESP8266HTTPUpdateServer.h> |
4 | 5 | #include <ESP8266WebServer.h> |
5 | 6 | #include <ESP8266WiFi.h> |
6 | 7 | #include <ESP8266mDNS.h> |
| 8 | +#include <coredecls.h> |
| 9 | +#elif defined(ESP32) |
| 10 | +#include <ESPmDNS.h> |
| 11 | +#include <HTTPUpdateServer.h> |
| 12 | +#include <Update.h> |
| 13 | +#include <WebServer.h> |
| 14 | +#include <WiFi.h> |
| 15 | +#endif |
7 | 16 | #include <NeoPixelBus.h> |
8 | 17 | #include <RTClib.h> |
9 | 18 | #include <WiFiClient.h> |
10 | 19 | #include <WiFiUdp.h> |
11 | 20 | #include <Wire.h> |
12 | | -#include <coredecls.h> |
13 | 21 | #include <sntp.h> |
14 | 22 |
|
15 | 23 | #include "Uhr.h" |
|
22 | 30 | iUhrType *usedUhrType = nullptr; |
23 | 31 |
|
24 | 32 | #include "NeoMultiFeature.hpp" |
| 33 | + |
| 34 | +#ifdef ESP8266 |
25 | 35 | NeoPixelBus<NeoMultiFeature, Neo800KbpsMethod> *strip_RGB = NULL; |
26 | 36 | NeoPixelBus<NeoGrbwFeature, Neo800KbpsMethod> *strip_RGBW = NULL; |
| 37 | +#elif defined(ESP32) |
| 38 | +NeoPixelBus<NeoGrbwFeature, NeoEsp32I2s1X8Sk6812Method> *strip_RGBW = NULL; |
| 39 | +NeoPixelBus<NeoMultiFeature, NeoEsp32I2s1X8Ws2812xMethod> *strip_RGB = NULL; |
| 40 | +#endif |
27 | 41 |
|
28 | 42 | WiFiClient client; |
29 | 43 |
|
30 | 44 | //--OTA-- |
| 45 | +#ifdef ESP8266 |
31 | 46 | ESP8266WebServer httpServer(81); |
32 | 47 | ESP8266HTTPUpdateServer httpUpdater; |
| 48 | +#elif defined(ESP32) |
| 49 | +WebServer httpServer(81); |
| 50 | +HTTPUpdateServer httpUpdater; |
| 51 | +#endif |
33 | 52 | //--OTA-- |
34 | 53 |
|
35 | 54 | // Timezone from |
@@ -103,7 +122,12 @@ void time_is_set() { |
103 | 122 | if (sntp_getreachability(0)) { |
104 | 123 | origin = sntp_getservername(0); |
105 | 124 | if (origin.length() == 0) { |
106 | | - origin = IPAddress(sntp_getserver(0)).toString(); |
| 125 | + const ip_addr_t *ip_addr = sntp_getserver(0); |
| 126 | +#ifdef ESP8266 |
| 127 | + origin = IPAddress(ip_addr->addr).toString(); |
| 128 | +#elif defined(ESP32) |
| 129 | + origin = IPAddress(ip_addr->u_addr.ip4.addr).toString(); |
| 130 | +#endif |
107 | 131 | } |
108 | 132 | } else { |
109 | 133 | origin = "SNTP not reachable"; |
@@ -306,7 +330,9 @@ void setup() { |
306 | 330 | Serial.println("No external real-time clock found"); |
307 | 331 | externalRTC = false; |
308 | 332 | } |
| 333 | +#ifdef ESP8266 |
309 | 334 | settimeofday_cb(time_is_set); |
| 335 | +#endif |
310 | 336 |
|
311 | 337 | //------------------------------------- |
312 | 338 | // Start WiFi |
@@ -366,23 +392,23 @@ void setup() { |
366 | 392 | Serial.println("--------------------------------------"); |
367 | 393 | Serial.println("ESP Uhr"); |
368 | 394 | Serial.printf("Version : %s\n", VERSION); |
| 395 | + |
| 396 | +#ifdef ESP8266 |
369 | 397 | Serial.printf("Chip ID : %08X\n", ESP.getChipId()); |
370 | | - Serial.printf("Flash ID : %08X\n\n", ESP.getFlashChipId()); |
371 | 398 | Serial.printf("CPU Speed : %u MHz \n\n", ESP.getCpuFreqMHz()); |
| 399 | +#elif defined(ESP32) |
| 400 | + Serial.printf("Chip ID : %08X\n", (uint32_t)ESP.getEfuseMac()); |
| 401 | + Serial.printf("CPU Speed : %u MHz \n\n", getCpuFrequencyMhz()); |
| 402 | +#endif |
372 | 403 |
|
373 | | - Serial.printf("Flash real Size : %u KByte\n", |
374 | | - ESP.getFlashChipRealSize() / 1024); |
375 | | - Serial.printf("Flash ide Size : %u KByte\n", |
376 | | - ESP.getFlashChipSize() / 1024); |
| 404 | + Serial.printf("Flash Size : %u KByte\n", ESP.getFlashChipSize() / 1024); |
377 | 405 | Serial.printf("Flash ide Speed : %u\n\n", ESP.getFlashChipSpeed()); |
378 | 406 |
|
379 | 407 | Serial.printf("Free Heap Size : %u Byte\n", ESP.getFreeHeap()); |
380 | 408 | Serial.printf("Sketch Size : %u Byte \n", ESP.getSketchSize()); |
381 | 409 | Serial.printf("Free Sketch Size: %u Byte \n\n", ESP.getFreeSketchSpace()); |
382 | 410 |
|
383 | 411 | Serial.printf("SDK Version : %s\n", ESP.getSdkVersion()); |
384 | | - Serial.print("RESET Info : "); |
385 | | - Serial.println(ESP.getResetInfo()); |
386 | 412 | Serial.print("COMPILED : "); |
387 | 413 | Serial.print(__DATE__); |
388 | 414 | Serial.print(" "); |
@@ -428,7 +454,9 @@ void loop() { |
428 | 454 |
|
429 | 455 | network.loop(); |
430 | 456 |
|
| 457 | +#ifdef ESP8266 |
431 | 458 | MDNS.update(); |
| 459 | +#endif |
432 | 460 |
|
433 | 461 | httpServer.handleClient(); |
434 | 462 |
|
|
0 commit comments