Changing the device name during runtime

⚠️
嗨,...感谢您来论坛。令人兴奋的消息!我们现在正在迁至我们的新论坛平台,将提供更好的功能,并包含在主对话框网站中。所有帖子和帐户都已迁移。我们现在只接受新论坛上的流量 - 请发布任何新线程https://www.dialog-seminile.com/support.。我们将在未来几天修复错误/优化搜索和标记。
6个帖子/ 0新
最后一篇
niekvdd.
离线
Last seen:1 year 11 months ago
加入:2017-01-25 09:29
Changing the device name during runtime

Hi all,

I want to change the advertising device name on the fly (during runtime, changeable by an android app). I've the forum thoroughly and came to the conclusion that I should write to NVDS_TAG_DEVICE_NAME, please correct me if I am wrong. I am working from the ble_app_peripheral project from the SDK.

但是,我可以找到改变这个价值的方法。可以anybode请告诉我如何写入nvds_tag_device_name?欢迎在运行时更改设备名称的替代方法也非常欢迎。
It is not an issue to restart advertising after the device name has been changed.

Kind regards,
Niek

P.S.我正在使用SDK 5.0.3.268,而不是5.0.2.1,但此选项未被选择

Device:
MT_dialog
离线
Last seen:2 months 4 weeks ago
职员
加入:2015-06-08 11:34
Hi Niekvdd,

Hi Niekvdd,

在运行时在广告字符串上更改设备的名称是可能的,并且从Android手机更改设备的名称也是可能的,但这需要连接到设备并通过自定义特征提供一个。因此,通过nvds_tag_device_name提供设备的名称,这是输入广告字符串中的内容,因此要更改您必须自定义广告功能。app_easy_gap_undirected_advertise_start_create_msg()这是填充邮件参数的函数,默认默认为nvds_tag_device_name的名称,因此您可以在sdk中保留空白空白,使用app_easy_gap_undircated_advertise_get_active()以所有适当的值分配消息然后针对包含广告字符串的成员并应用您想要的名称,您必须使用0x09闪存标记名称,以便其他设备知道这是设备的名称。

Thanks MT_dialog

niekvdd.
离线
Last seen:1 year 11 months ago
加入:2017-01-25 09:29
Hi MT_dialog,

Hi MT_dialog,

I can follow your explaination up untill "So the name of the device is provided through the NVDS_TAG_DEVICE_NAME ".

1)名字是什么意思?

2)“因此,为了改变您必须自定义广告函数”你的意思是我不应该改变nvds_tag_device_name的内容/值,而是修改函数,以便它们不会使用nvds_tag_device_name作为资源?我试过这个如下,但是广告名称不改变..

in static struct gapm_start_advertise_cmd* app_easy_gap_undirected_advertise_start_create_msg(void) in app.c from example ble_app_peripheral I edited the following from:
uint8_t device_name_length = 0;
uint8_t device_name_temp_buf [nvds_len_device_name];
// Check if data can be added to the Advertising data
if ((adv_avail_space > 0) || (scan_avail_space > 0))
{
//获取设备名称以添加在广告数据中
// Get default Device Name (No name if not enough space)
device_name_length = NVDS_LEN_DEVICE_NAME;
if(nvds_get(nvds_tag_device_name,&device_name_length,&device_name_temp_buf [0])!= nvds_ok)
{
//恢复默认值
assert_warning(0);
device_name_length = 0;
}
}

至:

// uint8_t device_name_length = 0;
// uint8_t device_name_temp_buf[NVDS_LEN_DEVICE_NAME];

uint8_t device_name_length = 6;
uint8_t device_name_temp_buf[6] = "1test1" ;
// memcpy(&cmd->info.host.adv_data[cmd->info.host.adv_data_len + 2], device_name_temp_buf, device_name_length);
//
// Check if data can be added to the Advertising data
// if ((adv_avail_space > 0) || (scan_avail_space > 0))
// {
// // Get the Device Name to add in the Advertising Data
// // Get default Device Name (No name if not enough space)
// device_name_length = NVDS_LEN_DEVICE_NAME;
//(nvds_get(nvds_tag_device_name,&device_name_length,&device_name_temp_buf [0])!= nvds_ok)
// {
// // Restore the default value
// assert_warning(0);
// device_name_length = 0;
//}
//}

To my understanding, the (original) snippet at the bottom of static struct gapm_start_advertise_cmd* app_easy_gap_undirected_advertise_start_create_msg(void) should then make 1test1 the advertising name:

