2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

49_IPCAM: imageWithCallback wrapped in internalTimer with 0 delay

git-svn-id: https://svn.fhem.de/fhem/trunk@24213 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
delmar 2021-04-11 08:33:11 +00:00
parent 8dc1b609fd
commit f9d53925c8
2 changed files with 24 additions and 17 deletions

View File

@ -1,5 +1,6 @@
# 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.
- change: 49_IPCAM: imageWithCallback wrapped in internalTimer with 0 delay
- bugfix: 47_OBIS: Reintegrate buggy DZG meters support
- change: 49_IPCAM: introduced attribute httpTimeout
- change: 49_IPCAM: introduced incrementalTimeout

View File

@ -1,4 +1,4 @@
# $Id$
#create $Id$
# vim: ts=2:et
################################################################
#
@ -383,7 +383,7 @@ Get($@) {
}
$hash->{READINGS}{snapshots}{VAL} = 0;
for (my $i=0;$i<$seqImages;$i++) {
InternalTimer(gettimeofday()+$seqWait, "IPCAM::getSnapshot", $hash, 0);
InternalTimer(gettimeofday()+$seqWait, "IPCAM::RequestSnapshot", $hash);
$seqWait = $seqWait + $seqDelay;
}
return undef;
@ -393,10 +393,7 @@ Get($@) {
my $callbackCommand = join(" ", @a);
Log3 $name, 3, "IPCAM ($name) - imageWithCallback command: $callbackCommand";
my $camUri = createSnapshotUrl($hash);
Log3 $name, 3, "IPCAM ($name) - imageWithCallback camUri: $camUri";
RequestSnapshotWithCallback($hash, $camUri, $callbackCommand);
RequestSnapshotWithCallback($hash,$callbackCommand);
return undef;
@ -411,12 +408,6 @@ Get($@) {
}
}
sub getSnapshot($$) {
my ($hash) = @_;
my $snapshotUrl = createSnapshotUrl($hash);
RequestSnapshot($hash, $snapshotUrl);
}
#####################################
sub
createSnapshotUrl($) {
@ -473,17 +464,25 @@ createSnapshotUrl($) {
return $camURI;
}
sub RequestSnapshot {
my ($hash, $camUrl) = @_;
my ($hash) = @_;
return RequestSnapshotWithCallback($hash, $camUrl, undef);
return ExecuteSnapshotRequest($hash, undef);
}
sub RequestSnapshotWithCallback {
my ($hash, $camUrl, $callbackCommand) = @_;
my ($hash, $callbackCommand) = @_;
return ExecuteSnapshotRequest($hash, $callbackCommand);
}
sub ExecuteSnapshotRequest {
my ($hash, $callbackCommand) = @_;
my $name = $hash->{NAME};
my $camUrl = createSnapshotUrl($hash);
Log3 $name, 3, "IPCAM ($name) - ExecuteSnapshotRequest camUrl: $camUrl";
my $apiParam = {
url => $camUrl,
method => "GET",
@ -493,7 +492,14 @@ sub RequestSnapshotWithCallback {
timeout => AttrVal($name, 'httpTimeout', 4),
callbackCommand => $callbackCommand
};
HttpUtils_NonblockingGet($apiParam);
# trying to fix timeouts by wrapping this in internalTimer
if (defined $callbackCommand) {
InternalTimer(gettimeofday(), "main::HttpUtils_NonblockingGet", $apiParam);
} else {
# without callback command, the internal timer has been set before already.
HttpUtils_NonblockingGet($apiParam);
}
return undef;
}