Skip to content

Commit 11920d7

Browse files
committed
blink on mqtt rx
1 parent 2f26c05 commit 11920d7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/ratgdo.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ void wallPanelEmulatorLoop(){
187187
}
188188

189189
void gdoStateLoop(){
190+
blink(false);
190191
if(!swSerial.available()) return;
191192
uint8_t serData = swSerial.read();
192193

@@ -531,7 +532,7 @@ void manageHardwareButton(){
531532

532533
/********************************** MQTT CALLBACK *****************************************/
533534
void callback(char *topic, byte *payload, unsigned int length){
534-
535+
blink(true);
535536
// Transform all messages in a JSON format
536537
StaticJsonDocument<BUFFER_SIZE> json = bootstrapManager.parseQueueMsg(topic, payload, length);
537538

@@ -631,6 +632,19 @@ void pullLow(){
631632
digitalWrite(OUTPUT_GDO, LOW);
632633
}
633634

635+
void blink(bool trigger){
636+
if(LED_BUILTIN == OUTPUT_GDO) return;
637+
static unsigned int onMillis = 0;
638+
unsigned int currentMillis = millis();
639+
640+
if(trigger){
641+
digitalWrite(LED_BUILTIN,LOW);
642+
onMillis = currentMillis;
643+
}else if(currentMillis - onMillis > 500){
644+
digitalWrite(LED_BUILTIN,HIGH);
645+
}
646+
}
647+
634648
void sync(){
635649
if(controlProtocol != "secplus2"){
636650
Serial.println("sync only needed with security+ 2.0");

src/ratgdo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ void manageDisconnections();
9797
void manageQueueSubscription();
9898
void manageHardwareButton();
9999

100+
void blink(bool trigger);
100101
void transmit(byte* payload, unsigned int length);
101102
void sync();
102103

0 commit comments

Comments
 (0)