Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
Nall-chan committed Nov 25, 2023
1 parent ee0fe57 commit 39fa7e5
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 351 deletions.
4 changes: 2 additions & 2 deletions FritzBox WAN Common Interface/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{
"name": "RefreshLinkPropertiesInterval",
"type": "NumberSpinner",
"caption": "Refresh Interval Link Properties",
"caption": "Refresh Linkstate Interval",
"suffix": "seconds",
"minimum": 60
}
Expand All @@ -42,7 +42,7 @@
},
{
"type": "Button",
"caption": "Update Values",
"caption": "Update Linkstate",
"onClick": "IPS_RequestAction($id,'RefreshLinkProperties',true);"
},
{
Expand Down
4 changes: 3 additions & 1 deletion FritzBox WAN Common Interface/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
"Service": "Dienst",
"<none>": "<keiner>",
"Refresh Interval": "Aktualisierungsintervall",
"Refresh Linkstate Interval": "Aktualisierungsintervall Linkstatus",
"seconds": "Sekunden",
"Update Values": "Werte aktualisieren",
"Update Linkstate": "Linkstatus aktualisieren",
"Event subscribe error": "Ereignisabonnementfehler",
"Invalid Ident.": "Ungültiger Ident.",
"Fiber": "Glasfaser",
"Cable": "Kabelanschluss",
"unknown": "unbekannt",
"Other": "Anders",
"Up": "Verbunden",
"Down": "Getrennt",
"Initializing": "Initialisieren",
Expand Down
26 changes: 14 additions & 12 deletions FritzBox WAN Common Interface/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function Destroy()
$this->UnregisterProfile('FB.Speed');
$this->UnregisterProfile('FB.MByte');
$this->UnregisterProfile('FB.kbs');
$this->UnregisterProfile('FB.AccessType');
$this->UnregisterProfile('FB.AvmAccessType');
}
//Never delete this line!
parent::Destroy();
Expand All @@ -51,14 +51,18 @@ public function ApplyChanges()
$this->RegisterProfileFloat('FB.Speed', '', '', '%', 0, 100, 0, 2);
$this->RegisterProfileFloat('FB.MByte', '', '', ' MB', 0, 0, 0, 2);
$this->RegisterProfileFloat('FB.kbs', '', '', ' kb/s', 0, 0, 0, 2);
$this->RegisterProfileStringEx('FB.AccessType', '', '', '', [
$this->RegisterProfileStringEx('FB.AvmAccessType', '', '', '', [
['DSL', 'DSL', '', -1],
['Ethernet', 'Ethernet', '', -1],
['X_AVM-DE_Fiber', 'Fiber', '', -1],
['X_AVMDE_UMTS', 'UMTS', '', -1],
['X_AVM-DE_Cable', 'Cable', '', -1],
['X_AVM-DE_LTE', 'LTE', '', -1],
['unknown', 'unknown', '', -1]
['ATA', 'ATA', '', -1],
['USB-Tethering', 'USB-Tethering', '', -1],
['Cable', 'Cable', '', -1],
['LTE', 'LTE', '', -1],
['Serial', 'Serial', '', -1],
['WLAN', 'WLAN', '', -1],
['ISDN', 'ISDN', '', -1],
['IP-Client', 'IP-Client', '', -1],
['Fiber', 'Fiber', '', -1],
['Other', 'Other', '', -1]
]);
parent::ApplyChanges();

Expand All @@ -82,7 +86,6 @@ public function RequestAction($Ident, $Value)
switch ($Ident) {
case 'RefreshInfo':
return $this->UpdateAddonInfos();

case 'RefreshLinkProperties':
return $this->UpdateCommonLinkProperties();
}
Expand Down Expand Up @@ -172,7 +175,7 @@ private function UpdateCommonLinkProperties()
return false;
}

$this->setIPSVariable('WANAccessType', 'WAN Access type', (string) $result['NewWANAccessType'], VARIABLETYPE_STRING, 'FB.AccessType');
//$this->setIPSVariable('WANAccessType', 'WAN Access type', (string) $result['NewWANAccessType'], VARIABLETYPE_STRING, 'FB.AccessType');
$this->setIPSVariable('PhysicalLinkStatus', 'Physical Link Status', (string) $result['NewPhysicalLinkStatus'], VARIABLETYPE_STRING);
$Downstream = (int) ((int) $result['NewLayer1DownstreamMaxBitRate'] / 1000);
$Upstream = (int) ((int) $result['NewLayer1UpstreamMaxBitRate'] / 1000);
Expand All @@ -189,7 +192,6 @@ private function UpdateCommonLinkProperties()
return true;
}
/* todo
function AVM-DE_SetWANAccessType
function X_AVM-DE_GetActiveProvider
*/
private function UpdateAddonInfos()
Expand Down Expand Up @@ -228,7 +230,7 @@ private function UpdateAddonInfos()
$this->setIPSVariable('DNSServer2', 'DNS-Server 2', (string) $result['NewDNSServer2'], VARIABLETYPE_STRING);
}
if (array_key_exists('NewX_AVM_DE_WANAccessType', $result)) {
$this->setIPSVariable('WANAccessType', 'WAN Access type', (string) $result['NewX_AVM_DE_WANAccessType'], VARIABLETYPE_STRING);
$this->setIPSVariable('WANAccessType', 'WAN Access type', (string) $result['NewX_AVM_DE_WANAccessType'], VARIABLETYPE_STRING, 'FB.AvmAccessType');
}
if (array_key_exists('NewVoipDNSServer1', $result)) {
$this->setIPSVariable('VoipDNSServer1', 'VoIP DNS-Server 1', (string) $result['NewVoipDNSServer1'], VARIABLETYPE_STRING);
Expand Down
62 changes: 62 additions & 0 deletions FritzBox WAN Physical Interface/6591_wancommonifconfigSCPD.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@
<direction>out</direction>
<relatedStateVariable>PhysicalLinkStatus</relatedStateVariable>
</argument>
<argument>
<name>NewX_AVM-DE_DownstreamCurrentUtilization</name>
<direction>out</direction>
<relatedStateVariable>X_AVM-DE_DownstreamCurrentUtilization</relatedStateVariable>
</argument>
<argument>
<name>NewX_AVM-DE_UpstreamCurrentUtilization</name>
<direction>out</direction>
<relatedStateVariable>X_AVM-DE_UpstreamCurrentUtilization</relatedStateVariable>
</argument>
<argument>
<name>NewX_AVM-DE_DownstreamCurrentMaxSpeed</name>
<direction>out</direction>
<relatedStateVariable>X_AVM-DE_DownstreamCurrentMaxSpeed</relatedStateVariable>
</argument>
<argument>
<name>NewX_AVM-DE_UpstreamCurrentMaxSpeed</name>
<direction>out</direction>
<relatedStateVariable>X_AVM-DE_UpstreamCurrentMaxSpeed</relatedStateVariable>
</argument>
</argumentList>
</action>
<action>
Expand Down Expand Up @@ -80,6 +100,16 @@
</argument>
</argumentList>
</action>
<action>
<name>X_AVM-DE_GetActiveProvider</name>
<argumentList>
<argument>
<name>NewX_AVM-DE_Provider</name>
<direction>out</direction>
<relatedStateVariable>X_AVM-DE_Provider</relatedStateVariable>
</argument>
</argumentList>
</action>
<action>
<name>X_AVM-DE_GetOnlineMonitor</name>
<argumentList>
Expand Down Expand Up @@ -155,6 +185,16 @@
<stateVariable sendEvents="no">
<name>WANAccessType</name>
<dataType>string</dataType>
<allowedValueList>
<allowedValue>DSL</allowedValue>
<allowedValue>Ethernet</allowedValue>
<allowedValue>X_AVM-DE_Fiber</allowedValue>
<allowedValue>X_AVM-DE_UMTS</allowedValue>
<allowedValue>X_AVM-DE_Cable</allowedValue>
<allowedValue>X_AVM-DE_LTE</allowedValue>
<allowedValue>unknown</allowedValue>
</allowedValueList>
<defaultValue>unknown</defaultValue>
</stateVariable>
<stateVariable sendEvents="no">
<name>Layer1UpstreamMaxBitRate</name>
Expand Down Expand Up @@ -194,6 +234,28 @@
<name>AccessType</name>
<dataType>string</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>X_AVM-DE_Provider</name>
<dataType>string</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>X_AVM-DE_DownstreamCurrentUtilization</name>
<dataType>string</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>X_AVM-DE_UpstreamCurrentUtilization</name>
<dataType>string</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>X_AVM-DE_DownstreamCurrentMaxSpeed</name>
<dataType>ui4</dataType>
<defaultValue>0</defaultValue>
</stateVariable>
<stateVariable sendEvents="no">
<name>X_AVM-DE_UpstreamCurrentMaxSpeed</name>
<dataType>ui4</dataType>
<defaultValue>0</defaultValue>
</stateVariable>
<stateVariable sendEvents="no">
<name>SyncGroupIndex</name>
<dataType>ui4</dataType>
Expand Down
4 changes: 4 additions & 0 deletions FritzBox WAN Physical Interface/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"Update Values": "Werte aktualisieren",
"Event subscribe error": "Ereignisabonnementfehler",
"Invalid Ident.": "Ungültiger Ident.",
"Cable": "Kabelanschluss",
"Ethernet": "Netzwerk",
"Fiber": "Glasfaser",
"unknown": "unbekannt",
"Up": "Verbunden",
"Down": "Getrennt",
"Initializing": "Initialisieren",
Expand Down
180 changes: 98 additions & 82 deletions FritzBox WAN Physical Interface/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,96 +4,112 @@

require_once __DIR__ . '/../libs/FritzBoxBase.php';

class FritzBoxWANPhysicalInterface extends FritzBoxModulBase
class FritzBoxWANPhysicalInterface extends FritzBoxModulBase
{
protected static $ControlUrlArray = [
'/upnp/control/wancommonifconfig1'
];
protected static $EventSubURLArray = [
//'/upnp/control/wancommonifconfig1'
];
protected static $ServiceTypeArray = [
'urn:dslforum-org:service:WANCommonInterfaceConfig:1'
];
protected static $DefaultIndex = 0;
public function Create()
{
protected static $ControlUrlArray = [
'/upnp/control/wancommonifconfig1'
];
protected static $EventSubURLArray = [
//'/upnp/control/wancommonifconfig1'
];
protected static $ServiceTypeArray = [
'urn:dslforum-org:service:WANCommonInterfaceConfig:1'
];
protected static $DefaultIndex = 0;
public function Create()
{
//Never delete this line!
parent::Create();
$this->RegisterPropertyInteger('RefreshInterval', 60);
$this->RegisterTimer('RefreshLinkProperties', 0, 'IPS_RequestAction(' . $this->InstanceID . ',"RefreshLinkProperties",true);');
}
//Never delete this line!
parent::Create();
$this->RegisterPropertyInteger('RefreshInterval', 60);
$this->RegisterTimer('RefreshLinkProperties', 0, 'IPS_RequestAction(' . $this->InstanceID . ',"RefreshLinkProperties",true);');
}

public function Destroy()
{
if (!IPS_InstanceExists($this->InstanceID)) {
$this->UnregisterProfile('FB.kBit');
}
//Never delete this line!
parent::Destroy();
public function Destroy()
{
if (!IPS_InstanceExists($this->InstanceID)) {
$this->UnregisterProfile('FB.kBit');
$this->UnregisterProfile('FB.AccessType');
}
//Never delete this line!
parent::Destroy();
}

public function ApplyChanges()
{
$this->SetTimerInterval('RefreshLinkProperties', 0);
$this->RegisterProfileInteger('FB.kBit', '', '', ' kBit/s', 0, 0, 0);
parent::ApplyChanges();
if (IPS_GetKernelRunlevel() != KR_READY) {
return;
}
$this->UpdateCommonLinkProperties();
$this->SetTimerInterval('RefreshLinkProperties', $this->ReadPropertyInteger('RefreshInterval') * 1000);
}
public function RequestAction($Ident, $Value)
{
if (parent::RequestAction($Ident, $Value)) {
return true;
}
switch ($Ident) {
case 'RefreshLinkProperties':
return $this->UpdateCommonLinkProperties();
}
trigger_error($this->Translate('Invalid Ident.'), E_USER_NOTICE);
return false;
}
public function GetCommonLinkProperties()
{
$result = $this->Send(__FUNCTION__);
if ($result === false) {
return false;
}
return $result;
public function ApplyChanges()
{
$this->SetTimerInterval('RefreshLinkProperties', 0);
$this->RegisterProfileInteger('FB.kBit', '', '', ' kBit/s', 0, 0, 0);
$this->RegisterProfileStringEx('FB.AccessType', '', '', '', [
['DSL', 'DSL', '', -1],
['Ethernet', 'Ethernet', '', -1],
['X_AVM-DE_Fiber', 'Fiber', '', -1],
['X_AVM-DE_UMTS', 'UMTS', '', -1],
['X_AVM-DE_Cable', 'Cable', '', -1],
['X_AVM-DE_LTE', 'LTE', '', -1],
['unknown', 'unknown', '', -1]
]);
parent::ApplyChanges();
if (IPS_GetKernelRunlevel() != KR_READY) {
return;
}
public function GetTotalBytesSent()
{
return $this->Send(__FUNCTION__);
$this->UpdateCommonLinkProperties();
$this->SetTimerInterval('RefreshLinkProperties', $this->ReadPropertyInteger('RefreshInterval') * 1000);
}
public function RequestAction($Ident, $Value)
{
if (parent::RequestAction($Ident, $Value)) {
return true;
}
public function GetTotalBytesReceived()
{
return $this->Send(__FUNCTION__);
switch ($Ident) {
case 'WANAccessType':
return $this->SetWANAccessType($Value);
case 'RefreshLinkProperties':
return $this->UpdateCommonLinkProperties();
}
public function GetTotalPacketsSent()
{
return $this->Send(__FUNCTION__);
trigger_error($this->Translate('Invalid Ident.'), E_USER_NOTICE);
return false;
}
public function GetCommonLinkProperties()
{
$result = $this->Send(__FUNCTION__);
if ($result === false) {
return false;
}
public function GetTotalPacketsReceived()
{
return $this->Send(__FUNCTION__);
return $result;
}
public function GetTotalBytesSent()
{
return $this->Send(__FUNCTION__);
}
public function GetTotalBytesReceived()
{
return $this->Send(__FUNCTION__);
}
public function GetTotalPacketsSent()
{
return $this->Send(__FUNCTION__);
}
public function GetTotalPacketsReceived()
{
return $this->Send(__FUNCTION__);
}
public function SetWANAccessType(string $WanAccessType)
{
$result = $this->Send('X_AVM-DE_SetWANAccessType', ['NewAccessType'=>$WanAccessType]);
return $result !== false;
}
private function UpdateCommonLinkProperties()
{
$result = $this->GetCommonLinkProperties();
if ($result === false) {
return false;
}

private function UpdateCommonLinkProperties()
{
$result = $this->GetCommonLinkProperties();
if ($result === false) {
return false;
}

$this->setIPSVariable('WANAccessType', 'WAN Access type', (string) $result['NewWANAccessType'], VARIABLETYPE_STRING);
$this->setIPSVariable('PhysicalLinkStatus', 'Physical Link Status', (string) $result['NewPhysicalLinkStatus'], VARIABLETYPE_STRING);
$Downstream = (int) ((int) $result['NewLayer1DownstreamMaxBitRate'] / 1000);
$Upstream = (int) ((int) $result['NewLayer1UpstreamMaxBitRate'] / 1000);
$this->setIPSVariable('UpstreamMaxBitRate', 'Upstream Max kBitrate', $Upstream, VARIABLETYPE_INTEGER, 'FB.kBit');
$this->setIPSVariable('DownstreamMaxBitRate', 'Downstream Max kBitrate', $Downstream, VARIABLETYPE_INTEGER, 'FB.kBit');
return true;
}
$this->setIPSVariable('WANAccessType', 'WAN Access type', (string) $result['NewWANAccessType'], VARIABLETYPE_STRING, 'FB.AccessType', true);
$this->setIPSVariable('PhysicalLinkStatus', 'Physical Link Status', (string) $result['NewPhysicalLinkStatus'], VARIABLETYPE_STRING);
$Downstream = (int) ((int) $result['NewLayer1DownstreamMaxBitRate'] / 1000);
$Upstream = (int) ((int) $result['NewLayer1UpstreamMaxBitRate'] / 1000);
$this->setIPSVariable('UpstreamMaxBitRate', 'Upstream Max kBitrate', $Upstream, VARIABLETYPE_INTEGER, 'FB.kBit');
$this->setIPSVariable('DownstreamMaxBitRate', 'Downstream Max kBitrate', $Downstream, VARIABLETYPE_INTEGER, 'FB.kBit');
return true;
}
}
Loading

0 comments on commit 39fa7e5

Please sign in to comment.