diff --git a/CHANGED b/CHANGED index 9ba4d2d75..78e501a17 100644 --- a/CHANGED +++ b/CHANGED @@ -1,5 +1,7 @@ # 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. + - bugfix: pilight_ctrl: reset - clear send queue + - feature: pilight_ctrl: add attribute SendTimeout for aborting sending commands - feature: FB_CALLMONITOR: add TR-064 support for remote phonebook reading via official AVM API (by JoWiemann) - feature: 10_pilight_ctrl.pm: added disconnect diff --git a/FHEM/10_pilight_ctrl.pm b/FHEM/10_pilight_ctrl.pm index 6620f642d..699ef9581 100644 --- a/FHEM/10_pilight_ctrl.pm +++ b/FHEM/10_pilight_ctrl.pm @@ -1,5 +1,5 @@ ############################################## -# $Id: 10_pilight_ctrl.pm 1.07 2015-06-23 Risiko $ +# $Id: 10_pilight_ctrl.pm 1.08 2015-06-23 Risiko $ # # Usage # @@ -31,6 +31,8 @@ # V 1.05 2015-06-07 - FIX: Reset # V 1.06 2015-06-20 - NEW: set disconnect, checking reading state # V 1.07 2015-06-23 - FIX: reading state always contains a valid value, checking reading state removed +# V 1.08 2015-06-23 - FIX: clear send queue by reset +# V 1.08 2015-06-23 - NEW: attribute SendTimeout for abort sending command non blocking ############################################## package main; @@ -76,7 +78,7 @@ sub pilight_ctrl_Initialize($) $hash->{SetFn} = "pilight_ctrl_Set"; $hash->{NotifyFn}= "pilight_ctrl_Notify"; $hash->{StateFn} = "pilight_ctrl_State"; - $hash->{AttrList}= "ignoreProtocol brands ContactAsSwitch ".$readingFnAttributes; + $hash->{AttrList}= "ignoreProtocol brands ContactAsSwitch SendTimeout ".$readingFnAttributes; $hash->{Clients} = ":pilight_switch:pilight_dimmer:pilight_temp:"; #$hash->{MatchList} = \%matchList; #only for autocreate @@ -176,6 +178,8 @@ sub pilight_ctrl_Close($) BlockingKill($hash->{helper}{RUNNING_PID}); delete($hash->{helper}{RUNNING_PID}); } + + splice($hash->{helper}->{sendQueue}); RemoveInternalTimer($hash); Log3 $me, 5, "$me(Close): close DevIo"; @@ -448,7 +452,7 @@ sub pilight_ctrl_Send($) PeerHost => $remote_ip, PeerPort => $remote_port, Proto => 'tcp', - ); + ); if (!$socket) { Log3 $me, 2, "$me(Send): ERROR. Can't open socket to pilight-daemon $remote_ip:$remote_port"; @@ -616,7 +620,7 @@ sub pilight_ctrl_SendNonBlocking($) my $blockingFn = "pilight_ctrl_Send"; my $arg = $me."|".$hash->{DeviceName}."|".$data; my $finishFn = "pilight_ctrl_SendDone"; - my $timeout = 4; + my $timeout = AttrVal($me, "SendTimeout",1); my $abortFn = "pilight_ctrl_SendAbort"; $hash->{helper}{RUNNING_PID} = BlockingCall($blockingFn, $arg, $finishFn, $timeout, $abortFn, $hash); @@ -625,6 +629,7 @@ sub pilight_ctrl_SendNonBlocking($) Log3 $me, 5, "$me(Write): Blocking Call running - will try it later"; } + $queueSize = @{$hash->{helper}->{sendQueue}}; InternalTimer(gettimeofday()+0.5,"pilight_ctrl_SendNonBlocking", $hash, 0) if ($queueSize > 0); } @@ -947,6 +952,9 @@ sub pilight_ctrl_SimpleWrite(@) In this case opened will be interpreted as on and closed as off.
Example: ContactAsSwitch 12345 +
  • SendTimeout
    + Timeout [s] for aborting sending commands (non blocking) - default 1s +