request setting on heartbeat
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 18 Sep 2020 14:06:16 +0000 (16:06 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 18 Sep 2020 14:06:16 +0000 (16:06 +0200)
zc-mqtt

diff --git a/zc-mqtt b/zc-mqtt
index 6aeafb7..f954956 100755 (executable)
--- a/zc-mqtt
+++ b/zc-mqtt
@@ -73,6 +73,19 @@ while (1) {
       } else {
         print $msg->string, "\n";
       }
+
+#      if ( $msg->topic =~ m{Inclinometer/ZCT330Ex_SWP_N_YK/869858031634109/up} ) {
+      if ( substr($msg->message,2,1) eq "\x07" ) { # heartbeat
+       my $raw = "\x5a\x0b\x03\x09\x00\x00\x04\xe8\x03\x00\x00\x21\x44\xaa\x4B\xF3";
+       my $topic = $msg->topic;
+       $topic =~ s/up$/down/;
+       send_message($socket,
+               message_type => MQTT_PUBLISH,
+               retain => 0, #$retain,
+               topic => $topic,
+               message => $raw);
+      }
+
       if (defined $count && --$count == 0) {
         exit;
       }