在运行时更改设备名称

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
6 posts / 0 new
Last post
Niekvdd
Offline
最后一次见到:1年11个月前
Joined:2017-01-25 09:29
在运行时更改设备名称

大家好,

我想动态更改广告设备名称(在运行期间,可由android应用程序更改)。我已经在论坛上做了充分的讨论,并得出结论,我应该写信给NVDS\u标签\u设备\u名称,请纠正我,如果我错了。我在SDK的ble\u app\u外围项目工作。

However, I could nowhere find a way to alter this value. Can anybode please tell me how to write to NVDS_TAG_DEVICE_NAME? Alternative ways to change the device name during runtime are also very welcome.
更改设备名称后重新启动广告不是问题。

谨致问候,
涅克

注,我使用SDK 5.0.3.268 5.0.2.1but this option was not selectable

设备:
MT\u对话框
Offline
最后一次见到:2 months 1 week ago
Staff
Joined:2015-06-08 11:34
你好Niekvdd,

你好Niekvdd,

Change the name of the device during runtime on the advertising string is possible, and changing the device's name from the android phone is also possible but this requires to connect to the device and provide one through a custom characteristic. So the name of the device is provided through the NVDS_TAG_DEVICE_NAME and that is what is entered into the advertising string, so in order to change that you will have to customize the advertising function. The app_easy_gap_undirected_advertise_start_create_msg() which is the function that fills in the parameters for the message takes by default the name from the NVDS_TAG_DEVICE_NAME, so you can leave that value blank in the SDK use the app_easy_gap_undirected_advertise_get_active() to allocate the message with all the appropriate values and then target the member that holds the advertising string and apply the name that you would like, you will have to TAG the name with the 0x09 flash in order for other devices to know that this is the name of the device.

谢谢你的对话

Niekvdd
Offline
最后一次见到:1年11个月前
Joined:2017-01-25 09:29
嗨,MT\u dialog,

嗨,MT\u dialog,

我可以按照你的解释一直到“所以设备的名称是通过NVDS\u TAG\u device\u name提供的”。

1) What does TAGing a name mean?

2) "so in order to change that you will have to customize the advertising function" Do you mean that I should not be altering the contents/value of NVDS_TAG_DEVICE_NAME, but instead modify the functions so that they don't use NVDS_TAG_DEVICE_NAME as a resource? I tried this as follows, however the advertising name is not changing..

在静态结构gapm\u start\u advertise\u cmd*app\u easy\u gap\u undirected\u advertise\u start\u create\u msg(void)in app.c from example ble\u app\u peripheral中,我编辑了以下内容:
uint8\u t设备名称\u长度=0;
uint8_t device_name_temp_buf[NVDS_LEN_DEVICE_NAME];
//检查是否可以将数据添加到广告数据中
if((高级可用空间>0)| |(扫描可用空间>0))
{
//Get the Device Name to add in the Advertising Data
//获取默认设备名称(如果没有足够的空间,则没有名称)
设备\u名称\u长度=NVDS \u长度\u设备\u名称;
if (nvds_get(NVDS_TAG_DEVICE_NAME, &device_name_length, &device_name_temp_buf[0]) != NVDS_OK)
{
//Restore the default value
ASSERT_WARNING(0);
设备名称长度=0;
}
}

to:

//uint8\u t设备名称\u长度=0;
//uint8_t device_name_temp_buf[NVDS_LEN_device_name];

uint8_t device_name_length = 6;
uint8\u t device\u name\u temp\u buf[6]=“1测试1”;
//memcpy(&cmd->info.host.adv\u data[cmd->info.host.adv\u data\u len+2],设备名称\u temp\u buf,设备名称\u length);
//
//检查是否可以将数据添加到广告数据中
//if((高级可用空间>0)| |(扫描可用空间>0))
//{
////获取要添加到广告数据中的设备名称
////获取默认设备名称(如果没有足够的空间,则没有名称)
//设备\u名称\u长度=NVDS \u长度\u设备\u名称;
//if (nvds_get(NVDS_TAG_DEVICE_NAME, &device_name_length, &device_name_temp_buf[0]) != NVDS_OK)
//{
////恢复默认值
//ASSERT_WARNING(0);
//设备名称长度=0;
//}
//}

据我所知,静态结构gapm\u start\u adversed\u cmd*app\u easy\u gap\u undirected\u adversed\u start\u create\u msg(void)底部的(原始)片段应使1test1成为广告名称:

