This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2340R2:受限广播持续时间参数

Guru**** 2336190 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1458862/cc2340r2-limited-advertising-duration-parameter

器件型号:CC2340R2

工具与软件:

您好、Clement、

我们需要支持2个不同的广播间隔。 我们需要一个持续时间为30s 的广播间隔、然后如果没有建立连接、我们需要将广播间隔更改为持续时间为4分钟。  我们修改了下面的结构以设置持续时间。 原始值如下所示(来自 app_peripheral.c)。

static const BLEAppUtil_AdvStart_t advSetStartParamsSet_1 =
{
    /* Use the maximum possible value. This is the spec-defined maximum for */
    /* directed advertising and infinite advertising for all other types */
    .enableOptions         = GAP_ADV_ENABLE_OPTIONS_USE_MAX,
    .durationOrMaxEvents   = 0
};

我们将结构更改为:  

static BLEAppUtil_AdvStart_t advSetStartParamsSet_1 =
{
    /* Use the maximum possible value. This is the spec-defined maximum for */
    /* directed advertising and infinite advertising for all other types */
    .enableOptions         = GAP_ADV_ENABLE_OPTIONS_USE_DURATION,
    /* Duration is in 10 msec ticks */
    .durationOrMaxEvents   = (30u * 100u)
};

原始广播间隔 按预期工作30秒。 30秒后,BLEAPPUTIL_ADV_END_AFTER_DISABLE 事件在 Peripheral_Adv Handler()中被触发和处理。 在处理程序中、我们设置了新的广播间隔、然后尝试将持续时间更新为240秒(即、设置 durationOrMaxEvents   =(240u * 100u)。 但是,将 duration 设置为此值会导致 BLEAppUtil_advStart()返回错误–0x18 ,即 bleInvalidRange: a parameter is out of range. 如果将值更改为180 * 100、则成功开始广播。 幸运的是、对于我们的应用、无论设置是180秒还是240秒都无关紧要

我想提醒您注意这一点、因为根据 bleapputil_api.h 中的注释显示、持续时间应该支持大于180秒的值。

/**
* @brief BLEAppUtil Adv Start Structure
*
* Should be created by the application and passed to
* @ref BLEAppUtil_advStart.
*/
typedef struct
{
    GapAdv_enableOptions_t  enableOptions;  //!< whether to advertise for the max possible time, for a user-specified duration, or for a user-specified number of advertising events
 
    /**
     * If enableOptions is set to @ref GAP_ADV_ENABLE_OPTIONS_USE_DURATION, this is the time (in 10 ms ticks) to advertise before stopping where the range is 10 ms - 655,540 ms
     * If enableOptions is set to @ref GAP_ADV_ENABLE_OPTIONS_USE_MAX_EVENTS, this is the maximum number of advertisements to send before stopping, where the range is 1-256
     * If enableOptions is set to @ref GAP_ADV_ENABLE_OPTIONS_USE_MAX, this parameter is not used
     * If enableOptions is set to @ref GAP_ADV_ENABLE_OPTIONS_USE_DURATION, this is the time (in 10 ms ticks) to advertise before stopping where the range is 10 ms - 655,540 ms
     */
    uint16_t                durationOrMaxEvents;
} BLEAppUtil_AdvStart_t;

谢谢!

Luke

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Luke:  

    由于 "有限可发现标志"在所用广播集中设置、 所述的行为符合蓝牙核心规范版本5.3 |第3卷、第 C 部分、§9.2.3.2–即限制广播最大广播为180秒。  

    此致、