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 0631da5 commit cd66127
Show file tree
Hide file tree
Showing 7 changed files with 327 additions and 318 deletions.
2 changes: 1 addition & 1 deletion .style
Submodule .style updated 2 files
+31 −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(): void
}
protected function DiscoverDevices(): array
{
//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(): array
$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
580 changes: 293 additions & 287 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 @@ -1212,7 +1212,7 @@ protected function WritePTZInHTMLBox(): void
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": "7.0"
},
"version": "2.13",
"build": 213,
"date": 1702047058
"build": 214,
"date": 1706077404
}
51 changes: 27 additions & 24 deletions libs/ONVIFModuleBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,13 @@ public function Destroy(): void

public function ApplyChanges(): void
{
$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(string $Ident, mixed $Value, bool &$done = false): void
{
$done = false;
Expand All @@ -115,12 +95,35 @@ public function MessageSink(int $TimeStamp, int $SenderID, int $Message, array $
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(): void
{
$this->RegisterParent();
if ($this->HasActiveParent()) {
$this->ApplyChanges();
$this->InitFilterAndEvents();
}
}

Expand All @@ -136,7 +139,7 @@ protected function IOChangeState(int $State): void
{
if ($State == IS_ACTIVE) {
$this->EventTopic = $this->ReadPropertyString(\ONVIF\Device\Property::EventTopic);
$this->ApplyChanges();
$this->InitFilterAndEvents();
$this->ReloadForm();
}
}
Expand Down
2 changes: 1 addition & 1 deletion libs/wsdl.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function __sleep(): array
}
public function toString(): string
{
switch($this->Type) {
switch ($this->Type) {
case self::Subscribe:
return 'Subscription';
case self::PullPoint:
Expand Down

0 comments on commit cd66127

Please sign in to comment.