gpt4 book ai didi

安卓10 : GATT error with 133 - how fix?

转载 作者:行者123 更新时间:2023-12-04 11:23:51 35 4
gpt4 key购买 nike

我有安卓应用。我使用 BLE(低功耗蓝牙)连接设备。它运行良好,但我在 Android 10 上遇到问题。这是我的代码:

 Hashtable<String, BluetoothDevice> myHtDevices;
....
BluetoothGatt gatt = myHtDevices.get(deviceId).connectGatt(this, false, gattCallback);

在 onConnectionStateChange 我得到:
//public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState){
status= 133,
newStatus =0,

我只有Android Q有这个问题。

我尝试了这种方法(添加参数 TRANSPORT_LE),但它不起作用:
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q){
gatt = myHtDevices.get(deviceId).connectGatt(this, false, gattCallback,
BluetoothDevice.TRANSPORT_LE);
}
else {
gatt = myHtDevices.get(deviceId).connectGatt(this, false, gattCallback);
}

添加信息:
  • 我通过执行 BLE 扫描获得了 myHtDevices。
  • 我马上回调过来。
  • 设备- 三星 9

  • 这是 nRF 连接日志:
      nRF Connect, 2020-03-24
    Device (50:8C:B1:52:B7:8D)
    V 19:37:26.248 Connecting to 50:8C:B1:52:B7:8D...
    D 19:37:26.248 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D 19:37:26.549 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    D 19:37:26.721 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I 19:37:26.721 Connected to 50:8C:B1:52:B7:8D
    V 19:37:26.745 Discovering services...
    D 19:37:26.745 gatt.discoverServices()
    I 19:37:26.872 Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    D 19:37:27.768 [Callback] Services discovered with status: 0
    I 19:37:27.768 Services discovered
    V 19:37:27.814 Generic Access (0x1800)
    - Device Name [R] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Privacy Flag [R W] (0x2A02)
    - Reconnection Address [W] (0x2A03)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    Generic Attribute (0x1801)
    - Service Changed [I] (0x2A05)
    Client Characteristic Configuration (0x2902)
    Device Information (0x180A)
    - System ID [R] (0x2A23)
    - Model Number String [R] (0x2A24)
    - Serial Number String [R] (0x2A25)
    - Firmware Revision String [R] (0x2A26)
    - Hardware Revision String [R] (0x2A27)
    - Software Revision String [R] (0x2A28)
    - Manufacturer Name String [R] (0x2A29)
    - IEEE 11073-20601 Regulatory Certification Data List [R] (0x2A2A)
    - PnP ID [R] (0x2A50)
    Unknown Service (6d95c372-02f0-4360-b0c0-432109c2b715)
    - Unknown Characteristic [R W WNR] (105998c0-5e55-4de3-9fc9-1cf857231477)
    Characteristic User Description (0x2901)
    - Unknown Characteristic [R W WNR] (4f294974-26c0-43f6-aff9-aac109231e0d)
    Characteristic User Description (0x2901)
    - Unknown Characteristic [R W WNR] (51bb9208-7ed1-4c10-821a-be0ca1880c36)
    Characteristic User Description (0x2901)
    - Unknown Characteristic [R W WNR] (1767ac17-5aac-4692-93b0-1cb11b28fda6)
    Characteristic User Description (0x2901)
    - Unknown Characteristic [R W WNR] (3242c75b-0ce2-4560-9cc4-5190b2ee93d3)
    Characteristic User Description (0x2901)
    - Unknown Characteristic [R W WNR] (ad2192c7-c2d0-4c2a-b705-194602bf3c9e)
    Characteristic User Description (0x2901)
    Unknown Service (18b794e2-9679-4676-93e1-6a244758002d)
    - Unknown Characteristic [R W WNR] (b8fe10c6-eba1-425d-849c-189e60f4dbc9)
    Characteristic User Description (0x2901)
    - Unknown Characteristic [R W WNR] (fd8c491c-e597-4e85-b831-5b4c37a3afc6)
    Characteristic User Description (0x2901)
    Unknown Service (bd31f74c-7f33-4b27-a2cf-6660b8d1efc2)
    - Unknown Characteristic [R W WNR] (e91ed239-2e78-4aa9-8f5a-9701ecac4740)
    Characteristic User Description (0x2901)
    - Unknown Characteristic [R W WNR] (6e143748-ac59-4522-bdd0-46fd3e2101d7)
    Characteristic User Description (0x2901)
    - Unknown Characteristic [R W WNR] (b1e20318-8afc-47e3-3ac2-1eea626ce7a9)
    Characteristic User Description (0x2901)
    Unknown Service (baefe645-2991-4f24-9fb1-a8ea687c395a)
    - Unknown Characteristic [R W WNR] (898542a6-55e6-4188-ac49-261d3e179640)
    Characteristic User Description (0x2901)
    - Unknown Characteristic [R W WNR] (06dc3129-99e3-45e6-8694-8845ce52fdda)
    Characteristic User Description (0x2901)
    - Unknown Characteristic [R W WNR] (d49aeb6d-a33c-4cf0-a06f-f7eca72bfe4f)
    Characteristic User Description (0x2901)
    - Unknown Characteristic [R W WNR] (583205af-5509-42ed-bdac-f95bb5c7bca3)
    Characteristic User Description (0x2901)
    - Unknown Characteristic [R W WNR] (fa54cb0c-ca4f-405d-b8e0-cf3c7d2f5ffe)
    Characteristic User Description (0x2901)
    - Unknown Characteristic [R W WNR] (b1e20318-8afc-47e3-a32c-e1ae26c67e9a)
    Characteristic User Description (0x2901)
    D 19:37:27.815 gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
    I 19:37:27.840 Connection parameters updated (interval: 48.75ms, latency: 0, timeout: 5000ms)

    有什么建议吗?

    最佳答案

    AOSP constants 中所示,这个错误是你能得到的最普遍的错误。通常,当设备超出范围但您仍然尝试连接时会发生这种情况。您应该检查完整的 logcat 和 dmesg 以找出根本原因。我的 BLE 应用无法连接到运行自定义 ROM 的华为手机上的任何设备,因此请确保该设备使用的是 Android 10 的 OEM 库存版本 - 如果这不起作用,请尝试使用 AOSP - 你永远不知道什么是制造商把他们的皮肤。

    关于安卓10 : GATT error with 133 - how fix?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60810522/

    35 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com