以编程方式更改广告率

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_adv_start(void)
{
...
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
....
}

这是工作吗?这是实现这一目标的最佳方式吗?

谢谢你提供的所有帮助。

gl_dialog.
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_app_adv_int_min&current_app_adv_int_max必须是相同的。

best regards,

Guillaume.

oren.
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,
oren.

hrg
Offline
Last seen:2年2个月前
格鲁鲁
加入:2014-08-05 13:37
#define app_adv_int_min.

#define app_adv_int_min.1100
#define APP_ADV_INT_MAX 1100
1100意思是?单元??

JE_Dialog
Offline
Last seen:1 day 1 hour ago
Staff
加入:2013-12-05 14:02
嗨HRG,我相信单位

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

BR

JE_Dialog

mhv_dialog.
Offline
Last seen:1 week 4 days ago
Staff
加入:2013-12-06 15:10
Hi,

Hi,

您应该将数字1100乘以0.625以获取事件之间的线索数。所以1100 => 688ms。

hrg
Offline
Last seen:2年2个月前
格鲁鲁
加入:2014-08-05 13:37
嗨je_dialog

嗨je_dialog

yu确定吗?因为它是广告间隔所以1100 *(1/100)= 11秒!!当或者是1100 * 0.625 = 687.S毫秒?因为在从电力分析中检查两个广告活动的时间约为680毫秒!!

mhv_dialog.
Offline
Last seen:1 week 4 days ago
Staff
加入:2013-12-06 15:10
嗨HRG,

嗨HRG,

看到我上面的答案。

除了设置之外,堆栈将不得不为广告添加一个随机数,以避免两个单独的设备连续碰撞空中。所以广告将波动一些+/- 10ms

JE_Dialog
Offline
Last seen:1 day 1 hour 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是正确的值。

#define app_adv_int_min.0x20 // *0.625ms (+ pseudo random advDelay from 0 to 10ms)

BR JE_Dialog

mhv_dialog.
Offline
Last seen:1 week 4 days ago
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:2 weeks 2 days ago
Staff
加入:2015-06-08 11:34
嗨,亚历克斯,

嗨,亚历克斯,

根据蓝牙规范,广告事件以规则的间隔发生,这些间隔略微修改,随机延迟以帮助干扰避免。即使没有这种机制,随着时间的推移,不同的广告间隔应该漂移并停止彼此重叠(无论您的广告如何开始,您的扫描仪无法发现其他设备的时间)。你使用不同的BD地址吗?你的软件版本是什么?

Thanks MT_dialog

alex
Offline
Last seen:2 years 3 months ago
加入:2014-08-20 03:39
谢谢mt ..

谢谢mt ..

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

Alex.

MT_dialog
Offline
Last seen:2 weeks 2 days ago
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:3 days 2 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_easy_gap_nonnectable_advertise_start_create_msg”,它相同地设置cmd-> intv_max和cmd-> intv_min
cmd->intv_max = user_non_connectable_advertise_conf.intv;
cmd-> intv_min = user_non_connectable_advertise_conf.intv;

真正的随机数生成器在“da1458x_config_advance.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:2 weeks 2 days ago
Staff
加入:2015-06-08 11:34
嗨Ciano,

嗨Ciano,

请确保在580中下载的图像具有所定义的CFG_TRNG,我将您的场景与SDK 5.0.2.1在未连接模式(不同的广告字符串,不同的BD_Addresses和相同的广告间隔不同)中使用SDK 5.0.2.1测试了您的场景并且通过连接两个重置引脚,我同时在两个板上发出复位。我可以用嗅探器和普通的Android BLE应用程序妥善看到电路板。我可以获得一个设备和损坏的广告数据的唯一方法是CFG_TRNG未定义。当TRNG定义时,请检查嗅探器附件。

Thanks MT_dialog

Attachment:
ciano
Offline
Last seen:3 days 2 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-10 ms延迟到广告每秒重新启动它?
如果在这种情况下没有添加随机延迟,那么这可以解释我在空中遇到广告的碰撞。

Looking forward for your answer.
最好的祝福,
Ciano

MT_dialog
Offline
Last seen:2 weeks 2 days ago
Staff
加入:2015-06-08 11:34
嗨Ciano,

嗨Ciano,

因此,您每1秒广告1广告数据包,这是由发布广告启动的经过时间的定时器定义。这解释了你是经验的,第一个广告消息没有应用于它的延迟。在APP_ADV_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_last_ble_event;
temp_last_ble_event = arch_last_rwble_evt_get();
if(app_last_ble_event!= temp_last_ble_event)
{
app_last_ble_event = temp_last_ble_event;
if (app_last_ble_event == BLE_EVT_END)
adv_count ++;
if(adv_count == 2)
{
adv_count=0;
app_easy_gap_advertise_stop();
}
}
return GOTO_SLEEP;
}

Thanks MT_dialog

ciano
Offline
Last seen:3 days 2 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:2 weeks 2 days ago
Staff
加入:2015-06-08 11:34
嗨Ciano,

嗨Ciano,

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:3 days 2 hours ago
加入:2014-10-03 08:13
Thank you very much for the

Thank you very much for the info.

我现在没有更多的问题。

最好的祝福,
Ciano Frost
丹麦。

Topic locked