update bakaceva 3 to use views for graph
[zc] / zc-mqtt
diff --git a/zc-mqtt b/zc-mqtt
index 690010e..e1593be 100755 (executable)
--- a/zc-mqtt
+++ b/zc-mqtt
@@ -117,6 +117,9 @@ while (1) {
         print $msg->string, "\n";
       }
 
+      # skip retained
+      next if $msg->string =~ m{Publish/at-most-once,retain};
+
        my $topic = $msg->topic;
        # Inclinometer/ZCT330Ex_SWP_N_YK/869858031634109/up
        my $dir = $topic; # leave imei in dir
@@ -132,7 +135,7 @@ while (1) {
        mkdir "$queue/$dir/$date" if ! -d "$queue/$dir/$date";
        write_file "$queue/$dir/$date/$time.$t.$up_down.$function_code", $msg->message;
 
-       if ( substr($msg->message,2,1) eq "\x07" ) { # heartbeat
+       if ( $function_code == 7 || $function_code == 8 ) { #  7 = heartbeat, 8 = alarm
                my $hash = protocol_decode( $up_down, $msg->message );
                $sth->execute( map { $hash->{data_id}->{$_} } @insert_data_ids );