line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
2063
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
101
|
|
2
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
159
|
|
3
|
|
|
|
|
|
|
package Device::RFXCOM::Decoder::OregonScale; |
4
|
|
|
|
|
|
|
$Device::RFXCOM::Decoder::OregonScale::VERSION = '1.163170'; |
5
|
|
|
|
|
|
|
# ABSTRACT: Device::RFXCOM::Decoder::OregonScale decode Oregon Scale RF messages |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
51
|
use 5.006; |
|
3
|
|
|
|
|
10
|
|
9
|
3
|
|
|
3
|
|
12
|
use constant DEBUG => $ENV{DEVICE_RFXCOM_DECODER_OREGON_SCALE_DEBUG}; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
173
|
|
10
|
3
|
|
|
3
|
|
12
|
use Carp qw/croak/; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
145
|
|
11
|
3
|
|
|
3
|
|
14
|
use Device::RFXCOM::Decoder qw/hi_nibble lo_nibble/; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
1295
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(Device::RFXCOM::Decoder); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub decode { |
16
|
58
|
|
|
58
|
1
|
109
|
my ($self, $parent, $message, $bytes, $bits, $result) = @_; |
17
|
58
|
100
|
100
|
|
|
289
|
if ($bits == 64 && lo_nibble($bytes->[0]) == 3) { |
18
|
1
|
|
|
|
|
5
|
return parse_gr101($self, $parent, $message, $bytes, $bits, $result); |
19
|
|
|
|
|
|
|
} |
20
|
57
|
100
|
|
|
|
300
|
return unless (scalar @$bytes == 7); |
21
|
4
|
100
|
100
|
|
|
41
|
return unless (($bytes->[0]&0xf0) == ($bytes->[5]&0xf0) && |
22
|
|
|
|
|
|
|
($bytes->[1]&0xf) == ($bytes->[6]&0xf)); |
23
|
2
|
|
|
|
|
16
|
my $weight = |
24
|
|
|
|
|
|
|
sprintf "%x%02x%x", $bytes->[5]&0x1, $bytes->[4], hi_nibble($bytes->[3]); |
25
|
2
|
100
|
|
|
|
23
|
return unless ($weight =~ /^\d+$/); |
26
|
1
|
|
|
|
|
5
|
$weight /= 10; |
27
|
1
|
|
|
|
|
5
|
my $dev_str = sprintf 'bwr102.%02x', hi_nibble($bytes->[1]); |
28
|
1
|
|
|
|
|
6
|
my $unknown = sprintf "%x%x", lo_nibble($bytes->[3]), hi_nibble($bytes->[2]); |
29
|
1
|
|
|
|
|
3
|
push @{$result->{messages}}, |
|
1
|
|
|
|
|
10
|
|
30
|
|
|
|
|
|
|
Device::RFXCOM::Response::Sensor->new(device => $dev_str, |
31
|
|
|
|
|
|
|
measurement => 'weight', |
32
|
|
|
|
|
|
|
value => $weight, |
33
|
|
|
|
|
|
|
unknown => $unknown, |
34
|
|
|
|
|
|
|
); |
35
|
1
|
|
|
|
|
8
|
return 1; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub parse_gr101 { |
40
|
1
|
|
|
1
|
1
|
5
|
my ($self, $parent, $message, $bytes, $bits, $result) = @_; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
6
|
my $weight = |
43
|
|
|
|
|
|
|
(lo_nibble($bytes->[4])<<12) + ($bytes->[3]<<4) + ($bytes->[2]>>4); |
44
|
1
|
|
|
|
|
21
|
$weight = sprintf "%.1f", $weight/400.8; |
45
|
1
|
|
|
|
|
7
|
my $dev_str = sprintf 'gr101.%02x', $bytes->[1]; |
46
|
1
|
|
|
|
|
3
|
push @{$result->{messages}}, |
|
1
|
|
|
|
|
12
|
|
47
|
|
|
|
|
|
|
Device::RFXCOM::Response::Sensor->new(device => $dev_str, |
48
|
|
|
|
|
|
|
measurement => 'weight', |
49
|
|
|
|
|
|
|
value => $weight); |
50
|
1
|
|
|
|
|
7
|
return 1; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |