按程序改变广告费率

21 posts / 0 new
Last post
motred
Offline
Last seen:5 years 3 months ago
Expert
加入:2014-01-20 21:48
按程序改变广告费率

I would like to change the advertising interval based on data from a sensor connected to the DA14580. I plan to do this by changing lines 209 and 210 in app.c to a global variable that can be updated by another function.

So I would have something like this in app.c:
void app\u adv\u start(无效)
{
...
cmd->intv_min = current_app_adv_int_min; // was APP_ADV_INT_MIN
cmd->intv_max = current_app_adv_int_max; // was APP_ADV_INT_MAX
....
}

这样行吗?这是最好的方法吗?

谢谢你的帮助。

GLU对话框
Offline
Last seen:3 years 3 months ago
Staff
加入:2014-02-07 13:35
Dear Motred,

Dear Motred,

You're right when saying that both lines 209 & 210 in app.c must be changed in case you need to change the advertising interval.
所以你menti的函数oned is fine.
请注意,current\u app\u adv\u int\u min和current\u app\u adv\u int\u max必须相同。

best regards,

Guillaume.

奥伦
Offline
Last seen:1 year 4 months ago
Expert
加入:2014-06-28 22:03
Hi Guillaume,

Hi Guillaume,
Do you know what happens if you set intv_min and intv_max to be different from each other?
From my tests, when intv_min < intv_max the advertising interval is intv_max.

Do you know if there are any side effects to do that? If intv_min is ignored, what is it good for?
(I am just interested out of curiosity).

Thanks,
奥伦

hrg
Offline
Last seen:2年2个月前
上师
加入:2014-08-05 13:37
#定义APP\u ADV\u INT\u MIN

#定义APP\u ADV\u INT\u MIN1100
#define APP_ADV_INT_MAX 1100
1100意味着??单位??

JE_Dialog
Offline
Last seen:4 days 7 hours ago
Staff
加入:2013-12-05 14:02
嗨,hrg,我相信

嗨,hrg,我相信单位是1/100秒。

BR

JE_Dialog

MHv\U对话框
Offline
Last seen:5天2小时前
Staff
加入:2013-12-06 15:10
Hi,

Hi,

您应该将数字1100乘以0.625,得到事件之间的毫秒数。所以1100=>688毫秒。

hrg
Offline
Last seen:2年2个月前
上师
加入:2014-08-05 13:37
Hi JE\u对话框

Hi JE\u对话框

你确定吗?因为是广告间隔所以1100*(1/100)=11秒??还是1100*0.625=687.s毫秒?因为在检查电源配置时,两个广告事件之间的时间约为680毫秒!!

MHv\U对话框
Offline
Last seen:5天2小时前
Staff
加入:2013-12-06 15:10
嗨,Hrg,

嗨,Hrg,

看我上面的答案。

除了设置之外,堆栈还必须在广告中添加一个随机数,以避免两个独立的设备在空中连续碰撞。所以广告会有+/-10毫秒的波动

JE_Dialog
Offline
Last seen:4 days 7 hours ago
Staff
加入:2013-12-05 14:02
Hello hrg, yes, you are right

Hello hrg, yes, you are right : i was looking at our Beacon SW by mistake where we have a different calculation.

main.c中的第81行和第83行应用了0.625的倍数,因此680mS是正确的值。

#定义APP\u ADV\u INT\u MIN0x20 // *0.625ms (+ pseudo random advDelay from 0 to 10ms)

BR JE_Dialog

MHv\U对话框
Offline
Last seen:5天2小时前
Staff
加入:2013-12-06 15:10
Hi,

Hi,

Just adding to this. You will have to stop, then restart advertising to actually change the intervals.

alex
Offline
Last seen:2 years 3 months ago
加入:2014-08-20 03:39
Hi JE,

Hi JE,

In #8, you mentioned the (BLE) stack will add random number(0~10ms) above APP_ADV_INT_MAX, while in our tests, we did not see this random adding to the interval:
- when we power up 3 DA modules(with same firmware) simutaneously, we could hardly scan all 3 modules(sometimes we can only scan 1, sometimes 2).
- while if we power up 3 DA modules one by one, we can scan all 3 modules everytime.
-如果我们把不同APP ADV INT MAX值的固件烧到每个模块上,同时给3个模块通电,我们也可以每次扫描所有3个模块。

请帮助检查并建议。。

Thanks.
Alex

MT_dialog
Offline
Last seen:1周3天前
Staff
加入:2015-06-08 11:34
嗨,亚历克斯,

嗨,亚历克斯,

根据蓝牙规范,广告事件以固定的时间间隔发生,并通过随机延迟进行轻微修改,以帮助避免干扰。即使没有这种机制,随着时间的推移,不同的广告间隔应该会漂移并停止重叠(无论你的广告同时开始多长时间,其他设备都不会被你的扫描仪发现)。你使用不同的bd地址吗?你的软件版本是什么?

Thanks MT_dialog

alex
Offline
Last seen:2 years 3 months ago
加入:2014-08-20 03:39
谢谢你,先生。。

谢谢你,先生。。

