X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=zc-send;h=93dfe8190d4eebad0dd417ce4da0ed91b159ce95;hb=675400b462e3b3b1323fbf54d092dd47e171e326;hp=a048c7f7846a5ce202a650967f67c70a418b79b7;hpb=bd52d1bce868bf910ad8b47b01673bd14e61b109;p=zc diff --git a/zc-send b/zc-send index a048c7f..93dfe81 100755 --- a/zc-send +++ b/zc-send @@ -13,27 +13,55 @@ my $queue = "queue"; my $path = shift @ARGV; die "Usage: $0 queue/IMEI\n" unless $path; +# strip slash to recognize by-name/name/ as symlink +if ( -d $path && $path =~ m{/$} ) { + my $tmp = $path; + $tmp =~ s{/$}{}; + if ( -l $tmp ) { + $path = $tmp; + } +} + +if ( -l $path ) { + $path = readlink $path; + warn "# using $path\n"; +} my $imei; -if ( $path =~ m{$queue/(\w+)/} ) { +if ( $path =~ m{$queue/(\d+)} ) { $imei = $1; + if ( ! -e "$queue/$imei") { + die "can't find $queue/$imei\n"; + } } else { die "can't find IMEI in $path\n"; } my $raw; -if ( $ARGV[0] eq m/interval/ ) { +if ( $ARGV[0] =~ m/interval/ ) { # heartbeat interval - $raw = write_parameter_frame( "\x21" => "\x04" . pack('l',60) ); + my $interval = $ARGV[1] || 300; + print "set heartbeat interval to $interval s\n"; + $raw = write_parameter_frame( "\x21" => "\x04" . pack('l',$interval) ); +} elsif ( $ARGV[0] =~ m/zero/ ) { + my $rel_zero = $ARGV[1] // 0; + print "Set relative zero $rel_zero\n"; + $raw = write_parameter_frame( "\x3a" => "\x01" . pack('C',$rel_zero) ); + +} elsif ( $ARGV[0] =~ m/arming/ ) { + my $rel_zero = $ARGV[1] // 1; + print "Set alarm arming $rel_zero\n"; + $raw = write_parameter_frame( "\x3a" => "\x11" . pack('C',$rel_zero) ); -} else { +} else { + print "read_parameter_frame\n"; $raw = read_parameter_frame( "\x00" => "\x04\xe8\x03\x00\x00", - "\x21", - "\x44", - "\x12", + "\x0e\x0f\x11\x12", "\x14", - "\x1a\x21\x22\x23\x24\x33\x34\x35\x3b" ); + "\x1a\x21\x22\x23\x24\x33\x34\x35\x3a\x3b", + "\x44", + ); } # temporary store to done