Diffstat (limited to 'noncore/settings/networksettings2/opietooth2/OTInquiry.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/OTInquiry.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
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 | |||
@@ -50,60 +50,60 @@ OTInquiry::OTInquiry( OTDriver * Drv ) : QObject( Drv ) { | |||
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 | ||
@@ -117,62 +117,62 @@ void OTInquiry::reset() { | |||
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 { |
@@ -194,25 +194,25 @@ void OTInquiry::slotHCIEvent(unsigned char eventCode, QByteArray buf) { | |||
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 | } |