2323#include <ESP8266WiFi.h> // WIFI
2424#include <ESP8266WiFiMulti.h> // WIFI
2525//#include <WiFiClientSecure.h> // HTTPS
26- //#include <WiFiUdp.h> // NTP
2726#include <TimeLib.h> // TIME
2827#include <EEPROM.h> // EEPROM
2928#include <FS.h> // FILESYSTEM
3029#include <ArduinoJson.h> // JSON
31- #include <ESP8266mDNS.h>
32- #include <ESPAsyncTCP.h>
30+ #include <ESP8266mDNS.h> // mDNS
31+ #include <ESPAsyncTCP.h> // ASYNCTCP
3332#include <ESPAsyncWebServer.h> // https://github.com/me-no-dev/ESPAsyncWebServer/issues/60
34- #include "AsyncJson.h"
35- #include <AsyncMqttClient.h>
36- #include <StreamString.h>
33+ #include "AsyncJson.h" // ASYNCJSON
34+ #include <AsyncMqttClient.h> // ASYNCMQTT
35+ // #include <StreamString.h>
3736
3837extern "C" {
3938#include "user_interface.h"
@@ -49,9 +48,9 @@ extern "C" uint32_t _SPIFFS_end; // FIRST ADRESS AFTER FS
4948
5049// ++++++++++++++++++++++++++++++++++++++++++++++++++
5150// SETTINGS
52- int co = 32 ;
51+
5352// HARDWARE
54- #define FIRMWAREVERSION "v0.7.9 "
53+ #define FIRMWAREVERSION "v0.8.0 "
5554#define APIVERSION "v1"
5655
5756// CHANNELS
@@ -155,13 +154,14 @@ struct ChannelData {
155154
156155ChannelData ch [CHANNELS ];
157156
157+ // SENSORTYP
158158String ttypname [SENSORTYPEN ] = {"Maverick" ,"Fantast-Neu" ,"Fantast" ,"iGrill2" ,"ET-73" ,
159159 "Perfektion" ,"5K3A1B" ,"MOUSER47K" ,"100K6A1B" ,"Weber_6743" ,
160160 "Santos" };
161-
162-
161+ // TEMPERATURE UNIT
163162String temp_unit = "C" ;
164- //String colors[8] = {"#6495ED", "#CD2626", "#66CDAA", "#F4A460", "#D02090", "#FFEC8B", "#BA55D3", "#008B8B"};
163+
164+ // CHANNEL COLORS
165165String colors [8 ] = {"#0C4C88" ,"#22B14C" ,"#EF562D" ,"#FFC100" ,"#A349A4" ,"#804000" ,"#5587A2" ,"#5C7148" };
166166
167167// PITMASTER
@@ -182,6 +182,7 @@ struct Pitmaster {
182182Pitmaster pitmaster ;
183183int pidsize ;
184184
185+ // PID PROFIL
185186struct PID {
186187 String name ;
187188 byte id ;
@@ -207,6 +208,7 @@ struct PID {
207208};
208209PID pid [PITMASTERSIZE ];
209210
211+ // AUTOTUNE
210212struct AutoTune {
211213 bool storeValues ;
212214 float temp ; // BETRIEBS-TEMPERATUR
@@ -243,6 +245,7 @@ struct AutoTune {
243245
244246AutoTune autotune ;
245247
248+ // DUTYCYCLE
246249struct DutyCycle {
247250 long timer ;
248251 int value ;
@@ -273,15 +276,14 @@ uint32_t log_sector; // erster Sector von APP2
273276uint32_t freeSpaceStart ; // First Sector of OTA
274277uint32_t freeSpaceEnd ; // Last Sector+1 of OTA
275278
279+ // NOTIFICATION
276280struct Notification {
277281 byte ch ; // CHANNEL
278282 bool limit ; // LIMIT: 0 = LOW TEMPERATURE, 1 = HIGH TEMPERATURE
279283};
280284
281285Notification notification ;
282286
283-
284-
285287// SYSTEM
286288struct System {
287289 byte hwversion ; // HARDWARE VERSION
@@ -295,13 +297,13 @@ struct System {
295297 String getupdate ;
296298 bool autoupdate ;
297299 bool god ;
300+ bool pitsupply ;
298301};
299302
300303System sys ;
301304bool stby = false; // USB POWER SUPPLY?
302305byte pulsalarm = 1 ;
303306
304-
305307// BATTERY
306308struct Battery {
307309 int voltage ; // CURRENT VOLTAGE
@@ -342,22 +344,22 @@ struct IoT {
342344
343345IoT iot ;
344346
345- // Chart
347+ // CLOUD CHART/LOG
346348struct Chart {
347- bool on ; // NANO CHART ON / OFF
348- String token ; // NANO CHART TOKEN
349- int interval ; // NANO CHART INTERVALL
349+ bool on = false ; // NANO CHART ON / OFF
350+ // String token; // NANO CHART TOKEN
351+ // int interval; // NANO CHART INTERVALL
350352};
351353
352354Chart chart ;
353355
354-
355356// OLED
356357int current_ch = 0 ; // CURRENTLY DISPLAYED CHANNEL
357358bool LADENSHOW = false; // LOADING INFORMATION?
358359bool displayblocked = false; // No OLED Update
359360enum {NO , CONFIGRESET , CHANGEUNIT , OTAUPDATE , HARDWAREALARM , IPADRESSE , AUTOTUNE };
360361
362+ // OLED QUESTION
361363struct MyQuestion {
362364 int typ ;
363365 int con ;
@@ -388,9 +390,6 @@ struct HoldSSID {
388390};
389391HoldSSID holdssid ;
390392
391- // NTP
392- byte packetBuffer [ NTP_PACKET_SIZE ]; //buffer to hold incoming and outgoing packets
393-
394393// BUTTONS
395394byte buttonPins []= {btn_r ,btn_l }; // Pins
396395#define NUMBUTTONS sizeof(buttonPins)
@@ -528,6 +527,9 @@ void sendDataCloud();
528527
529528String cloudData ();
530529
530+ // ++++++++++++++++++++++++++++++++++++++++++++++++++++
531+
532+
531533//++++++++++++++++++++++++++++++++++++++++++++++++++++++
532534// Initialize Serial
533535void set_serial () {
@@ -554,6 +556,7 @@ void set_system() {
554556 sys .god = false;
555557 battery .max = BATTMAX ;
556558 battery .min = BATTMIN ;
559+ sys .pitsupply = false;
557560}
558561
559562
@@ -627,7 +630,6 @@ void timer_iot() {
627630
628631}
629632
630-
631633//++++++++++++++++++++++++++++++++++++++++++++++++++++++
632634// DataLog Timer
633635void timer_datalog () {
@@ -846,6 +848,25 @@ String getMacAddress() {
846848}
847849
848850
851+ // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
852+ // Cloud Token Generator
853+ String newToken () {
854+ String stamp = String (now (), HEX );
855+ int x = 10 - stamp .length (); //pow(16,(10 - timestamp.length()));
856+ long y = 1 ; // long geht bis 16^7
857+ if (x > 7 ) {
858+ stamp += String (random (268435456 ), HEX );
859+ x -= 7 ;
860+ }
861+ for (int i = 0 ;i < x ;i ++ ) y *= 16 ;
862+ stamp += String (random (y ), HEX );
863+ return (String ) String (ESP .getChipId (), HEX ) + stamp ;
864+ }
865+
866+
867+ // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
868+ // GET/POST-Request
869+
849870#define SAVEDATALINK "/saveData.php"
850871#define SAVELOGSLINK "/saveLogs.php"
851872#define SENDTSLINK "/update.json"
@@ -922,7 +943,6 @@ String createParameter(int para) {
922943 return command ;
923944}
924945
925-
926946String createCommand (bool meth , int para , const char * link , const char * host , int content ) {
927947
928948 String command ;
@@ -998,20 +1018,6 @@ void serverAnswer(String payload, size_t len) {
9981018 }
9991019}
10001020
1001- String newToken () {
1002- String stamp = String (now (), HEX );
1003- int x = 10 - stamp .length (); //pow(16,(10 - timestamp.length()));
1004- long y = 1 ; // long geht bis 16^7
1005- if (x > 7 ) {
1006- stamp += String (random (268435456 ), HEX );
1007- x -= 7 ;
1008- }
1009- for (int i = 0 ;i < x ;i ++ ) y *= 16 ;
1010- stamp += String (random (y ), HEX );
1011- Serial .println (y );
1012- return (String ) String (ESP .getChipId (), HEX ) + stamp ;
1013- }
1014-
10151021void printRequest (uint8_t * datas ) {
10161022 DPRINTF ("[REQUEST]\t%s\r\n" , (const char * )datas );
10171023}
0 commit comments