Changeset 5358 for source/ariba/utility/bootstrap
- Timestamp:
- Jul 26, 2009, 5:17:30 PM (15 years ago)
- Location:
- source/ariba/utility/bootstrap/modules/bluetoothsdp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/utility/bootstrap/modules/bluetoothsdp/BluetoothSdp.cpp
r5344 r5358 283 283 284 284 for (i = 0; i < num_rsp; i++) { 285 286 285 address = (ii + i)->bdaddr; 287 logging_debug("found peer " << ba2string(&address) << ", querying SDP.") 286 287 string saddress = ba2string(&address); 288 string sname = ba2name(&address, sock); 289 290 logging_debug("found peer [" << saddress << "] [" << sname << "]"); 288 291 289 292 // TODO: sdp_search can be very slow, fork it! 290 sdp_search( address);293 sdp_search( address, sname ); 291 294 } 292 295 … … 295 298 296 299 int nextscan = (rand() % 40) + 5; 297 logging_debug(" Next sdp scan in " << nextscan << " seconds");298 299 scan_timer_.expires_from_now( boost::posix_time::seconds(nextscan));300 scan_timer_.async_wait( boost::bind(&BluetoothSdp::bt_scan, this));301 } 302 303 void BluetoothSdp::sdp_search(bdaddr_t target ) {300 logging_debug("next sdp scan in " << nextscan << " seconds"); 301 302 scan_timer_.expires_from_now( boost::posix_time::seconds(nextscan) ); 303 scan_timer_.async_wait( boost::bind(&BluetoothSdp::bt_scan, this) ); 304 } 305 306 void BluetoothSdp::sdp_search(bdaddr_t target, string devicename) { 304 307 305 308 /* … … 315 318 uint8_t port = 0; 316 319 320 // connect to the SDP server running on the remote machine 321 logging_debug("querying services from bt device [" 322 << ba2string(&target) << "] [" << devicename << "]"); 323 317 324 // prepare the buffers for the attributes 318 325 char name[256], info1[256], info2[256], info3[256]; 319 326 320 // connect to the SDP server running on the remote machine321 logging_debug("querying services from bt device " << ba2string(&target));322 327 session = sdp_connect(BDADDR_ANY, &target, SDP_RETRY_IF_BUSY); 323 328 … … 377 382 } 378 383 379 string BluetoothSdp::ba2string(bdaddr_t *ba) {384 string BluetoothSdp::ba2string(bdaddr_t* ba) { 380 385 /* 381 386 * Returns a string holding the bt adress in human readable form. … … 388 393 } 389 394 395 string BluetoothSdp::ba2name(bdaddr_t* ba, int sock){ 396 397 char name[256] = {0}; 398 memset(name, 0, sizeof(name)); 399 400 if( hci_read_remote_name(sock, ba, sizeof(name), name, 0) < 0 ) 401 strcpy(name, "unknown"); 402 403 string result = name; 404 return result; 405 } 406 390 407 #endif // HAVE_BLUETOOTH_BLUETOOTH_H 391 408 -
source/ariba/utility/bootstrap/modules/bluetoothsdp/BluetoothSdp.h
r5316 r5358 85 85 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H 86 86 void bt_scan(); 87 void sdp_search(bdaddr_t target); 88 string ba2string(bdaddr_t *ba); 87 void sdp_search(bdaddr_t target, string devicename); 88 string ba2string(bdaddr_t* ba); 89 string ba2name(bdaddr_t* ba, int sock); 89 90 90 91 sdp_session_t *sdp_session_;
Note:
See TracChangeset
for help on using the changeset viewer.