use HTML::Entities;
use MIME::Base64;
...
my %data;
my %deviceconf;
...
if (substr($v,0,2) eq "L:")
{
$data{"meta"}{"DevCount"}=5;
substr($v,0,2,'');
my $str = decode_base64($v);
my $pos = 0;
for my $j (1..$data{"meta"}{"DevCount"})
{
my %hilf;
# versteh ich nicht. Hier sind nur Zahlen enthalten
# keine Ahnung warum hier htmlentities drüber läuft
$hilf{"ReadLength"} = htmlentities(ord(substr($str,$pos,1)));
$pos += 1;
for my $i ($pos..(2+$pos))
{
$hilf{"RFAdress"} .= dechex2( substr( $str,$i,1 ) );
$pos += 5;
$hilf{"Data2"} .= decbin8( substr( $str,$pos,1 ) )."";
$deviceconf{$hilf{"RFAdress"}}{"LowBatt"} = substr($hilf{"Data2"},0,1);
$pos += 1;
if($hilf{"ReadLength"} == 11)
{
$pos += 1;
$deviceconf{$hilf{"RFAdress"}}{"Temperature"} = (ord(substr($str,$pos,1))/2)."";
$pos += 4;
}
my $val=substr($hilf{"Data2"},6,2)
if($val eq "00")
{
$deviceconf{$hilf{"RFAdress"}}{"Mode"} = "auto";
}
elsif($val eq "01")
{
$deviceconf{$hilf{"RFAdress"}}{"Mode"} = "manu";
}
elsif($val eq "10")
{
$deviceconf{$hilf{"RFAdress"}}{"Mode"} = "vacation";
}
elsif($val eq "11")
{
$deviceconf{$hilf{"RFAdress"}}{"Mode"} = "boost";
}
}
}
}
...
sub htmlentities
{
my $str=shift;
return encode_entities($str);
}
# kombination aus str_pad, decbin und ord
sub decbin8
{
my $str=shift;
return unpack('B8',$str);
}
# kombination aus str_pad, dechex und ord
sub dechex2
{
my $str=shift;
return unpack('H2',$str);
}