added some support for signal strength
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 7 Dec 2010 03:41:03 +0000 (03:41 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 7 Dec 2010 03:41:03 +0000 (03:41 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@258 01035d8c-6547-0410-b346-abe4f91aad63

dilimesh/README.txt
dilimesh/dilimesh/dilimesh.html
dilimesh/scripts/S99sigstr [new file with mode: 0755]

index 7d0fd4c264d792e8cb6eba89c3d0d97e14b426a4..8c1e91b54019b07cfcc69fdd04392ac5186cc0f7 100644 (file)
@@ -85,7 +85,8 @@ Directories
   
   sigstr.sh      - script that runs on MP as a telnet daemon to return signal
                    strength of each node to getsig.cgi.  Experimental.
-
+  S99sigstr      - /etc/init.d Mesh Potato start upscript for sigstr.sh telnet
+                   daemon
 
 Software
 --------
@@ -149,6 +150,22 @@ Installation
     # ps | grep batman
     552 root      1564 S    batmand -s 10.130.1.1 ath0
 
+4/ (Optional) Signal strength daemon:
+
+  Copy these scripts to each MP in your mesh that you wish to read sis
+  strength from:
+  
+    $ cd dilimesh/script
+    $ scp sigstr.sh root@10.130.1.36:/usr/sbin
+    $ scp S99sigstr  root@10.130.1.36:/etc/rc.d
+  
+  Now start daemon on remote machine:
+
+    $ ssh root@10.130.1.36 '/etc/rc.d/S99sigstr'
+
+  Test if deamon is running
+
+   $ telnet 10.130.1.36 4950
 
 Tests
 -----
@@ -196,6 +213,15 @@ Tests
    $ cat /var/www/dilimesh/nodes.txt
    (empty file)
 
+7/ Test signal strength daemon:
+
+   $ telnet 10.130.1.1 4950
+   Trying 10.130.1.36...
+   Connected to 10.130.1.36.
+   Escape character is '^]'.
+
+   10.130.1.1 10.130.1.56 10.130.1.14
+   -64 -90 -75
 
 Using Dilimesh
 --------------
index d4ca6cbfac7d39c1761f18d70afb2847f9c67ccd..793800ffb785b38efbde6094526a7da8399b184c 100644 (file)
   var drag_packet_loss;
   var drag_in_progress;
  
+  // pathes, vis server data, node list
+
   var pathes = []; // array of lines, used to delete them
   var vis    = []; // array of vis server information
   var nodes  = []; // database of nodes we keep in memory
                    // mirrors nodes.txt but also store marker locations
 
+  // states for polling sig strength
+
+  var sigstr_node_index = 0;
+
   // Called when we load page
 
   function initialize() {
       document.getElementById('ping_nodes').innerHTML = html;
     }
 
+    // fire off next sig strength
+
+    if (nodes[sigstr_node_index] != undefined) {
+      downloadUrl("/cgi-bin/getsig.cgi?ip=" + nodes[sigstr_node_index].ip, processgetSig);
+      document.getElementById('sigstr_current_node').innerHTML = nodes[sigstr_node_index].ip;
+    }
+    sigstr_node_index++;
+    if (sigstr_node_index >= nodes.length)
+      sigstr_node_index = 0;
   }
 
 
       var packet_loss_formatted = Math.round(nodes[j].packet_loss*100);
 
       nodes[j].marker.setTitle(nodes[j].ip + ' Packet Loss: ' + packet_loss_formatted + '%');  
-      nodes[j].infowindow.setContent(nodes[j].ip + '<br>Packet Loss: ' + packet_loss_formatted + '%');  
+      var html = nodes[j].ip + '<br>Packet Loss: ' + packet_loss_formatted + '%';
+      if (nodes[j].neighbour_ips != undefined) {
+        for(var i=0; i<nodes[j].neighbour_ips.length; i++) {
+          html += '<br>' + trim(nodes[j].neighbour_ips[i]) + ' ' + trim(nodes[j].neighbour_sigs[i]) + ' dBm';
+       }
+      }
+      nodes[j].infowindow.setContent(html);  
     }  
 
     document.getElementById('nodes_total').innerHTML = nodes.length;
         if (text_line == 0)
           ip = lines[j];
         if (text_line == 1)
-          neighour_ips = lines[j].split(" ");
+          neighbour_ips = lines[j].split(" ");
         if (text_line == 2)
-          neighour_sigs = lines[j].split(" ");
+          neighbour_sigs = trim(lines[j]).split(" ");
         text_line++;
       }
     }
 
-    // walk nodes list match ip
-
-    for (var j=0; j<nodes.length; j++) {
-
-      if (nodes[j].ip == ip) {
-
-        // update info window
-
-        var packet_loss_formatted = Math.round(nodes[j].packet_loss*100);
-        var content = nodes[j].ip;
-        content += '<br>Packet Loss: ' + packet_loss_formatted + '%<br>';
+    if (text_line == 3) {
  
-        if (text_line == 3) {
-          for(var i=0; i<neighour_ips.length; i++) {
-            content += '<br>' + trim(neighour_ips[i]) + ': ' + trim(neighour_sigs[i+1]) + ' dBm';   
-          }
-        }
-        else {
-          // check for error conditions
-
-          content += "<br>(No route or no sig strength daemon on that node)";
-        }
+     // walk nodes list to match ip
 
-        nodes[j].infowindow.setContent(content);        
-      }    
+      for (var j=0; j<nodes.length; j++) {
+        if (nodes[j].ip == ip) {
+          nodes[j].neighbour_ips  = neighbour_ips;
+          nodes[j].neighbour_sigs = neighbour_sigs;
+          var html="";
+          for(var i=0; i<neighbour_ips.length; i++) {
+            html += trim(neighbour_ips[i]) + ' ' + trim(neighbour_sigs[i]) + ' dBm';
+            if (i != (neighbour_ips.length-1))
+              html += '<br>';
+         }
+         document.getElementById('sigstr_last_node').innerHTML = ip;
+         document.getElementById('sigstr_results').innerHTML = html;
+        }    
+      }
     }
   }
 
       <h3>Contol Panel</h3>
       <form name="control_panel">
         <table>
-        <tr>
        <tr>
           <td width="5%">
           <td>Visualisation Server IP</td>
           <td>Debug Messages</td>
           <td><input type="checkbox" name="debug_enable" onclick="debugClicked()"></td>
         </tr>
-        <table>
+        </table>
       </form>
+
+      <h3>Signal Strength</h3>
+        <table>
+        <tr>
+         <td width="5%"></td>
+          <td>Currently Polling</td>
+          <td><div id="sigstr_current_node"></div></td>
+        </tr>
+        <tr>
+         <td></td>
+          <td>Last Node that<br>Responded</td>
+          <td><div id="sigstr_last_node"></div></td>
+        </tr>
+        <tr>
+         <td></td>
+          <td valign=top>Results</td>
+          <td><div id="sigstr_results"></div></td>
+        </tr>
+        </table>
     </div>
 
     <div id="tests" style="width: 100%;">
diff --git a/dilimesh/scripts/S99sigstr b/dilimesh/scripts/S99sigstr
new file mode 100755 (executable)
index 0000000..a33f816
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+telnetd -l /usr/sbin/sigstr.sh -p 4950