Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
Nall-chan committed Jul 20, 2023
1 parent 21f51f5 commit 8afcaba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ONVIF IO/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@
"code": 203,
"icon": "error",
"caption": "Connection lost"
},
{
"code": 204,
"icon": "error",
"caption": "No events received (check firewall)"
}
]
}
19 changes: 17 additions & 2 deletions ONVIF IO/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @property integer $MyPort
* @property bool $MyHTTPS
* @property bool $isSubscribed
* @property bool $WaitForFirstEvent
* @property \ONVIF\Profile $Profile
* @property array $Warnings
* @method void RegisterAttributeArray(string $name, mixed $Value, int $Size = 0)
Expand Down Expand Up @@ -77,6 +78,7 @@ public function Create(): void
$this->isSubscribed = false;
$this->Profile = new \ONVIF\Profile();
$this->Warnings = [];
$this->WaitForFirstEvent = false;
if (IPS_GetKernelRunlevel() == KR_READY) {
$this->RegisterMessage($this->InstanceID, FM_CHILDREMOVED);
} else {
Expand Down Expand Up @@ -872,11 +874,13 @@ protected function Subscribe(): bool
'InitialTerminationTime' => 'PT1M'
];
$Response = '';
$this->WaitForFirstEvent = true;
$SubscribeResult = $this->SendData($XAddr[\ONVIF\NS::Event], \ONVIF\WSDL::Event, 'Subscribe', true, $Params, $Response);
if (is_a($SubscribeResult, 'SoapFault')) {
$this->SetStatus(IS_EBASE + 3);
$this->LogMessage($this->Translate('Connection lost'), KL_ERROR);
$this->ShowLastError($SubscribeResult->getMessage());
$this->WaitForFirstEvent = false;
return false;
}
$SubscriptionReference = $SubscribeResult->SubscriptionReference->Address->{'_'};
Expand All @@ -903,14 +907,22 @@ protected function Subscribe(): bool
}
$this->isSubscribed = true;
$this->SetTimerInterval('RenewSubscription', 55 * 1000);
$this->SetStatus(IS_ACTIVE);
$this->UpdateFormField('DeviceData', 'items', json_encode($this->GetDeviceDataForForm()));
$this->UpdateFormField('DeviceDataPanel', 'visible', true);
$this->UpdateFormField('DeviceDataPanel', 'expanded', true);
$this->UpdateFormField('Events', 'visible', true);

$this->SetSynchronizationPoint();
return true;
for ($i = 0; $i < 400; $i++) {
if (!$this->WaitForFirstEvent) {
$this->SetStatus(IS_ACTIVE);
return true;
}
IPS_Sleep(5);
}
$this->WaitForFirstEvent = false;
$this->SetStatus(IS_EBASE + 4);
return false;
}
protected function SetSynchronizationPoint(): bool
{
Expand Down Expand Up @@ -1717,6 +1729,9 @@ protected function ProcessHookData()
return;
}
$this->SendDebug('Event', $Data, 0);
if ($this->WaitForFirstEvent) {
$this->WaitForFirstEvent = false;
}
$this->DecodeNotificationMessage($Data);
}
protected function DecodeNotificationMessage(string $NotificationMessageXML): bool
Expand Down

0 comments on commit 8afcaba

Please sign in to comment.