-rw-r--r-- | libopie2/examples/opiecore/odebugdemo/odebugdemo.pro | 3 | ||||
-rw-r--r-- | libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | 37 |
2 files changed, 38 insertions, 2 deletions
diff --git a/libopie2/examples/opiecore/odebugdemo/odebugdemo.pro b/libopie2/examples/opiecore/odebugdemo/odebugdemo.pro index c52cd02..aa37394 100644 --- a/libopie2/examples/opiecore/odebugdemo/odebugdemo.pro +++ b/libopie2/examples/opiecore/odebugdemo/odebugdemo.pro | |||
@@ -1,19 +1,20 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on debug | 2 | CONFIG = qt warn_on debug |
3 | HEADERS = | 3 | HEADERS = |
4 | SOURCES = odebugdemo.cpp | 4 | SOURCES = odebugdemo.cpp |
5 | INCLUDEPATH += $(OPIEDIR)/include | 5 | INCLUDEPATH += $(OPIEDIR)/include |
6 | DEPENDPATH += $(OPIEDIR)/include | 6 | DEPENDPATH += $(OPIEDIR)/include |
7 | LIBS += -lopiecore2 | 7 | LIBS += -lopiecore2 |
8 | TARGET = odebugdemo | 8 | TARGET = odebugdemo |
9 | 9 | ||
10 | MOC_DIR = moc | ||
11 | OBJECTS_DIR = obj | 10 | OBJECTS_DIR = obj |
12 | 11 | ||
13 | !contains( platform, x11 ) { | 12 | !contains( platform, x11 ) { |
14 | include ( $(OPIEDIR)/include.pro ) | 13 | include ( $(OPIEDIR)/include.pro ) |
15 | } | 14 | } |
16 | 15 | ||
17 | contains( platform, x11 ) { | 16 | contains( platform, x11 ) { |
18 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib | 17 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib |
19 | } | 18 | } |
19 | |||
20 | MOC_DIR = moc | ||
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp index 21026e1..06b8b19 100644 --- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | |||
@@ -1,107 +1,142 @@ | |||
1 | #include <opie2/onetwork.h> | 1 | #include <opie2/onetwork.h> |
2 | #include <opie2/ostation.h> | 2 | #include <opie2/ostation.h> |
3 | #include <opie2/omanufacturerdb.h> | 3 | #include <opie2/omanufacturerdb.h> |
4 | 4 | ||
5 | #include <unistd.h> | ||
6 | |||
5 | int main( int argc, char** argv ) | 7 | int main( int argc, char** argv ) |
6 | { | 8 | { |
7 | qDebug( "OPIE Network Demo" ); | 9 | qDebug( "OPIE Network Demo" ); |
8 | 10 | ||
9 | ONetwork* net = ONetwork::instance(); | 11 | ONetwork* net = ONetwork::instance(); |
10 | 12 | ||
11 | ONetwork::InterfaceIterator it = net->iterator(); | 13 | ONetwork::InterfaceIterator it = net->iterator(); |
12 | 14 | ||
13 | while ( it.current() ) | 15 | while ( it.current() ) |
14 | { | 16 | { |
15 | qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); | 17 | qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); |
18 | qDebug( "DEMO: Datalink code is '%d'", it.current()->dataLinkType() ); | ||
16 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); | 19 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); |
17 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) ); | 20 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) ); |
18 | qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() ); | 21 | qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() ); |
19 | qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) ); | 22 | qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) ); |
20 | qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) ); | 23 | qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) ); |
21 | qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); | 24 | qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); |
22 | if ( it.current()->isWireless() ) | 25 | if ( it.current()->isWireless() ) |
23 | { | 26 | { |
24 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); | 27 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); |
25 | qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); | 28 | qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); |
26 | qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); | 29 | qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); |
27 | qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); | 30 | qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); |
28 | 31 | ||
29 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) | 32 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) |
30 | //{ | 33 | //{ |
31 | qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP().toString() ); | 34 | //qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP().toString() ); |
32 | //} | 35 | //} |
33 | 36 | ||
37 | /* | ||
38 | |||
34 | // nickname | 39 | // nickname |
35 | qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); | 40 | qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); |
36 | iface->setNickName( "MyNickName" ); | 41 | iface->setNickName( "MyNickName" ); |
37 | if ( iface->nickName() != "MyNickName" ) | 42 | if ( iface->nickName() != "MyNickName" ) |
38 | qDebug( "DEMO: Warning! Can't change nickname" ); | 43 | qDebug( "DEMO: Warning! Can't change nickname" ); |
39 | else | 44 | else |
40 | qDebug( "DEMO: Nickname change successful." ); | 45 | qDebug( "DEMO: Nickname change successful." ); |
41 | 46 | ||
47 | /* | ||
48 | |||
42 | // operation mode | 49 | // operation mode |
43 | qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() ); | 50 | qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() ); |
44 | iface->setMode( "adhoc" ); | 51 | iface->setMode( "adhoc" ); |
45 | if ( iface->mode() != "adhoc" ) | 52 | if ( iface->mode() != "adhoc" ) |
46 | qDebug( "DEMO: Warning! Can't change operation mode" ); | 53 | qDebug( "DEMO: Warning! Can't change operation mode" ); |
47 | else | 54 | else |
48 | qDebug( "DEMO: Operation Mode change successful." ); | 55 | qDebug( "DEMO: Operation Mode change successful." ); |
49 | 56 | ||
50 | // RF channel | 57 | // RF channel |
51 | qDebug( "DEMO: Current Channel is '%d'", iface->channel() ); | 58 | qDebug( "DEMO: Current Channel is '%d'", iface->channel() ); |
52 | iface->setChannel( 1 ); | 59 | iface->setChannel( 1 ); |
53 | if ( iface->channel() != 1 ) | 60 | if ( iface->channel() != 1 ) |
54 | qDebug( "DEMO: Warning! Can't change RF channel" ); | 61 | qDebug( "DEMO: Warning! Can't change RF channel" ); |
55 | else | 62 | else |
56 | qDebug( "DEMO: RF channel change successful." ); | 63 | qDebug( "DEMO: RF channel change successful." ); |
57 | 64 | ||
58 | iface->setMode( "managed" ); | 65 | iface->setMode( "managed" ); |
59 | 66 | ||
67 | */ | ||
68 | |||
69 | /* | ||
70 | |||
60 | // network scan | 71 | // network scan |
61 | 72 | ||
62 | OStationList* stations = iface->scanNetwork(); | 73 | OStationList* stations = iface->scanNetwork(); |
63 | if ( stations ) | 74 | if ( stations ) |
64 | { | 75 | { |
65 | qDebug( "DEMO: # of stations around = %d", stations->count() ); | 76 | qDebug( "DEMO: # of stations around = %d", stations->count() ); |
66 | OStation* station; | 77 | OStation* station; |
67 | for ( station = stations->first(); station != 0; station = stations->next() ) | 78 | for ( station = stations->first(); station != 0; station = stations->next() ) |
68 | { | 79 | { |
69 | qDebug( "DEMO: station dump following..." ); | 80 | qDebug( "DEMO: station dump following..." ); |
70 | station->dump(); | 81 | station->dump(); |
71 | } | 82 | } |
72 | } | 83 | } |
73 | 84 | ||
74 | else | 85 | else |
75 | { | 86 | { |
76 | qDebug( "DEMO: Warning! Scan didn't work!" ); | 87 | qDebug( "DEMO: Warning! Scan didn't work!" ); |
77 | } | 88 | } |
78 | 89 | ||
79 | /* | 90 | /* |
80 | 91 | ||
81 | // first some wrong calls to check if this is working | 92 | // first some wrong calls to check if this is working |
82 | iface->setPrivate( "seppel", 10 ); | 93 | iface->setPrivate( "seppel", 10 ); |
83 | iface->setPrivate( "monitor", 0 ); | 94 | iface->setPrivate( "monitor", 0 ); |
84 | 95 | ||
85 | // now the real deal | 96 | // now the real deal |
86 | iface->setPrivate( "monitor", 2, 2, 3 ); | 97 | iface->setPrivate( "monitor", 2, 2, 3 ); |
87 | 98 | ||
88 | // trying to set hw address to 12:34:56:AB:CD:EF | 99 | // trying to set hw address to 12:34:56:AB:CD:EF |
89 | 100 | ||
90 | /* | 101 | /* |
91 | 102 | ||
92 | OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); | 103 | OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); |
93 | iface->setUp( false ); | 104 | iface->setUp( false ); |
94 | iface->setMacAddress( addr ); | 105 | iface->setMacAddress( addr ); |
95 | iface->setUp( true ); | 106 | iface->setUp( true ); |
96 | qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() ); | 107 | qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() ); |
97 | 108 | ||
98 | */ | 109 | */ |
99 | 110 | ||
111 | // monitor test | ||
112 | |||
113 | /* | ||
114 | |||
115 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | ||
116 | iface->setMode( "monitor" ); | ||
117 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | ||
118 | |||
119 | sleep( 1 ); */ | ||
120 | |||
121 | iface->setMode( "master" ); | ||
122 | |||
123 | //sleep( 1 ); | ||
124 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | ||
125 | |||
126 | /*iface->setMode( "adhoc" ); | ||
127 | sleep( 1 ); | ||
128 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | ||
129 | iface->setMode( "managed" ); | ||
130 | sleep( 1 ); | ||
131 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | ||
132 | iface->setMode( "master" ); | ||
133 | sleep( 1 ); | ||
134 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() );*/ | ||
100 | 135 | ||
101 | } | 136 | } |
102 | ++it; | 137 | ++it; |
103 | } | 138 | } |
104 | 139 | ||
105 | return 0; | 140 | return 0; |
106 | 141 | ||
107 | } | 142 | } |