author | mickeyl <mickeyl> | 2005-01-29 14:09:25 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-01-29 14:09:25 (UTC) |
commit | 7b06e36fe27adc6a4fde2004eac13aaf8c0f0f02 (patch) (unidiff) | |
tree | 5b38b6eb9d8430b0a96a2e156995bb421cc1a570 /examples/opienet/onetworkdemo | |
parent | 0db5704f66f0d08f9928f749774ee0f37bb0250d (diff) | |
download | opie-7b06e36fe27adc6a4fde2004eac13aaf8c0f0f02.zip opie-7b06e36fe27adc6a4fde2004eac13aaf8c0f0f02.tar.gz opie-7b06e36fe27adc6a4fde2004eac13aaf8c0f0f02.tar.bz2 |
examples start to appear here
Diffstat (limited to 'examples/opienet/onetworkdemo') (more/less context) (ignore whitespace changes)
-rw-r--r-- | examples/opienet/onetworkdemo/.cvsignore | 8 | ||||
-rw-r--r-- | examples/opienet/onetworkdemo/onetworkdemo.cpp | 176 | ||||
-rw-r--r-- | examples/opienet/onetworkdemo/onetworkdemo.pro | 12 |
3 files changed, 196 insertions, 0 deletions
diff --git a/examples/opienet/onetworkdemo/.cvsignore b/examples/opienet/onetworkdemo/.cvsignore new file mode 100644 index 0000000..c2638e5 --- a/dev/null +++ b/examples/opienet/onetworkdemo/.cvsignore | |||
@@ -0,0 +1,8 @@ | |||
1 | onetworkdemo | ||
2 | Makefile* | ||
3 | obj | ||
4 | moc* | ||
5 | *moc | ||
6 | *.o | ||
7 | ~* | ||
8 | |||
diff --git a/examples/opienet/onetworkdemo/onetworkdemo.cpp b/examples/opienet/onetworkdemo/onetworkdemo.cpp new file mode 100644 index 0000000..e0c93a2 --- a/dev/null +++ b/examples/opienet/onetworkdemo/onetworkdemo.cpp | |||
@@ -0,0 +1,176 @@ | |||
1 | /* | ||
2 | =. This file is part of the Opie Project | ||
3 | .=l. Copyright (C) 2004 Opie Team <opie-devel@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 */ | ||
30 | #include <opie2/onetwork.h> | ||
31 | #include <opie2/ostation.h> | ||
32 | #include <opie2/omanufacturerdb.h> | ||
33 | #include <opie2/odebug.h> | ||
34 | |||
35 | /* STD */ | ||
36 | #include <unistd.h> | ||
37 | |||
38 | using namespace Opie::Net; | ||
39 | |||
40 | int main( int argc, char** argv ) | ||
41 | { | ||
42 | odebug << "OPIE Network Demo" << oendl; | ||
43 | |||
44 | ONetwork* net = ONetwork::instance(); | ||
45 | |||
46 | ONetwork::InterfaceIterator it = net->iterator(); | ||
47 | |||
48 | while ( it.current() ) | ||
49 | { | ||
50 | odebug << "DEMO: ONetwork contains Interface '" << it.current()->name() << "'" << oendl; | ||
51 | odebug << "DEMO: Datalink code is '" << it.current()->dataLinkType() << "'" << oendl; | ||
52 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString() << "'" << oendl; | ||
53 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString(true) << "'" << oendl; | ||
54 | odebug << "DEMO: MAC Manufacturer seems to be '" << it.current()->macAddress().manufacturer() << "'" << oendl; | ||
55 | odebug << "DEMO: Manufacturertest1 = '" << OManufacturerDB::instance()->lookupExt( "08:00:87" ) << "'" << oendl; | ||
56 | odebug << "DEMO: Manufacturertest2 = '" << OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) << "'" << oendl; | ||
57 | odebug << "Demo: IPv4 Address is '" << it.current()->ipV4Address() << "'" << oendl; | ||
58 | if ( it.current()->isWireless() ) | ||
59 | { | ||
60 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); | ||
61 | odebug << "DEMO: '" << iface->name() << "' seems to feature the wireless extensions." << oendl; | ||
62 | odebug << "DEMO: Current SSID is '" << iface->SSID() << "'" << oendl; | ||
63 | odebug << "DEMO: Antenna is tuned to '" << iface->frequency() << "', that is channel " << iface->channel() << "" << oendl; | ||
64 | |||
65 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) | ||
66 | //{ | ||
67 | //odebug << "DEMO: Associated AP has MAC Address '" << iface->associatedAP().toString() << "'" << oendl; | ||
68 | //} | ||
69 | |||
70 | /* | ||
71 | |||
72 | // nickname | ||
73 | odebug << "DEMO: Current NickName is '" << iface->nickName() << "'" << oendl; | ||
74 | iface->setNickName( "MyNickName" ); | ||
75 | if ( iface->nickName() != "MyNickName" ) | ||
76 | odebug << "DEMO: Warning! Can't change nickname" << oendl; | ||
77 | else | ||
78 | odebug << "DEMO: Nickname change successful." << oendl; | ||
79 | |||
80 | /* | ||
81 | |||
82 | // operation mode | ||
83 | odebug << "DEMO: Current OperationMode is '" << iface->mode() << "'" << oendl; | ||
84 | iface->setMode( "adhoc" ); | ||
85 | if ( iface->mode() != "adhoc" ) | ||
86 | odebug << "DEMO: Warning! Can't change operation mode" << oendl; | ||
87 | else | ||
88 | odebug << "DEMO: Operation Mode change successful." << oendl; | ||
89 | |||
90 | // RF channel | ||
91 | odebug << "DEMO: Current Channel is '" << iface->channel() << "'" << oendl; | ||
92 | iface->setChannel( 1 ); | ||
93 | if ( iface->channel() != 1 ) | ||
94 | odebug << "DEMO: Warning! Can't change RF channel" << oendl; | ||
95 | else | ||
96 | odebug << "DEMO: RF channel change successful." << oendl; | ||
97 | |||
98 | iface->setMode( "managed" ); | ||
99 | |||
100 | */ | ||
101 | |||
102 | /* | ||
103 | |||
104 | // network scan | ||
105 | |||
106 | OStationList* stations = iface->scanNetwork(); | ||
107 | if ( stations ) | ||
108 | { | ||
109 | odebug << "DEMO: # of stations around = " << stations->count() << "" << oendl; | ||
110 | OStation* station; | ||
111 | for ( station = stations->first(); station != 0; station = stations->next() ) | ||
112 | { | ||
113 | odebug << "DEMO: station dump following..." << oendl; | ||
114 | station->dump(); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | else | ||
119 | { | ||
120 | odebug << "DEMO: Warning! Scan didn't work!" << oendl; | ||
121 | } | ||
122 | |||
123 | /* | ||
124 | |||
125 | // first some wrong calls to check if this is working | ||
126 | iface->setPrivate( "seppel", 10 ); | ||
127 | iface->setPrivate( "monitor", 0 ); | ||
128 | |||
129 | // now the real deal | ||
130 | iface->setPrivate( "monitor", 2, 2, 3 ); | ||
131 | |||
132 | // trying to set hw address to 12:34:56:AB:CD:EF | ||
133 | |||
134 | /* | ||
135 | |||
136 | OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); | ||
137 | iface->setUp( false ); | ||
138 | iface->setMacAddress( addr ); | ||
139 | iface->setUp( true ); | ||
140 | odebug << "DEMO: MAC Address now is '" << iface->macAddress().toString() << "'" << oendl; | ||
141 | |||
142 | */ | ||
143 | |||
144 | // monitor test | ||
145 | |||
146 | |||
147 | |||
148 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | ||
149 | iface->setMode( "monitor" ); | ||
150 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | ||
151 | |||
152 | sleep( 1 ); | ||
153 | |||
154 | iface->setChannel( 1 ); | ||
155 | iface->setMode( "managed" ); | ||
156 | |||
157 | //sleep( 1 ); | ||
158 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | ||
159 | |||
160 | /*iface->setMode( "adhoc" ); | ||
161 | sleep( 1 ); | ||
162 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | ||
163 | iface->setMode( "managed" ); | ||
164 | sleep( 1 ); | ||
165 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | ||
166 | iface->setMode( "master" ); | ||
167 | sleep( 1 ); | ||
168 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; */ | ||
169 | |||
170 | } | ||
171 | ++it; | ||
172 | } | ||
173 | |||
174 | return 0; | ||
175 | |||
176 | } | ||
diff --git a/examples/opienet/onetworkdemo/onetworkdemo.pro b/examples/opienet/onetworkdemo/onetworkdemo.pro new file mode 100644 index 0000000..cf293b5 --- a/dev/null +++ b/examples/opienet/onetworkdemo/onetworkdemo.pro | |||
@@ -0,0 +1,12 @@ | |||
1 | TEMPLATE = app | ||
2 | CONFIG = qt warn_on | ||
3 | HEADERS = | ||
4 | SOURCES = onetworkdemo.cpp | ||
5 | INCLUDEPATH += $(OPIEDIR)/include | ||
6 | DEPENDPATH += $(OPIEDIR)/include | ||
7 | LIBS += -lopiecore2 -lopienet2 | ||
8 | TARGET = onetworkdemo | ||
9 | MOC_DIR = moc | ||
10 | OBJECTS_DIR = obj | ||
11 | |||
12 | include( $(OPIEDIR)/include.pro ) | ||