Consecutive stop and start of the advertising messages

4 posts / 0 new
最后一篇
堂框
离线
Last seen:1 year 2 months ago
加入:2016-03-24 12:25
Consecutive stop and start of the advertising messages

你好,

我们使用最后一个版本SDK 5.0.4来创建具有特定功能的新BLE项目。周期性地,外部MCU发送数据。这些数据将在现场制造商特定数据中使用广告消息重新传输。目前的广告操作应该停止,adv。应更新消息并再次重新启动广告操作。
问题是:
1.Can I execute consecutively the functions app_easy_gap_advertise_stop() and app_easy_gap_undirected_advertise_start() without to use/wait the callback user_app_adv_undirect_complete()? The new advertising message will be prepared before the function app_easy_gap_undirected_advertise_start() to be called.

2.如果我调用函数app_easy_gap_advertise_stop()并且广告操作已经停止了问题,并且已经停止了问题?

3.使用函数app_easy_gap_undirected_advertise_get_active()分配新的广告消息。但是,新数据无法在新的广告消息中添加。我们不想继续使用新的广告操作。如何释放静态指针“adv_cmd”?现在只有函数app_easy_gap_undircated_advertise_start()将执行它。我们不想更改SDK的源代码。问题是指针不是null。函数app_easy_gap_undircated_advertise_get_active()的下一次调用将返回旧的准备的广告消息。

非常感谢您提前答案。

设备:
MT_dialog
离线
Last seen:2个月3周前
职员
加入:2015-06-08 11:34
嗨舞厅,

嗨舞厅,

1.不,如果你做这类的实现probably you will run into issues. When invoking the start advertising procedure with a defined string you will have to stop the advertising procedure and wait for the stack to notify you that the advertising procedure has stopped in order for you to change the advertising string and start advertising again. You can't start a new advertising procedure if you aren't aware if the previous one has been stopped.

我们从来没有尝试过,但我没有看到任何错误。虽然大多数可能是如果您的广告已停止并且您发出额外的广告停止,但直到下次醒来之前都不会执行,并且由于您不会连接,并且您不会被广告(自Stopted)消息(对于广告停止)如果从外部中断或从内核定时器唤醒,将发送到堆栈。当您实际取消广告活动时,广告完整处理程序将击中。

3.Sorry but i dont see what the problem is exactly, since you ve started advertising with some data (invoke app_easy_gap_undirected_advertise_start()) the pointer to the adv_cmd will be null. After stop advertising and starting again the get_active will check the pointer and fill in the standard data of your device, then the advertising data will be updated with the additional data from the app_add_ad_struct(). Unless if you fill in the advertising structure and you dont invoke the starting of the advertising operation and until you invoke it the data should be changed ? Is that the case ? Even if the the adv_cmd is not NULL you can always update your string just like app_add_ad_struct() does. Additionally you dont have to use the easy api functions in order to perform an advertisment, you can always allocate GAPM_START_ADVERTISE_CMD fill in the parameters with the data you would like and send it to the stack. You can implement the function at the user defined files and that way you wont mess with ths SDK.

Thanks MT_dialog

堂框
离线
Last seen:1 year 2 months ago
加入:2016-03-24 12:25
嗨mt_dialog,

嗨mt_dialog,
Thanks for the fast answers.

1.这些是要求,虽然我没有看到任何问题,但这两个函数要连续执行任何问题。因为我不修改当前的广告字符串。它与上一个命令“启动通告”发送到内核,并且在函数ke_msg_send()的标题中写入,一旦调用该函数,就无法访​​问其数据,因为内核可能已复制消息并释放原始内存。“新的广告字符串在堆内存中分配,尚未发送到内核。可能还有另一个原因。

3.目的不是编写我的功能并复制SDK。目的是通过最好的方式使用它。请参阅函数app_add_ad_struct()中的示例代码。如果在广告邮件中不能添加使用数据,则您只有Assert_Error(0);这就是结局。为什么?如果我们用assert_warning(0)替换断言;执行将继续,但是在没有使用数据的情况下会传输广告消息。指针将被释放,因为将执行函数app_easy_gap_undircated_advertise_start()。这就是为什么我的问题是是否存在函数或方法来释放分配的消息,而无需启动虚拟广告操作。 One additional function in the module app.c could fix the problem.
For example the code could be:

if(adv_cmd!= null)
{
KE_MSG_FREE(ADV_CMD);
adv_cmd == NULL;
}

这样对吗?

MT_dialog
离线
Last seen:2个月3周前
职员
加入:2015-06-08 11:34
嗨舞厅,

嗨舞厅,

1) Its the proper way to do it, if you dont wait for the stack to verify that the advertising is indeed stopped and you issue an advertising immidiatelly you will run into issues, it doesn't have to do with memory allocation but with the advertising procedure itself and how the stack is handling it.

2)关于ASSERT_ERROR(0)和广告数据,函数是检查附加数据是否适合广告或扫描响应字符串,如果不是它必须通知开发人员在那点出现错误。现在关于adv_cmd指针的释放,在当前的实现中,如果广告出现问题,并且用户消息不适用于广告字符串或扫描响应数据,则当前实现将其视为错误的条件,并且开发人员应该通知,它不会从这些情况中恢复并在没有用户数据的情况下继续广告。如果您希望您可以拥有这种实现,请释放分配的消息和adv_cmd指针。或者您可以删除ASSERT_ERROR并保持广告,没有用户数据(因为您将调用APP_EASY_GAP_UNDIRCEDCTED_ADVERTISE_START()将被设置为NULL)。user_barebone.c文件不是SDK核心文件的一部分,因此可以自由地更改它。

Thanks MT_dialog