在Android 6.0 Marsmallow BLE:连接参数 [英] Android 6.0 Marsmallow BLE : Connection Parameters

查看:3040
本文介绍了在Android 6.0 Marsmallow BLE:连接参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

蓝牙低功耗连接参数管理似乎是在Android的6已经改变了。

The Bluetooth Low Energy connection parameters management seems to have changed in Android 6.

我有谁需要使用一些特定的连接参数(值得注意的是,连接间隔)一BLE外围设备,我想使用由BLE规范所允许的最小连接间隔(即7,5ms)。

I have a BLE Peripheral device who needs to use some specific connection parameters (notably, the connection interval), and I want to use the minimum connection interval allowed by the BLE specification (i.e. 7,5ms).

Android的SDK不允许从BLE GAP环(智能手机)的一面,所以正确的方法选择它做的是让我的GAP外围设备发送一个 L2CAP连接参数更新请求的GAP连接后。

The Android SDK doesn't allow to choose it from the BLE GAP Central (the smartphone) side, so the proper way to do it is to make my GAP Peripheral device send a L2CAP Connection Parameter Update Request after the GAP connection is made.

我要求的参数是:


  • 连接间隔分钟:7,5ms

  • 连接区间最大值:7,5ms

  • 从延迟:0

  • 监督超时:2000毫秒

这工作与所有的Andr​​oid设备我一直在测试预期,从4.3到5.x:发送 L2CAP连接参数更新请求之后,我的设备收到 L2CAP连接参数更新响应将0x0000(接受),接着是 LE连接更新完成事件在那里我可以看到,所请求的连接参数以及被考虑在内。

This worked as expected with all Android devices I've been testing, from 4.3 to 5.x : after sending the L2CAP Connection Parameter Update Request, my device receives a L2CAP Connection Parameter Update Response with 0x0000 (accepted), followed by a LE Connection Update Complete event where I can see that the requested connection parameters have well been taken into account.

现在,与Nexus 9平板电脑或2个不同的Nexus 5设备中,所有的Andr​​oid有6.0.1,我可以看到的 L2CAP连接参数更新请求是始终拒绝(我收到 L2CAP连接参数更新响应将0x0001(拒绝))。然后,我收到一个 LE连接更新完成事件在那里我可以看到所请求的连接参数还没有被考虑进去。

Now, with a Nexus 9 tablet or with 2 different Nexus 5 devices, all having Android 6.0.1, I can see that the the L2CAP Connection Parameter Update Request is always rejected (I receive a L2CAP Connection Parameter Update Response with 0x0001 (rejected)). Then I receive a LE Connection Update Complete event where I can see that the requested connection parameters have NOT been taken into account.

我一直与外围侧2个不同的实现(一个ST Microelectronics的BlueNRG,其中一个Nordic半导体公司nRF52),两者具有完全相同的结果尝试此。

I've been trying this with 2 different implementations on the Peripheral side (one with ST Microelectronics' BlueNRG, one with Nordic Semiconductor's nRF52), both with the exact same result.

然后,更多的测试后,我曾尝试不同的参数设置,改变康涅狄格州最大间隔(我一直在其他参数相同)。以下是我发现的:

Then, after more testing : I have tried different parameter sets, changing the conn interval max (I kept other parameters the same). Here is what I found :


  • 与康恩区间上限= 18.75ms,更新请求被间隔设置接受18.75ms

  • 与康恩区间上限= 17.50ms,更新请求被间隔设置接受15.00ms

  • 与康恩区间上限= 15.00ms,更新请求被间隔设置接受15.00ms

  • 与康恩区间上限= 13.75ms,更新请求被间隔设置接受11.25ms

  • 与康恩区间上限= 11.25ms,更新请求被间隔设置接受11.25ms

  • 下面11.25ms任何其他康恩区间最大值,我被拒绝。

所以,观察是,事情已经清楚了Android 6的BLE堆栈处理连接参数的方式发生变化。但是,似乎没有被任何种类的信息或文件,以确认。

So the observation is that something has clearly changed with the way Android 6's BLE stack handles the connection parameters. But there doesn't seem to be any kind of information or documentation to confirm that.

我的意见导致的结论,即允许的最小连接间隔现在是11.25ms(这其实符合我的需求),而不是在早期的Andr​​oid版本7.5ms。不过话说发现经验,我想确保我不会错过了一些其他方面的限制/规则,或者如果最低不会是动态的,例如根据当前电池电量...

My observations lead to a conclusion that the minimum connection interval allowed is now 11.25ms (which actually fits my needs) instead of 7.5ms in earlier Android versions. But having found it empirically, I'd want to be sure that I'm not missing some other constraints/rules or if that minimum would not be dynamic, depending for example on the current battery level...

什么是伟大的是将有苹果的蓝牙设计准则相当于(参见3.6节)设置在一个LE外围应该如何处理这个话题事情说清楚。

What would be great would be to have the equivalent of Apple's Bluetooth Design Guidelines (cf. §3.6) to set things clear on how an LE Peripheral should deal with this topic.

是具有人同样的问题或知道从谷歌一些有用的信息?

Is anyone having the same issue or is aware of some more helpful information from Google ?

推荐答案

从比较法GattService.java connectionParameterUpdate()在AOSP 6.0.1_r17 VS AOSP 5.1.1_r14。在这两种情况下,呼叫将全部BTA_DmBleUpdateConnectionParams()与同PARAMS bta_dm_api.c到Buedroid的方式。

Compare method connectionParameterUpdate() from GattService.java in AOSP 6.0.1_r17 vs AOSP 5.1.1_r14. In both instances, call goes all the way to Buedroid in BTA_DmBleUpdateConnectionParams() in bta_dm_api.c with same params.

6.0

    switch (connectionPriority)
    {
        case BluetoothGatt.CONNECTION_PRIORITY_HIGH:
            minInterval = 9; // 11.25ms
            maxInterval = 12; // 15ms
            break;

        case BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER:
            minInterval = 80; // 100ms
            maxInterval = 100; // 125ms
            latency = 2;
            break;
    }

5.1

    switch (connectionPriority)
    {
        case BluetoothGatt.CONNECTION_PRIORITY_HIGH:
            minInterval = 6; // 7.5ms
            maxInterval = 8; // 10ms
            break;

        case BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER:
            minInterval = 80; // 100ms
            maxInterval = 100; // 125ms
            latency = 2;
            break;
    }

这可能是回答你的问题的一部分。尽管BLE允许下到7.5ms CI,我无法猜测为什么链路层不会因外围切换到较低的CI要求。我不知道安卓code控制与外围设备的谈判结果的任何部分。

This might be a part of the answer to your question. Although BLE allows down to 7.5ms CI, I cannot speculate why link layer would not switch to lower CI on request by peripheral. I don't know if any part of android code controls outcome of negotiations with peripheral device.

这篇关于在Android 6.0 Marsmallow BLE:连接参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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