6 posts / 0 new
Last post
Stone_wang
Offline
Last seen:11 months 4 weeks ago
Joined:2015-10-23 03:55
GAPM_SET_DEV_NAME_CMD 命令问题

SDK3.0.6
使用GAPM_SET_DEV_NAME_CMD 时,

/// Set Local device name command
struct gapm_set_dev_name_cmd
{
/// GAPM requested operation:
/// - GAPM_SET_DEV_NAME: Set Local device name
uint8_t operation;
/// name length
uint8_t length;
/// name value
uint8_t name[__ARRAY_EMPTY];
};
#define __ARRAY_EMPTY

该结构体中的name如何填充呢? (是否可以使用该命令动态修改设备名称?)

谢谢。

Device:
snowdream1
Offline
Last seen:6 months 2 weeks ago
Staff
Joined:2014-08-17 14:25
目前的代码好像没有调用的例程

目前的代码好像没有调用的例程。结构体的名字应该就是名字的字符串表示。如果需要动态修改名称,建议先直接更新attribute里面的设置,再更新广播包的名字。如果用的SDK3
void app_adv_func(struct gapm_start_advertise_cmd *cmd)
{
.......
// Check if data can be added to the Advertising data
if (device_name_avail_space > 0)
{
// Get the Device Name to add in the Advertising Data (Default one or NVDS one)
#if (NVDS_SUPPORT)
device_name_length = NVDS_LEN_DEVICE_NAME;
如果(nvds_get (NVDS_TAG_DEVICE_NAME &device_name_length, &device_name_temp_buf[0]) != NVDS_OK)
#endif //(NVDS_SUPPORT)
{
// Get default Device Name (No name if not enough space)
device_name_length = strlen(APP_DFLT_DEVICE_NAME);
memcpy(&device_name_temp_buf[0], APP_DFLT_DEVICE_NAME, device_name_length);
}

if (new_name_len) //newly added
{ //覆盖名字
device_name_length = new_name_len;
memcpy(&device_name_temp_buf[0], new_name, new_name_len);
attmdb_att_set_value(3,new_name_len,new_name); //更新database里存的名字
}

Wally
Offline
Last seen:1 year 4 months ago
Joined:2016-06-21 01:23
请问有相关的代码吗,我用GAPM_SET_DEV_NAME

请问有相关的代码吗,我用GAPM_SET_DEV_NAME_CMD命令修改了名字,通过GAPM_GET_DEV_NAME_CMD获取出来的名字和修改的是一样的,但是广播名字还是没有被修改。

Gongyu_Dialog
Offline
Last seen:3 days 14 hours ago
Joined:2016-04-27 07:07
广播的名字只有先调用断开广播的操作,然后再重启广播才会生效

广播的名字只有先调用断开广播的操作,然后再重启广播才会生效。你可以参照上文我贴的代码。

Wally
Offline
Last seen:1 year 4 months ago
Joined:2016-06-21 01:23
请问上面的new_name和new_name

请问上面的new_name和new_name_len是什么内容,怎么定义的,可以发上来看看吗

Gongyu_Dialog
Offline
Last seen:3 days 14 hours ago
Joined:2016-04-27 07:07
uint8_t new_name_len _

uint8_t new_name_len __attribute__((section("retention_mem_area0"),zero_init)); //@RETENTION MEMORY
uint8_t new_name[27] __attribute__((section("retention_mem_area0"),zero_init)); //@RETENTION MEMORY

放到了retention ram里。存储的就是你设的新名字和名字内容。