// Place the Device Name in the Advertising Data or in the Scan Response Data
if(device_name_length> 0)
{
if(adv_avail_space> = device_name_length)
{
app_easy_gap_place_name_ad_struct(&cmd-> info.host.adv_data_len,device_name_length,
&cmd->info.host.adv_data[cmd->info.host.adv_data_len], device_name_temp_buf);
}
if(scan_avail_space> = device_name_length)
{
app_easy_gap_place_name_ad_struct(&cmd->info.host.scan_rsp_data_len, device_name_length,
&cmd-> info.host.scan_rsp_data [cmd-> info.host.scan_rsp_data_len],device_name_temp_buf);
}
}
}

Kind regards,
Niek

MT_dialog
离线
Last seen:2 months 4 weeks ago
职员
加入:2015-06-08 11:34
Hi Niekvdd,

Hi Niekvdd,

1)在广告字符串所包含的所有数据are tagged in order for the client to be able to parse the data in the advertising string, for example in the BLE spec the 0x09 value is tagged as "Complete Local Name" the value 0xFF is tagged as "Manufacturer Specific data", for more info on this please check the BLE specification.

2) There are several ways to do this, you can either modify the advertising function in order to place the data that you would like in the advertising string. You can also leave the NVDS_TAG_DEVICE_NAME blank or even place a string in there and after the message has initialized (with the app_easy_gap_undirected_advertise_start()) overwrite the advertising data string (located in the cmd->info.host.adv_data[] array). The SDK has the default functionallity of obtaining the NVDS_TAG_DEVICE_NAME and place it in the advertising string, so you can either create a custom advertising function that doesn't do that and places in the adv string your data or leave the function as is and overwrite the name in the allocated command.

Thanks MT_dialog

niekvdd.
离线
Last seen:1 year 11 months ago
加入:2017-01-25 09:29
Hi MT_dialog,

Hi MT_dialog,

1) How would I place a string in NVDS_TAG_DEVICE_NAME during runtime? I see that it is initialized in const struct nvds_data_struct nvds_data_storage __attribute__((section("nvds_data_storage_area"))) but how can I alter this value during runtime?

2) How can I manually tag any value?

3)我设法更改通过施用strcpy((char *)device_name_temp_buf,“name12”)来更改正在宣传的设备名称;就在函数静态结构Gapm_start_advertise_cmd * app_easy_gap_undirected_advertise_start_create_msg(void)中的if(device_name_length> 0)之前。在这种情况下,名称12是新名称。
但是,当我从通用访问服务(UUID 0x1800)连接和读取设备名称(UUID 0x2A00)时,我仍然会获得正如在NVDS_TAG_DEVICE_NAME中设置的原始设备名称。如何将设备名称的值更改为uuid 0x2a00返回的设备名称?

Kind regards,
Niek

MT_dialog
离线
Last seen:2 months 4 weeks ago
职员
加入:2015-06-08 11:34
Hi Niekvdd,

Hi Niekvdd,

1)您不能这样做,在运行时无法更改NVDS_TAG_DEVICE的值。启动广告时,拍摄来自NVDS_TAG_DEVICE的值并将其放在广告字符串中,因此您可以直接更改广告命令中的值(例如,当APP_EASY_GAP_UNDIRCED_ADVERTES_GET_ACTING_ADVERTERS_ADVERTE_ACTION()返回时广告字符串的指针您可以更改cmd-> info.host.adata []中名称的值,而不是nvds_tag_device,或者如上所述创建自己的功能,可以创建广告消息并将其发送给堆栈。

2)广告字符串中的标签只是广告字符串本身的值,通过放置数据的长度,数据的标签和数据本身标记了广告字符串的特定部分,具体取决于长度和标签作为特定信息。请检查这个规格。

3) Changing the name of the device in the attribute database of the Generic Access service is something different from just changing the devices name in the advertising string, the value of that characteristic is taken from the NVDS structure upon creating the databases when the device boots up, and this is defined in the BLE stack in the ROM code, there are two ways to change that, you can either use the function attmdb_att_set_value() and as parameters you should pass the GAPM_GET_ATT_HANDLE(GAP_IDX_DEVNAME) in order for the device name handle to be returned and then provide the length and value of the characteristic as you would like, or you can use the GAPM_SET_DEV_NAME_CMD message (you will find more info regarding the message in the RW-BLE-GAP-IS.pdf).

Thanks MT_dialog