Source for file examples.guifi_api.radio.php
Documentation is available at examples.guifi_api.radio.php
-
-
// The source code packaged with this file is Free Software, Copyright (C) 2005 by
-
// Eduard Duran <eduard.duran at iglu.cat>.
-
// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
-
// You can get copies of the licenses here:
-
// http://www.affero.org/oagpl.html
-
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "LICENSE.txt".
-
-
require ( 'guifi_api.php' );
-
-
-
* Configuration of authentication against guifi.net
-
-
$username = "eduard.duran";
-
-
-
-
-
-
$gapi = new guifiAPI( $username, $password );
-
-
$action = $_GET['action'];
-
-
-
-
-
-
$mac = 'AA:BB:CC:DD:EE:FA';
-
-
-
$radio['antenna_angle'] = 120; // 60ยบ
-
$radio['antenna_gain'] = "21";
-
$radio['antenna_azimuth'] = 30;
-
$radio['protocol'] = '802.11b';
-
-
$radio['clients_accepted'] = 'Yes';
-
-
$added = $gapi->addRadio( $mode, $device_id, $mac, $radio );
-
-
echo "Radio created correctly!!<br />\n<br />\n";
-
echo "The identificator of the new radio is: radiodev_counter = <strong>$added->radiodev_counter</strong>";
-
if( $added->interfaces ) {
-
-
echo "New interfaces added!:<br />";
-
-
foreach( $added->interfaces as $interface ) {
-
-
echo "Type: $interface->interface_type<br />";
-
-
echo "New IPv4 configuration:<br />";
-
foreach( $interface->ipv4 as $ipv4 ) {
-
echo "ipv4_type = $ipv4->ipv4_type<br />";
-
echo "ipv4 = $ipv4->ipv4 <br />";
-
echo "netmask = $ipv4->netmask<br />";
-
-
-
-
-
-
-
-
echo "There was an error adding the radio.<br />\n";
-
echo $gapi->getErrorsStr();
-
-
-
-
-
-
-
-
$radio['antenna_angle'] = 90;
-
$radio['antenna_gain'] = 14;
-
-
$updated = $gapi->updateRadio( $device_id, $radiodev_counter, $radio );
-
-
echo "Radio <strong>$radiodev_counter</strong> at device <strong>$device_id</strong> was updated correctly.<br />\n<br />\n";
-
-
echo "There was an error updating the device.<br />\n";
-
echo $gapi->getErrorsStr();
-
-
-
-
-
-
-
$removed = $gapi->removeRadio( $device_id, $radiodev_counter );
-
-
echo "Radio <strong>$radiodev_counter</strong> at device <strong>$device_id</strong> removed correctly.<br />\n<br />\n";
-
-
echo "There was an error deleting the radio.<br />\n";
-
echo $gapi->getErrorsStr();
-
-
-
-
-
$nearest = $gapi->nearestRadio( $node_id );
-
-
-
$radios = $nearest->radios;
-
-
echo "Found some radios:\n";
-
-
foreach( $radios as $radio ) {
-
-
echo " SSID: <strong>$radio->ssid</strong><br />\n";
-
echo " Device ID: <strong>$radio->device_id</strong><br />\n";
-
echo " Radiodev_counter: <strong>$radio->radiodev_counter</strong><br />\n";
-
echo " Distance: <strong>$radio->distance km</strong>\n";
-
-
-
-
-
-
echo "There was an error getting the nearest radios.<br />\n";
-
echo $gapi->getErrorsStr();
-
-
-
-
-
|