2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

74_XiaomiFlowerSens: fix back to blockingDone Routine

git-svn-id: https://svn.fhem.de/fhem/trunk@13283 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2017-01-30 07:29:03 +00:00
parent c896fe3cc8
commit e6bf179cbb
2 changed files with 55 additions and 43 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # Do not insert empty lines here, update check depends on it.
- bugfix: 74_XiaomiFlowerSens: 0.6.3 fix blockingDone Routine
- feature: 75_MSG: support for ReplaceSetMagic; msg command may now be used - feature: 75_MSG: support for ReplaceSetMagic; msg command may now be used
with texts containing [device:reading] to replace with with texts containing [device:reading] to replace with
found readings found readings

View File

@ -35,7 +35,7 @@ use POSIX;
use JSON; use JSON;
use Blocking; use Blocking;
my $version = "0.6.0"; my $version = "0.6.3";
@ -125,6 +125,7 @@ sub XiaomiFlowerSens_Undef($$) {
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
BlockingKill($hash->{helper}{RUNNING_PID}) if(defined($hash->{helper}{RUNNING_PID}));
delete($modules{XiaomiFlowerSens}{defptr}{$mac}); delete($modules{XiaomiFlowerSens}{defptr}{$mac});
Log3 $name, 3, "Sub XiaomiFlowerSens_Undef ($name) - delete device $name"; Log3 $name, 3, "Sub XiaomiFlowerSens_Undef ($name) - delete device $name";
@ -257,7 +258,6 @@ sub XiaomiFlowerSens_Run($) {
$wfr = 1; $wfr = 1;
} }
BlockingKill($hash->{helper}{RUNNING_PID}) if(defined($hash->{helper}{RUNNING_PID}));
my $response_encode = XiaomiFlowerSens_forRun_encodeJSON($mac,$wfr); my $response_encode = XiaomiFlowerSens_forRun_encodeJSON($mac,$wfr);
@ -287,7 +287,8 @@ sub XiaomiFlowerSens_BlockingRun($) {
Log3 $name, 4, "Sub XiaomiFlowerSens_BlockingRun ($name) - Processing response data: $sensData"; Log3 $name, 4, "Sub XiaomiFlowerSens_BlockingRun ($name) - Processing response data: $sensData";
return "$name|$sensData" # if error in stdout the error will given to $lux variable
return "$name|Unknown Error, look at verbose 5 output" # if error in stdout the error will given to $sensData variable
unless( defined($batFwData) ); unless( defined($batFwData) );
@ -359,8 +360,10 @@ sub XiaomiFlowerSens_callGatttool($@) {
if($wfr == 1) { if($wfr == 1) {
do { do {
$wresp = qx(gatttool -i $hci -b $mac --char-write-req -a 0x33 -n A01F) if($wfr == 1); $wresp = qx(gatttool -i $hci -b $mac --char-write-req -a 0x33 -n A01F 2>&1 /dev/null) if($wfr == 1);
$loop++; $loop++;
Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - call gatttool charWrite loop $loop";
Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - charWrite wresp: $wresp" if(defined($wresp));
} while( ($loop < 10) and (not defined($wresp)) ); } while( ($loop < 10) and (not defined($wresp)) );
} }
@ -369,11 +372,12 @@ sub XiaomiFlowerSens_callGatttool($@) {
do { do {
@readSensData = split(": ",qx(gatttool -i $hci -b $mac --char-read -a 0x35 2>&1 /dev/null)); @readSensData = split(": ",qx(gatttool -i $hci -b $mac --char-read -a 0x35 2>&1 /dev/null));
Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - call gatttool charRead loop $loop";
$loop++; $loop++;
Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - call gatttool charRead loop $loop";
} while( $loop < 10 and $readSensData[0] =~ /connect error/ ); } while( $loop < 10 and $readSensData[0] =~ /connect error/ );
Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - processing gatttool response. sensData[0]: $readSensData[0]";
Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - processing gatttool response. sensData: $readSensData[1]"; Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - processing gatttool response. sensData: $readSensData[1]";
return ($readSensData[1],undef) return ($readSensData[1],undef)
@ -455,6 +459,13 @@ sub XiaomiFlowerSens_BlockingDone($) {
readingsEndUpdate($hash,1); readingsEndUpdate($hash,1);
return undef; return undef;
} elsif( $response eq "Unknown Error, look at verbose 5 output" ) {
readingsBulkUpdate($hash,"lastGattError","$response");
readingsBulkUpdate($hash,"state","unreachable");
readingsEndUpdate($hash,1);
return undef;
} elsif( ref($response) eq "HASH" ) { } elsif( ref($response) eq "HASH" ) {
readingsBulkUpdate($hash,"lastGattError","$response"); readingsBulkUpdate($hash,"lastGattError","$response");
readingsBulkUpdate($hash,"state","unreachable"); readingsBulkUpdate($hash,"state","unreachable");