author | wimpie <wimpie> | 2005-01-09 00:32:10 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-09 00:32:10 (UTC) |
commit | e54346d28b19d3ac671802a25e8c03f346693291 (patch) (unidiff) | |
tree | 0f8d6561e24a7ba36fd8a6ab1869aa470e1fdb36 /noncore/settings/networksettings2/opietooth2 | |
parent | 60a617583d0ccc793d9ea4465998d90ec208db58 (diff) | |
download | opie-e54346d28b19d3ac671802a25e8c03f346693291.zip opie-e54346d28b19d3ac671802a25e8c03f346693291.tar.gz opie-e54346d28b19d3ac671802a25e8c03f346693291.tar.bz2 |
Updated dependencies
NS2->app requires OT2Lib and NS2Lib
OT2Lib requires NS2Lib
Most plugins only require NS2Lib
Except
BTPlugin which requires als OT2Lib
Also renamed owarn -> odebug
Diffstat (limited to 'noncore/settings/networksettings2/opietooth2') (more/less context) (ignore whitespace changes)
11 files changed, 62 insertions, 55 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/OTDevice.cpp b/noncore/settings/networksettings2/opietooth2/OTDevice.cpp index 62f17a0..c6f7d5e 100644 --- a/noncore/settings/networksettings2/opietooth2/OTDevice.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTDevice.cpp | |||
@@ -58,199 +58,199 @@ bool OTDevice::attach(){ | |||
58 | if( needsAttach() && m_hciattachPid == 0 ) { | 58 | if( needsAttach() && m_hciattachPid == 0 ) { |
59 | QString Dev, Mode; | 59 | QString Dev, Mode; |
60 | unsigned long Spd; | 60 | unsigned long Spd; |
61 | 61 | ||
62 | detectDeviceType( Dev, Mode, Spd ); | 62 | detectDeviceType( Dev, Mode, Spd ); |
63 | 63 | ||
64 | // not yet started | 64 | // not yet started |
65 | m_hciattach = new OProcess(); | 65 | m_hciattach = new OProcess(); |
66 | *m_hciattach << "hciattach"; | 66 | *m_hciattach << "hciattach"; |
67 | *m_hciattach << "-p"; // so that it prints its pid | 67 | *m_hciattach << "-p"; // so that it prints its pid |
68 | *m_hciattach << Dev | 68 | *m_hciattach << Dev |
69 | << Mode | 69 | << Mode |
70 | << QString().setNum(Spd); | 70 | << QString().setNum(Spd); |
71 | 71 | ||
72 | connect( m_hciattach, | 72 | connect( m_hciattach, |
73 | SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), | 73 | SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), |
74 | this, SLOT | 74 | this, SLOT |
75 | (slotStdOut(Opie::Core::OProcess*,char*,int) ) ); | 75 | (slotStdOut(Opie::Core::OProcess*,char*,int) ) ); |
76 | 76 | ||
77 | connect( m_hciattach, | 77 | connect( m_hciattach, |
78 | SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ), | 78 | SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ), |
79 | this, SLOT | 79 | this, SLOT |
80 | (slotStdErr(Opie::Core::OProcess*,char*,int) ) ); | 80 | (slotStdErr(Opie::Core::OProcess*,char*,int) ) ); |
81 | 81 | ||
82 | // we need to start this in 'dontcare' mode because | 82 | // we need to start this in 'dontcare' mode because |
83 | // if qpe exists we want the hci to keep running | 83 | // if qpe exists we want the hci to keep running |
84 | if( ! m_hciattach->start( OProcess::DontCare, | 84 | if( ! m_hciattach->start( OProcess::DontCare, |
85 | OProcess::AllOutput | 85 | OProcess::AllOutput |
86 | ) ){ | 86 | ) ){ |
87 | emit error( tr( "Could not start hciattach" ) ); | 87 | emit error( tr( "Could not start hciattach" ) ); |
88 | delete m_hciattach; | 88 | delete m_hciattach; |
89 | m_hciattach = 0; | 89 | m_hciattach = 0; |
90 | return FALSE; | 90 | return FALSE; |
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | return TRUE; | 94 | return TRUE; |
95 | } | 95 | } |
96 | 96 | ||
97 | bool OTDevice::detach(){ | 97 | bool OTDevice::detach(){ |
98 | 98 | ||
99 | if( needsAttach() && m_hciattachPid ) { | 99 | if( needsAttach() && m_hciattachPid ) { |
100 | if( m_hciattach ) { | 100 | if( m_hciattach ) { |
101 | delete m_hciattach; | 101 | delete m_hciattach; |
102 | m_hciattach = 0; | 102 | m_hciattach = 0; |
103 | } | 103 | } |
104 | 104 | ||
105 | if( kill( m_hciattachPid, 9) < 0 ) { | 105 | if( kill( m_hciattachPid, 9) < 0 ) { |
106 | owarn << "could not stop " << errno << oendl; | 106 | odebug << "could not stop " << errno << oendl; |
107 | emit error( tr( "Could not stop process" ) ); | 107 | emit error( tr( "Could not stop process" ) ); |
108 | return FALSE; | 108 | return FALSE; |
109 | } | 109 | } |
110 | m_hciattachPid = 0; | 110 | m_hciattachPid = 0; |
111 | emit isEnabled( m_deviceNr, 0 ); | 111 | emit isEnabled( m_deviceNr, 0 ); |
112 | m_deviceNr = -1; | 112 | m_deviceNr = -1; |
113 | } | 113 | } |
114 | 114 | ||
115 | return TRUE; | 115 | return TRUE; |
116 | } | 116 | } |
117 | 117 | ||
118 | bool OTDevice::isAttached()const{ | 118 | bool OTDevice::isAttached()const{ |
119 | return ! needsAttach() || m_hciattachPid != 0; | 119 | return ! needsAttach() || m_hciattachPid != 0; |
120 | } | 120 | } |
121 | 121 | ||
122 | bool OTDevice::checkAttach(){ | 122 | bool OTDevice::checkAttach(){ |
123 | if( ! needsAttach() ) { | 123 | if( ! needsAttach() ) { |
124 | m_deviceNr = 0; | 124 | m_deviceNr = 0; |
125 | emit isEnabled( 0, 1 ); | 125 | emit isEnabled( 0, 1 ); |
126 | return TRUE; | 126 | return TRUE; |
127 | } | 127 | } |
128 | 128 | ||
129 | if( m_hciattachPid ) { | 129 | if( m_hciattachPid ) { |
130 | QString S; | 130 | QString S; |
131 | S.setNum( m_hciattachPid ); | 131 | S.setNum( m_hciattachPid ); |
132 | QDir D( "/proc" ); | 132 | QDir D( "/proc" ); |
133 | if( !D.exists( S ) ) { | 133 | if( !D.exists( S ) ) { |
134 | // down | 134 | // down |
135 | m_hciattachPid = 0; | 135 | m_hciattachPid = 0; |
136 | emit isEnabled( m_deviceNr, 0 ); | 136 | emit isEnabled( m_deviceNr, 0 ); |
137 | m_deviceNr = -1; | 137 | m_deviceNr = -1; |
138 | } | 138 | } |
139 | } else { | 139 | } else { |
140 | // check | 140 | // check |
141 | m_hciattachPid = getPidOfHCIAttach(); | 141 | m_hciattachPid = getPidOfHCIAttach(); |
142 | if ( m_hciattachPid ) { | 142 | if ( m_hciattachPid ) { |
143 | m_deviceNr = 0; | 143 | m_deviceNr = 0; |
144 | emit isEnabled( m_deviceNr, 1 ); | 144 | emit isEnabled( m_deviceNr, 1 ); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | return m_hciattachPid != 0; | 147 | return m_hciattachPid != 0; |
148 | } | 148 | } |
149 | 149 | ||
150 | void OTDevice::slotStdOut(OProcess* proc, char* , int ) { | 150 | void OTDevice::slotStdOut(OProcess* proc, char* , int ) { |
151 | if( proc == m_hciattach ) { | 151 | if( proc == m_hciattach ) { |
152 | m_hciattach->detach(); | 152 | m_hciattach->detach(); |
153 | 153 | ||
154 | // system enabled | 154 | // system enabled |
155 | // currently no way to figure out which attach produce which | 155 | // currently no way to figure out which attach produce which |
156 | // hci | 156 | // hci |
157 | if( m_deviceNr == -1 ) { | 157 | if( m_deviceNr == -1 ) { |
158 | m_deviceNr = 0; | 158 | m_deviceNr = 0; |
159 | emit isEnabled( m_deviceNr, 1 ); | 159 | emit isEnabled( m_deviceNr, 1 ); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | void OTDevice::slotStdErr(OProcess* proc, char* chars, int len) { | 164 | void OTDevice::slotStdErr(OProcess* proc, char* chars, int len) { |
165 | 165 | ||
166 | if(proc == m_hciattach && len >= 1 ){ | 166 | if(proc == m_hciattach && len >= 1 ){ |
167 | // collect output | 167 | // collect output |
168 | QCString string( chars, len+1 ); // \0 == +1 | 168 | QCString string( chars, len+1 ); // \0 == +1 |
169 | QString m_output; | 169 | QString m_output; |
170 | m_output.append( string.data() ); | 170 | m_output.append( string.data() ); |
171 | owarn << m_output << oendl; | 171 | odebug << m_output << oendl; |
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | pid_t OTDevice::getPidOfHCIAttach( void ) { | 175 | pid_t OTDevice::getPidOfHCIAttach( void ) { |
176 | 176 | ||
177 | if( needsAttach() ) { | 177 | if( needsAttach() ) { |
178 | // not yet attached -> perhaps now ? | 178 | // not yet attached -> perhaps now ? |
179 | // load /proc dir and check if command name contains hciattach | 179 | // load /proc dir and check if command name contains hciattach |
180 | QRegExp R("[0-9]+"); | 180 | QRegExp R("[0-9]+"); |
181 | QDir ProcDir( "/proc" ); | 181 | QDir ProcDir( "/proc" ); |
182 | QFileInfo FI; | 182 | QFileInfo FI; |
183 | QStringList EL = ProcDir.entryList( QDir::Dirs ); | 183 | QStringList EL = ProcDir.entryList( QDir::Dirs ); |
184 | 184 | ||
185 | // print it out | 185 | // print it out |
186 | for ( QStringList::Iterator it = EL.begin(); | 186 | for ( QStringList::Iterator it = EL.begin(); |
187 | it != EL.end(); | 187 | it != EL.end(); |
188 | ++it ) { | 188 | ++it ) { |
189 | if( R.match( (*it) ) >= 0 ) { | 189 | if( R.match( (*it) ) >= 0 ) { |
190 | // is pid | 190 | // is pid |
191 | 191 | ||
192 | // get command being executed | 192 | // get command being executed |
193 | FI.setFile( ProcDir.path()+"/"+ (*it) + "/exe" ); | 193 | FI.setFile( ProcDir.path()+"/"+ (*it) + "/exe" ); |
194 | 194 | ||
195 | // get the link | 195 | // get the link |
196 | if( FI.readLink().right( 9 ) == "hciattach" ) { | 196 | if( FI.readLink().right( 9 ) == "hciattach" ) { |
197 | // this is hci attach process | 197 | // this is hci attach process |
198 | 198 | ||
199 | return (*it).toULong(); | 199 | return (*it).toULong(); |
200 | break; | 200 | break; |
201 | } | 201 | } |
202 | } | 202 | } |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | return 0; | 206 | return 0; |
207 | } | 207 | } |
208 | 208 | ||
209 | void OTDevice::detectDeviceType( QString & Device, | 209 | void OTDevice::detectDeviceType( QString & Device, |
210 | QString & Mode, | 210 | QString & Mode, |
211 | unsigned long & Speed ) { | 211 | unsigned long & Speed ) { |
212 | 212 | ||
213 | // detect device type and determine parms | 213 | // detect device type and determine parms |
214 | owarn << "Detecting device" << oendl; | 214 | odebug << "Detecting device" << oendl; |
215 | switch ( ODevice::inst()->model() ) { | 215 | switch ( ODevice::inst()->model() ) { |
216 | case Model_iPAQ_H39xx: | 216 | case Model_iPAQ_H39xx: |
217 | Device = "/dev/tts/1"; | 217 | Device = "/dev/tts/1"; |
218 | Mode = "bcsp"; | 218 | Mode = "bcsp"; |
219 | Speed = 921600; | 219 | Speed = 921600; |
220 | NeedsAttach = 1; | 220 | NeedsAttach = 1; |
221 | break; | 221 | break; |
222 | 222 | ||
223 | case Model_iPAQ_H5xxx: | 223 | case Model_iPAQ_H5xxx: |
224 | Device = "/dev/tts/1"; | 224 | Device = "/dev/tts/1"; |
225 | Mode = "any"; | 225 | Mode = "any"; |
226 | Speed = 921600; | 226 | Speed = 921600; |
227 | NeedsAttach = 1; | 227 | NeedsAttach = 1; |
228 | break; | 228 | break; |
229 | 229 | ||
230 | case Model_GenuineIntel : | 230 | case Model_GenuineIntel : |
231 | Device = ""; | 231 | Device = ""; |
232 | Mode = ""; | 232 | Mode = ""; |
233 | Speed = 0; | 233 | Speed = 0; |
234 | NeedsAttach = 0; | 234 | NeedsAttach = 0; |
235 | break; | 235 | break; |
236 | 236 | ||
237 | default: | 237 | default: |
238 | Device = "/dev/ttySB0"; | 238 | Device = "/dev/ttySB0"; |
239 | Mode = "bcsp"; | 239 | Mode = "bcsp"; |
240 | Speed = 230400; | 240 | Speed = 230400; |
241 | NeedsAttach = 1; | 241 | NeedsAttach = 1; |
242 | break; | 242 | break; |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | QString OTDevice::getRFCommDevicePattern( void ) { | 246 | QString OTDevice::getRFCommDevicePattern( void ) { |
247 | 247 | ||
248 | QDir D( "/dev/bluetooth/rfcomm" ); | 248 | QDir D( "/dev/bluetooth/rfcomm" ); |
249 | if( D.exists() ) { | 249 | if( D.exists() ) { |
250 | // devfs | 250 | // devfs |
251 | return QString( "/dev/bluetooth/rfcomm/%1" ); | 251 | return QString( "/dev/bluetooth/rfcomm/%1" ); |
252 | } | 252 | } |
253 | 253 | ||
254 | // regular 'dev' directory | 254 | // regular 'dev' directory |
255 | return QString( "/dev/rfcomm%1" ); | 255 | return QString( "/dev/rfcomm%1" ); |
256 | } | 256 | } |
diff --git a/noncore/settings/networksettings2/opietooth2/OTDriver.cpp b/noncore/settings/networksettings2/opietooth2/OTDriver.cpp index 8bd7919..a7ee662 100644 --- a/noncore/settings/networksettings2/opietooth2/OTDriver.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTDriver.cpp | |||
@@ -105,97 +105,97 @@ static ClassMap_t MapAVClass[] = { | |||
105 | { 4, "Microphone" }, | 105 | { 4, "Microphone" }, |
106 | { 5, "Loudspeaker" }, | 106 | { 5, "Loudspeaker" }, |
107 | { 6, "Headphones" }, | 107 | { 6, "Headphones" }, |
108 | { 7, "Portable Audio" }, | 108 | { 7, "Portable Audio" }, |
109 | { 8, "Car Audio" }, | 109 | { 8, "Car Audio" }, |
110 | { 9, "Set-top box" }, | 110 | { 9, "Set-top box" }, |
111 | { 10, "HiFi Audio Device" }, | 111 | { 10, "HiFi Audio Device" }, |
112 | { 11, "VCR" }, | 112 | { 11, "VCR" }, |
113 | { 12, "Video Camera" }, | 113 | { 12, "Video Camera" }, |
114 | { 13, "Camcorder" }, | 114 | { 13, "Camcorder" }, |
115 | { 14, "Video Monitor" }, | 115 | { 14, "Video Monitor" }, |
116 | { 15, "Video Display and Loudspeaker" }, | 116 | { 15, "Video Display and Loudspeaker" }, |
117 | { 16, "Video Conferencing" }, | 117 | { 16, "Video Conferencing" }, |
118 | { 17, 0 }, | 118 | { 17, 0 }, |
119 | { 18, "Gaming/Toy" }, | 119 | { 18, "Gaming/Toy" }, |
120 | { -1, 0 } | 120 | { -1, 0 } |
121 | }; | 121 | }; |
122 | 122 | ||
123 | static ClassMap_t MapPeripheralClass[] = { | 123 | static ClassMap_t MapPeripheralClass[] = { |
124 | { 16, "Keyboard" }, | 124 | { 16, "Keyboard" }, |
125 | { 32, "Pointing device" }, | 125 | { 32, "Pointing device" }, |
126 | { 48, "Combo keyboard/pointing device" }, | 126 | { 48, "Combo keyboard/pointing device" }, |
127 | { -1, 0 } | 127 | { -1, 0 } |
128 | }; | 128 | }; |
129 | 129 | ||
130 | typedef struct { | 130 | typedef struct { |
131 | int Major; | 131 | int Major; |
132 | ClassMap_t * Map; | 132 | ClassMap_t * Map; |
133 | } MainClassMap_t; | 133 | } MainClassMap_t; |
134 | 134 | ||
135 | static MainClassMap_t MainClasses[] = { | 135 | static MainClassMap_t MainClasses[] = { |
136 | { 0, MapMiscClass }, | 136 | { 0, MapMiscClass }, |
137 | { 1, MapComputerClass }, | 137 | { 1, MapComputerClass }, |
138 | { 2, MapPhoneClass }, | 138 | { 2, MapPhoneClass }, |
139 | { 3, 0 }, // special case | 139 | { 3, 0 }, // special case |
140 | { 4, MapAVClass }, | 140 | { 4, MapAVClass }, |
141 | { 5, MapPeripheralClass }, | 141 | { 5, MapPeripheralClass }, |
142 | { 6, 0 }, // special case | 142 | { 6, 0 }, // special case |
143 | { 63, MapUnclassifiedClass }, | 143 | { 63, MapUnclassifiedClass }, |
144 | { -1, 0 } | 144 | { -1, 0 } |
145 | }; | 145 | }; |
146 | 146 | ||
147 | OTDriver::OTDriver( OTGateway * _OT, struct hci_dev_info* di) : QObject( _OT ), Address() { | 147 | OTDriver::OTDriver( OTGateway * _OT, struct hci_dev_info* di) : QObject( _OT ), Address() { |
148 | OT = _OT; | 148 | OT = _OT; |
149 | IsUp = 0; | 149 | IsUp = 0; |
150 | Socket = 0; | 150 | Socket = 0; |
151 | 151 | ||
152 | init(di); | 152 | init(di); |
153 | owarn << "Driver " << devname() << oendl; | 153 | odebug << "Driver " << devname() << oendl; |
154 | 154 | ||
155 | AutoClose = new QTimer( this ); | 155 | AutoClose = new QTimer( this ); |
156 | connect( AutoClose, | 156 | connect( AutoClose, |
157 | SIGNAL( timeout() ), | 157 | SIGNAL( timeout() ), |
158 | this, | 158 | this, |
159 | SLOT( SLOT_CloseFd() ) | 159 | SLOT( SLOT_CloseFd() ) |
160 | ); | 160 | ); |
161 | } | 161 | } |
162 | 162 | ||
163 | OTDriver::~OTDriver() { | 163 | OTDriver::~OTDriver() { |
164 | closeSocket(); | 164 | closeSocket(); |
165 | SLOT_CloseFd(); | 165 | SLOT_CloseFd(); |
166 | } | 166 | } |
167 | 167 | ||
168 | void OTDriver::SLOT_CloseFd( void ){ | 168 | void OTDriver::SLOT_CloseFd( void ){ |
169 | if ( isOpen() ) { | 169 | if ( isOpen() ) { |
170 | AutoClose->stop(); | 170 | AutoClose->stop(); |
171 | ::close( fd() ); | 171 | ::close( fd() ); |
172 | setfd( -1 ); | 172 | setfd( -1 ); |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | void OTDriver::init(struct hci_dev_info* di) { | 176 | void OTDriver::init(struct hci_dev_info* di) { |
177 | 177 | ||
178 | Dev = di->name; | 178 | Dev = di->name; |
179 | 179 | ||
180 | setDevId(di->dev_id); | 180 | setDevId(di->dev_id); |
181 | setType(di->type); | 181 | setType(di->type); |
182 | setFlags(di->flags); | 182 | setFlags(di->flags); |
183 | Address.setBDAddr( di->bdaddr ); | 183 | Address.setBDAddr( di->bdaddr ); |
184 | setFeatures(di->features); | 184 | setFeatures(di->features); |
185 | setfd( -1 ); // not open | 185 | setfd( -1 ); // not open |
186 | 186 | ||
187 | Manufacturer = ""; | 187 | Manufacturer = ""; |
188 | } | 188 | } |
189 | 189 | ||
190 | // internal reinitialize | 190 | // internal reinitialize |
191 | void OTDriver::reinit() { | 191 | void OTDriver::reinit() { |
192 | bool Old; | 192 | bool Old; |
193 | Old = IsUp; | 193 | Old = IsUp; |
194 | 194 | ||
195 | if( currentState() < 0 ) | 195 | if( currentState() < 0 ) |
196 | return; | 196 | return; |
197 | 197 | ||
198 | if( Old != IsUp ) { | 198 | if( Old != IsUp ) { |
199 | // state changes | 199 | // state changes |
200 | emit stateChange( this, IsUp ); | 200 | emit stateChange( this, IsUp ); |
201 | } | 201 | } |
@@ -340,120 +340,120 @@ QString OTDriver::getRevEricsson() { | |||
340 | return QString(); | 340 | return QString(); |
341 | } | 341 | } |
342 | 342 | ||
343 | return QString( revision+1 ); | 343 | return QString( revision+1 ); |
344 | } | 344 | } |
345 | 345 | ||
346 | QString OTDriver::getRevCsr( unsigned short rev) { | 346 | QString OTDriver::getRevCsr( unsigned short rev) { |
347 | 347 | ||
348 | int i; | 348 | int i; |
349 | 349 | ||
350 | for (i = 0; csr_map[i].str; i++) | 350 | for (i = 0; csr_map[i].str; i++) |
351 | if (csr_map[i].rev == rev) { | 351 | if (csr_map[i].rev == rev) { |
352 | return QString( csr_map[i].str ); | 352 | return QString( csr_map[i].str ); |
353 | } | 353 | } |
354 | 354 | ||
355 | return tr( "Unknown firmware" ); | 355 | return tr( "Unknown firmware" ); |
356 | } | 356 | } |
357 | 357 | ||
358 | int OTDriver::reset() { | 358 | int OTDriver::reset() { |
359 | 359 | ||
360 | if( ! open() ) { | 360 | if( ! open() ) { |
361 | return 0; | 361 | return 0; |
362 | } | 362 | } |
363 | 363 | ||
364 | if( ioctl(fd(), HCIDEVRESET, devId()) < 0 ) { | 364 | if( ioctl(fd(), HCIDEVRESET, devId()) < 0 ) { |
365 | if( errno != EALREADY ) { | 365 | if( errno != EALREADY ) { |
366 | emit error( tr( "Reset failed for %1. %2 : %3" ). | 366 | emit error( tr( "Reset failed for %1. %2 : %3" ). |
367 | arg( devname() ). | 367 | arg( devname() ). |
368 | arg( errno ). | 368 | arg( errno ). |
369 | arg( strerror(errno) ) ); | 369 | arg( strerror(errno) ) ); |
370 | if (errno == EACCES) { | 370 | if (errno == EACCES) { |
371 | return EACCES; | 371 | return EACCES; |
372 | } | 372 | } |
373 | } | 373 | } |
374 | } | 374 | } |
375 | return 0; | 375 | return 0; |
376 | } | 376 | } |
377 | 377 | ||
378 | void OTDriver::setUp( bool M ) { | 378 | void OTDriver::setUp( bool M ) { |
379 | if( M && ! isUp() ) { | 379 | if( M && ! isUp() ) { |
380 | bringUp(); | 380 | bringUp(); |
381 | } else if( ! M && isUp() ) { | 381 | } else if( ! M && isUp() ) { |
382 | bringDown(); | 382 | bringDown(); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | void OTDriver::bringUp() { | 386 | void OTDriver::bringUp() { |
387 | 387 | ||
388 | owarn << "bringUp : " << Dev << oendl; | 388 | odebug << "bringUp : " << Dev << oendl; |
389 | 389 | ||
390 | if( ! open() ) { | 390 | if( ! open() ) { |
391 | return; | 391 | return; |
392 | } | 392 | } |
393 | 393 | ||
394 | if (! isUp()) { | 394 | if (! isUp()) { |
395 | if( ioctl(fd(), HCIDEVUP, devId()) < 0 ) { | 395 | if( ioctl(fd(), HCIDEVUP, devId()) < 0 ) { |
396 | if( errno != EALREADY ) { | 396 | if( errno != EALREADY ) { |
397 | emit error( tr( "Cannot bring interface %1 up. %2 : %3" ). | 397 | emit error( tr( "Cannot bring interface %1 up. %2 : %3" ). |
398 | arg( devname() ). | 398 | arg( devname() ). |
399 | arg( errno ). | 399 | arg( errno ). |
400 | arg( strerror(errno) ) ); | 400 | arg( strerror(errno) ) ); |
401 | } | 401 | } |
402 | return; | 402 | return; |
403 | } | 403 | } |
404 | // have to wait a bit for the 'up' to become active | 404 | // have to wait a bit for the 'up' to become active |
405 | QTimer::singleShot( 3000, this, SLOT( reinit() ) ); | 405 | QTimer::singleShot( 3000, this, SLOT( reinit() ) ); |
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
409 | void OTDriver::bringDown() { | 409 | void OTDriver::bringDown() { |
410 | 410 | ||
411 | owarn << "bringDown : " << Dev << oendl; | 411 | odebug << "bringDown : " << Dev << oendl; |
412 | 412 | ||
413 | if( ! open() ) { | 413 | if( ! open() ) { |
414 | return; | 414 | return; |
415 | } | 415 | } |
416 | 416 | ||
417 | if ( isUp() ) { | 417 | if ( isUp() ) { |
418 | if( ioctl(fd(), HCIDEVDOWN, devId()) < 0 ) { | 418 | if( ioctl(fd(), HCIDEVDOWN, devId()) < 0 ) { |
419 | if( errno != EALREADY ) { | 419 | if( errno != EALREADY ) { |
420 | emit error( tr( "Cannot bring interface %1 down. %2 : %3" ). | 420 | emit error( tr( "Cannot bring interface %1 down. %2 : %3" ). |
421 | arg( devname() ). | 421 | arg( devname() ). |
422 | arg( errno ). | 422 | arg( errno ). |
423 | arg( strerror(errno) ) ); | 423 | arg( strerror(errno) ) ); |
424 | } | 424 | } |
425 | return; | 425 | return; |
426 | } | 426 | } |
427 | reinit(); | 427 | reinit(); |
428 | } | 428 | } |
429 | } | 429 | } |
430 | 430 | ||
431 | void OTDriver::setScanMode(bool iscan, bool pscan) { | 431 | void OTDriver::setScanMode(bool iscan, bool pscan) { |
432 | 432 | ||
433 | struct hci_dev_req dr; | 433 | struct hci_dev_req dr; |
434 | 434 | ||
435 | if( ! open() ) { | 435 | if( ! open() ) { |
436 | return; | 436 | return; |
437 | } | 437 | } |
438 | 438 | ||
439 | dr.dev_id = devId(); | 439 | dr.dev_id = devId(); |
440 | dr.dev_opt = SCAN_DISABLED; | 440 | dr.dev_opt = SCAN_DISABLED; |
441 | 441 | ||
442 | if( iscan&&(!pscan) ) | 442 | if( iscan&&(!pscan) ) |
443 | dr.dev_opt = SCAN_INQUIRY; | 443 | dr.dev_opt = SCAN_INQUIRY; |
444 | else if( pscan&&(!iscan) ) | 444 | else if( pscan&&(!iscan) ) |
445 | dr.dev_opt = SCAN_PAGE; | 445 | dr.dev_opt = SCAN_PAGE; |
446 | else if( pscan&&iscan ) | 446 | else if( pscan&&iscan ) |
447 | dr.dev_opt = SCAN_PAGE | SCAN_INQUIRY; | 447 | dr.dev_opt = SCAN_PAGE | SCAN_INQUIRY; |
448 | 448 | ||
449 | if( ioctl(fd(), HCISETSCAN, (unsigned long)&dr) < 0 ) { | 449 | if( ioctl(fd(), HCISETSCAN, (unsigned long)&dr) < 0 ) { |
450 | if( errno != EALREADY ) { | 450 | if( errno != EALREADY ) { |
451 | emit error( tr( "Can't set scan mode on %1. %2 : %3" ). | 451 | emit error( tr( "Can't set scan mode on %1. %2 : %3" ). |
452 | arg( devname() ). | 452 | arg( devname() ). |
453 | arg( errno ). | 453 | arg( errno ). |
454 | arg( strerror(errno) ) ); | 454 | arg( strerror(errno) ) ); |
455 | } | 455 | } |
456 | return; | 456 | return; |
457 | } | 457 | } |
458 | 458 | ||
459 | reinit(); | 459 | reinit(); |
@@ -616,129 +616,129 @@ void OTDriver::getClass( QString & service, | |||
616 | device = "50-67% utilized"; | 616 | device = "50-67% utilized"; |
617 | break; | 617 | break; |
618 | case 5: | 618 | case 5: |
619 | device = "67-83% utilized"; | 619 | device = "67-83% utilized"; |
620 | break; | 620 | break; |
621 | case 6: | 621 | case 6: |
622 | device = "83-99% utilized"; | 622 | device = "83-99% utilized"; |
623 | break; | 623 | break; |
624 | case 7: | 624 | case 7: |
625 | device = "No service available"; | 625 | device = "No service available"; |
626 | break; | 626 | break; |
627 | } | 627 | } |
628 | } | 628 | } |
629 | } else if( major == 6 ) { /* imaging */ | 629 | } else if( major == 6 ) { /* imaging */ |
630 | if (minor & 4) | 630 | if (minor & 4) |
631 | device = "Display"; | 631 | device = "Display"; |
632 | if (minor & 8) | 632 | if (minor & 8) |
633 | device = "Camera"; | 633 | device = "Camera"; |
634 | if (minor & 16) | 634 | if (minor & 16) |
635 | device = "Scanner"; | 635 | device = "Scanner"; |
636 | if (minor & 32) | 636 | if (minor & 32) |
637 | device = "Printer"; | 637 | device = "Printer"; |
638 | } | 638 | } |
639 | } | 639 | } |
640 | break; | 640 | break; |
641 | } | 641 | } |
642 | MCM ++; | 642 | MCM ++; |
643 | } | 643 | } |
644 | 644 | ||
645 | if( MCM->Major == -1 ) { | 645 | if( MCM->Major == -1 ) { |
646 | device = "Unknown (reserved) minor device class"; | 646 | device = "Unknown (reserved) minor device class"; |
647 | } | 647 | } |
648 | } | 648 | } |
649 | 649 | ||
650 | QString OTDriver::strType() { | 650 | QString OTDriver::strType() { |
651 | return QString( hci_dtypetostr(Type) ); | 651 | return QString( hci_dtypetostr(Type) ); |
652 | } | 652 | } |
653 | 653 | ||
654 | void OTDriver::setFeatures( unsigned char * _f) { | 654 | void OTDriver::setFeatures( unsigned char * _f) { |
655 | Features = lmp_featurestostr(_f, NULL, 255); | 655 | Features = lmp_featurestostr(_f, NULL, 255); |
656 | } | 656 | } |
657 | 657 | ||
658 | void OTDriver::setManufacturer(int compid) { | 658 | void OTDriver::setManufacturer(int compid) { |
659 | Manufacturer = bt_compidtostr(compid); | 659 | Manufacturer = bt_compidtostr(compid); |
660 | } | 660 | } |
661 | 661 | ||
662 | OTHCISocket * OTDriver::openSocket( void ) { | 662 | OTHCISocket * OTDriver::openSocket( void ) { |
663 | if( ! Socket ) { | 663 | if( ! Socket ) { |
664 | owarn << "Open HCI socket to " << devname() << oendl; | 664 | odebug << "Open HCI socket to " << devname() << oendl; |
665 | Socket = new OTHCISocket( this ); | 665 | Socket = new OTHCISocket( this ); |
666 | } | 666 | } |
667 | return Socket; | 667 | return Socket; |
668 | } | 668 | } |
669 | 669 | ||
670 | void OTDriver::closeSocket( void ) { | 670 | void OTDriver::closeSocket( void ) { |
671 | if( Socket ) { | 671 | if( Socket ) { |
672 | owarn << "Close HCI socket to " << devname() << oendl; | 672 | odebug << "Close HCI socket to " << devname() << oendl; |
673 | delete Socket; | 673 | delete Socket; |
674 | Socket = 0; | 674 | Socket = 0; |
675 | } | 675 | } |
676 | } | 676 | } |
677 | 677 | ||
678 | QString OTDriver::getPeerName( const OTDeviceAddress & PAddr ) { | 678 | QString OTDriver::getPeerName( const OTDeviceAddress & PAddr ) { |
679 | QString S; | 679 | QString S; |
680 | char name[100 ]; | 680 | char name[100 ]; |
681 | 681 | ||
682 | if( ! open() ) { | 682 | if( ! open() ) { |
683 | return QString("N/A"); | 683 | return QString("N/A"); |
684 | } | 684 | } |
685 | 685 | ||
686 | if( hci_read_remote_name( fd(), | 686 | if( hci_read_remote_name( fd(), |
687 | &(PAddr.getBDAddr()), | 687 | &(PAddr.getBDAddr()), |
688 | sizeof(name), | 688 | sizeof(name), |
689 | name, | 689 | name, |
690 | 100000 ) < 0 ) { | 690 | 100000 ) < 0 ) { |
691 | return QString( "N/A" ); | 691 | return QString( "N/A" ); |
692 | } | 692 | } |
693 | 693 | ||
694 | return QString( name ); | 694 | return QString( name ); |
695 | } | 695 | } |
696 | 696 | ||
697 | long OTDriver::getLinkQuality( const OTDeviceAddress & Addr ) { | 697 | long OTDriver::getLinkQuality( const OTDeviceAddress & Addr ) { |
698 | struct hci_conn_info_req *cr; | 698 | struct hci_conn_info_req *cr; |
699 | struct hci_request rq; | 699 | struct hci_request rq; |
700 | read_rssi_rp rp; | 700 | read_rssi_rp rp; |
701 | uint16_t handle; | 701 | uint16_t handle; |
702 | 702 | ||
703 | if( ! open() ) { | 703 | if( ! open() ) { |
704 | return 0; | 704 | return 0; |
705 | } | 705 | } |
706 | 706 | ||
707 | cr = (struct hci_conn_info_req *)malloc( | 707 | cr = (struct hci_conn_info_req *)malloc( |
708 | sizeof(*cr) + sizeof(struct hci_conn_info)); | 708 | sizeof(*cr) + sizeof(struct hci_conn_info)); |
709 | if (!cr) | 709 | if (!cr) |
710 | return 0; | 710 | return 0; |
711 | 711 | ||
712 | bacpy( &(cr->bdaddr), &(Addr.getBDAddr()) ); | 712 | bacpy( &(cr->bdaddr), &(Addr.getBDAddr()) ); |
713 | cr->type = ACL_LINK; | 713 | cr->type = ACL_LINK; |
714 | 714 | ||
715 | if (ioctl( fd(), HCIGETCONNINFO, (unsigned long) cr) < 0) { | 715 | if (ioctl( fd(), HCIGETCONNINFO, (unsigned long) cr) < 0) { |
716 | owarn << "Get connection info failed" << oendl; | 716 | odebug << "Get connection info failed" << oendl; |
717 | free(cr); | 717 | free(cr); |
718 | return 0; | 718 | return 0; |
719 | } | 719 | } |
720 | 720 | ||
721 | handle = htobs(cr->conn_info->handle); | 721 | handle = htobs(cr->conn_info->handle); |
722 | 722 | ||
723 | free(cr); | 723 | free(cr); |
724 | 724 | ||
725 | memset(&rq, 0, sizeof(rq)); | 725 | memset(&rq, 0, sizeof(rq)); |
726 | rq.ogf = OGF_STATUS_PARAM; | 726 | rq.ogf = OGF_STATUS_PARAM; |
727 | rq.ocf = OCF_READ_RSSI; | 727 | rq.ocf = OCF_READ_RSSI; |
728 | rq.cparam = &handle; | 728 | rq.cparam = &handle; |
729 | rq.clen = 2; | 729 | rq.clen = 2; |
730 | rq.rparam = &rp; | 730 | rq.rparam = &rp; |
731 | rq.rlen = GET_LINK_QUALITY_RP_SIZE; | 731 | rq.rlen = GET_LINK_QUALITY_RP_SIZE; |
732 | 732 | ||
733 | if (hci_send_req( fd(), &rq, 100) < 0) { | 733 | if (hci_send_req( fd(), &rq, 100) < 0) { |
734 | owarn << "Get connection info failed" << oendl; | 734 | odebug << "Get connection info failed" << oendl; |
735 | return 0; | 735 | return 0; |
736 | } | 736 | } |
737 | 737 | ||
738 | if( rp.status ) { | 738 | if( rp.status ) { |
739 | owarn << QString().sprintf("HCI get_link_quality cmd failed (0x%2.2X)", rp.status) << oendl; | 739 | odebug << QString().sprintf("HCI get_link_quality cmd failed (0x%2.2X)", rp.status) << oendl; |
740 | return 0; | 740 | return 0; |
741 | } | 741 | } |
742 | 742 | ||
743 | return rp.rssi+50; | 743 | return rp.rssi+50; |
744 | } | 744 | } |
diff --git a/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp b/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp index f703834..e5af742 100644 --- a/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp | |||
@@ -8,79 +8,79 @@ | |||
8 | * (at your option) any later version. * | 8 | * (at your option) any later version. * |
9 | ***************************************************************************/ | 9 | ***************************************************************************/ |
10 | 10 | ||
11 | #include <malloc.h> | 11 | #include <malloc.h> |
12 | #include <bluezlib.h> | 12 | #include <bluezlib.h> |
13 | 13 | ||
14 | #include <opie2/odebug.h> | 14 | #include <opie2/odebug.h> |
15 | 15 | ||
16 | #include <OTDriverList.h> | 16 | #include <OTDriverList.h> |
17 | #include <OTGateway.h> | 17 | #include <OTGateway.h> |
18 | #include <OTDriver.h> | 18 | #include <OTDriver.h> |
19 | 19 | ||
20 | using namespace Opietooth2; | 20 | using namespace Opietooth2; |
21 | 21 | ||
22 | OTDriverList::OTDriverList( OTGateway * _OT ) : QVector<OTDriver>() { | 22 | OTDriverList::OTDriverList( OTGateway * _OT ) : QVector<OTDriver>() { |
23 | 23 | ||
24 | OT = _OT; | 24 | OT = _OT; |
25 | setAutoDelete( true ); | 25 | setAutoDelete( true ); |
26 | } | 26 | } |
27 | 27 | ||
28 | OTDriverList::~OTDriverList() { | 28 | OTDriverList::~OTDriverList() { |
29 | } | 29 | } |
30 | 30 | ||
31 | void OTDriverList::update() { | 31 | void OTDriverList::update() { |
32 | 32 | ||
33 | struct hci_dev_list_req *dl; | 33 | struct hci_dev_list_req *dl; |
34 | struct hci_dev_req *dr; | 34 | struct hci_dev_req *dr; |
35 | struct hci_dev_info di; | 35 | struct hci_dev_info di; |
36 | int cur; | 36 | int cur; |
37 | 37 | ||
38 | dl = 0; | 38 | dl = 0; |
39 | cur = 0; | 39 | cur = 0; |
40 | do { | 40 | do { |
41 | cur += 5; | 41 | cur += 5; |
42 | 42 | ||
43 | dl = (struct hci_dev_list_req*) | 43 | dl = (struct hci_dev_list_req*) |
44 | ::realloc( dl, sizeof( struct hci_dev_list_req ) + | 44 | ::realloc( dl, sizeof( struct hci_dev_list_req ) + |
45 | ( cur * sizeof(struct hci_dev_req) ) | 45 | ( cur * sizeof(struct hci_dev_req) ) |
46 | ); | 46 | ); |
47 | 47 | ||
48 | if( dl == 0 ) { | 48 | if( dl == 0 ) { |
49 | // memory problem | 49 | // memory problem |
50 | exit(1); | 50 | exit(1); |
51 | } | 51 | } |
52 | 52 | ||
53 | dl->dev_num = cur; | 53 | dl->dev_num = cur; |
54 | 54 | ||
55 | if( ioctl( OT->getSocket(), HCIGETDEVLIST, (void*)dl) ) { | 55 | if( ioctl( OT->getSocket(), HCIGETDEVLIST, (void*)dl) ) { |
56 | owarn << "WARNING : cannot read device list. " | 56 | odebug << "WARNING : cannot read device list. " |
57 | << errno | 57 | << errno |
58 | << strerror( errno ) << oendl; | 58 | << strerror( errno ) << oendl; |
59 | return; | 59 | return; |
60 | } | 60 | } |
61 | 61 | ||
62 | // if num == cur perhaps we did not get all devices yet | 62 | // if num == cur perhaps we did not get all devices yet |
63 | } while( dl->dev_num == cur ); | 63 | } while( dl->dev_num == cur ); |
64 | 64 | ||
65 | if( dl->dev_num != count() ) { | 65 | if( dl->dev_num != count() ) { |
66 | // new or missing devices | 66 | // new or missing devices |
67 | clear(); | 67 | clear(); |
68 | 68 | ||
69 | dr = dl->dev_req; | 69 | dr = dl->dev_req; |
70 | resize( dl->dev_num ); | 70 | resize( dl->dev_num ); |
71 | 71 | ||
72 | for( cur=0; cur < dl->dev_num; cur ++) { | 72 | for( cur=0; cur < dl->dev_num; cur ++) { |
73 | memset( &di, 0, sizeof( di ) ); | 73 | memset( &di, 0, sizeof( di ) ); |
74 | di.dev_id = (dr+cur)->dev_id; | 74 | di.dev_id = (dr+cur)->dev_id; |
75 | 75 | ||
76 | // get device info | 76 | // get device info |
77 | if( ioctl( OT->getSocket(), HCIGETDEVINFO, (void*)&di) != 0 ) | 77 | if( ioctl( OT->getSocket(), HCIGETDEVINFO, (void*)&di) != 0 ) |
78 | continue; // uh ? | 78 | continue; // uh ? |
79 | insert( cur, new OTDriver( OT, &di ) ); | 79 | insert( cur, new OTDriver( OT, &di ) ); |
80 | } | 80 | } |
81 | 81 | ||
82 | owarn << "Found " << count() << " devices" << oendl; | 82 | odebug << "Found " << count() << " devices" << oendl; |
83 | 83 | ||
84 | ::free( dl ); | 84 | ::free( dl ); |
85 | } | 85 | } |
86 | } | 86 | } |
diff --git a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp index 6531cf6..e8137dd 100644 --- a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp | |||
@@ -109,334 +109,334 @@ OTDevice * OTGateway::getOTDevice( ) { | |||
109 | TheOTDevice = new OTDevice( this ); | 109 | TheOTDevice = new OTDevice( this ); |
110 | connect( TheOTDevice, | 110 | connect( TheOTDevice, |
111 | SIGNAL( isEnabled( int, bool ) ), | 111 | SIGNAL( isEnabled( int, bool ) ), |
112 | this, | 112 | this, |
113 | SLOT( SLOT_Enabled( int, bool ) ) ); | 113 | SLOT( SLOT_Enabled( int, bool ) ) ); |
114 | 114 | ||
115 | connect( TheOTDevice, | 115 | connect( TheOTDevice, |
116 | SIGNAL( error( const QString & ) ), | 116 | SIGNAL( error( const QString & ) ), |
117 | this, | 117 | this, |
118 | SLOT( SLOT_ShowError( const QString & ) ) ); | 118 | SLOT( SLOT_ShowError( const QString & ) ) ); |
119 | } | 119 | } |
120 | 120 | ||
121 | return TheOTDevice; | 121 | return TheOTDevice; |
122 | } | 122 | } |
123 | 123 | ||
124 | // start bluetooth (if stopped) | 124 | // start bluetooth (if stopped) |
125 | // return TRUE if started | 125 | // return TRUE if started |
126 | void OTGateway::SLOT_SetEnabled( bool Mode ) { | 126 | void OTGateway::SLOT_SetEnabled( bool Mode ) { |
127 | if( Mode ) { | 127 | if( Mode ) { |
128 | SLOT_Enable(); | 128 | SLOT_Enable(); |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | SLOT_Disable(); | 131 | SLOT_Disable(); |
132 | } | 132 | } |
133 | 133 | ||
134 | void OTGateway::SLOT_Enable() { | 134 | void OTGateway::SLOT_Enable() { |
135 | getOTDevice()->attach(); | 135 | getOTDevice()->attach(); |
136 | } | 136 | } |
137 | 137 | ||
138 | void OTGateway::SLOT_Disable() { | 138 | void OTGateway::SLOT_Disable() { |
139 | getOTDevice()->detach(); | 139 | getOTDevice()->detach(); |
140 | } | 140 | } |
141 | 141 | ||
142 | bool OTGateway::needsEnabling() { | 142 | bool OTGateway::needsEnabling() { |
143 | return getOTDevice()->needsAttach(); | 143 | return getOTDevice()->needsAttach(); |
144 | } | 144 | } |
145 | 145 | ||
146 | bool OTGateway::isEnabled() { | 146 | bool OTGateway::isEnabled() { |
147 | if( getOTDevice()->deviceNr() >= 0 && | 147 | if( getOTDevice()->deviceNr() >= 0 && |
148 | driver( getOTDevice()->deviceNr() )->isUp() ) | 148 | driver( getOTDevice()->deviceNr() )->isUp() ) |
149 | return TRUE; | 149 | return TRUE; |
150 | 150 | ||
151 | // else check system | 151 | // else check system |
152 | return getOTDevice()->isAttached(); | 152 | return getOTDevice()->isAttached(); |
153 | } | 153 | } |
154 | 154 | ||
155 | void OTGateway::SLOT_ShowError( const QString & S ) { | 155 | void OTGateway::SLOT_ShowError( const QString & S ) { |
156 | 156 | ||
157 | owarn << S << oendl; | 157 | odebug << S << oendl; |
158 | 158 | ||
159 | if( ErrorConnectCount > 0 ) { | 159 | if( ErrorConnectCount > 0 ) { |
160 | // pass error | 160 | // pass error |
161 | emit error( QString( "<p>" ) + S + "</p>" ); | 161 | emit error( QString( "<p>" ) + S + "</p>" ); |
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | 164 | ||
165 | QMessageBox::warning( 0, | 165 | QMessageBox::warning( 0, |
166 | tr("OTGateway error"), | 166 | tr("OTGateway error"), |
167 | S ); | 167 | S ); |
168 | } | 168 | } |
169 | 169 | ||
170 | void OTGateway::connectNotify( const char * S ) { | 170 | void OTGateway::connectNotify( const char * S ) { |
171 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { | 171 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { |
172 | ErrorConnectCount ++; | 172 | ErrorConnectCount ++; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | void OTGateway::disconnectNotify( const char * S ) { | 176 | void OTGateway::disconnectNotify( const char * S ) { |
177 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { | 177 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { |
178 | ErrorConnectCount --; | 178 | ErrorConnectCount --; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | void OTGateway::timerEvent( QTimerEvent * ) { | 182 | void OTGateway::timerEvent( QTimerEvent * ) { |
183 | 183 | ||
184 | OTDriver * D; | 184 | OTDriver * D; |
185 | unsigned int oldc = AllDrivers.count(); | 185 | unsigned int oldc = AllDrivers.count(); |
186 | bool old; | 186 | bool old; |
187 | 187 | ||
188 | AllDrivers.update(); | 188 | AllDrivers.update(); |
189 | 189 | ||
190 | if( oldc != AllDrivers.count() ) { | 190 | if( oldc != AllDrivers.count() ) { |
191 | updateDrivers(); | 191 | updateDrivers(); |
192 | } else { | 192 | } else { |
193 | for( unsigned int i = 0; | 193 | for( unsigned int i = 0; |
194 | i < AllDrivers.count(); | 194 | i < AllDrivers.count(); |
195 | i ++ ) { | 195 | i ++ ) { |
196 | D = AllDrivers[i]; | 196 | D = AllDrivers[i]; |
197 | old = D->isUp(); | 197 | old = D->isUp(); |
198 | if( D->currentState() >= 0 ) { | 198 | if( D->currentState() >= 0 ) { |
199 | if( old != D->isUp() ) { | 199 | if( old != D->isUp() ) { |
200 | emit stateChange( D, D->isUp() ); | 200 | emit stateChange( D, D->isUp() ); |
201 | } | 201 | } |
202 | } else { | 202 | } else { |
203 | // if one driver is unable to provide info | 203 | // if one driver is unable to provide info |
204 | // we refresh all devices | 204 | // we refresh all devices |
205 | updateDrivers(); | 205 | updateDrivers(); |
206 | return; | 206 | return; |
207 | } | 207 | } |
208 | } | 208 | } |
209 | } | 209 | } |
210 | } | 210 | } |
211 | 211 | ||
212 | void OTGateway::SLOT_Enabled( int id, bool Up ) { | 212 | void OTGateway::SLOT_Enabled( int id, bool Up ) { |
213 | owarn << "device " << id << " state " << Up << oendl; | 213 | odebug << "device " << id << " state " << Up << oendl; |
214 | if( Up ) { | 214 | if( Up ) { |
215 | // device is up -> detect it | 215 | // device is up -> detect it |
216 | updateDrivers(); | 216 | updateDrivers(); |
217 | if( (unsigned)id >= AllDrivers.count() ) { | 217 | if( (unsigned)id >= AllDrivers.count() ) { |
218 | // to make sure that the driver really IS detected | 218 | // to make sure that the driver really IS detected |
219 | AllDrivers[id]->bringUp(); | 219 | AllDrivers[id]->bringUp(); |
220 | } | 220 | } |
221 | } // if DOWN device already down | 221 | } // if DOWN device already down |
222 | emit deviceEnabled( Up ); | 222 | emit deviceEnabled( Up ); |
223 | } | 223 | } |
224 | 224 | ||
225 | void OTGateway::updateDrivers( void ) { | 225 | void OTGateway::updateDrivers( void ) { |
226 | OTDriver * D; | 226 | OTDriver * D; |
227 | 227 | ||
228 | AllDrivers.update(); | 228 | AllDrivers.update(); |
229 | 229 | ||
230 | owarn << "updated drivers. now " << AllDrivers.count() << oendl; | 230 | odebug << "updated drivers. now " << AllDrivers.count() << oendl; |
231 | 231 | ||
232 | // connect signals for each driver | 232 | // connect signals for each driver |
233 | for( unsigned int i = 0; | 233 | for( unsigned int i = 0; |
234 | i < AllDrivers.count(); | 234 | i < AllDrivers.count(); |
235 | i ++ ) { | 235 | i ++ ) { |
236 | D = AllDrivers[i]; | 236 | D = AllDrivers[i]; |
237 | 237 | ||
238 | connect( D, | 238 | connect( D, |
239 | SIGNAL( error( const QString & ) ), | 239 | SIGNAL( error( const QString & ) ), |
240 | this, | 240 | this, |
241 | SLOT( SLOT_ShowError( const QString & ) ) | 241 | SLOT( SLOT_ShowError( const QString & ) ) |
242 | ); | 242 | ); |
243 | 243 | ||
244 | connect( D, | 244 | connect( D, |
245 | SIGNAL( stateChange( OTDriver *, bool ) ), | 245 | SIGNAL( stateChange( OTDriver *, bool ) ), |
246 | this, | 246 | this, |
247 | SIGNAL( stateChange( OTDriver *, bool ) ) | 247 | SIGNAL( stateChange( OTDriver *, bool ) ) |
248 | ); | 248 | ); |
249 | 249 | ||
250 | connect( D, | 250 | connect( D, |
251 | SIGNAL( driverDisappeared( OTDriver * ) ), | 251 | SIGNAL( driverDisappeared( OTDriver * ) ), |
252 | this, | 252 | this, |
253 | SLOT( SLOT_DriverDisappeared( OTDriver * ) ) | 253 | SLOT( SLOT_DriverDisappeared( OTDriver * ) ) |
254 | ); | 254 | ); |
255 | } | 255 | } |
256 | 256 | ||
257 | // verify main device too | 257 | // verify main device too |
258 | if( TheOTDevice ) | 258 | if( TheOTDevice ) |
259 | TheOTDevice->checkAttach(); | 259 | TheOTDevice->checkAttach(); |
260 | 260 | ||
261 | // set to default scanning hardware | 261 | // set to default scanning hardware |
262 | setScanWith( 0 ); | 262 | setScanWith( 0 ); |
263 | 263 | ||
264 | emit driverListChanged(); | 264 | emit driverListChanged(); |
265 | } | 265 | } |
266 | 266 | ||
267 | void OTGateway::SLOT_DriverDisappeared( OTDriver * D ) { | 267 | void OTGateway::SLOT_DriverDisappeared( OTDriver * D ) { |
268 | owarn << "Driver " << D->devname() << " when offline" << oendl; | 268 | odebug << "Driver " << D->devname() << " when offline" << oendl; |
269 | updateDrivers(); | 269 | updateDrivers(); |
270 | } | 270 | } |
271 | 271 | ||
272 | void OTGateway::scanNeighbourhood( OTDriver * D ) { | 272 | void OTGateway::scanNeighbourhood( OTDriver * D ) { |
273 | 273 | ||
274 | if( Scanning ) { | 274 | if( Scanning ) { |
275 | stopScanOfNeighbourhood(); | 275 | stopScanOfNeighbourhood(); |
276 | } | 276 | } |
277 | 277 | ||
278 | if( D ) { | 278 | if( D ) { |
279 | setScanWith( D ); | 279 | setScanWith( D ); |
280 | } | 280 | } |
281 | 281 | ||
282 | Scanning = new OTInquiry( scanWith() ); | 282 | Scanning = new OTInquiry( scanWith() ); |
283 | 283 | ||
284 | connect( Scanning, | 284 | connect( Scanning, |
285 | SIGNAL( peerFound( OTPeer *, bool )), | 285 | SIGNAL( peerFound( OTPeer *, bool )), |
286 | this, | 286 | this, |
287 | SLOT( SLOT_PeerDetected( OTPeer *, bool ) ) | 287 | SLOT( SLOT_PeerDetected( OTPeer *, bool ) ) |
288 | ); | 288 | ); |
289 | connect( Scanning, | 289 | connect( Scanning, |
290 | SIGNAL( finished()), | 290 | SIGNAL( finished()), |
291 | this, | 291 | this, |
292 | SLOT( SLOT_FinishedDetecting() ) | 292 | SLOT( SLOT_FinishedDetecting() ) |
293 | ); | 293 | ); |
294 | 294 | ||
295 | // start scanning | 295 | // start scanning |
296 | Scanning->inquire( 30.0 ); | 296 | Scanning->inquire( 30.0 ); |
297 | } | 297 | } |
298 | 298 | ||
299 | OTPeer* OTGateway::findPeer( const OTDeviceAddress & Addr ) { | 299 | OTPeer* OTGateway::findPeer( const OTDeviceAddress & Addr ) { |
300 | for( unsigned int i = 0 ; i < AllPeers.count(); i ++ ) { | 300 | for( unsigned int i = 0 ; i < AllPeers.count(); i ++ ) { |
301 | if( AllPeers[i]->address() == Addr ) { | 301 | if( AllPeers[i]->address() == Addr ) { |
302 | return AllPeers[i]; | 302 | return AllPeers[i]; |
303 | } | 303 | } |
304 | } | 304 | } |
305 | return 0; | 305 | return 0; |
306 | } | 306 | } |
307 | 307 | ||
308 | OTDriver* OTGateway::findDriver( const OTDeviceAddress & Addr ) { | 308 | OTDriver* OTGateway::findDriver( const OTDeviceAddress & Addr ) { |
309 | for( unsigned int i = 0 ; i < AllDrivers.count(); i ++ ) { | 309 | for( unsigned int i = 0 ; i < AllDrivers.count(); i ++ ) { |
310 | if( AllDrivers[i]->address() == Addr ) { | 310 | if( AllDrivers[i]->address() == Addr ) { |
311 | return AllDrivers[i]; | 311 | return AllDrivers[i]; |
312 | } | 312 | } |
313 | } | 313 | } |
314 | return 0; | 314 | return 0; |
315 | } | 315 | } |
316 | 316 | ||
317 | void OTGateway::SLOT_PeerDetected( OTPeer * P, bool IsNew ) { | 317 | void OTGateway::SLOT_PeerDetected( OTPeer * P, bool IsNew ) { |
318 | 318 | ||
319 | if( IsNew ) { | 319 | if( IsNew ) { |
320 | // new peer | 320 | // new peer |
321 | owarn << "New peer " << P->name() << oendl; | 321 | odebug << "New peer " << P->name() << oendl; |
322 | addPeer( P ); | 322 | addPeer( P ); |
323 | } | 323 | } |
324 | 324 | ||
325 | emit detectedPeer( P, IsNew ); | 325 | emit detectedPeer( P, IsNew ); |
326 | } | 326 | } |
327 | 327 | ||
328 | void OTGateway::addPeer( OTPeer * P ) { | 328 | void OTGateway::addPeer( OTPeer * P ) { |
329 | AllPeers.resize( AllPeers.size()+1); | 329 | AllPeers.resize( AllPeers.size()+1); |
330 | AllPeers.insert( AllPeers.size()-1, P ); | 330 | AllPeers.insert( AllPeers.size()-1, P ); |
331 | AllPeersModified = 1; | 331 | AllPeersModified = 1; |
332 | } | 332 | } |
333 | 333 | ||
334 | void OTGateway::removePeer( OTPeer * P ) { | 334 | void OTGateway::removePeer( OTPeer * P ) { |
335 | int i = AllPeers.find( P ); | 335 | int i = AllPeers.find( P ); |
336 | if( i ) { | 336 | if( i ) { |
337 | AllPeers.remove( i ); | 337 | AllPeers.remove( i ); |
338 | AllPeersModified = 1; | 338 | AllPeersModified = 1; |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | void OTGateway::stopScanOfNeighbourhood( void ) { | 342 | void OTGateway::stopScanOfNeighbourhood( void ) { |
343 | if( Scanning ) { | 343 | if( Scanning ) { |
344 | delete Scanning; | 344 | delete Scanning; |
345 | Scanning = 0; | 345 | Scanning = 0; |
346 | } | 346 | } |
347 | } | 347 | } |
348 | 348 | ||
349 | void OTGateway::SLOT_FinishedDetecting() { | 349 | void OTGateway::SLOT_FinishedDetecting() { |
350 | stopScanOfNeighbourhood(); | 350 | stopScanOfNeighbourhood(); |
351 | emit finishedDetecting(); | 351 | emit finishedDetecting(); |
352 | } | 352 | } |
353 | 353 | ||
354 | const char * OTGateway::deviceTypeToName( int cls ) { | 354 | const char * OTGateway::deviceTypeToName( int cls ) { |
355 | switch ( (cls & 0x001F00) >> 8) { | 355 | switch ( (cls & 0x001F00) >> 8) { |
356 | case 0x00: | 356 | case 0x00: |
357 | return "misc"; | 357 | return "misc"; |
358 | case 0x01: | 358 | case 0x01: |
359 | return "computer"; | 359 | return "computer"; |
360 | case 0x02: | 360 | case 0x02: |
361 | return "phone"; | 361 | return "phone"; |
362 | case 0x03: | 362 | case 0x03: |
363 | return "lan"; | 363 | return "lan"; |
364 | case 0x04: | 364 | case 0x04: |
365 | return "av"; | 365 | return "av"; |
366 | case 0x05: | 366 | case 0x05: |
367 | return "peripheral"; | 367 | return "peripheral"; |
368 | case 0x06: | 368 | case 0x06: |
369 | return "imaging"; | 369 | return "imaging"; |
370 | case 0x07: | 370 | case 0x07: |
371 | default : | 371 | default : |
372 | break; | 372 | break; |
373 | } | 373 | } |
374 | return "unknown"; | 374 | return "unknown"; |
375 | } | 375 | } |
376 | 376 | ||
377 | PANConnectionVector OTGateway::getPANConnections( void ) { | 377 | PANConnectionVector OTGateway::getPANConnections( void ) { |
378 | PANConnectionVector V; | 378 | PANConnectionVector V; |
379 | 379 | ||
380 | struct bnep_connlist_req req; | 380 | struct bnep_connlist_req req; |
381 | struct bnep_conninfo ci[48]; | 381 | struct bnep_conninfo ci[48]; |
382 | 382 | ||
383 | V.setAutoDelete(TRUE); | 383 | V.setAutoDelete(TRUE); |
384 | 384 | ||
385 | int ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP); | 385 | int ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP); |
386 | if (ctl < 0) { | 386 | if (ctl < 0) { |
387 | owarn << "Failed to open control socket" << oendl; | 387 | odebug << "Failed to open control socket" << oendl; |
388 | return V; | 388 | return V; |
389 | } | 389 | } |
390 | 390 | ||
391 | req.cnum = 48; | 391 | req.cnum = 48; |
392 | req.ci = ci; | 392 | req.ci = ci; |
393 | if (ioctl(ctl, BNEPGETCONNLIST, &req)) { | 393 | if (ioctl(ctl, BNEPGETCONNLIST, &req)) { |
394 | owarn << "Failed to get connection list" << oendl; | 394 | odebug << "Failed to get connection list" << oendl; |
395 | ::close( ctl ); | 395 | ::close( ctl ); |
396 | return V; | 396 | return V; |
397 | } | 397 | } |
398 | 398 | ||
399 | for ( unsigned i=0; i < req.cnum; i++) { | 399 | for ( unsigned i=0; i < req.cnum; i++) { |
400 | V.resize( V.size() + 1 ); | 400 | V.resize( V.size() + 1 ); |
401 | if( ci[i].role == BNEP_SVC_PANU ) { | 401 | if( ci[i].role == BNEP_SVC_PANU ) { |
402 | // we are the client | 402 | // we are the client |
403 | V.insert( V.size()-1, new OTPANConnection( | 403 | V.insert( V.size()-1, new OTPANConnection( |
404 | ci[i].device, | 404 | ci[i].device, |
405 | batostr((bdaddr_t *) ci[i].dst) | 405 | batostr((bdaddr_t *) ci[i].dst) |
406 | ) ); | 406 | ) ); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | 409 | ||
410 | ::close( ctl ); | 410 | ::close( ctl ); |
411 | return V; | 411 | return V; |
412 | } | 412 | } |
413 | 413 | ||
414 | struct link_key { | 414 | struct link_key { |
415 | bdaddr_t sba; | 415 | bdaddr_t sba; |
416 | bdaddr_t dba; | 416 | bdaddr_t dba; |
417 | uint8_t key[16]; | 417 | uint8_t key[16]; |
418 | uint8_t type; | 418 | uint8_t type; |
419 | time_t time; | 419 | time_t time; |
420 | }; | 420 | }; |
421 | 421 | ||
422 | void OTGateway::readLinkKeys( void ) { | 422 | void OTGateway::readLinkKeys( void ) { |
423 | 423 | ||
424 | struct link_key k; | 424 | struct link_key k; |
425 | int rv; | 425 | int rv; |
426 | 426 | ||
427 | AllKeys.truncate(0); | 427 | AllKeys.truncate(0); |
428 | 428 | ||
429 | QFile F( "/etc/bluetooth/link_key" ); | 429 | QFile F( "/etc/bluetooth/link_key" ); |
430 | 430 | ||
431 | if( ! F.open( IO_ReadOnly ) ) { | 431 | if( ! F.open( IO_ReadOnly ) ) { |
432 | emit error( tr("Cannot open link_key file") ); | 432 | emit error( tr("Cannot open link_key file") ); |
433 | return; | 433 | return; |
434 | } | 434 | } |
435 | 435 | ||
436 | while( 1 ) { | 436 | while( 1 ) { |
437 | rv = F.readBlock( (char *)&k, sizeof( k ) ); | 437 | rv = F.readBlock( (char *)&k, sizeof( k ) ); |
438 | if( rv == 0 ) | 438 | if( rv == 0 ) |
439 | // EOF | 439 | // EOF |
440 | break; | 440 | break; |
441 | 441 | ||
442 | if( rv < 0 ) { | 442 | if( rv < 0 ) { |
diff --git a/noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp b/noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp index 471c3bf..1997b44 100644 --- a/noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp | |||
@@ -1,97 +1,97 @@ | |||
1 | //-*-c++-*- | 1 | //-*-c++-*- |
2 | /*************************************************************************** | 2 | /*************************************************************************** |
3 | * Copyright (C) 2003 by Fred Schaettgen * | 3 | * Copyright (C) 2003 by Fred Schaettgen * |
4 | * kdebluetooth@schaettgen.de * | 4 | * kdebluetooth@schaettgen.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * | 7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License, or * | 8 | * the Free Software Foundation; either version 2 of the License, or * |
9 | * (at your option) any later version. * | 9 | * (at your option) any later version. * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | #include <qbuffer.h> | 12 | #include <qbuffer.h> |
13 | #include <qtimer.h> | 13 | #include <qtimer.h> |
14 | #include <qdatastream.h> | 14 | #include <qdatastream.h> |
15 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
16 | 16 | ||
17 | #include <bluezlib.h> | 17 | #include <bluezlib.h> |
18 | 18 | ||
19 | // #include "deviceaddress.h" | 19 | // #include "deviceaddress.h" |
20 | #include <OTHCISocket.h> | 20 | #include <OTHCISocket.h> |
21 | #include <OTDriver.h> | 21 | #include <OTDriver.h> |
22 | 22 | ||
23 | using namespace Opietooth2; | 23 | using namespace Opietooth2; |
24 | 24 | ||
25 | OTHCISocket::OTHCISocket( OTDriver * D ) : | 25 | OTHCISocket::OTHCISocket( OTDriver * D ) : |
26 | QObject( D, D->devname() ) { | 26 | QObject( D, D->devname() ) { |
27 | BStatusSet = false; | 27 | BStatusSet = false; |
28 | Driver = D; | 28 | Driver = D; |
29 | HCIReadNotifier = 0; | 29 | HCIReadNotifier = 0; |
30 | } | 30 | } |
31 | 31 | ||
32 | OTHCISocket::~OTHCISocket() { | 32 | OTHCISocket::~OTHCISocket() { |
33 | close(); | 33 | close(); |
34 | } | 34 | } |
35 | 35 | ||
36 | void OTHCISocket::close() { | 36 | void OTHCISocket::close() { |
37 | owarn << "OTHCISocket::close()" << oendl; | 37 | odebug << "OTHCISocket::close()" << oendl; |
38 | if( HCIReadNotifier ) { | 38 | if( HCIReadNotifier ) { |
39 | delete HCIReadNotifier; | 39 | delete HCIReadNotifier; |
40 | } | 40 | } |
41 | 41 | ||
42 | if( HCISocket.isValid() ) { | 42 | if( HCISocket.isValid() ) { |
43 | HCISocket.close(); | 43 | HCISocket.close(); |
44 | } | 44 | } |
45 | } | 45 | } |
46 | 46 | ||
47 | bool OTHCISocket::open() { | 47 | bool OTHCISocket::open() { |
48 | 48 | ||
49 | owarn << "OTHCISocket::open()" << oendl; | 49 | odebug << "OTHCISocket::open()" << oendl; |
50 | int s; | 50 | int s; |
51 | 51 | ||
52 | s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); | 52 | s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); |
53 | 53 | ||
54 | if (s < 0) { | 54 | if (s < 0) { |
55 | emit error( tr( "Error creating socket on %1 : %2 %3"). | 55 | emit error( tr( "Error creating socket on %1 : %2 %3"). |
56 | arg( Driver->devname() ). | 56 | arg( Driver->devname() ). |
57 | arg( errno ). | 57 | arg( errno ). |
58 | arg( strerror(errno) ) | 58 | arg( strerror(errno) ) |
59 | ); | 59 | ); |
60 | return false; | 60 | return false; |
61 | } | 61 | } |
62 | 62 | ||
63 | /* Bind socket to the HCI device */ | 63 | /* Bind socket to the HCI device */ |
64 | struct sockaddr_hci sa; | 64 | struct sockaddr_hci sa; |
65 | sa.hci_family = AF_BLUETOOTH; | 65 | sa.hci_family = AF_BLUETOOTH; |
66 | sa.hci_dev = Driver->devId(); | 66 | sa.hci_dev = Driver->devId(); |
67 | if (bind(s, (struct sockaddr *)&sa, sizeof(sa)) < 0) { | 67 | if (bind(s, (struct sockaddr *)&sa, sizeof(sa)) < 0) { |
68 | ::close(s); | 68 | ::close(s); |
69 | emit error( tr( "Error binding to socket to %1 : %2 %3"). | 69 | emit error( tr( "Error binding to socket to %1 : %2 %3"). |
70 | arg( Driver->devname() ). | 70 | arg( Driver->devname() ). |
71 | arg( errno ). | 71 | arg( errno ). |
72 | arg( strerror(errno) ) | 72 | arg( strerror(errno) ) |
73 | ); | 73 | ); |
74 | return false; | 74 | return false; |
75 | } | 75 | } |
76 | 76 | ||
77 | struct hci_filter flt; | 77 | struct hci_filter flt; |
78 | hci_filter_clear(&flt); | 78 | hci_filter_clear(&flt); |
79 | hci_filter_set_ptype(HCI_EVENT_PKT, &flt); | 79 | hci_filter_set_ptype(HCI_EVENT_PKT, &flt); |
80 | hci_filter_all_events(&flt); | 80 | hci_filter_all_events(&flt); |
81 | if( setsockopt(s, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0 ) { | 81 | if( setsockopt(s, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0 ) { |
82 | ::close(s); | 82 | ::close(s); |
83 | emit error( tr( "HCI filter setup failed on %1 : %2 %3"). | 83 | emit error( tr( "HCI filter setup failed on %1 : %2 %3"). |
84 | arg( Driver->devname() ). | 84 | arg( Driver->devname() ). |
85 | arg( errno ). | 85 | arg( errno ). |
86 | arg( strerror(errno) ) | 86 | arg( strerror(errno) ) |
87 | ); | 87 | ); |
88 | return false; | 88 | return false; |
89 | } | 89 | } |
90 | 90 | ||
91 | if( HCIReadNotifier ) { | 91 | if( HCIReadNotifier ) { |
92 | delete HCIReadNotifier; | 92 | delete HCIReadNotifier; |
93 | } | 93 | } |
94 | 94 | ||
95 | HCISocket.setSocket(s, QSocketDevice::Datagram); | 95 | HCISocket.setSocket(s, QSocketDevice::Datagram); |
96 | HCIReadNotifier = new QSocketNotifier( | 96 | HCIReadNotifier = new QSocketNotifier( |
97 | s, QSocketNotifier::Read, this); | 97 | s, QSocketNotifier::Read, this); |
@@ -106,169 +106,169 @@ bool OTHCISocket::open() { | |||
106 | // this, SLOT(slotSocketError(int))); | 106 | // this, SLOT(slotSocketError(int))); |
107 | //connect(hciSocket, SIGNAL(connectionClosed()), | 107 | //connect(hciSocket, SIGNAL(connectionClosed()), |
108 | // this, SLOT(slotConnectionClosed())); | 108 | // this, SLOT(slotConnectionClosed())); |
109 | //hciSocket->setSocket(s); | 109 | //hciSocket->setSocket(s); |
110 | 110 | ||
111 | return true; | 111 | return true; |
112 | } | 112 | } |
113 | 113 | ||
114 | void OTHCISocket::slotSocketError(int e) { | 114 | void OTHCISocket::slotSocketError(int e) { |
115 | close(); | 115 | close(); |
116 | emit error( tr( "HCI socket error 0x%1 on %1 : %2 %3"). | 116 | emit error( tr( "HCI socket error 0x%1 on %1 : %2 %3"). |
117 | arg(e,2,16). | 117 | arg(e,2,16). |
118 | arg( Driver->devname() ). | 118 | arg( Driver->devname() ). |
119 | arg( errno ). | 119 | arg( errno ). |
120 | arg( strerror(errno) ) | 120 | arg( strerror(errno) ) |
121 | ); | 121 | ); |
122 | } | 122 | } |
123 | 123 | ||
124 | void OTHCISocket::slotSocketActivated() { | 124 | void OTHCISocket::slotSocketActivated() { |
125 | 125 | ||
126 | QSocketDevice::Error err = HCISocket.error(); | 126 | QSocketDevice::Error err = HCISocket.error(); |
127 | 127 | ||
128 | if( (err == QSocketDevice::NoError ) && | 128 | if( (err == QSocketDevice::NoError ) && |
129 | ( HCISocket.isValid() ) ) { | 129 | ( HCISocket.isValid() ) ) { |
130 | //kdDebug() << "HCI socket ready read." << endl; | 130 | //kdDebug() << "HCI socket ready read." << endl; |
131 | 131 | ||
132 | unsigned char buf[512]; | 132 | unsigned char buf[512]; |
133 | int psize = HCISocket.readBlock((char*)buf, 512); | 133 | int psize = HCISocket.readBlock((char*)buf, 512); |
134 | 134 | ||
135 | if (psize <= 0) { | 135 | if (psize <= 0) { |
136 | slotSocketError(HCISocket.error()); | 136 | slotSocketError(HCISocket.error()); |
137 | HCISocket.close(); | 137 | HCISocket.close(); |
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | 140 | ||
141 | //unsigned char packetType = buf[0]; | 141 | //unsigned char packetType = buf[0]; |
142 | unsigned char eventCode = buf[1]; | 142 | unsigned char eventCode = buf[1]; |
143 | unsigned char len = buf[2]; | 143 | unsigned char len = buf[2]; |
144 | 144 | ||
145 | if (psize-3 == len) { | 145 | if (psize-3 == len) { |
146 | 146 | ||
147 | QByteArray databuf; | 147 | QByteArray databuf; |
148 | databuf.duplicate((char*)(buf+3), len); | 148 | databuf.duplicate((char*)(buf+3), len); |
149 | emit event(eventCode, databuf); | 149 | emit event(eventCode, databuf); |
150 | if (eventCode == EVT_CMD_STATUS) { | 150 | if (eventCode == EVT_CMD_STATUS) { |
151 | updateStatus( databuf ); | 151 | updateStatus( databuf ); |
152 | } | 152 | } |
153 | } else { | 153 | } else { |
154 | owarn << "Error reading hci packet: packetSize(" | 154 | odebug << "Error reading hci packet: packetSize(" |
155 | << psize | 155 | << psize |
156 | << ")-3 != dataSize(" | 156 | << ")-3 != dataSize(" |
157 | << len | 157 | << len |
158 | << ")" | 158 | << ")" |
159 | << oendl; | 159 | << oendl; |
160 | } | 160 | } |
161 | } else if (err == QSocketDevice::NoError) { | 161 | } else if (err == QSocketDevice::NoError) { |
162 | slotConnectionClosed(); | 162 | slotConnectionClosed(); |
163 | } else { | 163 | } else { |
164 | HCISocket.close(); | 164 | HCISocket.close(); |
165 | slotSocketError(err); | 165 | slotSocketError(err); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | void OTHCISocket::updateStatus(const QByteArray& data) { | 169 | void OTHCISocket::updateStatus(const QByteArray& data) { |
170 | 170 | ||
171 | QDataStream stream(data, IO_ReadOnly); | 171 | QDataStream stream(data, IO_ReadOnly); |
172 | stream.setByteOrder(QDataStream::LittleEndian); | 172 | stream.setByteOrder(QDataStream::LittleEndian); |
173 | Q_UINT8 status, dummy; | 173 | Q_UINT8 status, dummy; |
174 | Q_UINT16 opcode; | 174 | Q_UINT16 opcode; |
175 | 175 | ||
176 | BStatusSet = true; | 176 | BStatusSet = true; |
177 | 177 | ||
178 | stream >> status >> dummy >> opcode; | 178 | stream >> status >> dummy >> opcode; |
179 | //kdDebug() << "updatestatus opcode=" << uint32_t(opcode) << endl; | 179 | //kdDebug() << "updatestatus opcode=" << uint32_t(opcode) << endl; |
180 | LastStatus = status; | 180 | LastStatus = status; |
181 | LastStatusOgf = cmd_opcode_ogf(opcode); | 181 | LastStatusOgf = cmd_opcode_ogf(opcode); |
182 | LastStatusOcf = cmd_opcode_ocf(opcode); | 182 | LastStatusOcf = cmd_opcode_ocf(opcode); |
183 | } | 183 | } |
184 | 184 | ||
185 | void OTHCISocket::slotConnectionClosed() { | 185 | void OTHCISocket::slotConnectionClosed() { |
186 | owarn << "HCI connection closed." << oendl; | 186 | odebug << "HCI connection closed." << oendl; |
187 | emit connectionClosed(); | 187 | emit connectionClosed(); |
188 | } | 188 | } |
189 | 189 | ||
190 | void OTHCISocket::readEvent() { | 190 | void OTHCISocket::readEvent() { |
191 | 191 | ||
192 | if (HCIReadNotifier) { | 192 | if (HCIReadNotifier) { |
193 | slotSocketActivated(); | 193 | slotSocketActivated(); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | bool OTHCISocket::sendCommand( unsigned char ogf, | 197 | bool OTHCISocket::sendCommand( unsigned char ogf, |
198 | unsigned short ocf, | 198 | unsigned short ocf, |
199 | QByteArray buf | 199 | QByteArray buf |
200 | ) { | 200 | ) { |
201 | QBuffer packet; | 201 | QBuffer packet; |
202 | QDataStream stream(&packet); | 202 | QDataStream stream(&packet); |
203 | 203 | ||
204 | stream.setByteOrder(QDataStream::LittleEndian); | 204 | stream.setByteOrder(QDataStream::LittleEndian); |
205 | packet.open(IO_WriteOnly); | 205 | packet.open(IO_WriteOnly); |
206 | 206 | ||
207 | if (buf.size() > 255) return false; | 207 | if (buf.size() > 255) return false; |
208 | 208 | ||
209 | //kdDebug() << "sendCommand. ogf=" << ogf << " ocf=" << ocf << endl; | 209 | //kdDebug() << "sendCommand. ogf=" << ogf << " ocf=" << ocf << endl; |
210 | Q_UINT16 opcode = cmd_opcode_pack(ogf, ocf); | 210 | Q_UINT16 opcode = cmd_opcode_pack(ogf, ocf); |
211 | Q_UINT8 pType = HCI_COMMAND_PKT; | 211 | Q_UINT8 pType = HCI_COMMAND_PKT; |
212 | Q_UINT8 buflen = buf.size(); | 212 | Q_UINT8 buflen = buf.size(); |
213 | 213 | ||
214 | stream << pType << opcode << buflen; | 214 | stream << pType << opcode << buflen; |
215 | stream.writeRawBytes(buf.data(), buflen); | 215 | stream.writeRawBytes(buf.data(), buflen); |
216 | packet.close(); | 216 | packet.close(); |
217 | HCISocket.writeBlock((const char*)packet.buffer(), | 217 | HCISocket.writeBlock((const char*)packet.buffer(), |
218 | packet.buffer().size()); | 218 | packet.buffer().size()); |
219 | return true; | 219 | return true; |
220 | } | 220 | } |
221 | 221 | ||
222 | bool OTHCISocket::readStatus( unsigned char ogf, | 222 | bool OTHCISocket::readStatus( unsigned char ogf, |
223 | unsigned short ocf, | 223 | unsigned short ocf, |
224 | int *status, | 224 | int *status, |
225 | int timeout_ms) { | 225 | int timeout_ms) { |
226 | QTimer timer; | 226 | QTimer timer; |
227 | 227 | ||
228 | timer.start(timeout_ms, true); | 228 | timer.start(timeout_ms, true); |
229 | BStatusSet = false; | 229 | BStatusSet = false; |
230 | 230 | ||
231 | while (timer.isActive() && HCISocket.isValid()) { | 231 | while (timer.isActive() && HCISocket.isValid()) { |
232 | 232 | ||
233 | owarn << "OTHCISocket::readStatus()" << oendl; | 233 | odebug << "OTHCISocket::readStatus()" << oendl; |
234 | bool timeout = false; | 234 | bool timeout = false; |
235 | 235 | ||
236 | if( HCISocket.bytesAvailable() == 0) { | 236 | if( HCISocket.bytesAvailable() == 0) { |
237 | int rv = HCISocket.waitForMore(timeout_ms); | 237 | int rv = HCISocket.waitForMore(timeout_ms); |
238 | timeout = (rv == 0); | 238 | timeout = (rv == 0); |
239 | } | 239 | } |
240 | 240 | ||
241 | if (!timeout) { | 241 | if (!timeout) { |
242 | slotSocketActivated(); | 242 | slotSocketActivated(); |
243 | } | 243 | } |
244 | 244 | ||
245 | if( BStatusSet == true && | 245 | if( BStatusSet == true && |
246 | ogf == LastStatusOgf && | 246 | ogf == LastStatusOgf && |
247 | ocf == LastStatusOcf) { | 247 | ocf == LastStatusOcf) { |
248 | *status = LastStatus; | 248 | *status = LastStatus; |
249 | owarn << "OTHCISocket::readStatus(ogf=" | 249 | odebug << "OTHCISocket::readStatus(ogf=" |
250 | << ogf | 250 | << ogf |
251 | << ",ocf=" | 251 | << ",ocf=" |
252 | << ocf | 252 | << ocf |
253 | << ",timeout=" | 253 | << ",timeout=" |
254 | << LastStatus | 254 | << LastStatus |
255 | << ")" | 255 | << ")" |
256 | << oendl; | 256 | << oendl; |
257 | return true; | 257 | return true; |
258 | } | 258 | } |
259 | } | 259 | } |
260 | 260 | ||
261 | owarn << "OTHCISocket::readStatus(ogf=" | 261 | odebug << "OTHCISocket::readStatus(ogf=" |
262 | << ogf | 262 | << ogf |
263 | << ",ocf=" | 263 | << ",ocf=" |
264 | << ocf | 264 | << ocf |
265 | << ",timeout=" | 265 | << ",timeout=" |
266 | << LastStatus | 266 | << LastStatus |
267 | << ") : timeout " | 267 | << ") : timeout " |
268 | << oendl; | 268 | << oendl; |
269 | return false; | 269 | return false; |
270 | } | 270 | } |
271 | 271 | ||
272 | int OTHCISocket::socket() { | 272 | int OTHCISocket::socket() { |
273 | return HCISocket.socket(); | 273 | return HCISocket.socket(); |
274 | } | 274 | } |
diff --git a/noncore/settings/networksettings2/opietooth2/OTInquiry.cpp b/noncore/settings/networksettings2/opietooth2/OTInquiry.cpp index 8e94bbc..2bc63c7 100644 --- a/noncore/settings/networksettings2/opietooth2/OTInquiry.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTInquiry.cpp | |||
@@ -14,206 +14,206 @@ | |||
14 | #include <qsocket.h> | 14 | #include <qsocket.h> |
15 | #include <qdatetime.h> | 15 | #include <qdatetime.h> |
16 | #include <qtimer.h> | 16 | #include <qtimer.h> |
17 | #include <qthread.h> | 17 | #include <qthread.h> |
18 | #include <qapplication.h> | 18 | #include <qapplication.h> |
19 | 19 | ||
20 | #include <bluezlib.h> | 20 | #include <bluezlib.h> |
21 | 21 | ||
22 | #include <OTGateway.h> | 22 | #include <OTGateway.h> |
23 | #include <OTDriver.h> | 23 | #include <OTDriver.h> |
24 | #include <OTPeer.h> | 24 | #include <OTPeer.h> |
25 | #include <OTHCISocket.h> | 25 | #include <OTHCISocket.h> |
26 | #include <OTInquiry.h> | 26 | #include <OTInquiry.h> |
27 | 27 | ||
28 | #include <opie2/odebug.h> | 28 | #include <opie2/odebug.h> |
29 | 29 | ||
30 | using namespace Opietooth2; | 30 | using namespace Opietooth2; |
31 | 31 | ||
32 | #define max(a,b) (((a)>(b)) ? (a) : (b)) | 32 | #define max(a,b) (((a)>(b)) ? (a) : (b)) |
33 | #define min(a,b) (((a)>(b)) ? (b) : (a)) | 33 | #define min(a,b) (((a)>(b)) ? (b) : (a)) |
34 | 34 | ||
35 | OTInquiry::OTInquiry( OTDriver * Drv ) : QObject( Drv ) { | 35 | OTInquiry::OTInquiry( OTDriver * Drv ) : QObject( Drv ) { |
36 | 36 | ||
37 | reset(); | 37 | reset(); |
38 | 38 | ||
39 | InquiryTimeoutTimer = new QTimer(this); | 39 | InquiryTimeoutTimer = new QTimer(this); |
40 | 40 | ||
41 | connect( InquiryTimeoutTimer, | 41 | connect( InquiryTimeoutTimer, |
42 | SIGNAL(timeout()), | 42 | SIGNAL(timeout()), |
43 | this, | 43 | this, |
44 | SLOT(slotInquiryTimeout())); | 44 | SLOT(slotInquiryTimeout())); |
45 | 45 | ||
46 | Driver = Drv; | 46 | Driver = Drv; |
47 | Socket = Drv->openSocket(); | 47 | Socket = Drv->openSocket(); |
48 | Socket->open(); | 48 | Socket->open(); |
49 | 49 | ||
50 | connect( Socket, | 50 | connect( Socket, |
51 | SIGNAL( event(unsigned char, QByteArray)), | 51 | SIGNAL( event(unsigned char, QByteArray)), |
52 | this, | 52 | this, |
53 | SLOT(slotHCIEvent(unsigned char, QByteArray))); | 53 | SLOT(slotHCIEvent(unsigned char, QByteArray))); |
54 | } | 54 | } |
55 | 55 | ||
56 | OTInquiry::~OTInquiry() { | 56 | OTInquiry::~OTInquiry() { |
57 | stopInquiring(); | 57 | stopInquiring(); |
58 | } | 58 | } |
59 | 59 | ||
60 | void OTInquiry::stopInquiring( void ) { | 60 | void OTInquiry::stopInquiring( void ) { |
61 | if( Socket ) { | 61 | if( Socket ) { |
62 | owarn << "Stop inquiry" << oendl; | 62 | odebug << "Stop inquiry" << oendl; |
63 | Driver->closeSocket(); | 63 | Driver->closeSocket(); |
64 | Socket = 0; | 64 | Socket = 0; |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | bool OTInquiry::inquire( double timeout, int numResponses, int lap) { | 68 | bool OTInquiry::inquire( double timeout, int numResponses, int lap) { |
69 | 69 | ||
70 | QByteArray cmdBuf(5); | 70 | QByteArray cmdBuf(5); |
71 | 71 | ||
72 | cmdBuf[0] = lap & 0xFF; | 72 | cmdBuf[0] = lap & 0xFF; |
73 | cmdBuf[1] = (lap >> 8) & 0xFF; | 73 | cmdBuf[1] = (lap >> 8) & 0xFF; |
74 | cmdBuf[2] = (lap >> 16) & 0xFF; | 74 | cmdBuf[2] = (lap >> 16) & 0xFF; |
75 | cmdBuf[3] = max(0x01, min(0x30, int(timeout/1.28))); | 75 | cmdBuf[3] = max(0x01, min(0x30, int(timeout/1.28))); |
76 | cmdBuf[4] = (unsigned char)numResponses; | 76 | cmdBuf[4] = (unsigned char)numResponses; |
77 | 77 | ||
78 | owarn << "Send HCI inquiry command. wait for " << cmdBuf[3] << oendl; | 78 | odebug << "Send HCI inquiry command. wait for " << cmdBuf[3] << oendl; |
79 | 79 | ||
80 | Socket->sendCommand(0x01, 0x0001, cmdBuf); | 80 | Socket->sendCommand(0x01, 0x0001, cmdBuf); |
81 | 81 | ||
82 | int status; | 82 | int status; |
83 | 83 | ||
84 | if( Socket->readStatus(0x01, 0x0001, &status)) { | 84 | if( Socket->readStatus(0x01, 0x0001, &status)) { |
85 | if (status == 0) { | 85 | if (status == 0) { |
86 | SuccessfullyStarted = true; | 86 | SuccessfullyStarted = true; |
87 | InquiryTimeoutTimer->start( int(1000*(timeout+1.0)), true); | 87 | InquiryTimeoutTimer->start( int(1000*(timeout+1.0)), true); |
88 | return true; | 88 | return true; |
89 | } | 89 | } |
90 | else { | 90 | else { |
91 | QString S =QString().sprintf( "%x", status ); | 91 | QString S =QString().sprintf( "%x", status ); |
92 | owarn << "OTInquiry::inquiry() failed: 0x" << S << oendl; | 92 | odebug << "OTInquiry::inquiry() failed: 0x" << S << oendl; |
93 | emit finished(); | 93 | emit finished(); |
94 | return false; | 94 | return false; |
95 | } | 95 | } |
96 | } else { | 96 | } else { |
97 | owarn << "OTInquiry::inquiry(): Timeout." << oendl; | 97 | odebug << "OTInquiry::inquiry(): Timeout." << oendl; |
98 | return false; | 98 | return false; |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | bool OTInquiry::isInquiring() { | 102 | bool OTInquiry::isInquiring() { |
103 | return InquiryTimeoutTimer->isActive(); | 103 | return InquiryTimeoutTimer->isActive(); |
104 | } | 104 | } |
105 | 105 | ||
106 | bool OTInquiry::isFinished() { | 106 | bool OTInquiry::isFinished() { |
107 | return SuccessfullyStarted && SuccessfullyEnded; | 107 | return SuccessfullyStarted && SuccessfullyEnded; |
108 | } | 108 | } |
109 | 109 | ||
110 | void OTInquiry::reset() { | 110 | void OTInquiry::reset() { |
111 | 111 | ||
112 | SuccessfullyStarted = false; | 112 | SuccessfullyStarted = false; |
113 | SuccessfullyEnded = false; | 113 | SuccessfullyEnded = false; |
114 | //addrCache.clear(); | 114 | //addrCache.clear(); |
115 | //infoQueue.clear(); | 115 | //infoQueue.clear(); |
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
119 | void OTInquiry::onPeerFound( OTPeer * Peer, bool IsNew ) { | 119 | void OTInquiry::onPeerFound( OTPeer * Peer, bool IsNew ) { |
120 | emit peerFound( Peer, IsNew ); | 120 | emit peerFound( Peer, IsNew ); |
121 | } | 121 | } |
122 | 122 | ||
123 | void OTInquiry::slotInquiryTimeout() { | 123 | void OTInquiry::slotInquiryTimeout() { |
124 | emit error( tr( "Timeout while waiting for end of inquiry.") ); | 124 | emit error( tr( "Timeout while waiting for end of inquiry.") ); |
125 | } | 125 | } |
126 | 126 | ||
127 | void OTInquiry::slotHCIEvent(unsigned char eventCode, QByteArray buf) { | 127 | void OTInquiry::slotHCIEvent(unsigned char eventCode, QByteArray buf) { |
128 | 128 | ||
129 | owarn << "OTInquiry: hci packet received: eventCode=" | 129 | odebug << "OTInquiry: hci packet received: eventCode=" |
130 | << (unsigned int)eventCode | 130 | << (unsigned int)eventCode |
131 | << " packetLength=" | 131 | << " packetLength=" |
132 | << (unsigned int)buf.size() | 132 | << (unsigned int)buf.size() |
133 | << oendl; | 133 | << oendl; |
134 | 134 | ||
135 | unsigned char *data = (unsigned char*)buf.data(); | 135 | unsigned char *data = (unsigned char*)buf.data(); |
136 | switch (eventCode) { | 136 | switch (eventCode) { |
137 | case EVT_INQUIRY_COMPLETE: | 137 | case EVT_INQUIRY_COMPLETE: |
138 | { unsigned char status = data[0]; | 138 | { unsigned char status = data[0]; |
139 | owarn << "EVT_INQUIRY_COMPLETE status=" << status << oendl; | 139 | odebug << "EVT_INQUIRY_COMPLETE status=" << status << oendl; |
140 | InquiryTimeoutTimer->stop(); | 140 | InquiryTimeoutTimer->stop(); |
141 | if (status == 0) { | 141 | if (status == 0) { |
142 | if( SuccessfullyStarted == true) { | 142 | if( SuccessfullyStarted == true) { |
143 | owarn << "OTInquiry ended successfully" << oendl; | 143 | odebug << "OTInquiry ended successfully" << oendl; |
144 | SuccessfullyEnded = true; | 144 | SuccessfullyEnded = true; |
145 | } | 145 | } |
146 | emit finished(); | 146 | emit finished(); |
147 | } | 147 | } |
148 | else { | 148 | else { |
149 | emit error( tr( "OTInquiry completed with error (code %1)" ). | 149 | emit error( tr( "OTInquiry completed with error (code %1)" ). |
150 | arg(status)); | 150 | arg(status)); |
151 | } | 151 | } |
152 | } | 152 | } |
153 | break; | 153 | break; |
154 | case EVT_INQUIRY_RESULT: | 154 | case EVT_INQUIRY_RESULT: |
155 | { int numResults = data[0]; | 155 | { int numResults = data[0]; |
156 | OTPeer * P = 0; | 156 | OTPeer * P = 0; |
157 | bool IsNew; | 157 | bool IsNew; |
158 | OTDeviceAddress Addr; | 158 | OTDeviceAddress Addr; |
159 | QString N; | 159 | QString N; |
160 | 160 | ||
161 | inquiry_info *results = (inquiry_info*)(data+1); | 161 | inquiry_info *results = (inquiry_info*)(data+1); |
162 | 162 | ||
163 | for (int n=0; n<numResults; n++) { | 163 | for (int n=0; n<numResults; n++) { |
164 | Addr.setBDAddr( results[n].bdaddr ); | 164 | Addr.setBDAddr( results[n].bdaddr ); |
165 | 165 | ||
166 | owarn << "INQUIRY_RESULT: " | 166 | odebug << "INQUIRY_RESULT: " |
167 | << Addr.toString() | 167 | << Addr.toString() |
168 | << oendl; | 168 | << oendl; |
169 | 169 | ||
170 | P = Driver->gateway()->findPeer( Addr ); | 170 | P = Driver->gateway()->findPeer( Addr ); |
171 | 171 | ||
172 | if( P ) { | 172 | if( P ) { |
173 | // peer known | 173 | // peer known |
174 | if( P->state() != OTPeer::Peer_Up ) { | 174 | if( P->state() != OTPeer::Peer_Up ) { |
175 | P->setState( OTPeer::Peer_Up ); | 175 | P->setState( OTPeer::Peer_Up ); |
176 | } | 176 | } |
177 | IsNew = 0; | 177 | IsNew = 0; |
178 | } else { | 178 | } else { |
179 | IsNew = 1; | 179 | IsNew = 1; |
180 | // push the address to the address queue | 180 | // push the address to the address queue |
181 | // where it can be consumed by nextNeighbour() | 181 | // where it can be consumed by nextNeighbour() |
182 | P = new OTPeer( Driver->gateway() ); | 182 | P = new OTPeer( Driver->gateway() ); |
183 | P->setState( OTPeer::Peer_Up ); // we just detected it | 183 | P->setState( OTPeer::Peer_Up ); // we just detected it |
184 | P->setAddress( Addr ); | 184 | P->setAddress( Addr ); |
185 | //if( addrCache.find(info.addr) == addrCache.end()) { | 185 | //if( addrCache.find(info.addr) == addrCache.end()) { |
186 | // addrCache.insert(info.addr); | 186 | // addrCache.insert(info.addr); |
187 | 187 | ||
188 | P->setDeviceClass( (results[n].dev_class[0] << 16) | | 188 | P->setDeviceClass( (results[n].dev_class[0] << 16) | |
189 | (results[n].dev_class[1] << 8) | | 189 | (results[n].dev_class[1] << 8) | |
190 | (results[n].dev_class[2] << 0) ); | 190 | (results[n].dev_class[2] << 0) ); |
191 | // infoQueue.push_back(info); | 191 | // infoQueue.push_back(info); |
192 | P->setName( Driver->getPeerName( Addr ) ); | 192 | P->setName( Driver->getPeerName( Addr ) ); |
193 | } | 193 | } |
194 | 194 | ||
195 | // call the handler. Emits a signal if not overwritten | 195 | // call the handler. Emits a signal if not overwritten |
196 | onPeerFound( P, IsNew ); | 196 | onPeerFound( P, IsNew ); |
197 | 197 | ||
198 | // } | 198 | // } |
199 | } | 199 | } |
200 | } | 200 | } |
201 | break; | 201 | break; |
202 | case EVT_CMD_STATUS : | 202 | case EVT_CMD_STATUS : |
203 | { int status = data[0]; | 203 | { int status = data[0]; |
204 | int numHciCmdPkts = data[1]; | 204 | int numHciCmdPkts = data[1]; |
205 | int cmdOpcode = *((uint16_t*)(data+2)); | 205 | int cmdOpcode = *((uint16_t*)(data+2)); |
206 | owarn << "EVT_CMD_STATUS status=" | 206 | odebug << "EVT_CMD_STATUS status=" |
207 | << status | 207 | << status |
208 | << " numPkts=" | 208 | << " numPkts=" |
209 | << numHciCmdPkts | 209 | << numHciCmdPkts |
210 | << " cmdOpcode=" | 210 | << " cmdOpcode=" |
211 | << cmdOpcode | 211 | << cmdOpcode |
212 | << oendl; | 212 | << oendl; |
213 | if (cmdOpcode == OCF_INQUIRY) { | 213 | if (cmdOpcode == OCF_INQUIRY) { |
214 | 214 | ||
215 | } | 215 | } |
216 | } | 216 | } |
217 | break; | 217 | break; |
218 | } | 218 | } |
219 | } | 219 | } |
diff --git a/noncore/settings/networksettings2/opietooth2/OTPeer.cpp b/noncore/settings/networksettings2/opietooth2/OTPeer.cpp index 0d7e943..2272f04 100644 --- a/noncore/settings/networksettings2/opietooth2/OTPeer.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTPeer.cpp | |||
@@ -6,361 +6,361 @@ | |||
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * | 7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License, or * | 8 | * the Free Software Foundation; either version 2 of the License, or * |
9 | * (at your option) any later version. * | 9 | * (at your option) any later version. * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | #include <assert.h> | 12 | #include <assert.h> |
13 | #include <sys/poll.h> | 13 | #include <sys/poll.h> |
14 | #include <string.h> | 14 | #include <string.h> |
15 | 15 | ||
16 | #include <bluezlib.h> | 16 | #include <bluezlib.h> |
17 | #include <qarray.h> | 17 | #include <qarray.h> |
18 | #include <qtextstream.h> | 18 | #include <qtextstream.h> |
19 | 19 | ||
20 | #include <opie2/odebug.h> | 20 | #include <opie2/odebug.h> |
21 | 21 | ||
22 | #include <OTDeviceAddress.h> | 22 | #include <OTDeviceAddress.h> |
23 | #include <OTSDPAttribute.h> | 23 | #include <OTSDPAttribute.h> |
24 | #include <OTSDPService.h> | 24 | #include <OTSDPService.h> |
25 | #include <OTPeer.h> | 25 | #include <OTPeer.h> |
26 | #include <OTGateway.h> | 26 | #include <OTGateway.h> |
27 | #include <OTDriver.h> | 27 | #include <OTDriver.h> |
28 | 28 | ||
29 | using namespace Opietooth2; | 29 | using namespace Opietooth2; |
30 | 30 | ||
31 | OTPeer::OTPeer( OTGateway * _OT ) { | 31 | OTPeer::OTPeer( OTGateway * _OT ) { |
32 | OT = _OT; | 32 | OT = _OT; |
33 | State = Peer_Unknown; | 33 | State = Peer_Unknown; |
34 | ConnectedTo = 0; | 34 | ConnectedTo = 0; |
35 | } | 35 | } |
36 | 36 | ||
37 | OTPeer::OTPeer( QTextStream & TS, OTGateway * _OT ) { | 37 | OTPeer::OTPeer( QTextStream & TS, OTGateway * _OT ) { |
38 | OT = _OT; | 38 | OT = _OT; |
39 | State = Peer_Unknown; | 39 | State = Peer_Unknown; |
40 | ConnectedTo = 0; | 40 | ConnectedTo = 0; |
41 | 41 | ||
42 | load( TS ); | 42 | load( TS ); |
43 | } | 43 | } |
44 | 44 | ||
45 | OTPeer::~OTPeer( ) { | 45 | OTPeer::~OTPeer( ) { |
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | void OTPeer::updateServices( void ) { | 49 | void OTPeer::updateServices( void ) { |
50 | sdp_session_t *session; | 50 | sdp_session_t *session; |
51 | 51 | ||
52 | serviceList.clear(); | 52 | serviceList.clear(); |
53 | 53 | ||
54 | owarn << "Get services from " << Addr.toString() << oendl; | 54 | odebug << "Get services from " << Addr.toString() << oendl; |
55 | 55 | ||
56 | session = sdp_connect( &(OTDeviceAddress::any.getBDAddr()), | 56 | session = sdp_connect( &(OTDeviceAddress::any.getBDAddr()), |
57 | &(Addr.getBDAddr()), | 57 | &(Addr.getBDAddr()), |
58 | 0); | 58 | 0); |
59 | 59 | ||
60 | if (!session) { | 60 | if (!session) { |
61 | owarn << "sdp_connect(" | 61 | odebug << "sdp_connect(" |
62 | << Addr.toString() | 62 | << Addr.toString() |
63 | << ") failed" | 63 | << ") failed" |
64 | << oendl; | 64 | << oendl; |
65 | return; // error | 65 | return; // error |
66 | } | 66 | } |
67 | 67 | ||
68 | uint32_t range = 0x0000ffff; | 68 | uint32_t range = 0x0000ffff; |
69 | sdp_list_t* attrId = sdp_list_append(0, &range); | 69 | sdp_list_t* attrId = sdp_list_append(0, &range); |
70 | 70 | ||
71 | // search all public features | 71 | // search all public features |
72 | uuid_t grp; | 72 | uuid_t grp; |
73 | sdp_uuid16_create( &grp, PUBLIC_BROWSE_GROUP ); | 73 | sdp_uuid16_create( &grp, PUBLIC_BROWSE_GROUP ); |
74 | sdp_list_t * search = sdp_list_append(0, &grp ); | 74 | sdp_list_t * search = sdp_list_append(0, &grp ); |
75 | 75 | ||
76 | // get data from peer | 76 | // get data from peer |
77 | sdp_list_t* seq; | 77 | sdp_list_t* seq; |
78 | if (sdp_service_search_attr_req( session, | 78 | if (sdp_service_search_attr_req( session, |
79 | search, | 79 | search, |
80 | SDP_ATTR_REQ_RANGE, | 80 | SDP_ATTR_REQ_RANGE, |
81 | attrId, | 81 | attrId, |
82 | &seq ) ) { | 82 | &seq ) ) { |
83 | owarn << "Service Search failed" << oendl; | 83 | odebug << "Service Search failed" << oendl; |
84 | sdp_close(session); | 84 | sdp_close(session); |
85 | return; | 85 | return; |
86 | } | 86 | } |
87 | 87 | ||
88 | sdp_list_free(attrId, 0); | 88 | sdp_list_free(attrId, 0); |
89 | sdp_list_free(search, 0); | 89 | sdp_list_free(search, 0); |
90 | 90 | ||
91 | // process result | 91 | // process result |
92 | sdp_list_t* next = NULL; | 92 | sdp_list_t* next = NULL; |
93 | 93 | ||
94 | for (; seq; seq = next) { | 94 | for (; seq; seq = next) { |
95 | sdp_record_t *rec = (sdp_record_t *) seq->data; | 95 | sdp_record_t *rec = (sdp_record_t *) seq->data; |
96 | 96 | ||
97 | sdp_list_t* attrlist = rec->attrlist; | 97 | sdp_list_t* attrlist = rec->attrlist; |
98 | AttributeVector alist; | 98 | AttributeVector alist; |
99 | OTSDPService * service; | 99 | OTSDPService * service; |
100 | 100 | ||
101 | service = new OTSDPService(); | 101 | service = new OTSDPService(); |
102 | 102 | ||
103 | for (; attrlist; attrlist = attrlist->next) { | 103 | for (; attrlist; attrlist = attrlist->next) { |
104 | int attrID = ((sdp_data_t*)(attrlist->data))->attrId; | 104 | int attrID = ((sdp_data_t*)(attrlist->data))->attrId; |
105 | service->addAttribute( | 105 | service->addAttribute( |
106 | attrID, | 106 | attrID, |
107 | new OTSDPAttribute( (sdp_data_t*)(attrlist->data) ) | 107 | new OTSDPAttribute( (sdp_data_t*)(attrlist->data) ) |
108 | ); | 108 | ); |
109 | } | 109 | } |
110 | 110 | ||
111 | serviceList.resize( serviceList.size() + 1 ); | 111 | serviceList.resize( serviceList.size() + 1 ); |
112 | serviceList.insert( serviceList.size() - 1, service ); | 112 | serviceList.insert( serviceList.size() - 1, service ); |
113 | 113 | ||
114 | next = seq->next; | 114 | next = seq->next; |
115 | free(seq); | 115 | free(seq); |
116 | sdp_record_free(rec); | 116 | sdp_record_free(rec); |
117 | } | 117 | } |
118 | sdp_close(session); | 118 | sdp_close(session); |
119 | } | 119 | } |
120 | 120 | ||
121 | bool OTPeer::hasServiceClassID( const OTUUID & uuid) { | 121 | bool OTPeer::hasServiceClassID( const OTUUID & uuid) { |
122 | for( unsigned int i = 0; | 122 | for( unsigned int i = 0; |
123 | i < serviceList.count(); | 123 | i < serviceList.count(); |
124 | i ++ ) { | 124 | i ++ ) { |
125 | if( serviceList[i]->hasClassID(uuid)) | 125 | if( serviceList[i]->hasClassID(uuid)) |
126 | return true; | 126 | return true; |
127 | } | 127 | } |
128 | return false; | 128 | return false; |
129 | } | 129 | } |
130 | /** Get a vector of Rfcomm channels of the services having "uuid" in the class ID List*/ | 130 | /** Get a vector of Rfcomm channels of the services having "uuid" in the class ID List*/ |
131 | QArray<int> OTPeer::rfcommList( const OTUUID & uuid) { | 131 | QArray<int> OTPeer::rfcommList( const OTUUID & uuid) { |
132 | 132 | ||
133 | QArray<int> rfcommList; | 133 | QArray<int> rfcommList; |
134 | unsigned int channel; | 134 | unsigned int channel; |
135 | 135 | ||
136 | for( unsigned int i = 0; | 136 | for( unsigned int i = 0; |
137 | i < serviceList.count(); | 137 | i < serviceList.count(); |
138 | i ++ ) { | 138 | i ++ ) { |
139 | if( serviceList[i]->hasClassID(uuid)) { | 139 | if( serviceList[i]->hasClassID(uuid)) { |
140 | if( serviceList[i]->rfcommChannel(channel) ) { | 140 | if( serviceList[i]->rfcommChannel(channel) ) { |
141 | rfcommList.resize( rfcommList.size()+1 ); | 141 | rfcommList.resize( rfcommList.size()+1 ); |
142 | rfcommList[rfcommList.size()-1] = channel; | 142 | rfcommList[rfcommList.size()-1] = channel; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | } | 145 | } |
146 | return rfcommList; | 146 | return rfcommList; |
147 | } | 147 | } |
148 | 148 | ||
149 | void OTPeer::save( QTextStream & TS ) { | 149 | void OTPeer::save( QTextStream & TS ) { |
150 | TS << "bdaddr " << address().toString() << endl; | 150 | TS << "bdaddr " << address().toString() << endl; |
151 | TS << "name " << name() << endl; | 151 | TS << "name " << name() << endl; |
152 | TS << "class " << deviceClass() << endl; | 152 | TS << "class " << deviceClass() << endl; |
153 | } | 153 | } |
154 | 154 | ||
155 | void OTPeer::load( QTextStream & TS ) { | 155 | void OTPeer::load( QTextStream & TS ) { |
156 | QString S; | 156 | QString S; |
157 | S = TS.readLine(); | 157 | S = TS.readLine(); |
158 | setAddress( OTDeviceAddress( S.mid( 7 ) ) ); | 158 | setAddress( OTDeviceAddress( S.mid( 7 ) ) ); |
159 | 159 | ||
160 | S = TS.readLine(); | 160 | S = TS.readLine(); |
161 | setName( S.mid( 5 ) ); | 161 | setName( S.mid( 5 ) ); |
162 | 162 | ||
163 | S = TS.readLine(); | 163 | S = TS.readLine(); |
164 | setDeviceClass( S.mid( 6 ).toLong() ); | 164 | setDeviceClass( S.mid( 6 ).toLong() ); |
165 | } | 165 | } |
166 | 166 | ||
167 | #define MAGICNR -99999 | 167 | #define MAGICNR -99999 |
168 | #define POLLDELAY 1000 | 168 | #define POLLDELAY 1000 |
169 | #define PREMAGICNR (MAGICNR+POLLDELAY) | 169 | #define PREMAGICNR (MAGICNR+POLLDELAY) |
170 | 170 | ||
171 | void OTPeer::findOutState( int timeoutInSec, bool Force ) { | 171 | void OTPeer::findOutState( int timeoutInSec, bool Force ) { |
172 | ProbeFD = -1; | 172 | ProbeFD = -1; |
173 | if( Force && ConnectedTo == 0 ) { | 173 | if( Force && ConnectedTo == 0 ) { |
174 | State = OTPeer::Peer_Unknown; | 174 | State = OTPeer::Peer_Unknown; |
175 | } // else keep state or is connected to us | 175 | } // else keep state or is connected to us |
176 | 176 | ||
177 | if( State == OTPeer::Peer_Unknown ) { | 177 | if( State == OTPeer::Peer_Unknown ) { |
178 | ProbePhase = 0; | 178 | ProbePhase = 0; |
179 | ProbeTimeout = timeoutInSec*1000; | 179 | ProbeTimeout = timeoutInSec*1000; |
180 | owarn << "Ping " << address().toString() << oendl; | 180 | odebug << "Ping " << address().toString() << oendl; |
181 | startTimer( POLLDELAY ); | 181 | startTimer( POLLDELAY ); |
182 | } else { | 182 | } else { |
183 | ProbeTimeout = 0; | 183 | ProbeTimeout = 0; |
184 | startTimer( 0 ); | 184 | startTimer( 0 ); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | #define PINGSIZE 20 | 188 | #define PINGSIZE 20 |
189 | void OTPeer::timerEvent( QTimerEvent * ev ) { | 189 | void OTPeer::timerEvent( QTimerEvent * ev ) { |
190 | 190 | ||
191 | ProbeTimeout -= POLLDELAY; | 191 | ProbeTimeout -= POLLDELAY; |
192 | 192 | ||
193 | if( State == OTPeer::Peer_Unknown ) { | 193 | if( State == OTPeer::Peer_Unknown ) { |
194 | switch( ProbePhase ) { | 194 | switch( ProbePhase ) { |
195 | case 0 : // connect nonblock | 195 | case 0 : // connect nonblock |
196 | { struct sockaddr_l2 addr; | 196 | { struct sockaddr_l2 addr; |
197 | 197 | ||
198 | if (( ProbeFD = ::socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_L2CAP)) < 0) { | 198 | if (( ProbeFD = ::socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_L2CAP)) < 0) { |
199 | ProbeTimeout = 0; | 199 | ProbeTimeout = 0; |
200 | break; | 200 | break; |
201 | } | 201 | } |
202 | 202 | ||
203 | memset(&addr, 0, sizeof(addr)); | 203 | memset(&addr, 0, sizeof(addr)); |
204 | 204 | ||
205 | addr.l2_family = AF_BLUETOOTH; | 205 | addr.l2_family = AF_BLUETOOTH; |
206 | addr.l2_bdaddr = OTDeviceAddress::any.getBDAddr(); | 206 | addr.l2_bdaddr = OTDeviceAddress::any.getBDAddr(); |
207 | 207 | ||
208 | if( ::bind( ProbeFD, (struct sockaddr *) &addr, sizeof(addr)) < 0) { | 208 | if( ::bind( ProbeFD, (struct sockaddr *) &addr, sizeof(addr)) < 0) { |
209 | ProbeTimeout = 0; | 209 | ProbeTimeout = 0; |
210 | break; | 210 | break; |
211 | } | 211 | } |
212 | 212 | ||
213 | // non blocking | 213 | // non blocking |
214 | if( ::fcntl( ProbeFD, F_SETFL, O_NONBLOCK ) < 0 ) { | 214 | if( ::fcntl( ProbeFD, F_SETFL, O_NONBLOCK ) < 0 ) { |
215 | ProbeTimeout = 0; | 215 | ProbeTimeout = 0; |
216 | break; | 216 | break; |
217 | } | 217 | } |
218 | 218 | ||
219 | // to this peer | 219 | // to this peer |
220 | addr.l2_bdaddr = address().getBDAddr(); | 220 | addr.l2_bdaddr = address().getBDAddr(); |
221 | if( ::connect( ProbeFD, (struct sockaddr *) &addr, sizeof(addr)) < 0) { | 221 | if( ::connect( ProbeFD, (struct sockaddr *) &addr, sizeof(addr)) < 0) { |
222 | if( errno != EAGAIN && errno != EINPROGRESS ) { | 222 | if( errno != EAGAIN && errno != EINPROGRESS ) { |
223 | ProbeTimeout = 0; | 223 | ProbeTimeout = 0; |
224 | break; | 224 | break; |
225 | } // wait for connect to fail or succeed | 225 | } // wait for connect to fail or succeed |
226 | } | 226 | } |
227 | } | 227 | } |
228 | ProbePhase = 1; // wait for connect | 228 | ProbePhase = 1; // wait for connect |
229 | break; | 229 | break; |
230 | case 1 : | 230 | case 1 : |
231 | { struct pollfd pf[1]; | 231 | { struct pollfd pf[1]; |
232 | char buf[L2CAP_CMD_HDR_SIZE + PINGSIZE + 20]; | 232 | char buf[L2CAP_CMD_HDR_SIZE + PINGSIZE + 20]; |
233 | int n; | 233 | int n; |
234 | 234 | ||
235 | pf[0].fd = ProbeFD; | 235 | pf[0].fd = ProbeFD; |
236 | pf[0].events = POLLOUT; | 236 | pf[0].events = POLLOUT; |
237 | if( (n = ::poll(pf, 1, 0)) < 0 ) { | 237 | if( (n = ::poll(pf, 1, 0)) < 0 ) { |
238 | owarn << address().toString() | 238 | odebug << address().toString() |
239 | << " : errno " | 239 | << " : errno " |
240 | << errno | 240 | << errno |
241 | << " " | 241 | << " " |
242 | << strerror(errno)<<oendl; | 242 | << strerror(errno)<<oendl; |
243 | ProbeTimeout = 0; | 243 | ProbeTimeout = 0; |
244 | break; | 244 | break; |
245 | } | 245 | } |
246 | 246 | ||
247 | if( ! n ) { | 247 | if( ! n ) { |
248 | // not ready -> try again | 248 | // not ready -> try again |
249 | break; | 249 | break; |
250 | } | 250 | } |
251 | 251 | ||
252 | // send ping | 252 | // send ping |
253 | for( unsigned int i = L2CAP_CMD_HDR_SIZE; i < sizeof(buf); i++) | 253 | for( unsigned int i = L2CAP_CMD_HDR_SIZE; i < sizeof(buf); i++) |
254 | buf[i] = (i % 40) + 'A'; | 254 | buf[i] = (i % 40) + 'A'; |
255 | 255 | ||
256 | l2cap_cmd_hdr *cmd = (l2cap_cmd_hdr *) buf; | 256 | l2cap_cmd_hdr *cmd = (l2cap_cmd_hdr *) buf; |
257 | 257 | ||
258 | /* Build command header */ | 258 | /* Build command header */ |
259 | cmd->code = L2CAP_ECHO_REQ; | 259 | cmd->code = L2CAP_ECHO_REQ; |
260 | cmd->ident = *(char *)this; // get some byte | 260 | cmd->ident = *(char *)this; // get some byte |
261 | cmd->len = PINGSIZE; | 261 | cmd->len = PINGSIZE; |
262 | 262 | ||
263 | /* Send Echo Request */ | 263 | /* Send Echo Request */ |
264 | if( ::send(ProbeFD, buf, PINGSIZE + L2CAP_CMD_HDR_SIZE, 0) <= 0) { | 264 | if( ::send(ProbeFD, buf, PINGSIZE + L2CAP_CMD_HDR_SIZE, 0) <= 0) { |
265 | if( errno == EACCES ) { | 265 | if( errno == EACCES ) { |
266 | // permission denied means that we could not | 266 | // permission denied means that we could not |
267 | // connect because the device does not allow us | 267 | // connect because the device does not allow us |
268 | // but it is UP | 268 | // but it is UP |
269 | owarn << address().toString() | 269 | odebug << address().toString() |
270 | << " good send error " | 270 | << " good send error " |
271 | << errno | 271 | << errno |
272 | << " " | 272 | << " " |
273 | << strerror( errno) | 273 | << strerror( errno) |
274 | << oendl; | 274 | << oendl; |
275 | State = OTPeer::Peer_Up; | 275 | State = OTPeer::Peer_Up; |
276 | ProbeTimeout = 0; | 276 | ProbeTimeout = 0; |
277 | break; | 277 | break; |
278 | } else if( errno != EBUSY ) { | 278 | } else if( errno != EBUSY ) { |
279 | owarn << address().toString() | 279 | odebug << address().toString() |
280 | << " : errno " | 280 | << " : errno " |
281 | << errno | 281 | << errno |
282 | << " " | 282 | << " " |
283 | << strerror(errno) | 283 | << strerror(errno) |
284 | << oendl; | 284 | << oendl; |
285 | ProbeTimeout = 0; | 285 | ProbeTimeout = 0; |
286 | break; | 286 | break; |
287 | } // else want some more | 287 | } // else want some more |
288 | } | 288 | } |
289 | 289 | ||
290 | ProbePhase = 2; // wait for ping reply | 290 | ProbePhase = 2; // wait for ping reply |
291 | } | 291 | } |
292 | break; | 292 | break; |
293 | case 2 : // wait for reply | 293 | case 2 : // wait for reply |
294 | { struct pollfd pf[1]; | 294 | { struct pollfd pf[1]; |
295 | char buf[L2CAP_CMD_HDR_SIZE + PINGSIZE + 20]; | 295 | char buf[L2CAP_CMD_HDR_SIZE + PINGSIZE + 20]; |
296 | l2cap_cmd_hdr *cmd = (l2cap_cmd_hdr *) buf; | 296 | l2cap_cmd_hdr *cmd = (l2cap_cmd_hdr *) buf; |
297 | int n; | 297 | int n; |
298 | 298 | ||
299 | pf[0].fd = ProbeFD; | 299 | pf[0].fd = ProbeFD; |
300 | pf[0].events = POLLIN; | 300 | pf[0].events = POLLIN; |
301 | if( (n = ::poll(pf, 1, 0)) < 0 ) { | 301 | if( (n = ::poll(pf, 1, 0)) < 0 ) { |
302 | owarn << address().toString() | 302 | odebug << address().toString() |
303 | << " : errno " | 303 | << " : errno " |
304 | << errno | 304 | << errno |
305 | << " " | 305 | << " " |
306 | << strerror(errno) | 306 | << strerror(errno) |
307 | <<oendl; | 307 | <<oendl; |
308 | ProbeTimeout = 0; | 308 | ProbeTimeout = 0; |
309 | break; | 309 | break; |
310 | } | 310 | } |
311 | 311 | ||
312 | if( ! n ) { | 312 | if( ! n ) { |
313 | // not ready -> try again | 313 | // not ready -> try again |
314 | break; | 314 | break; |
315 | } | 315 | } |
316 | 316 | ||
317 | if( (n = ::recv( ProbeFD, buf, sizeof(buf), 0)) < 0) { | 317 | if( (n = ::recv( ProbeFD, buf, sizeof(buf), 0)) < 0) { |
318 | owarn << address().toString() | 318 | odebug << address().toString() |
319 | << "errno " | 319 | << "errno " |
320 | << errno | 320 | << errno |
321 | << " " | 321 | << " " |
322 | << strerror(errno) | 322 | << strerror(errno) |
323 | << oendl; | 323 | << oendl; |
324 | ProbeTimeout = 0; | 324 | ProbeTimeout = 0; |
325 | break; | 325 | break; |
326 | } | 326 | } |
327 | 327 | ||
328 | /* Check for our id */ | 328 | /* Check for our id */ |
329 | if( cmd->ident != *(char *)this ) | 329 | if( cmd->ident != *(char *)this ) |
330 | // not our reply | 330 | // not our reply |
331 | break; | 331 | break; |
332 | 332 | ||
333 | owarn << "reply from " | 333 | odebug << "reply from " |
334 | << address().toString() | 334 | << address().toString() |
335 | << oendl; | 335 | << oendl; |
336 | // whatever reply we get is a valid reply | 336 | // whatever reply we get is a valid reply |
337 | State = OTPeer::Peer_Up; | 337 | State = OTPeer::Peer_Up; |
338 | ProbeTimeout = 0; | 338 | ProbeTimeout = 0; |
339 | } | 339 | } |
340 | break; | 340 | break; |
341 | } | 341 | } |
342 | 342 | ||
343 | if( State != OTPeer::Peer_Unknown ) { | 343 | if( State != OTPeer::Peer_Unknown ) { |
344 | ProbeTimeout = 0; | 344 | ProbeTimeout = 0; |
345 | } | 345 | } |
346 | } | 346 | } |
347 | 347 | ||
348 | if( ProbeTimeout <= 0 ) { | 348 | if( ProbeTimeout <= 0 ) { |
349 | // regular timeout | 349 | // regular timeout |
350 | emit peerStateReport( this ); | 350 | emit peerStateReport( this ); |
351 | if( State == Peer_Unknown ) { | 351 | if( State == Peer_Unknown ) { |
352 | State = Peer_Down; | 352 | State = Peer_Down; |
353 | } | 353 | } |
354 | if( ProbeFD >= 0 ) { | 354 | if( ProbeFD >= 0 ) { |
355 | // requested to stop by caller -> stop probing | 355 | // requested to stop by caller -> stop probing |
356 | ::close( ProbeFD ); | 356 | ::close( ProbeFD ); |
357 | } | 357 | } |
358 | // no more waiting | 358 | // no more waiting |
359 | killTimer( ev->timerId() ); | 359 | killTimer( ev->timerId() ); |
360 | } // else sleep some more | 360 | } // else sleep some more |
361 | } | 361 | } |
362 | 362 | ||
363 | void OTPeer::stopFindingOutState( void ) { | 363 | void OTPeer::stopFindingOutState( void ) { |
364 | ProbeTimeout = PREMAGICNR; | 364 | ProbeTimeout = PREMAGICNR; |
365 | } | 365 | } |
366 | 366 | ||
diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp index b14cc2f..8323549 100644 --- a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp +++ b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp | |||
@@ -492,166 +492,166 @@ int OTScan::getDevice( OTPeer *& Peer, | |||
492 | 492 | ||
493 | delete Dlg; | 493 | delete Dlg; |
494 | 494 | ||
495 | return rv; | 495 | return rv; |
496 | } | 496 | } |
497 | 497 | ||
498 | void OTScan::setScanFilter( const UUIDVector & V ) { | 498 | void OTScan::setScanFilter( const UUIDVector & V ) { |
499 | Filter = V; | 499 | Filter = V; |
500 | } | 500 | } |
501 | 501 | ||
502 | void OTScan::resetScanFilter( void ) { | 502 | void OTScan::resetScanFilter( void ) { |
503 | Filter.truncate(0); | 503 | Filter.truncate(0); |
504 | } | 504 | } |
505 | 505 | ||
506 | void OTScan::SLOT_DoScan( bool DoIt ) { | 506 | void OTScan::SLOT_DoScan( bool DoIt ) { |
507 | if( DoIt ) { | 507 | if( DoIt ) { |
508 | OT->scanNeighbourhood(); | 508 | OT->scanNeighbourhood(); |
509 | } else { | 509 | } else { |
510 | OT->stopScanOfNeighbourhood(); | 510 | OT->stopScanOfNeighbourhood(); |
511 | } | 511 | } |
512 | 512 | ||
513 | scanMode( DoIt ); | 513 | scanMode( DoIt ); |
514 | } | 514 | } |
515 | 515 | ||
516 | // double clicked on a device | 516 | // double clicked on a device |
517 | void OTScan::SLOT_Selected( QListViewItem * it ) { | 517 | void OTScan::SLOT_Selected( QListViewItem * it ) { |
518 | if( ! it ) | 518 | if( ! it ) |
519 | return; | 519 | return; |
520 | 520 | ||
521 | if( Filter.count() > 0 ) { | 521 | if( Filter.count() > 0 ) { |
522 | // filter on service | 522 | // filter on service |
523 | if( it->depth() == 0 ) { | 523 | if( it->depth() == 0 ) { |
524 | // select a service and not a device | 524 | // select a service and not a device |
525 | return; | 525 | return; |
526 | } | 526 | } |
527 | 527 | ||
528 | // store result | 528 | // store result |
529 | SelectedPeer = ((PeerLVI *)it->parent())->peer(); | 529 | SelectedPeer = ((PeerLVI *)it->parent())->peer(); |
530 | SelectedChannel = ((ChannelLVI *)it)->channel(); | 530 | SelectedChannel = ((ChannelLVI *)it)->channel(); |
531 | } else { | 531 | } else { |
532 | // click on device | 532 | // click on device |
533 | if( it->depth() != 0 ) { | 533 | if( it->depth() != 0 ) { |
534 | return; | 534 | return; |
535 | } | 535 | } |
536 | 536 | ||
537 | SelectedPeer = ((PeerLVI *)it)->peer(); | 537 | SelectedPeer = ((PeerLVI *)it)->peer(); |
538 | SelectedChannel = 0; | 538 | SelectedChannel = 0; |
539 | } | 539 | } |
540 | owarn << "Selected " << SelectedPeer->address().toString() << | 540 | odebug << "Selected " << SelectedPeer->address().toString() << |
541 | " Channel " << SelectedChannel << oendl; | 541 | " Channel " << SelectedChannel << oendl; |
542 | emit selected(); | 542 | emit selected(); |
543 | } | 543 | } |
544 | 544 | ||
545 | void OTScan::SLOT_FinishedDetecting( ) { | 545 | void OTScan::SLOT_FinishedDetecting( ) { |
546 | scanMode( false ); | 546 | scanMode( false ); |
547 | } | 547 | } |
548 | 548 | ||
549 | void OTScan::SLOT_CleanupOld( ) { | 549 | void OTScan::SLOT_CleanupOld( ) { |
550 | 550 | ||
551 | // iterate over all peers and find those that | 551 | // iterate over all peers and find those that |
552 | // are down and have no pairing info | 552 | // are down and have no pairing info |
553 | OTPeer * TheP; | 553 | OTPeer * TheP; |
554 | const LinkKeyArray & Keys = OT->getLinkKeys(); | 554 | const LinkKeyArray & Keys = OT->getLinkKeys(); |
555 | 555 | ||
556 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); | 556 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); |
557 | while( Lit ) { | 557 | while( Lit ) { |
558 | TheP = ((PeerLVI *)Lit)->peer(); | 558 | TheP = ((PeerLVI *)Lit)->peer(); |
559 | if( TheP->state() == OTPeer::Peer_Down ) { | 559 | if( TheP->state() == OTPeer::Peer_Down ) { |
560 | unsigned int k; | 560 | unsigned int k; |
561 | 561 | ||
562 | // what about linkkeys ? | 562 | // what about linkkeys ? |
563 | for( k = 0; k < Keys.count(); k ++ ) { | 563 | for( k = 0; k < Keys.count(); k ++ ) { |
564 | if( TheP->address() == Keys[k].to() || | 564 | if( TheP->address() == Keys[k].to() || |
565 | TheP->address() == Keys[k].from() | 565 | TheP->address() == Keys[k].from() |
566 | ) { | 566 | ) { |
567 | // part of linkkey | 567 | // part of linkkey |
568 | owarn << "LINKKEY " << TheP->address().toString() << oendl; | 568 | odebug << "LINKKEY " << TheP->address().toString() << oendl; |
569 | break; | 569 | break; |
570 | } | 570 | } |
571 | } | 571 | } |
572 | 572 | ||
573 | if( k == Keys.count() ) { | 573 | if( k == Keys.count() ) { |
574 | owarn << "RM LINKKEY " << TheP->address().toString() << oendl; | 574 | odebug << "RM LINKKEY " << TheP->address().toString() << oendl; |
575 | // not found -> remember to remove this peer | 575 | // not found -> remember to remove this peer |
576 | QListViewItem * Nit; | 576 | QListViewItem * Nit; |
577 | OT->removePeer( TheP ); | 577 | OT->removePeer( TheP ); |
578 | Nit = Lit->nextSibling(); | 578 | Nit = Lit->nextSibling(); |
579 | delete Lit; | 579 | delete Lit; |
580 | Lit = Nit; | 580 | Lit = Nit; |
581 | continue; | 581 | continue; |
582 | } | 582 | } |
583 | } else { | 583 | } else { |
584 | owarn << "NODOWN " << TheP->address().toString() << oendl; | 584 | odebug << "NODOWN " << TheP->address().toString() << oendl; |
585 | } | 585 | } |
586 | 586 | ||
587 | Lit = Lit->nextSibling(); | 587 | Lit = Lit->nextSibling(); |
588 | } | 588 | } |
589 | } | 589 | } |
590 | 590 | ||
591 | void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){ | 591 | void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){ |
592 | PeerLVI * it = 0; | 592 | PeerLVI * it = 0; |
593 | 593 | ||
594 | if( IsNew ) { | 594 | if( IsNew ) { |
595 | it = new PeerLVI( P, DetectedPeers_LV ); | 595 | it = new PeerLVI( P, DetectedPeers_LV ); |
596 | } else { | 596 | } else { |
597 | // find peer in table | 597 | // find peer in table |
598 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); | 598 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); |
599 | while( Lit ) { | 599 | while( Lit ) { |
600 | if( ((PeerLVI *)Lit)->peer() == P ) { | 600 | if( ((PeerLVI *)Lit)->peer() == P ) { |
601 | // this item | 601 | // this item |
602 | it = (PeerLVI *)Lit; | 602 | it = (PeerLVI *)Lit; |
603 | break; | 603 | break; |
604 | } | 604 | } |
605 | Lit = Lit->nextSibling(); | 605 | Lit = Lit->nextSibling(); |
606 | } | 606 | } |
607 | 607 | ||
608 | if( ! it ) { | 608 | if( ! it ) { |
609 | owarn << "Should not occur" << oendl; | 609 | odebug << "Should not occur" << oendl; |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | } | 612 | } |
613 | 613 | ||
614 | // update/show info | 614 | // update/show info |
615 | it->setText( 0, P->name() ); | 615 | it->setText( 0, P->name() ); |
616 | it->setPixmap(0, Icons->deviceIcon( | 616 | it->setPixmap(0, Icons->deviceIcon( |
617 | OT->deviceTypeToName( P->deviceClass() ) ) ); | 617 | OT->deviceTypeToName( P->deviceClass() ) ) ); |
618 | 618 | ||
619 | // tell peer to report its state async | 619 | // tell peer to report its state async |
620 | connect( P, | 620 | connect( P, |
621 | SIGNAL( peerStateReport( OTPeer *)), | 621 | SIGNAL( peerStateReport( OTPeer *)), |
622 | this, | 622 | this, |
623 | SLOT( SLOT_PeerState( OTPeer *)) | 623 | SLOT( SLOT_PeerState( OTPeer *)) |
624 | ); | 624 | ); |
625 | 625 | ||
626 | if( IsNew ) { | 626 | if( IsNew ) { |
627 | // find state | 627 | // find state |
628 | refreshState( (PeerLVI *)it, 1 ); | 628 | refreshState( (PeerLVI *)it, 1 ); |
629 | } else { | 629 | } else { |
630 | // update staet | 630 | // update staet |
631 | SLOT_PeerState( P ); | 631 | SLOT_PeerState( P ); |
632 | } | 632 | } |
633 | } | 633 | } |
634 | 634 | ||
635 | void OTScan::SLOT_PeerState( OTPeer * P ) { | 635 | void OTScan::SLOT_PeerState( OTPeer * P ) { |
636 | PeerLVI * it = (PeerLVI *)DetectedPeers_LV->firstChild(); | 636 | PeerLVI * it = (PeerLVI *)DetectedPeers_LV->firstChild(); |
637 | while( it ) { | 637 | while( it ) { |
638 | if( it->peer() == P ) { | 638 | if( it->peer() == P ) { |
639 | break; | 639 | break; |
640 | } | 640 | } |
641 | it = (PeerLVI * )it->nextSibling(); | 641 | it = (PeerLVI * )it->nextSibling(); |
642 | } | 642 | } |
643 | 643 | ||
644 | if( ! it ) | 644 | if( ! it ) |
645 | return; | 645 | return; |
646 | 646 | ||
647 | switch( P->state() ) { | 647 | switch( P->state() ) { |
648 | case OTPeer::Peer_Unknown : | 648 | case OTPeer::Peer_Unknown : |
649 | case OTPeer::Peer_Down : | 649 | case OTPeer::Peer_Down : |
650 | it->setPixmap( 1, 0 ); | 650 | it->setPixmap( 1, 0 ); |
651 | break; | 651 | break; |
652 | case OTPeer::Peer_Up : | 652 | case OTPeer::Peer_Up : |
653 | it->setPixmap( 1, Icons->loadPixmap( | 653 | it->setPixmap( 1, Icons->loadPixmap( |
654 | ( P->connectedTo() ) ? "connected" : "notconnected" ) ); | 654 | ( P->connectedTo() ) ? "connected" : "notconnected" ) ); |
655 | if( it == Current && ! StrengthTimer->isActive() ) { | 655 | if( it == Current && ! StrengthTimer->isActive() ) { |
656 | // start showing strength | 656 | // start showing strength |
657 | StrengthTimer->start( 1000, FALSE ); | 657 | StrengthTimer->start( 1000, FALSE ); |
@@ -884,97 +884,97 @@ void OTScan::scanMode( bool M ) { | |||
884 | // | 884 | // |
885 | // | 885 | // |
886 | 886 | ||
887 | OTManage::OTManage( QWidget * parent, OTIcons * _IC ) : | 887 | OTManage::OTManage( QWidget * parent, OTIcons * _IC ) : |
888 | OTManageGUI( parent ) { | 888 | OTManageGUI( parent ) { |
889 | 889 | ||
890 | OT = OTGateway::getOTGateway(); | 890 | OT = OTGateway::getOTGateway(); |
891 | 891 | ||
892 | Icons = (_IC ) ? _IC : new OTIcons(); | 892 | Icons = (_IC ) ? _IC : new OTIcons(); |
893 | MyIcons = (_IC == 0 ); | 893 | MyIcons = (_IC == 0 ); |
894 | AllDrivers_LV->setSorting(-1); | 894 | AllDrivers_LV->setSorting(-1); |
895 | 895 | ||
896 | connect( OT, | 896 | connect( OT, |
897 | SIGNAL( driverListChanged() ), | 897 | SIGNAL( driverListChanged() ), |
898 | this, | 898 | this, |
899 | SLOT( SLOT_DriverListChanged() ) | 899 | SLOT( SLOT_DriverListChanged() ) |
900 | ); | 900 | ); |
901 | connect( OT, | 901 | connect( OT, |
902 | SIGNAL( stateChange( OTDriver *, bool ) ), | 902 | SIGNAL( stateChange( OTDriver *, bool ) ), |
903 | this, | 903 | this, |
904 | SLOT( SLOT_StateChange( OTDriver *, bool ) ) | 904 | SLOT( SLOT_StateChange( OTDriver *, bool ) ) |
905 | ); | 905 | ); |
906 | 906 | ||
907 | SLOT_DriverListChanged(); | 907 | SLOT_DriverListChanged(); |
908 | 908 | ||
909 | AllDrivers_LV->header()->hide(); | 909 | AllDrivers_LV->header()->hide(); |
910 | } | 910 | } |
911 | 911 | ||
912 | OTManage::~OTManage() { | 912 | OTManage::~OTManage() { |
913 | if( MyIcons ) | 913 | if( MyIcons ) |
914 | delete Icons; | 914 | delete Icons; |
915 | OTGateway::releaseOTGateway(); | 915 | OTGateway::releaseOTGateway(); |
916 | } | 916 | } |
917 | 917 | ||
918 | void OTManage::SLOT_ShowDriver( QListViewItem * It ) { | 918 | void OTManage::SLOT_ShowDriver( QListViewItem * It ) { |
919 | if( It == 0 || It->depth() > 0 ) | 919 | if( It == 0 || It->depth() > 0 ) |
920 | // not toplevel | 920 | // not toplevel |
921 | return; | 921 | return; |
922 | 922 | ||
923 | DriverLVI * it = (DriverLVI *) It; | 923 | DriverLVI * it = (DriverLVI *) It; |
924 | DriverIsUp_CB->setChecked( it->driver()->isUp() ); | 924 | DriverIsUp_CB->setChecked( it->driver()->isUp() ); |
925 | } | 925 | } |
926 | 926 | ||
927 | void OTManage::SLOT_UpDriver( bool Up ) { | 927 | void OTManage::SLOT_UpDriver( bool Up ) { |
928 | QListViewItem * it = AllDrivers_LV->firstChild(); | 928 | QListViewItem * it = AllDrivers_LV->firstChild(); |
929 | while( it ) { | 929 | while( it ) { |
930 | if( it->isSelected() ) { | 930 | if( it->isSelected() ) { |
931 | OTDriver * D = ((DriverLVI *)it)->driver(); | 931 | OTDriver * D = ((DriverLVI *)it)->driver(); |
932 | owarn << "UP driver " << D->devname() << oendl; | 932 | odebug << "UP driver " << D->devname() << oendl; |
933 | // this | 933 | // this |
934 | D->setUp( Up ); | 934 | D->setUp( Up ); |
935 | return; | 935 | return; |
936 | } | 936 | } |
937 | it = it->nextSibling(); | 937 | it = it->nextSibling(); |
938 | } | 938 | } |
939 | } | 939 | } |
940 | 940 | ||
941 | void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) { | 941 | void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) { |
942 | QListViewItem * it = AllDrivers_LV->firstChild(); | 942 | QListViewItem * it = AllDrivers_LV->firstChild(); |
943 | while( it ) { | 943 | while( it ) { |
944 | if( ((DriverLVI *)it)->driver() == D ) { | 944 | if( ((DriverLVI *)it)->driver() == D ) { |
945 | it->setPixmap( 0, | 945 | it->setPixmap( 0, |
946 | Icons->loadPixmap( ( Up ) ? "bluezon" : "bluezoff" ) ); | 946 | Icons->loadPixmap( ( Up ) ? "bluezon" : "bluezoff" ) ); |
947 | return; | 947 | return; |
948 | } | 948 | } |
949 | it = it->nextSibling(); | 949 | it = it->nextSibling(); |
950 | } | 950 | } |
951 | } | 951 | } |
952 | 952 | ||
953 | void OTManage::SLOT_DriverListChanged( ) { | 953 | void OTManage::SLOT_DriverListChanged( ) { |
954 | DriverLVI * It; | 954 | DriverLVI * It; |
955 | QListViewItem * Sub; | 955 | QListViewItem * Sub; |
956 | QListViewItem * First = 0; | 956 | QListViewItem * First = 0; |
957 | OTDriver* D; | 957 | OTDriver* D; |
958 | OTDriverList & DL = OT->getDriverList(); | 958 | OTDriverList & DL = OT->getDriverList(); |
959 | 959 | ||
960 | AllDrivers_LV->clear(); | 960 | AllDrivers_LV->clear(); |
961 | for( unsigned int i = 0; | 961 | for( unsigned int i = 0; |
962 | i < DL.count(); | 962 | i < DL.count(); |
963 | i ++ ) { | 963 | i ++ ) { |
964 | D = DL[i]; | 964 | D = DL[i]; |
965 | It = new DriverLVI( D, AllDrivers_LV ); | 965 | It = new DriverLVI( D, AllDrivers_LV ); |
966 | 966 | ||
967 | if( ! First ) | 967 | if( ! First ) |
968 | First = It; | 968 | First = It; |
969 | 969 | ||
970 | It->setText( 0, D->devname() ); | 970 | It->setText( 0, D->devname() ); |
971 | It->setPixmap( 0, | 971 | It->setPixmap( 0, |
972 | Icons->loadPixmap( (D->isUp()) ? | 972 | Icons->loadPixmap( (D->isUp()) ? |
973 | "bluezon" : "bluezoff" ) ); | 973 | "bluezon" : "bluezoff" ) ); |
974 | 974 | ||
975 | Sub = new QListViewItem( It ); | 975 | Sub = new QListViewItem( It ); |
976 | Sub->setText( 0, tr( "Name" ) ); | 976 | Sub->setText( 0, tr( "Name" ) ); |
977 | Sub->setText( 1, D->name() ); | 977 | Sub->setText( 1, D->name() ); |
978 | 978 | ||
979 | Sub = new QListViewItem( It ); | 979 | Sub = new QListViewItem( It ); |
980 | Sub->setText( 0, tr( "Address" ) ); | 980 | Sub->setText( 0, tr( "Address" ) ); |
diff --git a/noncore/settings/networksettings2/opietooth2/config.in b/noncore/settings/networksettings2/opietooth2/config.in index 720f49a..084e8c0 100644 --- a/noncore/settings/networksettings2/opietooth2/config.in +++ b/noncore/settings/networksettings2/opietooth2/config.in | |||
@@ -1,5 +1,5 @@ | |||
1 | config NS2OPIETOOTH | 1 | config NS2OPIETOOTH |
2 | boolean "opie-networksettings2 bluetooth library" | 2 | boolean "Opietooth2 bluetooth library" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBBLUEZ_DEP && NS2CORE |
5 | 5 | ||
diff --git a/noncore/settings/networksettings2/opietooth2/libopietooth2.postinst b/noncore/settings/networksettings2/opietooth2/libopietooth2.postinst index cd605c2..2713c61 100755 --- a/noncore/settings/networksettings2/opietooth2/libopietooth2.postinst +++ b/noncore/settings/networksettings2/opietooth2/libopietooth2.postinst | |||
@@ -1,10 +1,10 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | QTPB=/opt/QtPalmtop/bin | 3 | QTPB=/opt/QtPalmtop/bin |
4 | 4 | ||
5 | [ ! -L ${QTPB}/networksettings2-opietooth ] && ln -sf ${QTPB}/networksettings2 ${QTPB}/networksettings2-opietooth | 5 | [ ! -L ${QTPB}/networksettings2-opietooth ] && ln -sf ${QTPB}/networksettings2 ${QTPB}/networksettings2-opietooth |
6 | 6 | ||
7 | # qcop QPE/Taskbar "linkChanged(opietooth)" | 7 | # qcop QPE/Taskbar "linkChanged(opietooth)" |
8 | qcop QPE/Taskbar "reloadApps()" | 8 | ${QTPB}/qcop QPE/Taskbar "reloadApps()" |
9 | 9 | ||
10 | exit 0 | 10 | exit 0 |
diff --git a/noncore/settings/networksettings2/opietooth2/opietooth2.pro b/noncore/settings/networksettings2/opietooth2/opietooth2.pro index e0057a9..16277cf 100644 --- a/noncore/settings/networksettings2/opietooth2/opietooth2.pro +++ b/noncore/settings/networksettings2/opietooth2/opietooth2.pro | |||
@@ -1,37 +1,44 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #CONFIG += qt warn_on debug | 3 | #CONFIG += qt warn_on debug |
4 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) | 4 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) |
5 | HEADERS = OTDevice.h \ | 5 | HEADERS = OTDevice.h \ |
6 | OTDriver.h \ | 6 | OTDriver.h \ |
7 | OTGateway.h \ | 7 | OTGateway.h \ |
8 | OTHCISocket.h \ | 8 | OTHCISocket.h \ |
9 | OTInquiry.h \ | 9 | OTInquiry.h \ |
10 | OTDeviceAddress.h \ | 10 | OTDeviceAddress.h \ |
11 | OTIcons.h \ | 11 | OTIcons.h \ |
12 | OTUUID.h \ | 12 | OTUUID.h \ |
13 | OTSDPAttribute.h \ | 13 | OTSDPAttribute.h \ |
14 | OTSDPService.h \ | 14 | OTSDPService.h \ |
15 | OTPeer.h \ | 15 | OTPeer.h \ |
16 | Opietooth.h | 16 | Opietooth.h |
17 | SOURCES = OTDevice.cpp \ | 17 | SOURCES = OTDevice.cpp \ |
18 | OTDriver.cpp \ | 18 | OTDriver.cpp \ |
19 | OTDriverList.cpp \ | 19 | OTDriverList.cpp \ |
20 | OTHCISocket.cpp \ | 20 | OTHCISocket.cpp \ |
21 | OTInquiry.cpp \ | 21 | OTInquiry.cpp \ |
22 | OTDeviceAddress.cpp \ | 22 | OTDeviceAddress.cpp \ |
23 | OTUUID.cpp \ | 23 | OTUUID.cpp \ |
24 | OTSDPAttribute.cpp \ | 24 | OTSDPAttribute.cpp \ |
25 | OTSDPService.cpp \ | 25 | OTSDPService.cpp \ |
26 | OTIcons.cpp \ | 26 | OTIcons.cpp \ |
27 | OTPeer.cpp \ | 27 | OTPeer.cpp \ |
28 | OTGateway.cpp \ | 28 | OTGateway.cpp \ |
29 | Opietooth.cpp | 29 | Opietooth.cpp |
30 | INCLUDEPATH+= $(OPIEDIR)/include ../networksettings2 | 30 | INCLUDEPATH+= $(OPIEDIR)/include ../networksettings2 |
31 | DEPENDPATH+= $(OPIEDIR)/include | 31 | DEPENDPATH+= $(OPIEDIR)/include |
32 | LIBS += -lqpe -lopiecore2 -lbluetooth -lnetworksettings2 | 32 | LIBS += -lqpe -lopiecore2 -lbluetooth -lnetworksettings2 |
33 | INTERFACES= OTMainGUI.ui OTSniffGUI.ui OTScanGUI.ui OTManageGUI.ui OTPairingGUI.ui | 33 | INTERFACES= OTMainGUI.ui OTSniffGUI.ui OTScanGUI.ui OTManageGUI.ui OTPairingGUI.ui |
34 | TARGET = opietooth2 | 34 | TARGET = opietooth2 |
35 | VERSION = 1.0.0 | 35 | VERSION = 1.0.0 |
36 | 36 | ||
37 | include ( $(OPIEDIR)/include.pro ) | 37 | include ( $(OPIEDIR)/include.pro ) |
38 | |||
39 | !isEmpty( LIBBLUEZ_INC_DIR ) { | ||
40 | INCLUDEPATH += $$LIBBLUEZ_INC_DIR | ||
41 | } | ||
42 | !isEmpty( LIBBLUEZ_LIB_DIR ) { | ||
43 | LIBS += -L$$LIBBLUEZ_LIB_DIR | ||
44 | } | ||