你使用不同的bd地址吗?
- Yes, we are having different BDA for each module.
你的软件版本是什么?
- The firmware developed based on SDK304.

Alex.

MT_dialog
Offline
Last seen:1周3天前
Staff
加入:2015-06-08 11:34
嗨,亚历克斯,

嗨,亚历克斯,

Can you please try to define the CFG_TRNG configuration, and check again if the advertising events overlaps ?

Thanks MT_dialog.

ciano
Offline
Last seen:1 day 9 hours ago
加入:2014-10-03 08:13
Hi Dialog

Hi Dialog
We have the same issue as #11, and we are using SDK 5.0.2.1

Info:
我们正在使用“app\u easy\u gap\u non\u connectable\u advertise\u start\u create\u msg”设置cmd->intv\u max和cmd->intv\u min
cmd->intv_max = user_non_connectable_advertise_conf.intv;
cmd->intv\u min=user\u non\u connectable\u播发_配置intv;

“da1458x\u config\u advanced.h”中启用了真随机数生成器
#define CFG_TRNG

Hope you have a solution, since this is a real issue for the application.

致以最诚挚的问候,
Ciano Frost
丹麦

MT_dialog
Offline
Last seen:1周3天前
Staff
加入:2015-06-08 11:34
你好,齐亚诺,

你好,齐亚诺,

请确保在580中下载的映像定义了CFG\u TRNG,我用sdk5.0.2.1在修改的模板示例中测试了您的场景,该示例以不可连接模式进行广告(不同的广告字符串,不同的bd_地址和相同的广告间隔),通过连接两个复位引脚,我在同一时间在两块板上发出一个复位。我可以正确地看到与嗅探器和正常的android应用程序板。我能得到一个设备和损坏的广告数据的唯一方法是当CFG\u TRNG未定义时。定义TRNG和未定义TRNG时,请检查嗅探器附件。

Thanks MT_dialog

Attachment:
ciano
Offline
Last seen:1 day 9 hours ago
加入:2014-10-03 08:13
Hi Dialog

Hi Dialog

One thing I forgot to mention, is that I am using a timer to restart the advertisment every one second. I change the advertisment data every time. I set up the advertisement with user_non_connectable_advertise_conf.intv = 16000 which is 10seconds. So my effective interval is determined by my 1 second timer, where I stop and restart the advertisement.

现在我的问题是:当蓝牙协议栈每秒钟重启一次播发时,还会给播发添加0-10ms的随机延迟吗?
如果在这种情况下不加上随机延迟,那么这就可以解释我在空中遇到的广告碰撞。

Looking forward for your answer.
致以最诚挚的问候,
Ciano

MT_dialog
Offline
Last seen:1周3天前
Staff
加入:2015-06-08 11:34
你好,齐亚诺,

你好,齐亚诺,

因此,您每1秒播发一个播发包,这是由发出播发开始的已用计时器定义的。这就解释了你的体验,第一条广告信息没有延迟。在发出app\u adv\u start之后,广告字符串将与另一个DUT在同一时间传输,之后下一个广告事件将以随机延迟重新安排,因此在您发送的第一条消息中,两条广告消息之间存在冲突。你正在经历的一个解决方法是减少广告间隔,以便第二个广告字符串在1秒间隔内传输,并随机延迟插入广告间隔,以便两个广告字符串不会发生冲突。

You can count the advertising string that you have emmited and stop the advertising in the second emmited advertising string (which will be received correctly), you can catch the completetion of the advertising and and start the timer, when tha timer elapses start advertising again.

以下是一个关于如何计算广告事件的小片段:

enum arch_main_loop_callback_ret count_adv_events(void)
{
uint8\t temp\u last\u ble\u事件;
temp_last_ble_event = arch_last_rwble_evt_get();
如果(应用程序\u上次\u ble \u事件!=温度(上次事件)
{
app_last_ble_event = temp_last_ble_event;
if (app_last_ble_event == BLE_EVT_END)
高级计数++;
如果(adv\u count==2)
{
adv_count=0;
app_easy_gap_advertise_stop();
}
}
return GOTO_SLEEP;
}

Thanks MT_dialog

ciano
Offline
Last seen:1 day 9 hours ago
加入:2014-10-03 08:13
Thank you for the answer.

Thank you for the answer.

还有一个问题:
As I understand, then the random delay which is added to the advertisement interval i in the range of 10 ms. Is it possible to increase this range to something like 500 or 1000ms?

Currently I have done this manually with an app timer setup from a fixed delay plus a random (TRNG) time from -500ms to 500ms ... This spreads the advertisement in time, and I do almost not see any collisions with many fobs.

致以最诚挚的问候,
Ciano Frost
丹麦

MT_dialog
Offline
Last seen:1周3天前
Staff
加入:2015-06-08 11:34
你好,齐亚诺,

你好,齐亚诺,

The delay that is inserted in the advertising operation is located in the ROM code according to the BLE spec, you cant change that.

Thanks MT_dialog

ciano
Offline
Last seen:1 day 9 hours ago
加入:2014-10-03 08:13
Thank you very much for the

Thank you very much for the info.

我现在没有问题了。

致以最诚挚的问候,
Ciano Frost
丹麦。

Topic locked