Diffstat (limited to 'libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | 97 |
1 files changed, 64 insertions, 33 deletions
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp index 4f8af60..65866af 100644 --- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | |||
@@ -1 +1,30 @@ | |||
1 | /* | ||
2 | =. This file is part of the Opie Project | ||
3 | .=l. Copyright (C) 2004 Opie Team <opie@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | /* OPIE */ | ||
1 | #include <opie2/onetwork.h> | 30 | #include <opie2/onetwork.h> |
@@ -3,3 +32,5 @@ | |||
3 | #include <opie2/omanufacturerdb.h> | 32 | #include <opie2/omanufacturerdb.h> |
33 | #include <opie2/odebug.h> | ||
4 | 34 | ||
35 | /* STD */ | ||
5 | #include <unistd.h> | 36 | #include <unistd.h> |
@@ -10,3 +41,3 @@ int main( int argc, char** argv ) | |||
10 | { | 41 | { |
11 | qDebug( "OPIE Network Demo" ); | 42 | odebug << "OPIE Network Demo" << oendl; |
12 | 43 | ||
@@ -18,10 +49,10 @@ int main( int argc, char** argv ) | |||
18 | { | 49 | { |
19 | qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); | 50 | odebug << "DEMO: ONetwork contains Interface '" << it.current()->name() << "'" << oendl; |
20 | qDebug( "DEMO: Datalink code is '%d'", it.current()->dataLinkType() ); | 51 | odebug << "DEMO: Datalink code is '" << it.current()->dataLinkType() << "'" << oendl; |
21 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); | 52 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString() << "'" << oendl; |
22 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) ); | 53 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString(true) << "'" << oendl; |
23 | qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() ); | 54 | odebug << "DEMO: MAC Manufacturer seems to be '" << it.current()->macAddress().manufacturer() << "'" << oendl; |
24 | qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) ); | 55 | odebug << "DEMO: Manufacturertest1 = '" << OManufacturerDB::instance()->lookupExt( "08:00:87" ) << "'" << oendl; |
25 | qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) ); | 56 | odebug << "DEMO: Manufacturertest2 = '" << OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) << "'" << oendl; |
26 | qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); | 57 | odebug << "Demo: IPv4 Address is '" << it.current()->ipV4Address() << "'" << oendl; |
27 | if ( it.current()->isWireless() ) | 58 | if ( it.current()->isWireless() ) |
@@ -29,5 +60,5 @@ int main( int argc, char** argv ) | |||
29 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); | 60 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); |
30 | qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); | 61 | odebug << "DEMO: '" << iface->name() << "' seems to feature the wireless extensions." << oendl; |
31 | qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); | 62 | odebug << "DEMO: Current SSID is '" << iface->SSID() << "'" << oendl; |
32 | qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); | 63 | odebug << "DEMO: Antenna is tuned to '" << iface->frequency() << "', that is channel " << iface->channel() << "" << oendl; |
33 | 64 | ||
@@ -35,3 +66,3 @@ int main( int argc, char** argv ) | |||
35 | //{ | 66 | //{ |
36 | //qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP().toString() ); | 67 | //odebug << "DEMO: Associated AP has MAC Address '" << iface->associatedAP().toString() << "'" << oendl; |
37 | //} | 68 | //} |
@@ -41,8 +72,8 @@ int main( int argc, char** argv ) | |||
41 | // nickname | 72 | // nickname |
42 | qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); | 73 | odebug << "DEMO: Current NickName is '" << iface->nickName() << "'" << oendl; |
43 | iface->setNickName( "MyNickName" ); | 74 | iface->setNickName( "MyNickName" ); |
44 | if ( iface->nickName() != "MyNickName" ) | 75 | if ( iface->nickName() != "MyNickName" ) |
45 | qDebug( "DEMO: Warning! Can't change nickname" ); | 76 | odebug << "DEMO: Warning! Can't change nickname" << oendl; |
46 | else | 77 | else |
47 | qDebug( "DEMO: Nickname change successful." ); | 78 | odebug << "DEMO: Nickname change successful." << oendl; |
48 | 79 | ||
@@ -51,16 +82,16 @@ int main( int argc, char** argv ) | |||
51 | // operation mode | 82 | // operation mode |
52 | qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() ); | 83 | odebug << "DEMO: Current OperationMode is '" << iface->mode() << "'" << oendl; |
53 | iface->setMode( "adhoc" ); | 84 | iface->setMode( "adhoc" ); |
54 | if ( iface->mode() != "adhoc" ) | 85 | if ( iface->mode() != "adhoc" ) |
55 | qDebug( "DEMO: Warning! Can't change operation mode" ); | 86 | odebug << "DEMO: Warning! Can't change operation mode" << oendl; |
56 | else | 87 | else |
57 | qDebug( "DEMO: Operation Mode change successful." ); | 88 | odebug << "DEMO: Operation Mode change successful." << oendl; |
58 | 89 | ||
59 | // RF channel | 90 | // RF channel |
60 | qDebug( "DEMO: Current Channel is '%d'", iface->channel() ); | 91 | odebug << "DEMO: Current Channel is '" << iface->channel() << "'" << oendl; |
61 | iface->setChannel( 1 ); | 92 | iface->setChannel( 1 ); |
62 | if ( iface->channel() != 1 ) | 93 | if ( iface->channel() != 1 ) |
63 | qDebug( "DEMO: Warning! Can't change RF channel" ); | 94 | odebug << "DEMO: Warning! Can't change RF channel" << oendl; |
64 | else | 95 | else |
65 | qDebug( "DEMO: RF channel change successful." ); | 96 | odebug << "DEMO: RF channel change successful." << oendl; |
66 | 97 | ||
@@ -77,3 +108,3 @@ int main( int argc, char** argv ) | |||
77 | { | 108 | { |
78 | qDebug( "DEMO: # of stations around = %d", stations->count() ); | 109 | odebug << "DEMO: # of stations around = " << stations->count() << "" << oendl; |
79 | OStation* station; | 110 | OStation* station; |
@@ -81,3 +112,3 @@ int main( int argc, char** argv ) | |||
81 | { | 112 | { |
82 | qDebug( "DEMO: station dump following..." ); | 113 | odebug << "DEMO: station dump following..." << oendl; |
83 | station->dump(); | 114 | station->dump(); |
@@ -88,3 +119,3 @@ int main( int argc, char** argv ) | |||
88 | { | 119 | { |
89 | qDebug( "DEMO: Warning! Scan didn't work!" ); | 120 | odebug << "DEMO: Warning! Scan didn't work!" << oendl; |
90 | } | 121 | } |
@@ -108,3 +139,3 @@ int main( int argc, char** argv ) | |||
108 | iface->setUp( true ); | 139 | iface->setUp( true ); |
109 | qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() ); | 140 | odebug << "DEMO: MAC Address now is '" << iface->macAddress().toString() << "'" << oendl; |
110 | 141 | ||
@@ -114,7 +145,7 @@ int main( int argc, char** argv ) | |||
114 | 145 | ||
115 | |||
116 | 146 | ||
117 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | 147 | |
148 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | ||
118 | iface->setMode( "monitor" ); | 149 | iface->setMode( "monitor" ); |
119 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | 150 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
120 | 151 | ||
@@ -126,3 +157,3 @@ int main( int argc, char** argv ) | |||
126 | //sleep( 1 ); | 157 | //sleep( 1 ); |
127 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | 158 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
128 | 159 | ||
@@ -130,9 +161,9 @@ int main( int argc, char** argv ) | |||
130 | sleep( 1 ); | 161 | sleep( 1 ); |
131 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | 162 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
132 | iface->setMode( "managed" ); | 163 | iface->setMode( "managed" ); |
133 | sleep( 1 ); | 164 | sleep( 1 ); |
134 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | 165 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
135 | iface->setMode( "master" ); | 166 | iface->setMode( "master" ); |
136 | sleep( 1 ); | 167 | sleep( 1 ); |
137 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() );*/ | 168 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; */ |
138 | 169 | ||