Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
Nall-chan committed Jan 24, 2024
1 parent c4bde08 commit 23c80e9
Show file tree
Hide file tree
Showing 7 changed files with 295 additions and 288 deletions.
2 changes: 1 addition & 1 deletion .style
Submodule .style updated 2 files
+32 −31 .php-cs-fixer.php
+71 −71 json-check.php
4 changes: 2 additions & 2 deletions ONVIF Discovery/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ protected function Discover()
}
protected function DiscoverDevices()
{
//IPS_Sleep(5000);
//return []; // testing
$Interfaces = $this->getIPAdresses();
$uuid = self::uuidV4();
$discoveryMessage = str_replace('[UUID]', $uuid, self::WS_DISCOVERY_MESSAGE);
Expand Down Expand Up @@ -527,6 +525,8 @@ private function getIPAdresses()
$InterfaceDescriptions = array_column($Interfaces, 'Description', 'InterfaceIndex');
$Networks = net_get_interfaces();
$Addresses = [];
$Addresses['ipv6'] = [];
$Addresses['ipv4'] = [];
foreach ($Networks as $InterfaceDescription => $Interface) {
if (!$Interface['up']) {
continue;
Expand Down
519 changes: 261 additions & 258 deletions ONVIF IO/module.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ONVIF Media Stream/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ protected function WritePTZInHTMLBox()
file_get_contents(__DIR__ . '/../libs/PTZControl.js')
);

$JSCode = '<script>' . $JS . /*'initPTZ(' . $this->InstanceID . ');*/'</script>';
$JSCode = '<script>' . $JS . /*'initPTZ(' . $this->InstanceID . ');*/ '</script>';
$HTMLData = '<div class="extended"><div class="ipsContainer media">' .
$ImgSrc .
'<div style="position:absolute; right:0px; bottom:0px; margin:10px">' .
Expand Down
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"version": "6.1"
},
"version": "2.13",
"build": 213,
"date": 1702047058
"build": 214,
"date": 1706077404
}
50 changes: 27 additions & 23 deletions libs/ONVIFModuleBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,12 @@ public function Destroy()

public function ApplyChanges()
{
$EventTopic = $this->ReadPropertyString(\ONVIF\Device\Property::EventTopic);
$SyncEvents = ($EventTopic != $this->EventTopic);
//Never delete this line!
parent::ApplyChanges();

$this->RegisterMessage($this->InstanceID, FM_CONNECT);
$this->RegisterMessage($this->InstanceID, FM_DISCONNECT);

if ($EventTopic == '') {
$TopicFilter = '.*"Topic":"NOTHING".*';
} else {
$TopicFilter = '.*"Topic":"' . preg_quote(substr(json_encode($EventTopic), 1, -1)) . '.*';
}
$this->SetReceiveDataFilter($TopicFilter);
$this->SendDebug('SetReceiveDataFilter', $TopicFilter, 0);

if (IPS_GetKernelRunlevel() != KR_READY) {
return;
}
$this->RegisterParent();
$Events = $this->GetEvents($EventTopic);
$this->WriteAttributeArray(\ONVIF\Device\Attribute::EventProperties, $Events);
if ($SyncEvents && ($this->HasActiveParent())) {
$this->$EventTopic = $EventTopic;
IPS_RunScriptText('IPS_RequestAction(' . $this->InstanceID . ',"SetSynchronizationPoint",true);');
}
$this->InitFilterAndEvents();
}

public function RequestAction($Ident, $Value)
Expand All @@ -113,12 +94,35 @@ public function MessageSink($TimeStamp, $SenderID, $Message, $Data)
break;
}
}
protected function InitFilterAndEvents()
{
$EventTopic = $this->ReadPropertyString(\ONVIF\Device\Property::EventTopic);
$SyncEvents = ($EventTopic != $this->EventTopic);
if ($EventTopic == '') {
$TopicFilter = '.*"Topic":"NOTHING".*';
} else {
$TopicFilter = '.*"Topic":"' . preg_quote(substr(json_encode($EventTopic), 1, -1)) . '.*';
}
$this->SetReceiveDataFilter($TopicFilter);
$this->SendDebug('SetReceiveDataFilter', $TopicFilter, 0);

if (IPS_GetKernelRunlevel() != KR_READY) {
return;
}
$this->RegisterParent();
$Events = $this->GetEvents($EventTopic);
$this->WriteAttributeArray(\ONVIF\Device\Attribute::EventProperties, $Events);
if ($SyncEvents && ($this->HasActiveParent())) {
$this->$EventTopic = $EventTopic;
IPS_RunScriptText('IPS_RequestAction(' . $this->InstanceID . ',"SetSynchronizationPoint",true);');
}
}

protected function KernelReady()
{
$this->RegisterParent();
if ($this->HasActiveParent()) {
$this->ApplyChanges();
$this->InitFilterAndEvents();
}
}

Expand All @@ -134,7 +138,7 @@ protected function IOChangeState($State)
{
if ($State == IS_ACTIVE) {
$this->EventTopic = $this->ReadPropertyString(\ONVIF\Device\Property::EventTopic);
$this->ApplyChanges();
$this->InitFilterAndEvents();
$this->ReloadForm();
}
}
Expand Down

0 comments on commit 23c80e9

Please sign in to comment.