mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-01 20:20:10 +00:00
MAX: automatically use fast send after wakeup
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@2739 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
dd3fcb667d
commit
3a4d608b92
@ -224,6 +224,15 @@ MAX_ParseWeekProfile(@) {
|
||||
readingsEndUpdate($hash, 1) if($beginUpdate);
|
||||
}
|
||||
#############################
|
||||
|
||||
sub
|
||||
MAX_WakeUp($)
|
||||
{
|
||||
my $hash = @_[0];
|
||||
#3F corresponds to 31 seconds wakeup (so its probably the lower 5 bits)
|
||||
return ($hash->{IODev}{Send})->($hash->{IODev},"WakeUp",$hash->{addr}, "3F", callbackParam => "31" );
|
||||
}
|
||||
|
||||
sub
|
||||
MAX_Set($@)
|
||||
{
|
||||
@ -413,11 +422,14 @@ MAX_Set($@)
|
||||
}
|
||||
|
||||
} elsif($setting eq "wakeUp") {
|
||||
return ($hash->{IODev}{Send})->($hash->{IODev},"WakeUp",$hash->{addr}, 0x3F);
|
||||
return MAX_WakeUp($hash);
|
||||
|
||||
} elsif($setting eq "weekProfile" and $hash->{type} =~ /.*Thermostat.*/) {
|
||||
return "Number of arguments must be even" if(@args%2 == 1);
|
||||
|
||||
#Send wakeUp, so we can send the weekprofile pakets without preamble
|
||||
MAX_WakeUp($hash) if( @args > 2 );
|
||||
|
||||
for(my $i = 0; $i < @args; $i += 2) {
|
||||
return "Expected day, got $args[$i]" if(!exists($decalcDaysInv{$args[$i]}));
|
||||
my $day = $decalcDaysInv{$args[$i]};
|
||||
@ -695,6 +707,11 @@ MAX_Parse($$)
|
||||
$shash->{ERROR} = join(",",$args[0]);
|
||||
}
|
||||
|
||||
} elsif($msgtype eq "AckWakeUp") {
|
||||
my ($duration) = @args;
|
||||
#substract five seconds safety margin
|
||||
$shash->{wakeUpUntil} = gettimeofday() + $duration - 5;
|
||||
|
||||
} elsif($msgtype eq "AckConfigWeekProfile") {
|
||||
my ($day, $part, $profile) = @args;
|
||||
|
||||
|
@ -315,7 +315,6 @@ CUL_MAX_Send(@)
|
||||
{
|
||||
# $cmd is one of
|
||||
my ($hash, $cmd, $dst, $payload, %opts) = @_;
|
||||
CUL_MAX_Check($hash);
|
||||
|
||||
my $flags = "00";
|
||||
my $groupId = "00";
|
||||
@ -378,11 +377,17 @@ CUL_MAX_SendQueueHandler($)
|
||||
my $packet = $hash->{sendQueue}[0];
|
||||
|
||||
if( $packet->{sent} == 0 ) { #Need to send it first
|
||||
#We can use fast sending without preamble on culfw 1.53 and higher when the devices has been woken up
|
||||
my $needPreamble = ((CUL_MAX_Check($hash) < 153)
|
||||
|| !defined($modules{MAX}{defptr}{$packet->{dst}}{wakeUpUntil})
|
||||
|| $modules{MAX}{defptr}{$packet->{dst}}{wakeUpUntil} < gettimeofday()) ? 1 : 0;
|
||||
|
||||
#Send to CUL
|
||||
my ($credit10ms) = (CommandGet("","$hash->{IODev}{NAME} credit10ms") =~ /[^ ]* [^ ]* => (.*)/);
|
||||
# We need 1000ms for preamble + len in bits (=hex len * 4) ms for payload. Divide by 10 to get credit10ms units
|
||||
# keep this in sync with culfw's code in clib/rf_moritz.c!
|
||||
my $necessaryCredit = ceil(100 + (length($packet->{packet})*4)/10);
|
||||
my $necessaryCredit = ceil(100*$needPreamble + (length($packet->{packet})*4)/10);
|
||||
Log 5, "needPreamble: $needPreamble, necessaryCredit: $necessaryCredit, credit10ms: $credit10ms";
|
||||
if( defined($credit10ms) && $credit10ms < $necessaryCredit ) {
|
||||
my $waitTime = $necessaryCredit-$credit10ms; #we get one credit10ms every second
|
||||
$timeout += $waitTime;
|
||||
@ -395,7 +400,8 @@ CUL_MAX_SendQueueHandler($)
|
||||
Log GetLogLevel($hash->{NAME}, 5), "Updating TimeInformation payload";
|
||||
substr($packet->{packet},22) = CUL_MAX_GetTimeInformationPayload();
|
||||
}
|
||||
IOWrite($hash, "", "Zs". $packet->{packet});
|
||||
IOWrite($hash, "", ($needPreamble ? "Zs" : "Zf") . $packet->{packet});
|
||||
|
||||
$packet->{sent} = 1;
|
||||
$packet->{sentTime} = gettimeofday();
|
||||
$timeout += 0.5; #recheck for Ack
|
||||
|
Loading…
x
Reference in New Issue
Block a user