'; /** * the MAC address of the access point to modify */ $ap_mac = ''; /** * power level for 2.4GHz */ $ng_tx_power_mode = 'low'; /** * channel for 2.4GHz */ $ng_channel = 6; /** * power level for 5GHz */ $na_tx_power_mode = 'medium'; /** * channel for 5GHz */ $na_channel = 44; /** * initialize the UniFi API connection class and log in to the controller and do our thing */ $unifi_connection = new UniFi_API\Client( $controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion ); $set_debug_mode = $unifi_connection->set_debug(false); $loginresults = $unifi_connection->login(); $data = $unifi_connection->list_devices($ap_mac); $radio_table = $data[0]->radio_table; $device_id = $data[0]->device_id; foreach ($radio_table as $radio) { if ($radio->radio === 'ng') { $radio->tx_power_mode = $ng_tx_power_mode; $radio->channel = $ng_channel; } if ($radio->radio === 'na') { $radio->tx_power_mode = $na_tx_power_mode; $radio->channel = $na_channel; } } $update_device = $unifi_connection->set_device_settings_base($device_id, ['radio_table' => $radio_table]); if (!$update_device) { $error = $unifi_connection->get_last_results_raw(); echo json_encode($error, JSON_PRETTY_PRINT); } /** * provide feedback in json format */ echo json_encode($update_device, JSON_PRETTY_PRINT);