fetchUuidWithSdp 总是给出缓存的 UUID [英] fetchUuidWithSdp always giving the cached UUID

查看:61
本文介绍了fetchUuidWithSdp 总是给出缓存的 UUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个应用程序,在该应用程序中我必须在选定的设备上进行服务发现,但是每当我执行 fetchUuid 时,它总是在远程设备上为我提供缓存的 UUID.

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.

这是我正在尝试的

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.

这里是日志:

这是开始descovery时的错误:

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

发生上述错误后,fetchUuidWithSdp() 返回带有缓存 UUID 的意图作为错误

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

上述 UUID 被标记为错误,因为 fetchUuidWithSdp 在服务发现中遇到错误或需要很长时间才能执行相同操作时返回缓存的 UUID.

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.

推荐答案

我看到这是一篇旧帖子,但它是我在 Google 搜索中关于 Android 和服务发现协议 (SDP) 中缓存的 UUID 的第一个结果

I see this is an old post but it's first result in my Google search about Android and cached UUIDs in the Service Discovery Protocol (SDP)

Android 缓存设备的 SDP UUID 记录以及设备的蓝牙地址,因此如果您更改服务的 UUID 而不是设备的蓝牙地址,Android 仍然会在列表中保留旧的缓存 UUID在设备上调用 getUuids() 时的 UUID.

Android cache the SDP UUID records for devices together with the Bluetooth address of the device, so if you change the UUID for you service but not the Bluetooth address of the device, Android will still have the old cached UUID in the list of UUIDs when calling getUuids() on the device.

摆脱缓存的 UUID 记录的唯一方法是在 Android 系统设置中重置网络设置.似乎无法以编程方式清除缓存.

The only way to get rid of the cached UUID records is to reset Network settings in the Android system settings. It doesn't seem that it's possible to clear the cache programatically.

这篇关于fetchUuidWithSdp 总是给出缓存的 UUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