mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
36_LaCrosseGateway: connect non blocking
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@18150 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
69fc152773
commit
afebfeb52b
@ -70,7 +70,8 @@ sub LaCrosseGateway_Notify($$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#=======================================================================================
|
#=======================================================================================
|
||||||
sub LaCrosseGateway_Define($$) {my ($hash, $def) = @_;
|
sub LaCrosseGateway_Define($$) {
|
||||||
|
my ($hash, $def) = @_;
|
||||||
my @a = split("[ \t][ \t]*", $def);
|
my @a = split("[ \t][ \t]*", $def);
|
||||||
|
|
||||||
if(@a != 3) {
|
if(@a != 3) {
|
||||||
@ -86,7 +87,8 @@ sub LaCrosseGateway_Define($$) {my ($hash, $def) = @_;
|
|||||||
|
|
||||||
$hash->{Clients} = $clients;
|
$hash->{Clients} = $clients;
|
||||||
$hash->{MatchList} = \%matchList;
|
$hash->{MatchList} = \%matchList;
|
||||||
$hash->{TIMEOUT} = 0.5;
|
$hash->{TIMEOUT} = 1.0;
|
||||||
|
$hash->{devioLoglevel} = 4;
|
||||||
|
|
||||||
if( !defined( $attr{$name}{usbFlashCommand} ) ) {
|
if( !defined( $attr{$name}{usbFlashCommand} ) ) {
|
||||||
$attr{$name}{usbFlashCommand} = "./FHEM/firmware/esptool.py -b 921600 -p [PORT] write_flash -ff 80m -fm dio -fs 4MB-c1 0x00000 [BINFILE] > [LOGFILE] 2>&1"
|
$attr{$name}{usbFlashCommand} = "./FHEM/firmware/esptool.py -b 921600 -p [PORT] write_flash -ff 80m -fm dio -fs 4MB-c1 0x00000 [BINFILE] > [LOGFILE] 2>&1"
|
||||||
@ -433,15 +435,7 @@ sub LaCrosseGateway_Ready($) {
|
|||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
LaCrosseGateway_Connect($hash, 1);
|
return LaCrosseGateway_Connect($hash, 1);
|
||||||
|
|
||||||
# This is relevant for windows/USB only
|
|
||||||
my $po = $hash->{USBDev};
|
|
||||||
my ($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags);
|
|
||||||
if($po) {
|
|
||||||
($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags) = $po->status;
|
|
||||||
}
|
|
||||||
return ($InBytes && $InBytes>0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#=======================================================================================
|
#=======================================================================================
|
||||||
@ -740,13 +734,18 @@ sub LaCrosseGateway_Connect($;$) {
|
|||||||
my ($hash, $mode) = @_;
|
my ($hash, $mode) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
DevIo_CloseDev($hash);
|
if(DevIo_IsOpen($hash)) {
|
||||||
|
DevIo_CloseDev($hash);
|
||||||
|
}
|
||||||
|
|
||||||
$mode = 0 if!($mode);
|
$mode = 0 if!($mode);
|
||||||
my $enabled = AttrVal($name, "disable", "0") != "1" && !defined($hash->{helper}{FLASHING});
|
my $enabled = AttrVal($name, "disable", "0") != "1" && !defined($hash->{helper}{FLASHING});
|
||||||
if($enabled) {
|
if($enabled) {
|
||||||
$hash->{nextOpenDelay} = 2;
|
$hash->{nextOpenDelay} = 2;
|
||||||
my $ret = DevIo_OpenDev($hash, $mode, "LaCrosseGateway_DoInit");
|
my $ret = DevIo_OpenDev($hash, $mode, "LaCrosseGateway_DoInit", sub($$){
|
||||||
|
my ($hash, $error) = @_;
|
||||||
|
####Log 3, "LGW: " . $hash->{NAME} . " " . $error;
|
||||||
|
});
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -781,7 +780,7 @@ sub LaCrosseGateway_OnConnectTimer($) {
|
|||||||
my ($timeout, $interval) = split(',', $attrVal);
|
my ($timeout, $interval) = split(',', $attrVal);
|
||||||
my $useOldMethod = $interval;
|
my $useOldMethod = $interval;
|
||||||
$interval = $timeout if !$interval;
|
$interval = $timeout if !$interval;
|
||||||
|
|
||||||
InternalTimer(gettimeofday() + $interval, "LaCrosseGateway_OnConnectTimer", $hash, 0);
|
InternalTimer(gettimeofday() + $interval, "LaCrosseGateway_OnConnectTimer", $hash, 0);
|
||||||
|
|
||||||
if(AttrVal($name, "disable", "0") != "1" && !defined($hash->{helper}{FLASHING})) {
|
if(AttrVal($name, "disable", "0") != "1" && !defined($hash->{helper}{FLASHING})) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user