//将设备名称放入广告数据或扫描响应数据中
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\u data[cmd->info.host.adv\u data\u len],设备名称\u temp\u buf);
}
if(scan_avail_space >= device_name_length)
{
app\u easy\u gap\u place\u name\u ad结构(&cmd->info.host.scan\u rsp\u data\u len,device\u name\u length,
&cmd->info.host.scan_rsp_data[cmd->info.host.scan_rsp_data_len], device_name_temp_buf);
}
}
}

谨致问候,
涅克

MT\u对话框
Offline
最后一次见到:2 months 1 week ago
Staff
Joined:2015-06-08 11:34
你好Niekvdd,

你好Niekvdd,

1) 在广告字符串中,所有包含的数据都被标记,以便客户端能够解析广告字符串中的数据,例如在BLE规范中,0x09值被标记为“完整本地名称”,0xFF值被标记为“制造商特定数据”,有关此的详细信息,请检查BLE规范。

2) 有几种方法可以做到这一点,您可以修改广告函数,以便将您想要的数据放入广告字符串中。您还可以将NVDS\u TAG\u DEVICE\u NAME留空,甚至在其中放置一个字符串,并在消息初始化后(使用app\u easy\u gap\u undirected\u advertive\u start())覆盖广告数据字符串(位于cmd->info.host.adv\u data[]数组中)。SDK的默认功能是获取NVDS\u TAG\u DEVICE\u名称并将其放在广告字符串中,因此您可以创建一个不执行此操作的自定义广告函数,并将数据放在adv字符串中,也可以保持函数不变并在分配的命令中覆盖名称。

谢谢你的对话

Niekvdd
Offline
最后一次见到:1年11个月前
Joined:2017-01-25 09:29
嗨,MT\u dialog,

嗨,MT\u dialog,

1) 在运行时,如何在NVDS\u TAG\u DEVICE\u NAME中放置字符串?我看到它是在const struct nvds\u data\u struct nvds\u data\u storage\uuu attribute\uuuu((section(“nvds\u data\u storage\u area”))中初始化的,但是在运行时如何更改这个值呢?

2) 如何手动标记任何值?

3) I managed to change the device name that is being advertised by putting strcpy((char*) device_name_temp_buf, "name12"); just before if(device_name_length > 0) in the function static struct gapm_start_advertise_cmd* app_easy_gap_undirected_advertise_start_create_msg(void). In this case name12 is the new name.
However, when I connect and read the Device Name (UUID 0x2A00) from the Generic Access Service (UUID 0x1800) I still get the original device name returned as set in NVDS_TAG_DEVICE_NAME. How can I change the value of the device name as returned by UUID 0x2A00 ?

谨致问候,
涅克

MT\u对话框
Offline
最后一次见到:2 months 1 week ago
Staff
Joined:2015-06-08 11:34
你好Niekvdd,

你好Niekvdd,

1) You can't do that, you cannot alter the value of the NVDS_TAG_DEVICE during runtime. The value from the NVDS_TAG_DEVICE is taken and placed in the advertising string when you start advertising, so you can directly alter the values placed in the advertising command (for example in the barebone project in the user_app_adv_start() function when the app_easy_gap_undirected_advertise_get_active() returns the pointer of the advertising string message you can alter the value of the name in the cmd->info.host.adv_data[]) and not the NVDS_TAG_DEVICE, or as mentioned above create your own function that will create the advertising message and send it to the stack.

2) The tags in the advertising string are just values of the advertising string itself, by placing the length of the data, the tag of the data and the data itself tags a specific part of the advertising string, depending on the length and the tag as a particular information. Please check the BLE specification for this.

3) 在通用访问服务的属性数据库中更改设备名称与在广告字符串中更改设备名称有所不同,当设备启动时,在创建数据库时,该特征的值取自NVDS结构,这在ROM代码的BLE堆栈中定义,有两种方法可以改变这一点,您可以使用函数attmdb\u att\u set\u value(),作为参数,您应该传递GAPM\u GET\u att\u HANDLE(GAP\u IDX\u DEVNAME),以便返回设备名称句柄,然后根据需要提供特征的长度和值,或者您可以使用GAPM\u SET\u DEV\u NAME\u CMD消息(您将在RW-BLE-GAP-IS.pdf中找到有关该消息的更多信息)。

谢谢你的对话