-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.php
executable file
·66 lines (48 loc) · 1.24 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/php
<?php
/*
For all Ubus Calls, refer to:
https://openwrt.org/docs/techref/ubus
*/
// Fill this
$cfg['host']="OpenWRT IP ADDRESS";
$cfg['user']="root";
$cfg['pass']="PASSWORD";
$debug=false;
// --------------------------------------------------------------------------
require_once(dirname(__FILE__)."/src/owa.php");
$owa=new OpenWrtApi("http://".$cfg['host'] , $debug);
$owa->UbusLogin($cfg['user'], $cfg['pass']);
echo "<pre>";
TestUbusCall('system','board');
TestUbusCall('system','info');
// grab all interfaces
if($devices=TestUbusCall('luci-rpc','getWirelessDevices')){
foreach($devices as $dev => $info){
foreach($info['interfaces'] as $interface ){
$ifs[]=$interface['ifname'];
}
}
// grab all stations / interface
if(is_array($ifs)){
echo "--- STATIONS ----------------------------------------------------------------\n";
$r=$owa->UbusListStations($ifs);
print_r($r);
}
}
// -------------------------------------------------------------------
function TestUbusCall($path,$meth, $arg=array()){
global $owa;
echo str_pad("## $path - $meth ",80,'#')."\n";
$r=$owa->UbusCall($path,$meth, $arg);
if($r){
print_r($r);
return $r;
}
else{
echo " -> ERROR: ";
print_r($owa->GetErrors());
}
echo "\n";
}
?>