summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp
authorwimpie <wimpie>2005-01-09 00:32:10 (UTC)
committer wimpie <wimpie>2005-01-09 00:32:10 (UTC)
commite54346d28b19d3ac671802a25e8c03f346693291 (patch) (unidiff)
tree0f8d6561e24a7ba36fd8a6ab1869aa470e1fdb36 /noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp
parent60a617583d0ccc793d9ea4465998d90ec208db58 (diff)
downloadopie-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/OTHCISocket.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp14
1 files changed, 7 insertions, 7 deletions
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
@@ -25,37 +25,37 @@ using namespace Opietooth2;
25OTHCISocket::OTHCISocket( OTDriver * D ) : 25OTHCISocket::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
32OTHCISocket::~OTHCISocket() { 32OTHCISocket::~OTHCISocket() {
33 close(); 33 close();
34} 34}
35 35
36void OTHCISocket::close() { 36void 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
47bool OTHCISocket::open() { 47bool 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 }
@@ -142,25 +142,25 @@ void OTHCISocket::slotSocketActivated() {
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 }
@@ -174,25 +174,25 @@ void OTHCISocket::updateStatus(const QByteArray& data) {
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
185void OTHCISocket::slotConnectionClosed() { 185void OTHCISocket::slotConnectionClosed() {
186 owarn << "HCI connection closed." << oendl; 186 odebug << "HCI connection closed." << oendl;
187 emit connectionClosed(); 187 emit connectionClosed();
188} 188}
189 189
190void OTHCISocket::readEvent() { 190void OTHCISocket::readEvent() {
191 191
192 if (HCIReadNotifier) { 192 if (HCIReadNotifier) {
193 slotSocketActivated(); 193 slotSocketActivated();
194 } 194 }
195} 195}
196 196
197bool OTHCISocket::sendCommand( unsigned char ogf, 197bool OTHCISocket::sendCommand( unsigned char ogf,
198 unsigned short ocf, 198 unsigned short ocf,
@@ -221,53 +221,53 @@ bool OTHCISocket::sendCommand( unsigned char ogf,
221 221
222bool OTHCISocket::readStatus( unsigned char ogf, 222bool 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
272int OTHCISocket::socket() { 272int OTHCISocket::socket() {
273 return HCISocket.socket(); 273 return HCISocket.socket();