change code out side of the loop
This commit is contained in:
parent
59ae938f20
commit
954436d654
@ -47,7 +47,7 @@ use JSON;
|
|||||||
use Blocking;
|
use Blocking;
|
||||||
|
|
||||||
|
|
||||||
my $version = "2.0.8pri1";
|
my $version = "2.0.8pri2";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -475,19 +475,17 @@ sub XiaomiBTLESens_ExecGatttool_Run($) {
|
|||||||
|
|
||||||
$loop = 0;
|
$loop = 0;
|
||||||
do {
|
do {
|
||||||
|
|
||||||
|
Log3 $name, 5, "XiaomiBTLESens ($name) - ExecGatttool_Run: call gatttool with command: $cmd and loop $loop";
|
||||||
|
|
||||||
Log3 $name, 5, "XiaomiBTLESens ($name) - ExecGatttool_Run: call gatttool with command - $cmd and loop - $loop";
|
@gtResult = split(": ",qx($cmd));
|
||||||
@gtResult = split(": ",qx($cmd)); # unless( AttrVal($name,"model","none") eq 'thermoHygroSens' and $gattCmd eq 'write' and $handle eq '0x10');
|
|
||||||
#@gtResult = split(",",qx($cmd)) if( AttrVal($name,"model","none") eq 'thermoHygroSens' and $gattCmd eq 'write' and $handle eq '0x10');
|
|
||||||
Log3 $name, 5, "XiaomiBTLESens ($name) - ExecGatttool_Run: gatttool loop result ".join(",", @gtResult);
|
Log3 $name, 5, "XiaomiBTLESens ($name) - ExecGatttool_Run: gatttool loop result ".join(",", @gtResult);
|
||||||
$loop++;
|
$loop++;
|
||||||
|
|
||||||
($gtResult[1]) = split("\n",$gtResult[1]) if( AttrVal($name,"model","none") eq 'thermoHygroSens' and $gattCmd eq 'write' and $handle eq '0x10');
|
|
||||||
$gtResult[1] =~ s/\\n//g if( AttrVal($name,"model","none") eq 'thermoHygroSens' and $gattCmd eq 'write' and $handle eq '0x10');
|
|
||||||
|
|
||||||
$gtResult[0] = 'connect error'
|
$gtResult[0] = 'connect error'
|
||||||
unless( defined($gtResult[0]) );
|
unless( defined($gtResult[0]) );
|
||||||
|
|
||||||
} while( $loop < 5 and $gtResult[0] eq 'connect error' );
|
} while( $loop < 5 and $gtResult[0] eq 'connect error' );
|
||||||
|
|
||||||
Log3 $name, 4, "XiaomiBTLESens ($name) - ExecGatttool_Run: gatttool result ".join(",", @gtResult);
|
Log3 $name, 4, "XiaomiBTLESens ($name) - ExecGatttool_Run: gatttool result ".join(",", @gtResult);
|
||||||
@ -497,7 +495,12 @@ sub XiaomiBTLESens_ExecGatttool_Run($) {
|
|||||||
|
|
||||||
$gtResult[1] = 'no data response'
|
$gtResult[1] = 'no data response'
|
||||||
unless( defined($gtResult[1]) );
|
unless( defined($gtResult[1]) );
|
||||||
|
|
||||||
|
if( $gtResult[1] ne 'no data response' and $listen ) {
|
||||||
|
($gtResult[1]) = split("\n",$gtResult[1]);
|
||||||
|
$gtResult[1] =~ s/\\n//g;
|
||||||
|
}
|
||||||
|
|
||||||
$json_notification = XiaomiBTLESens_encodeJSON($gtResult[1]);
|
$json_notification = XiaomiBTLESens_encodeJSON($gtResult[1]);
|
||||||
|
|
||||||
if($gtResult[1] =~ /^([0-9a-f]{2}(\s?))*$/) {
|
if($gtResult[1] =~ /^([0-9a-f]{2}(\s?))*$/) {
|
||||||
@ -712,9 +715,9 @@ sub XiaomiBTLESens_ThermoHygroSensHandle0x10($$) {
|
|||||||
$readings{'temperature'} = pack('H*',substr($notification,4,8));
|
$readings{'temperature'} = pack('H*',substr($notification,4,8));
|
||||||
|
|
||||||
if( scalar(@numberOfHex) < 14 ) {
|
if( scalar(@numberOfHex) < 14 ) {
|
||||||
$readings{'humidity'} = pack('H*',substr($notification,18,8));
|
|
||||||
} else {
|
|
||||||
$readings{'humidity'} = pack('H*',substr($notification,16,8));
|
$readings{'humidity'} = pack('H*',substr($notification,16,8));
|
||||||
|
} else {
|
||||||
|
$readings{'humidity'} = pack('H*',substr($notification,18,8));
|
||||||
}
|
}
|
||||||
|
|
||||||
$hash->{helper}{CallBattery} = 0;
|
$hash->{helper}{CallBattery} = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user