|
@ -217,16 +217,20 @@ void setup() { |
|
|
rotary.registerCallback(rotation); |
|
|
rotary.registerCallback(rotation); |
|
|
rotary.begin(rotaryPinA, rotaryPinB, rotaryPinButton); |
|
|
rotary.begin(rotaryPinA, rotaryPinB, rotaryPinButton); |
|
|
|
|
|
|
|
|
|
|
|
/* udp.beginMulticast(udpMulticastAddress, udpMulticastPort);*/ |
|
|
|
|
|
|
|
|
lastActive = millis(); |
|
|
lastActive = millis(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void onWiFiConnect() { |
|
|
//This function is called when the MQTT-Server is connected
|
|
|
if (!alarmclock.isTimeValid()) { |
|
|
void onMqttConnect(bool sessionPresent) { |
|
|
ESP_LOGI(TAG, "Time is not set yet. Connecting to WiFi and getting time over NTP."); |
|
|
DEBUG_PRINTLN(__func__); |
|
|
alarmclock.updateNTPTime(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Subscribe to the delay topic
|
|
|
|
|
|
iot.mqtt.subscribe(commandTopic.c_str(), 0); |
|
|
|
|
|
//Trigger the transmission of the current state.
|
|
|
|
|
|
transmitStatus(); |
|
|
esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause(); |
|
|
esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause(); |
|
|
if (wakeup_reason == ESP_SLEEP_WAKEUP_EXT1) { |
|
|
if (wakeup_reason == ESP_SLEEP_WAKEUP_EXT1) { |
|
|
uint64_t wakeup_pinmask = esp_sleep_get_ext1_wakeup_status(); |
|
|
uint64_t wakeup_pinmask = esp_sleep_get_ext1_wakeup_status(); |
|
@ -235,19 +239,6 @@ void onWiFiConnect() { |
|
|
sensorON = true; |
|
|
sensorON = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* udp.beginMulticast(udpMulticastAddress, udpMulticastPort);*/ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//This function is called when the MQTT-Server is connected
|
|
|
|
|
|
void onMqttConnect(bool sessionPresent) { |
|
|
|
|
|
DEBUG_PRINTLN(__func__); |
|
|
|
|
|
|
|
|
|
|
|
//Subscribe to the delay topic
|
|
|
|
|
|
iot.mqtt.subscribe(commandTopic.c_str(), 0); |
|
|
|
|
|
//Trigger the transmission of the current state.
|
|
|
|
|
|
transmitStatus(); |
|
|
|
|
|
lastTransmit = millis(); |
|
|
lastTransmit = millis(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|