2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-13 17:26:34 +00:00

74_XiaomiFlowerSens: 0.6.4 rewrite Errorhandling

git-svn-id: https://svn.fhem.de/fhem/trunk@13342 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2017-02-06 05:14:04 +00:00
parent 93c0125753
commit 6b0dd37f10
2 changed files with 12 additions and 6 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.4 rewrite Errorhandling
- bugfix: 70_BRAVIA: utf-8 character handling - bugfix: 70_BRAVIA: utf-8 character handling
use WOL only if device is absent (exception 2013 model) use WOL only if device is absent (exception 2013 model)
respect channel uri for tv input selection respect channel uri for tv input selection

View File

@ -35,7 +35,7 @@ use POSIX;
use JSON; use JSON;
use Blocking; use Blocking;
my $version = "0.6.3"; my $version = "0.6.4";
@ -340,12 +340,13 @@ sub XiaomiFlowerSens_callGatttool($@) {
my ($name,$mac,$wfr) = @_; my ($name,$mac,$wfr) = @_;
my $hci = ReadingsVal($name,"hciDevice","hci0"); my $hci = ReadingsVal($name,"hciDevice","hci0");
my $loop = 0; my $loop;
my $wresp; my $wresp;
my @readSensData; my @readSensData;
my @readBatFwData; my @readBatFwData;
$loop = 0;
while ( (qx(ps ax | grep -v grep | grep "gatttool -b $mac") and $loop = 0) or (qx(ps ax | grep -v grep | grep "gatttool -b $mac") and $loop < 5) ) { while ( (qx(ps ax | grep -v grep | grep "gatttool -b $mac") and $loop = 0) or (qx(ps ax | grep -v grep | grep "gatttool -b $mac") and $loop < 5) ) {
Log3 $name, 4, "Sub XiaomiFlowerSens ($name) - check gattool is running. loop: $loop"; Log3 $name, 4, "Sub XiaomiFlowerSens ($name) - check gattool is running. loop: $loop";
sleep 0.5; sleep 0.5;
@ -359,7 +360,9 @@ sub XiaomiFlowerSens_callGatttool($@) {
## support for Firmware 2.6.6, man muß erst einen Characterwert schreiben ## support for Firmware 2.6.6, man muß erst einen Characterwert schreiben
if($wfr == 1) { if($wfr == 1) {
$loop = 0;
do { do {
$wresp = qx(gatttool -i $hci -b $mac --char-write-req -a 0x33 -n A01F 2>&1 /dev/null) 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) - call gatttool charWrite loop $loop";
@ -370,12 +373,14 @@ sub XiaomiFlowerSens_callGatttool($@) {
Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - run gatttool"; Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - run gatttool";
$loop = 0;
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));
$loop++; $loop++;
Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - call gatttool charRead 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 not $readSensData[0] =~ /Characteristic value/ );
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[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]";
@ -385,14 +390,14 @@ sub XiaomiFlowerSens_callGatttool($@) {
### Read Firmware and Battery Data ### Read Firmware and Battery Data
$loop = 0;
do { do {
@readBatFwData = split(": ",qx(gatttool -i $hci -b $mac --char-read -a 0x38 2>&1 /dev/null)); @readBatFwData = split(": ",qx(gatttool -i $hci -b $mac --char-read -a 0x38 2>&1 /dev/null));
Log3 $name, 4, "Sub XiaomiFlowerSens ($name) - call gatttool readBatFw loop $loop";
$loop++; $loop++;
Log3 $name, 4, "Sub XiaomiFlowerSens ($name) - call gatttool readBatFw loop $loop";
} while( $loop < 10 and $readBatFwData[0] =~ /connect error/ ); } while( $loop < 10 and not $readSensData[0] =~ /Characteristic value/ );
Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - processing gatttool response. batFwData: $readBatFwData[1]"; Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - processing gatttool response. batFwData: $readBatFwData[1]";