Diffstat (limited to 'libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp index fc2026f..21026e1 100644 --- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | |||
@@ -1,89 +1,97 @@ | |||
1 | #include <opie2/onetwork.h> | 1 | #include <opie2/onetwork.h> |
2 | #include <opie2/ostation.h> | ||
2 | #include <opie2/omanufacturerdb.h> | 3 | #include <opie2/omanufacturerdb.h> |
3 | 4 | ||
4 | int main( int argc, char** argv ) | 5 | int main( int argc, char** argv ) |
5 | { | 6 | { |
6 | qDebug( "OPIE Network Demo" ); | 7 | qDebug( "OPIE Network Demo" ); |
7 | 8 | ||
8 | ONetwork* net = ONetwork::instance(); | 9 | ONetwork* net = ONetwork::instance(); |
9 | 10 | ||
10 | ONetwork::InterfaceIterator it = net->iterator(); | 11 | ONetwork::InterfaceIterator it = net->iterator(); |
11 | 12 | ||
12 | while ( it.current() ) | 13 | while ( it.current() ) |
13 | { | 14 | { |
14 | qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); | 15 | qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); |
15 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); | 16 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); |
16 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) ); | 17 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) ); |
17 | qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() ); | 18 | qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() ); |
18 | qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) ); | 19 | qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) ); |
19 | qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) ); | 20 | qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) ); |
20 | qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); | 21 | qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); |
21 | if ( it.current()->isWireless() ) | 22 | if ( it.current()->isWireless() ) |
22 | { | 23 | { |
23 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); | 24 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); |
24 | qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); | 25 | qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); |
25 | qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); | 26 | qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); |
26 | qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); | 27 | qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); |
27 | 28 | ||
28 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) | 29 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) |
29 | //{ | 30 | //{ |
30 | qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP() ); | 31 | qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP().toString() ); |
31 | //} | 32 | //} |
32 | 33 | ||
33 | // nickname | 34 | // nickname |
34 | qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); | 35 | qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); |
35 | iface->setNickName( "MyNickName" ); | 36 | iface->setNickName( "MyNickName" ); |
36 | if ( iface->nickName() != "MyNickName" ) | 37 | if ( iface->nickName() != "MyNickName" ) |
37 | qDebug( "DEMO: Warning! Can't change nickname" ); | 38 | qDebug( "DEMO: Warning! Can't change nickname" ); |
38 | else | 39 | else |
39 | qDebug( "DEMO: Nickname change successful." ); | 40 | qDebug( "DEMO: Nickname change successful." ); |
40 | 41 | ||
41 | // operation mode | 42 | // operation mode |
42 | qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() ); | 43 | qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() ); |
43 | iface->setMode( "adhoc" ); | 44 | iface->setMode( "adhoc" ); |
44 | if ( iface->mode() != "adhoc" ) | 45 | if ( iface->mode() != "adhoc" ) |
45 | qDebug( "DEMO: Warning! Can't change operation mode" ); | 46 | qDebug( "DEMO: Warning! Can't change operation mode" ); |
46 | else | 47 | else |
47 | qDebug( "DEMO: Operation Mode change successful." ); | 48 | qDebug( "DEMO: Operation Mode change successful." ); |
48 | 49 | ||
49 | // RF channel | 50 | // RF channel |
50 | qDebug( "DEMO: Current Channel is '%d'", iface->channel() ); | 51 | qDebug( "DEMO: Current Channel is '%d'", iface->channel() ); |
51 | iface->setChannel( 1 ); | 52 | iface->setChannel( 1 ); |
52 | if ( iface->channel() != 1 ) | 53 | if ( iface->channel() != 1 ) |
53 | qDebug( "DEMO: Warning! Can't change RF channel" ); | 54 | qDebug( "DEMO: Warning! Can't change RF channel" ); |
54 | else | 55 | else |
55 | qDebug( "DEMO: RF channel change successful." ); | 56 | qDebug( "DEMO: RF channel change successful." ); |
56 | 57 | ||
57 | iface->setMode( "managed" ); | 58 | iface->setMode( "managed" ); |
58 | 59 | ||
59 | // network scan | 60 | // network scan |
60 | 61 | ||
61 | int stations = iface->scanNetwork(); | 62 | OStationList* stations = iface->scanNetwork(); |
62 | if ( stations != -1 ) | 63 | if ( stations ) |
63 | { | 64 | { |
64 | qDebug( "DEMO: # of stations around = %d", stations ); | 65 | qDebug( "DEMO: # of stations around = %d", stations->count() ); |
66 | OStation* station; | ||
67 | for ( station = stations->first(); station != 0; station = stations->next() ) | ||
68 | { | ||
69 | qDebug( "DEMO: station dump following..." ); | ||
70 | station->dump(); | ||
71 | } | ||
65 | } | 72 | } |
73 | |||
66 | else | 74 | else |
67 | { | 75 | { |
68 | qDebug( "DEMO: Warning! Scan didn't work!" ); | 76 | qDebug( "DEMO: Warning! Scan didn't work!" ); |
69 | } | 77 | } |
70 | 78 | ||
71 | /* | 79 | /* |
72 | 80 | ||
73 | // first some wrong calls to check if this is working | 81 | // first some wrong calls to check if this is working |
74 | iface->setPrivate( "seppel", 10 ); | 82 | iface->setPrivate( "seppel", 10 ); |
75 | iface->setPrivate( "monitor", 0 ); | 83 | iface->setPrivate( "monitor", 0 ); |
76 | 84 | ||
77 | // now the real deal | 85 | // now the real deal |
78 | iface->setPrivate( "monitor", 2, 2, 3 ); | 86 | iface->setPrivate( "monitor", 2, 2, 3 ); |
79 | 87 | ||
80 | // trying to set hw address to 12:34:56:AB:CD:EF | 88 | // trying to set hw address to 12:34:56:AB:CD:EF |
81 | 89 | ||
82 | /* | 90 | /* |
83 | 91 | ||
84 | OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); | 92 | OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); |
85 | iface->setUp( false ); | 93 | iface->setUp( false ); |
86 | iface->setMacAddress( addr ); | 94 | iface->setMacAddress( addr ); |
87 | iface->setUp( true ); | 95 | iface->setUp( true ); |
88 | qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() ); | 96 | qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() ); |
89 | 97 | ||