default
[ class tree: default ] [ index: default ] [ all elements ]

Source for file examples.guifi_api.radio.php

Documentation is available at examples.guifi_api.radio.php

  1. <?php 
  2. // The source code packaged with this file is Free Software, Copyright (C) 2005 by
  3. // Eduard Duran <eduard.duran at iglu.cat>.
  4. // It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
  5. // You can get copies of the licenses here:
  6. //         http://www.affero.org/oagpl.html
  7. // AFFERO GENERAL PUBLIC LICENSE is also included in the file called "LICENSE.txt".
  8.  
  9. require 'guifi_api.php' );
  10.  
  11. /**
  12.  * Configuration of authentication against guifi.net
  13.  */
  14. $username "eduard.duran";
  15. $password "12345";
  16.  
  17. /**
  18.  * Code from here!
  19.  */
  20. $gapi new guifiAPI$username$password );
  21.  
  22. $action $_GET['action'];
  23.  
  24. switch$action {
  25.     case 'add':
  26.         $mode "ap";
  27.         $device_id 19534;
  28.         $mac 'AA:BB:CC:DD:EE:FA';
  29.         
  30.         $radio array();
  31.         $radio['antenna_angle'120// 60ยบ
  32.         $radio['antenna_gain'"21";
  33.         $radio['antenna_azimuth'30;
  34.         $radio['protocol''802.11b';
  35.         $radio['channel'13;
  36.         $radio['clients_accepted''Yes';
  37.  
  38.         $added $gapi->addRadio$mode$device_id$mac$radio );
  39.         if$added {
  40.             echo "Radio created correctly!!<br />\n<br />\n";
  41.             echo "The identificator of the new radio is: radiodev_counter = <strong>$added->radiodev_counter</strong>";
  42.             if$added->interfaces {
  43.                 echo "<br />\n<br />\n";
  44.                 echo "New interfaces added!:<br />";
  45.                 echo '<ul>';
  46.                 foreach$added->interfaces as $interface {
  47.                     echo '<li>';
  48.                     echo "Type: $interface->interface_type<br />";
  49.                     if$interface->ipv4 {
  50.                         echo "New IPv4 configuration:<br />";
  51.                         foreach$interface->ipv4 as $ipv4 {
  52.                             echo "ipv4_type = $ipv4->ipv4_type<br />";
  53.                             echo "ipv4 = $ipv4->ipv4 <br />";
  54.                             echo "netmask = $ipv4->netmask<br />";
  55.                         }
  56.                     }
  57.                     echo '</li>';
  58.                 }
  59.                 echo '</ul>';
  60.             }
  61.         else {
  62.             echo "There was an error adding the radio.<br />\n";
  63.             echo $gapi->getErrorsStr();
  64.         }
  65.         break;
  66.     case 'update':
  67.         $device_id 19534;
  68.         $radiodev_counter 0;
  69.         
  70.         $radio array();
  71.         $radio['antenna_angle'90;
  72.         $radio['antenna_gain'14;
  73.         
  74.         $updated $gapi->updateRadio$device_id$radiodev_counter$radio );
  75.         if$updated {
  76.             echo "Radio <strong>$radiodev_counter</strong> at device <strong>$device_id</strong> was updated correctly.<br />\n<br />\n";
  77.         else {
  78.             echo "There was an error updating the device.<br />\n";
  79.             echo $gapi->getErrorsStr();
  80.         }
  81.         break;
  82.     case 'delete':
  83.         $device_id 19534;
  84.         $radiodev_counter 0;
  85.         
  86.         $removed $gapi->removeRadio$device_id$radiodev_counter );
  87.         if$removed {
  88.             echo "Radio <strong>$radiodev_counter</strong> at device <strong>$device_id</strong> removed correctly.<br />\n<br />\n";
  89.         else {
  90.             echo "There was an error deleting the radio.<br />\n";
  91.             echo $gapi->getErrorsStr();
  92.         }
  93.         break;
  94.     case 'nearest':
  95.         $node_id 14095;
  96.         $nearest $gapi->nearestRadio$node_id );
  97.         if$nearest {
  98.             if$nearest->radios {
  99.                 $radios $nearest->radios;
  100.                 echo "<br />\n";
  101.                 echo "Found some radios:\n";
  102.                 echo '<ul>' "\n";
  103.                 foreach$radios as $radio {
  104.                     echo "<li>\n";
  105.                     echo "&nbsp;&nbsp;SSID: <strong>$radio->ssid</strong><br />\n";
  106.                     echo "&nbsp;&nbsp;Device ID: <strong>$radio->device_id</strong><br />\n";
  107.                     echo "&nbsp;&nbsp;Radiodev_counter: <strong>$radio->radiodev_counter</strong><br />\n";
  108.                     echo "&nbsp;&nbsp;Distance: <strong>$radio->distance km</strong>\n";
  109.                     echo "</li>\n";
  110.                 }
  111.                 echo "</ul>\n";
  112.             }
  113.         else {
  114.             echo "There was an error getting the nearest radios.<br />\n";
  115.             echo $gapi->getErrorsStr();
  116.         }
  117.         break;
  118. }
  119.  
  120. ?>

Documentation generated on Sun, 10 Jan 2010 21:02:49 +0100 by phpDocumentor 1.4.3