fetchUuidWithSdp always giving the cached UUID

匿名 (未验证) 提交于 2019-12-03 02:33:02

问题:

i am writing an app in which i have to do a service discovery on a selected device, but whenever i am doing a fetchUuid it is always giving me the cached UUIDs on the remote device.

here is what i am trying

public boolean UUIDsearch(BluetoothDevice device){      t=device.fetchUuidsWithSdp();     Log.d(TAG,"Device class = :"+device.getClass());        mReceiver = new BroadcastReceiver() {       @Override       public void onReceive(Context arg0, Intent intent) {            String action = intent.getAction();         //BluetoothDevice deviceExtra = intent.getParcelableExtra("android.bluetooth.device.extra.DEVICE");           if (BluetoothDevice.ACTION_UUID.equals(action)){              uuidExtra =intent.getParcelableArrayExtra("android.bluetooth.device.extra.UUID");           }           Log.d(TAG,"SDP has no errors: = "+t);          // if(found==false){           for(int i=0;i<uuidExtra.length;i++){               Log.d(TAG,"UUID:   "+ uuidExtra[i]);               if((uuidExtra[i].toString()).equals(MY_UUID.toString())){                   found=true;                   Log.d(TAG,"Match found in loop");                }            }          // }       }   };      // Register the BroadcastReceiver    IntentFilter filter1 = new IntentFilter(BluetoothDevice.ACTION_UUID);   registerReceiver(mReceiver, filter1);    return true;  } 

Can someone tell me what is wrong with the code.

here is the logcat:

this is the error when it starts descovery:

 09-05 15:05:15.906: D/(32591): bta_jv_start_discovery_cback: p_sdp_rec:0x52ab0e4c  09-05 15:05:15.906: D/BTIF_SOCK(32591): jv_dm_cback: event:8, slot id:26  09-05 15:05:15.906: E/BTIF_SOCK(32591): ## ERROR : jv_dm_cback: BTA_JV_DISCOVERY_COMP_EVT, slot id:26, found channle #, status:0, scn:7##  09-05 15:05:15.906: I/(32591): BTA_JvRfcommConnect  09-05 15:05:15.910: D/BluetoothSocket(2100): inputStream.read ret: 4  09-05 15:05:15.910: D/(32591): releasing SDP rsp_list 

after the above error occurs fetchUuidWithSdp() returns the intent with cached UUIDs as error

 09-04 16:54:51.851: I/(24860): BTA got event 0x206  09-04 16:54:51.851: I/(24860): btif_dm_search_services_evt:  event = 2  09-04 16:54:51.851: D/(24860): btif_dm_search_services_evt:(result=0x0, services 0xa42ed8f)  09-04 16:54:51.851: E/(24860): Index: 0 uuid:00001101-0000-1000-8000-00805f9b34fb  09-04 16:54:51.851: E/(24860): Index: 1 uuid:00001103-0000-1000-8000-00805f9b34fb  09-04 16:54:51.851: E/(24860): Index: 2 uuid:0000110a-0000-1000-8000-00805f9b34fb  09-04 16:54:51.851: E/(24860): Index: 3 uuid:00001105-0000-1000-8000-00805f9b34fb  09-04 16:54:51.851: E/(24860): Index: 4 uuid:00001106-0000-1000-8000-00805f9b34fb  09-04 16:54:51.851: E/(24860): Index: 5 uuid:00001110-0000-1000-8000-00805f9b34fb  09-04 16:54:51.851: E/(24860): Index: 6 uuid:00001104-0000-1000-8000-00805f9b34fb  09-04 16:54:51.851: E/(24860): Index: 7 uuid:0000111b-0000-1000-8000-00805f9b34fb  09-04 16:54:51.855: E/(24860): Index: 8 uuid:00001115-0000-1000-8000-00805f9b34fb  09-04 16:54:51.855: E/(24860): Index: 9 uuid:00001116-0000-1000-8000-00805f9b34fb  09-04 16:54:51.855: E/(24860): Index: 10 uuid:0000112d-0000-1000-8000-00805f9b34fb  09-04 16:54:51.855: E/(24860): Index: 11 uuid:0000112f-0000-1000-8000-00805f9b34fb  09-04 16:54:51.855: E/(24860): Index: 12 uuid:00001132-0000-1000-8000-00805f9b34fb  09-04 16:54:51.855: E/(24860): Index: 13 uuid:00001400-0000-1000-8000-00805f9b34fb  09-04 16:54:51.855: D/(24860): btif_dm_search_services_evt Remote Service SDP done. Call bond_state_changed_cb BONDED  09-04 16:54:51.855: D/(24860): bond_state_changed: state=2 prev_state=1  09-04 16:54:51.855: D/(24860): HAL bt_hal_cbacks->bond_state_changed_cb  09-04 16:54:51.855: I/(24860): bta_dm_search_sm_execute state:3, event:0x206  09-04 16:54:51.855: D/(24860): bta_dm_search_cmpl  09-04 16:55:59.703: E/BluetoothRemoteDevices(24860): aclStateChangeCallback: State:DisConnected to Device:00:0A:3A:64:A7:34 

the above UUIDs are tagged as errors because fetchUuidWithSdp returns cached UUID when an error is encountered in the service discovery or it is taking a long time to do the same.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!