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
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 );