From 84997c4dc8ddbdd7e5e51302a91c54c33f25f0b6 Mon Sep 17 00:00:00 2001 From: mgehre <> Date: Wed, 13 Feb 2013 23:35:19 +0000 Subject: [PATCH] CUL_MAX: update TimeInformation payload just before sending git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@2724 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/14_CUL_MAX.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/FHEM/14_CUL_MAX.pm b/FHEM/14_CUL_MAX.pm index 616098c68..e6212735c 100644 --- a/FHEM/14_CUL_MAX.pm +++ b/FHEM/14_CUL_MAX.pm @@ -13,8 +13,10 @@ sub CUL_MAX_BroadcastTime(@); sub CUL_MAX_Set($@); sub CUL_MAX_SendAck($$$); sub CUL_MAX_SendTimeInformation(@); +sub CUL_MAX_GetTimeInformationPayload(); sub CUL_MAX_Send(@); sub CUL_MAX_SendQueueHandler($); + my $pairmodeDuration = 60; #seconds my $timeBroadcastInterval = 6*60*60; #= 6 hours, the same time that the cube uses @@ -321,6 +323,13 @@ CUL_MAX_SendQueueHandler($) $timeout += $waitTime; Log 2, "CUL_MAX_SendQueueHandler: Not enough credit! credit10ms is $credit10ms, but we need $necessaryCredit. Waiting $waitTime seconds."; } 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}); $packet->{sent} = 1; $packet->{sentTime} = gettimeofday(); @@ -330,7 +339,7 @@ CUL_MAX_SendQueueHandler($) } elsif( $packet->{sent} == 1 ) { #Already sent it, got no Ack if( $packet->{sentTime} + $ackTimeout < gettimeofday() ) { # 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 readingsSingleUpdate($hash, "packetsLost", ReadingsVal($hash->{NAME}, "packetsLost", 0) + 1, 1); } else {