mirror of
https://github.com/Art-of-WiFi/UniFi-API-client.git
synced 2024-11-22 02:00:21 +01:00
Add ap_upgrade_firmware.php to Examples (#12)
- add ap_upgrade_firmware.php, contributed by @4oo4
This commit is contained in:
parent
546334c88e
commit
93d78b2f22
33
examples/ap_upgrade_firmware.php
Normal file
33
examples/ap_upgrade_firmware.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks and upgrades AP firmware (can be scheduled with systemd/cron)
|
||||||
|
**/
|
||||||
|
|
||||||
|
require_once('vendor/autoload.php');
|
||||||
|
require_once('config.php');
|
||||||
|
|
||||||
|
// Because of a bug in the API, the site name is probably stuck at 'default' rather than what you actually named it:
|
||||||
|
// https://github.com/Art-of-WiFi/UniFi-API-browser/issues/35
|
||||||
|
$site_id = 'default';
|
||||||
|
|
||||||
|
// AP MAC address formatted with colons
|
||||||
|
$device_mac = 'de:ad:be:ef:01:23';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initialize the Unifi API connection class, log in to the controller and request the alarms collection
|
||||||
|
* (this example assumes you have already assigned the correct values to the variables used)
|
||||||
|
*/
|
||||||
|
|
||||||
|
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion, false);
|
||||||
|
$login = $unifi_connection->login();
|
||||||
|
|
||||||
|
// Run the actual upgrade
|
||||||
|
$results = $unifi_connection->upgrade_device($device_mac);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* provide feedback in json format from $response given by upgrade_device();
|
||||||
|
*/
|
||||||
|
echo json_encode($results, JSON_PRETTY_PRINT);
|
||||||
|
|
||||||
|
?>
|
@ -21,4 +21,4 @@ $controllerversion = ''; // the version of the Controller software, eg. '4.6.6'
|
|||||||
/**
|
/**
|
||||||
* set to true (without quotes) to enable debug output to the browser and the PHP error log
|
* set to true (without quotes) to enable debug output to the browser and the PHP error log
|
||||||
*/
|
*/
|
||||||
$debug = false;
|
$debug = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user