From 5411b21a74070c5fbcb6d1a4c23ad9fd8b13af91 Mon Sep 17 00:00:00 2001 From: alphayax Date: Tue, 24 May 2016 22:37:05 +0200 Subject: [PATCH] Add UPnPAV API --- README.md | 2 ++ TODO.md | 2 +- exemple/config/LCD.php | 2 +- exemple/config/UPnP.php | 14 ++++++++ freebox/api/v3/models/UPnP/UpnpAvConfig.php | 28 +++++++++++++++ freebox/api/v3/services/config/UPnP/AV.php | 38 +++++++++++++++++++++ 6 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 exemple/config/UPnP.php create mode 100644 freebox/api/v3/models/UPnP/UpnpAvConfig.php create mode 100644 freebox/api/v3/services/config/UPnP/AV.php diff --git a/README.md b/README.md index 2a98192..a54b595 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ Jusqu'a présent, les fonctionalités suivantes ont été implémentées : - Dmz - Port Forwarding - Incoming Port + - UPnP + - AV ## Utilisation diff --git a/TODO.md b/TODO.md index 00690a8..f41f2f2 100644 --- a/TODO.md +++ b/TODO.md @@ -31,7 +31,7 @@ - UPnP IGD - ~~LCD~~ - Network Share - - UPnP AV + - ~~UPnP AV~~ - Switch - Wi-Fi - ~~System~~ diff --git a/exemple/config/LCD.php b/exemple/config/LCD.php index 12baa3c..76b97d8 100644 --- a/exemple/config/LCD.php +++ b/exemple/config/LCD.php @@ -8,7 +8,7 @@ $App = new \alphayax\freebox\utils\Application( 'com.alphayax.freebox.config', ' $App->authorize(); $App->openSession(); -// DMZ +// LCD Configuration $LCDService = new \alphayax\freebox\api\v3\services\config\LCD( $App); $a = $LCDService->getConfiguration(); var_dump( $a); diff --git a/exemple/config/UPnP.php b/exemple/config/UPnP.php new file mode 100644 index 0000000..da0d4b0 --- /dev/null +++ b/exemple/config/UPnP.php @@ -0,0 +1,14 @@ +authorize(); +$App->openSession(); + +// UPnP AV +$UPnPAvService = new \alphayax\freebox\api\v3\services\config\UPnP\AV( $App); +$UPnPAvConfig = $UPnPAvService->getConfiguration(); +print_r( $UPnPAvConfig); diff --git a/freebox/api/v3/models/UPnP/UpnpAvConfig.php b/freebox/api/v3/models/UPnP/UpnpAvConfig.php new file mode 100644 index 0000000..42d3897 --- /dev/null +++ b/freebox/api/v3/models/UPnP/UpnpAvConfig.php @@ -0,0 +1,28 @@ +enabled; + } + + /** + * @param boolean $enabled + */ + public function setEnabled( $enabled) { + $this->enabled = $enabled; + } + +} diff --git a/freebox/api/v3/services/config/UPnP/AV.php b/freebox/api/v3/services/config/UPnP/AV.php new file mode 100644 index 0000000..37a12d1 --- /dev/null +++ b/freebox/api/v3/services/config/UPnP/AV.php @@ -0,0 +1,38 @@ +getAuthService( self::API_UPNP_AV_CONFIG); + $rest->GET(); + + return new UpnpAvConfig( $rest->getCurlResponse()['result']); + } + + /** + * Update the UPnP AV configuration + * @param UpnpAvConfig $new_UpnpAvConfig + * @return UpnpAvConfig + * @throws \Exception + */ + public function setConfiguration( UpnpAvConfig $new_UpnpAvConfig){ + $rest = $this->getAuthService( self::API_UPNP_AV_CONFIG); + $rest->PUT( $new_UpnpAvConfig->toArray()); + + return new UpnpAvConfig( $rest->getCurlResponse()['result']); + } + +} \ No newline at end of file