gpt4 book ai didi

android - Ble 配对失败

转载 作者:行者123 更新时间:2023-11-29 20:10:57 26 4
gpt4 key购买 nike

我参与了一个 Android APP,它与我们公司的 Bt 芯片进行 BLE 连接和配对。 APP作为BLE central角色,Bt芯片作为BLE peripheral角色。

APP在Android 4.4或5.0智能手机上运行时,BLE连接配对正常。当APP在Android 5.1或最新版本6.0上运行时,BLE配对终止并出现错误码(错误码:13),而BLE连接成功。这是飞行日志:

4,148   0x50654c1d  0x0000  1   LL_VERSION_IND      24      2015/12/3 14:13:39.600368   
4,160 0x50654c1d 0x0001 2 LL_VERSION_IND 24 00:00:00.048473 2015/12/3 14:13:39.648841
4,163 0x50654c1d 0x0002 1 LL_FEATURE_REQ 27 00:00:00.048522 2015/12/3 14:13:39.697363
4,169 0x50654c1d 0x0003 2 LL_FEATURE_RSP 27 00:00:00.049066 2015/12/3 14:13:39.746429
4,179 0x50654c1d 0x0004 1 LL_CONNECTION_UPDATE_REQ 0x000a 30 00:00:00.048436 2015/12/3 14:13:39.794865
4,234 0x50654c1d 0x000b 1 LL_ENC_REQ 41 00:00:00.303755 2015/12/3 14:13:40.098620
4,237 0x50654c1d 0x000c 2 LL_ENC_RSP 31 00:00:00.007727 2015/12/3 14:13:40.106347
4,244 0x50654c1d 0x000d 2 LL_START_ENC_REQ 19 00:00:00.007500 2015/12/3 14:13:40.113847
4,245 0x50654c1d 0x000e M LL_START_ENC_RSP 23 00:00:00.007273 2015/12/3 14:13:40.121120
4,248 0x50654c1d 0x000f S LL_START_ENC_RSP 23 00:00:00.007726 2015/12/3 14:13:40.128846
4,392 0x50654c1d 0x004a M LL_CONNECTION_UPDATE_REQ 0x0050 34 00:00:00.442275 2015/12/3 14:13:40.571121
4,794 0x50654c1d 0x008c M LL_CHANNEL_MAP_REQ 0x0093 30 00:00:03.002545 2015/12/3 14:13:43.573666
7,168 0x50654c1d 0x0131 M LL_CHANNEL_MAP_REQ 0x0138 30 00:00:08.043797 2015/12/3 14:13:51.617463
10,065 0x50654c1d 0x0261 M LL_CHANNEL_MAP_REQ 0x0268 30 00:00:14.820121 2015/12/3 14:14:06.437584
10,449 0x50654c1d 0x029d M LL_TERMINATE_IND 24 00:00:02.925044 2015/12/3 14:14:09.362628

我的Bt主机程序(基于Bt芯片)接收到CONNECTION_PARAMETER_UPDATE_COMP_IND事件,然后接收到LE_DEVICE_DISCONNECT_COMP_IND事件。我猜断开连接 BLE 的操作是由 Android Bt 堆栈完成的。

在Android 4.4或5.0中,没有接收到CONNECTION_PARAMETER_UPDATE_COMP_IND事件,请问这是怎么回事,如何在Android 5.1或6.0上使BLE配对成功。任何帮助将不胜感激。

最佳答案

对于蓝牙低功耗设备的查找和配对,支持两种方式

  1. 对于kitkat版本及以下

    startLeScan() 

此方法将BluetoothAdapter.LeScanCallback作为参数

  1. 适用于 Lollipop 版本及以上

    mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();

    mBluetoothLeScanner.startScan(filters, settings, mScanCallback);

    并且您需要将回调定义为流以获取响应

    private ScanCallback mScanCallback = new ScanCallback() {
    @Override
    public void onScanResult(int callbackType, ScanResult result) {

    }

    @Override
    public void onBatchScanResults(List<ScanResult> results) {

    }

    @Override
    public void onScanFailed(int errorCode) {

    }
    };

关于android - Ble 配对失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34941431/

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