mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
50_MOBILEALERTSGW: Checksum check added
git-svn-id: https://svn.fhem.de/fhem/trunk@19278 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
472d3f9c77
commit
269f7fa0e2
@ -1,5 +1,6 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- change: 50_MOBILEALERTSGW: Checksum check added
|
||||
- change: 93_DbRep: check index "Report_Idx" during first DB connect
|
||||
- change: 98_RandomTimer: remove 59_Twilight dependency
|
||||
- feature: 93_DbRep: new set "index" command to manage needed indexe for
|
||||
|
@ -150,7 +150,7 @@ sub MOBILEALERTSGW_Set ($$@) {
|
||||
if ( $cmd eq "clear" ) {
|
||||
if ( $args[0] eq "readings" ) {
|
||||
for ( keys %{ $hash->{READINGS} } ) {
|
||||
readingsDelete($hash, $_) if ( $_ ne 'state' );
|
||||
readingsDelete( $hash, $_ ) if ( $_ ne 'state' );
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
@ -237,6 +237,8 @@ sub MOBILEALERTSGW_Set ($$@) {
|
||||
my $data = pack( "H*", $args[0] );
|
||||
my ( $packageHeader, $timeStamp, $packageLength, $deviceID ) =
|
||||
unpack( "CNCH12", $data );
|
||||
my ( $sum, $sumWert ) = unpack( "%C63C", $data );
|
||||
$sum &= 0x7F;
|
||||
Log3 $name, 4,
|
||||
"$name MOBILEALERTSGW: Debuginsert PackageHeader: "
|
||||
. $packageHeader
|
||||
@ -248,6 +250,19 @@ sub MOBILEALERTSGW_Set ($$@) {
|
||||
. $deviceID;
|
||||
Log3 $name, 5, "$name MOBILEALERTSGW: Debuginsert for $deviceID: "
|
||||
. unpack( "H*", $data );
|
||||
if ( $sum != $sumWert ) {
|
||||
Log3 $MA_wname, 4,
|
||||
"$MA_wname MOBILEALERTSGW: Wrong Checksum expected: 0x"
|
||||
. sprintf( "%02X", $sum )
|
||||
. " got: 0x"
|
||||
. sprintf( "%02X", $sumWert )
|
||||
. "=> ignoring";
|
||||
return undef;
|
||||
}
|
||||
Log3 $MA_wname, 5,
|
||||
"$MA_wname MOBILEALERTSGW: Good Checksum got: 0x"
|
||||
. sprintf( "%02X", $sum );
|
||||
|
||||
Dispatch( $hash, $data, undef );
|
||||
return undef;
|
||||
}
|
||||
@ -558,23 +573,35 @@ sub MOBILEALERTSGW_DecodeData($$) {
|
||||
|
||||
for ( my $pos = 0 ; $pos < length($POSTdata) ; $pos += MA_PACKAGE_LENGTH ) {
|
||||
my $data = substr $POSTdata, $pos, MA_PACKAGE_LENGTH;
|
||||
my ( $packageHeader, $timeStamp, $packageLength, $deviceID ) =
|
||||
unpack( "CNCH12", $data );
|
||||
Log3 $MA_wname, 4,
|
||||
"$MA_wname MOBILEALERTSGW: PackageHeader: "
|
||||
. $packageHeader
|
||||
. " Timestamp: "
|
||||
. scalar( FmtDateTimeRFC1123($timeStamp) )
|
||||
. " PackageLength: "
|
||||
. $packageLength
|
||||
. " DeviceID: "
|
||||
. $deviceID
|
||||
if ( $verbose >= 4 );
|
||||
Log3 $MA_wname, 5,
|
||||
"$MA_wname MOBILEALERTSGW: Data for $deviceID: "
|
||||
. unpack( "H*", $data )
|
||||
if ( $verbose >= 5 );
|
||||
my $found = Dispatch( $defs{$MA_wname}, $data, undef );
|
||||
my ( $sum, $sumWert ) = unpack( "%C63C", $data );
|
||||
$sum &= 0x7F;
|
||||
if ( $sum != $sumWert ) {
|
||||
Log3 $MA_wname, 4,
|
||||
"$MA_wname MOBILEALERTSGW: Wrong Checksum expected: 0x"
|
||||
. sprintf( "%02X", $sum )
|
||||
. " got: 0x"
|
||||
. sprintf( "%02X", $sumWert )
|
||||
. "=> ignoring";
|
||||
}
|
||||
else {
|
||||
my ( $packageHeader, $timeStamp, $packageLength, $deviceID ) =
|
||||
unpack( "CNCH12", $data );
|
||||
Log3 $MA_wname, 4,
|
||||
"$MA_wname MOBILEALERTSGW: PackageHeader: "
|
||||
. $packageHeader
|
||||
. " Timestamp: "
|
||||
. scalar( FmtDateTimeRFC1123($timeStamp) )
|
||||
. " PackageLength: "
|
||||
. $packageLength
|
||||
. " DeviceID: "
|
||||
. $deviceID
|
||||
if ( $verbose >= 4 );
|
||||
Log3 $MA_wname, 5,
|
||||
"$MA_wname MOBILEALERTSGW: Data for $deviceID: "
|
||||
. unpack( "H*", $data )
|
||||
if ( $verbose >= 5 );
|
||||
my $found = Dispatch( $defs{$MA_wname}, $data, undef );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user