mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-04 05:16:45 +00:00
CUL_MAX: update TimeInformation payload just before sending
git-svn-id: https://svn.fhem.de/fhem/trunk@2724 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b58456e69f
commit
f1a6ede5a6
@ -13,8 +13,10 @@ sub CUL_MAX_BroadcastTime(@);
|
|||||||
sub CUL_MAX_Set($@);
|
sub CUL_MAX_Set($@);
|
||||||
sub CUL_MAX_SendAck($$$);
|
sub CUL_MAX_SendAck($$$);
|
||||||
sub CUL_MAX_SendTimeInformation(@);
|
sub CUL_MAX_SendTimeInformation(@);
|
||||||
|
sub CUL_MAX_GetTimeInformationPayload();
|
||||||
sub CUL_MAX_Send(@);
|
sub CUL_MAX_Send(@);
|
||||||
sub CUL_MAX_SendQueueHandler($);
|
sub CUL_MAX_SendQueueHandler($);
|
||||||
|
|
||||||
my $pairmodeDuration = 60; #seconds
|
my $pairmodeDuration = 60; #seconds
|
||||||
|
|
||||||
my $timeBroadcastInterval = 6*60*60; #= 6 hours, the same time that the cube uses
|
my $timeBroadcastInterval = 6*60*60; #= 6 hours, the same time that the cube uses
|
||||||
@ -321,6 +323,13 @@ CUL_MAX_SendQueueHandler($)
|
|||||||
$timeout += $waitTime;
|
$timeout += $waitTime;
|
||||||
Log 2, "CUL_MAX_SendQueueHandler: Not enough credit! credit10ms is $credit10ms, but we need $necessaryCredit. Waiting $waitTime seconds.";
|
Log 2, "CUL_MAX_SendQueueHandler: Not enough credit! credit10ms is $credit10ms, but we need $necessaryCredit. Waiting $waitTime seconds.";
|
||||||
} else {
|
} else {
|
||||||
|
#Update TimeInformation payload. It should reflect the current time when sending,
|
||||||
|
#not the time when it was enqueued. A low credit10ms can defer such a packet for multiple
|
||||||
|
#minutes
|
||||||
|
if( $msgId2Cmd{substr($packet->{packet},6,2)} eq "TimeInformation" ) {
|
||||||
|
Log GetLogLevel($hash->{NAME}, 5), "Updating TimeInformation payload";
|
||||||
|
substr($packet->{packet},22) = CUL_MAX_GetTimeInformationPayload();
|
||||||
|
}
|
||||||
IOWrite($hash, "", "Zs". $packet->{packet});
|
IOWrite($hash, "", "Zs". $packet->{packet});
|
||||||
$packet->{sent} = 1;
|
$packet->{sent} = 1;
|
||||||
$packet->{sentTime} = gettimeofday();
|
$packet->{sentTime} = gettimeofday();
|
||||||
@ -330,7 +339,7 @@ CUL_MAX_SendQueueHandler($)
|
|||||||
} elsif( $packet->{sent} == 1 ) { #Already sent it, got no Ack
|
} elsif( $packet->{sent} == 1 ) { #Already sent it, got no Ack
|
||||||
if( $packet->{sentTime} + $ackTimeout < gettimeofday() ) {
|
if( $packet->{sentTime} + $ackTimeout < gettimeofday() ) {
|
||||||
# ackTimeout exceeded
|
# ackTimeout exceeded
|
||||||
Log 2, "CUL_MAX_Resend: Missing ack from $packet->{dest} for $packet->{packet}";
|
Log 2, "CUL_MAX_SendQueueHandler: Missing ack from $packet->{dest} for $packet->{packet}";
|
||||||
splice @{$hash->{sendQueue}}, 0, 1; #Remove from array
|
splice @{$hash->{sendQueue}}, 0, 1; #Remove from array
|
||||||
readingsSingleUpdate($hash, "packetsLost", ReadingsVal($hash->{NAME}, "packetsLost", 0) + 1, 1);
|
readingsSingleUpdate($hash, "packetsLost", ReadingsVal($hash->{NAME}, "packetsLost", 0) + 1, 1);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user