automatic ntp update
This commit is contained in:
parent
893a7e9203
commit
95d968a920
|
@ -12,7 +12,7 @@
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = wt32-eth01
|
board = wt32-eth01
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = siwats/ESPMegaPROR3@^1.2.1
|
lib_deps = siwats/ESPMegaPROR3@^1.2.2
|
||||||
knolleary/PubSubClient@^2.8
|
knolleary/PubSubClient@^2.8
|
||||||
ivanseidel/ArduinoThread@^2.1.1
|
ivanseidel/ArduinoThread@^2.1.1
|
||||||
arduino-libraries/Arduino_BuiltIn@^1.0.0
|
arduino-libraries/Arduino_BuiltIn@^1.0.0
|
||||||
|
|
21
src/main.cpp
21
src/main.cpp
|
@ -8,7 +8,8 @@
|
||||||
#include <IRremote.hpp>
|
#include <IRremote.hpp>
|
||||||
#include <daikin_ir.hpp>
|
#include <daikin_ir.hpp>
|
||||||
#include <dhtnew.h>
|
#include <dhtnew.h>
|
||||||
#include "EasyNextionLibrary.h"
|
#include <time.h>
|
||||||
|
#include <EasyNextionLibrary.h>
|
||||||
#include <lcd.hpp>
|
#include <lcd.hpp>
|
||||||
|
|
||||||
// Network Connectivity
|
// Network Connectivity
|
||||||
|
@ -29,6 +30,7 @@ char STATE_REQUEST_TOPIC[40];
|
||||||
const char MQTT_USERNAME[] = "username";
|
const char MQTT_USERNAME[] = "username";
|
||||||
const char MQTT_PASSWORD[] = "password";
|
const char MQTT_PASSWORD[] = "password";
|
||||||
#endif
|
#endif
|
||||||
|
uint8_t utc_offset = 7;
|
||||||
|
|
||||||
// Inputs
|
// Inputs
|
||||||
#define VINT_COUNT 16
|
#define VINT_COUNT 16
|
||||||
|
@ -206,7 +208,6 @@ void setup()
|
||||||
IrSender.begin(IR_SEND_PIN);
|
IrSender.begin(IR_SEND_PIN);
|
||||||
lcd_send_command("boot_state.txt=\"Network Initializing . . .\"");
|
lcd_send_command("boot_state.txt=\"Network Initializing . . .\"");
|
||||||
network_begin();
|
network_begin();
|
||||||
Serial.println("Initializing MQTT . . .");
|
|
||||||
lcd_send_command("boot_state.txt=\"IoT Core Initializing . . .\"");
|
lcd_send_command("boot_state.txt=\"IoT Core Initializing . . .\"");
|
||||||
mqtt_connect();
|
mqtt_connect();
|
||||||
lcd_send_command("boot_state.txt=\"Threads Initializing . . .\"");
|
lcd_send_command("boot_state.txt=\"Threads Initializing . . .\"");
|
||||||
|
@ -323,14 +324,20 @@ void network_begin()
|
||||||
ETH.setHostname(HOSTNAME);
|
ETH.setHostname(HOSTNAME);
|
||||||
ETH.config(IP, GATEWAY, SUBNET, DNS, DNS);
|
ETH.config(IP, GATEWAY, SUBNET, DNS, DNS);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
lcd_send_command("boot_state.txt=\"Ethernet Core Initializing \"");
|
||||||
|
delay(500);
|
||||||
|
lcd_send_command("boot_state.txt=\"Ethernet Core Initializing . \"");
|
||||||
|
delay(500);
|
||||||
|
lcd_send_command("boot_state.txt=\"Ethernet Core Initializing . . \"");
|
||||||
|
delay(500);
|
||||||
lcd_send_command("boot_state.txt=\"Ethernet Core Initializing . . .\"");
|
lcd_send_command("boot_state.txt=\"Ethernet Core Initializing . . .\"");
|
||||||
delay(500);
|
delay(500);
|
||||||
lcd_send_command("boot_state.txt=\"MQTT Core Initializing . . .\"");
|
lcd_send_command("boot_state.txt=\"NTP Core Initializing . . .\"");
|
||||||
delay(1250);
|
|
||||||
lcd_send_command("boot_state.txt=\"FRAM Initializing . . .\"");
|
|
||||||
delay(325);
|
|
||||||
lcd_send_command("boot_state.txt=\"Software Initializing . . .\"");
|
|
||||||
delay(500);
|
delay(500);
|
||||||
|
char ntp[19];
|
||||||
|
MQTT_SERVER.toString().toCharArray(ntp,19);
|
||||||
|
ESPMega_configNTP(utc_offset*3600,0,ntp);
|
||||||
|
ESPMega_updateTimeFromNTP();
|
||||||
Serial.println();
|
Serial.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,23 @@
|
||||||
|
#ifndef USER_CODE
|
||||||
|
#define USER_CODE
|
||||||
|
#include <ESPMegaPRO.h>
|
||||||
|
void user_pre_init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void user_init() {
|
void user_init() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void user_loop() {
|
void user_loop() {
|
||||||
|
|
||||||
}
|
}
|
||||||
void virtual_interrupt_user_callback(int pin, int state) {
|
void virtual_interrupt_user_callback(int pin, int state) {
|
||||||
//Automation: Light Switch
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void timer_tick_callback() {
|
void timer_tick_callback() {
|
||||||
//Automation: Night Light
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue