Skip to main content

Change advertisement data on the fly

6个月前

Change advertisement data on the fly

Posted byANT7772220 points 5回复
0旋转

I am using Codeless example for development. I have a function in user_cmd_interpreter that parses UART for 'SN' and will change the local name to something in the form SN123456 for example. The problem I am having is that I have to connect, disconnect and reconnect for the name to update. I have tried calling user_advertise(), but that does not work. I have read that app_easy_gap_update_adv_data() needs to be called. I have searched for that function and I can not find it in the ble_app_barebone files. My two questions are would calling app_easy_gap_update_adv_data() resolve the problem I'm having, and what is the code for app_easy_gap_update_adv_data().

6个月前

PM_DIALOG.

Hi ant777222,

谢谢你的问题在线。只是为了确保无附加版本:DA14580是DA14580所用版本的依氏_v_5.380.5.4.0

>>> “will change the local name to something in the form SN123456 for example”

你的意思是BLE设备名称?如果是,则设备名称被定义为user_device_name宏(ser_config_580.h标题文件),然后将存储到nvds_data_storage结构的nvds_tag_device_name项中。

因此,设备的名称是通过NVDS_TAG_DEVICE_NAME提供的,这是输入广告字符串中的内容。为了改变它,您必须自定义广告功能。und向量_advertise_start_create_msg()是填充邮件参数的函数,默认默认来自nvds_tag_device_name的名称。您可以在SDK中留下该值空白,使用App_easy_gap_undircated_advertise_get_active()用所有相应的值分配消息,然后针对包含广告字符串的成员并应用您想要的名称。此外,您必须使用0x09闪存标记名称,以便其他设备知道这是设备的名称。

如果您正在启动新的设计/项目,我们将强烈建议首先以DA14531或DA14585 / 586产品和我们最新的SDK6.0.14开始,因为它更加提高。亚博电竞菠菜我们有很多代码示例和改进的文档,还有软件路线图支持。DA14580产品系列和SDK5没有软件路线图支持。

Please check out DA14531:

//www.xmece.com/products/connectivity/bluetooth-low-energy/products/da14531

有更多完成的教程开发自定义配置文件 - 在DA14531和DA14585 / DA14586设备上创建自定义GATT配置文件。

我们也有一个DA14531模块,即DA14531 SmartBond TINY™ Module! It has very small dimensions and is very low power. Follow the link below to find datasheet, documentation and HW collaterals for the module:

//www.xmece.com/products/bluetooth-module-da14531-smartbond-tiny

还有参考设计,您将帮助您减少开发阶段,因为您不需要花费这么多时间开发您的应用程序代码。

无代表

无附件允许您快速使用一组AT命令使用无线IOT应用程序。亚博国际官网平台网址Dodeless AT命令平台允许通过BLE控制本地UART连接的设备以​​及远程设备。您可以创建简单的演示/应用程序/概念证明,而无需任何代码开发亚博国际官网平台网址或在顶部构建您自己的应用程序!

https://www.dialog-seminile.com/produ亚博电竞菠菜cts/smartbond-codeless-commands.

对话框串行端口服务(DSP)

DSP模拟串行电缆通信。它为RS-232连接提供了简单的替代品,包括通过蓝牙低能量的熟悉的软件流控制逻辑。SPS软件分发包括应用程序和配置文件源代码并支持间隙中央/外设角色。

https://www.dialog-seminile.com/produ亚博电竞菠菜cts/dialog-serial-port-service-dsps.

谢谢,PM_DIALOG.

6个月前

ANT777222 0 points

这是我正在使用的版本。我正在更改GAP_AD_TYPE_COMPLETE_NAME和GAP_AD_TYPE_MANU_SPECIFIC_DATA,我在USR_CMD_INTERPRER中拥有以下代码

else if ((input_cmd_type == AT_CMD_SN)&&(cmd_source == CMD_SRC_LOCAL)){

for(uint8_t i = 0; i <= 40; i++){

if((cmd_rx_buffer [i] =='s')&&(cmd_rx_buffer [i + 1] =='n')){

UINT8_T Advertisement_Data []
= {
17,GAP_AD_TYPE_MANU_SPECIFIC_DATA,0x07,0x4D,0xE4,0x00,0x00,0x00,0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//蓝牙设备名称
9,gap_ad_type_complete_name,cmd_rx_buffer [i],cmd_rx_buffer [i + 1],cmd_rx_buffer [i + 2],cmd_rx_buffer [i + 3],
cmd_rx_buffer[i+4],cmd_rx_buffer[i+5],cmd_rx_buffer[i+6],cmd_rx_buffer[i+7] };


for (uint8_t a = 3 ; a < 8; a++) {
广告_data [2 + a] = 0x00;
}
for(Uint8_t a = 8; a <16; a ++){
advertisement_data [2 + a] = cmd_rx_buffer [a + i-8];
}


Memcpy(&Dodeless_env.service_uuid,&广告_data [2],16);
memcpy(&dodeless_env.addata,&广告_data,sizeof(广告_data));
Codeless_env.addata_len = sizeof(广告_data);
//没有扫描响应数据
Dodeless_env.resp_data_len = 0;
//将无附件设置为可连接。
Dodeless_env.is_connectable = true;
//初始化输入命令索引到零。
console_env.input_cmd_char_index = 0;
//初始化Parser标志
console_env.parser_flag = char_parser_not_active;


user_advertise();
send_to_local(cmd_arguments.cmd_buffer);

break;
}
}
}

这是有效的,但我需要连接一个并断开名称更改的连接。无需连接,我需要名称要更改。

6个月前

PM_DIALOG.

Hi ant777222,

是否有可能澄清以下声明?

>>>“这是有效的,但我需要连接一个并断开名称更改的连接。我需要名称无需连接而更改。“

谢谢,PM_DIALOG.

6个月前

ANT777222 0 points

The command comes in that changes GAP_AD_TYPE_COMPLETE_NAME and GAP_AD_TYPE_MANU_SPECIFIC_DATA. I connect to the BLE device with a phone using lightblue. These fields are unchanged. I disconnect from the BLE device then reconnect and the fields are changed to what the command specified. I need the fields to change immediately without having to connect, disconnect, and reconnect.

6个月前

PM_DIALOG.

Hi ant777222,

You should set up a TIMER in order to update the advertising data. Please have a look at the ble_app_sleepmode example of the SDK and check the app_adv_data_update_timer_used timer. Upon its expiration the adv_data_update_timer_cb() is getting triggered and updates the advertising data.

谢谢,PM_DIALOG.