我正在修改DSP示例代码,并使用更改设备通告的名称运行到问题中。名称常量在.nvds_tag_device_name下列出,似乎有8个字节的长度限制,但我需要10.我尝试改变
#define ADV_DATA_LEN 0x1F (in co_bt.h)
对于有2个比特的东西,但这会破坏代码
Specifically what are the contents of the 31 byte advertising message?
我只能看到
设备名称
device_name_length.
Also I thought the BLE stack limited packets to 20 bytes, does advertising have a different rule or does it just sent two packets?
Hi,
除了6字节的蓝牙设备地址之外,BLE广告包实际上可以携带31字节的有效载荷 - 总计37bytes。
In the DSPS implementation, 3 bytes are used for flags and 18 bytes are used for a unique service ID (includes one byte for length and one byte for type). This leaves 10bytes for the length of the name (1 byte), the data type of the name (1byte) and the name itself. As you can see this limits the name to 8bytes/characters.
但不要恐慌; o)
您不必在广告数据中放置唯一的服务ID。你可以继续删除它。在app_sps_device_project.h中更改
#define app_dflt_adv_data“\ x11 \ x07 \ xb7 \ x5c \ x49 \ xd2 \ x04 \ xa3 \ x40 \ x71 \ x85 \ x3e \ x35 \ x85 \ x3e \ xb0 \ x83 \ x30 \ x83 \ x30”
#define app_dflt_adv_data_len(18)
至
#define APP_DFLT_ADV_DATA "\x04\xFFHi!"
#define APP_DFLT_ADV_DATA_LEN (5)
这将广告数据更改为短语“hi!”的制造商特定数据集。您可以将蓝牙设备名称延长为NVDS:
。NVDS_TAG_DEVICE_NAME = "DA1458x123", //This is 10 characters long
。NVDS_TAG_BD_ADDRESS = {0xCC, 0x00, 0x00, 0xCA, 0xEA, 0xCC},
。ADV_DATA_TAG_LEN = 27,
.can_resp_data_tag_len = 10,
。DEVICE_NAME_TAG_LEN = 10,
I hope that helps.
谢谢mhv_dialog!这绝对有助于澄清我的问题,我能够做到这一点。我对App_dflt_addata定义的第二个字节感到好奇。在此标记为0x07之前,在代码中评论为“* x07 - 可用的128位uuids的完整列表”,并且您将其更改为0xff并将其描述为制造特定数据集。你能再解释一下你改变它的原因以及它的意思吗?谢谢你的帮助,〜克里斯
Hi,
您可以在广告中放置不同的数据细分。有时候,告诉世界您的设备提供的服务是有用的。这允许说,智能手机扫描设备,只能列出提供适用于智能手机应用程序的特定服务的设备 - 就像心率服务一样。您可以具有尽可能多的数据段作为空间允许。每个段都组织如下:
段的长度包括类型和数据的一个字节。对于标志,0x09,对于蓝牙设备名称或制造商特定数据的0x09,该类型可以为0x02。您可以在BT SIG网站上查看所有数据类型:https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile.。
为了让你对你的德维克更多的空间e name, I had to replace the "Complete list of 128bit..." with something that does not require as many bytes. We could also have placed your BD name in the scan response packet. In doing so, you would have to follow the format as described above and the BD name would only be detected by devices that are scanning in active mode.
Hi,
如何从智能手机应用程序更改.nvds_tag_device_name?
当DA14580从APP接收数据时,例如:新的Dev Name,如何替换旧的?
谢谢!
嗨红熊
You can use following CMDs to BLE low layer, ( you can find all commands list in gapm_task.h)
gapm_set_dev_name_cmd;
gapm_get_dev_name_cmd;
GAPM_GET_DEV_BDADDR_CMD;
可以在以下链接中找到命令的详细信息:
http://support.dialog-semiconductor.com/resource/gap-interface-specification
以下是您参考的一些代码:
1.按HCI主机函数set_device_name ====================
/* 内部的 */
void set_device_name(void)
{
struct gapm_set_dev_name_cmd *req = BleMsgAlloc(GAPM_SET_DEV_NAME_CMD, TASK_GAPM, TASK_APP,9 + sizeof(struct gapm_set_dev_name_cmd));
req->操作= gapm_set_dev_name;
req->length = 10;
Sprintf((char *)req->名称,“DialogDemo”);
BleSendMsg((void *) req);
}
==============================
对于BlesendMsg,Blemsgalloc请检查文件BLE_MSG.c中的代码
==============================
我们的句柄代码GAPM_SET_DEV_NAME如下:
========================================
CASE GAPM_SET_DEV_NAME:
{
uint8_t status = (uint8_t) GAP_ERR_NOT_SUPPORTED;
#if(ble_atts)
/ *更新名称* /
status = attmdb_att_set_value(GAPM_GET_ATT_HANDLE(GAP_IDX_DEVNAME), param->length,
(uint8_t*) &(param->name[0]));
#endif / * ble_atts * /
/* send command complete event with status code */
gapm_send_complete_evt(GAPM_CFG_OP, status);
}
谢谢mt_dialog.
Hi, thank you for your reply.
I found ble_msg.c in sdk, not in DA14580_DialogBeacon_3.40.6,
是否需要将所有所需文件复制到当前的Proj?任何其他方式?
我从app_task.c中找到了这些代码:
case GAPM_RESET:
{
//设置设备配置
struct gapm_set_dev_config_cmd* cmd = KE_MSG_ALLOC(GAPM_SET_DEV_CONFIG_CMD,
task_gapm,task_app,gapm_set_dev_config_cmd);
app_configuration_func(dest_id,cmd);
ke_msg_send(cmd);
}
// --------------------------------------------------------------
I added these, seems not working:
CASE GAPM_SET_DEV_NAME:
attmdb_att_set_value(gapm_get_att_handle(gap_idx_devname),7,
"da14580"); // I don't know how to get the name form below msg, so ...
休息;
在app_dia_xx_proj.c中添加:
void app_set_dev_name(const uint8_t * name)
{
struct gapm_set_dev_name_cmd* cmd = KE_MSG_ALLOC(GAPM_SET_DEV_NAME_CMD,
task_gapm,task_app,gapm_set_dev_name_cmd);
cmd->操作= gapm_set_dev_name;
cmd->length = 7;
memcpy(&cmd->name, &name, 7);
ke_msg_send(cmd);
}
按钮回调将调用app_set_dev_name(name);
// -------------------------------------------------------------
and, I need to save the new config data(dev name, adv interval, UUID,user defined cmd, etc), even after power off.
looking forward to your response.
谢谢!
嗨Antony42,
Please try the following,
只需将功能放在您的项目中:
void set_device_name(void)
{
struct gapm_set_dev_name_cmd * req = ke_msg_alloc(gapm_set_dev_name_cmd,
task_gapm,
task_app,
gapm_set_dev_name_cmd
);
req->操作= gapm_set_dev_name;
req->length = 6;
memcpy(req->name,"Dialog",6);
KE_MSG_SEND(REQ);
}
在文件app_task.c catch the proofition事件gapm_set_dev_name:
CASE GAPM_SET_DEV_NAME:
{
app_set_dev_name();
}
休息;
with the function void app_set_dev_name(void){ return }
In the implementation i used a timer instead of a button who is triggered some time after connection.
谢谢mt_dialog.
嗨mt_dialog,
thank you for your reply,
我尝试了,它有效!谢谢!
我需要从智能手机配置灯架,
and these data should be stored in the flash.
我在cfg_prf_device_config中找到:
struct app_beacon_config_tag
{
uint8_t uuid[16];
uint16_t major;
uint16_t未成年人;
uint16_t company_id;
UINT16_T ADV_INT;
uint8_t power;
uint8_t pad;
};
can I add some items to this structure?
eg: dev name, led control and several user defined parameters.
Thanks Anthony
Hi Antony42,
Yes, you can add additional fields in the struct in order to store them in flash, you should also add the specific fields of the struct in beacon_params array in app_dialog_beacon_proj.c file.
谢谢mt_dialog.
请注意,当分配GAPM_SET_DEV_NAME_CMD以避免损坏内存时,可能会使用KE_MSG_ALLOC_DYN而不是KE_MSG_ALLOC_DYN而不是如此(用于长度为6的名称):
KE_MSG_ALLOC_DYN(GAPM_SET_DEV_NAME_CMD, TASK_GAPM, TASK_APP, gapm_set_dev_name_cmd,6.);
嗨Joacimwe,
感谢你的回复,
you are right!
至day I test the set_dev_name func,sometimes the system corruped,
然后我记得你的回答,使用Ke_msg_alloc_dyn工作正常。
why ?
在REF编码中,使用KE_MSG_ALLOC很多。
在API文档中,您can see that some of the message structs end with a dynamically-sized array, such as GAPM_SET_DEV_NAME_CMD, GAPM_WHITE_LIST_MGT_CMD, GAPM_RESOLV_ADDR_CMD etc. Since the sizeof(such a struct) assumes 0 elements in the array, the size they occupy must be added as well to the size that are allocated for the message.