我正在修改DSPS示例代码,并且在更改设备播发的名称时遇到了问题。name常量列在.NVDS\u TAG\u DEVICE\u name下,似乎有8个字节的长度限制,但我需要10个字节。我尝试更改
#define ADV_DATA_LEN 0x1F (in co_bt.h)
再加上2位,但这会破坏代码
Specifically what are the contents of the 31 byte advertising message?
我只能看到
设备名称
设备名称\u长度
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,
一个BLE广告包除了6字节的蓝牙设备地址(总共37字节)外,实际上还可以承载31字节的有效负载。
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。你可以把它取下来。应用内\u sps\u设备\u项目.h更改
#define APP \u DFLT \u ADV \u DATA“\x11\x07\xb7\x5c\x49\xd2\x04\xa3\x40\x71\xa0\xb5\x35\x85\x3e\xb0\x83\x07”
#定义应用程序数据长度(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,
.SCAN\u RESP\u DATA\u TAG\u LEN=10,
.DEVICE_NAME_TAG_LEN = 10,
I hope that helps.
谢谢你的对话!这肯定有助于澄清我的问题,我能够得到工作。我对APP\u DFLT\u ADV\u数据定义的第二个字节很好奇。在此之前,它被标记为0x07,在代码中被注释为“*x07-可用的128位uuid的完整列表”,您将其更改为0xFF,并将其描述为特定于制造商的数据集。你能再解释一下你为什么要改变它以及它的含义吗?谢谢你的帮助,克里斯
Hi,
你可以在广告中加入不同的数据段。有时告诉世界你的设备提供什么样的服务是有用的。比如说,智能手机可以扫描设备,只列出提供适用于智能手机应用程序的特定服务(如心率服务)的设备。您可以拥有空间允许的任意多个数据段。每个部分的组织如下:
段的长度包括类型和数据的一个字节。对于标志,类型可以是0x02;对于蓝牙设备名称,类型可以是0x09;对于制造商特定的数据,类型可以是0xFF。您可以在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\u TAG\u DEVICE\u NAME
当da14580从应用程序接收数据时,例如:新的设备名称,如何替换旧的?
谢谢您!
嗨,红熊
You can use following CMDs to BLE low layer, ( you can find all commands list in gapm_task.h)
GAPM\u SET\u DEV\u NAME\u CMD;
GAPM\u GET\u DEV\u NAME\u CMD;
GAPM_GET_DEV_BDADDR_CMD;
有关命令的详细信息,请参见以下链接:
http://support.dialog-semiconductor.com/resource/gap-interface-specification
以下是一些代码供您参考:
1.从HCI主机设置以下功能\u设备\u名称====================
/*内部*/
void set\设备\名称(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));
请求->操作=GAPM\u SET\u DEV\u NAME;
req->length = 10;
sprintf((char*)请求->名称,“DialogDemo”);
BleSendMsg((void *) req);
}
==============================
对于BleSendMsg,BleMsgAlloc请检查ble_msg.c文件中的代码
==============================
我们的句柄GAPM\u SET\u DEV\u NAME代码如下:
========================================
案例GAPM\u SET\u DEV\u NAME:
{
uint8_t status = (uint8_t) GAP_ERR_NOT_SUPPORTED;
#如果(请注意)
/*更新名称*/
status = attmdb_att_set_value(GAPM_GET_ATT_HANDLE(GAP_IDX_DEVNAME), param->length,
(uint8_t*) &(param->name[0]));
#endif/*BLE附件*/
/* send command complete event with status code */
gapm_send_complete_evt(GAPM_CFG_OP, status);
}
谢谢你的对话
Hi, thank you for your reply.
I found ble_msg.c in sdk, not in DA14580_DialogBeacon_3.40.6,
我需要将所有需要的文件复制到当前项目吗?还有别的办法吗?
我从app\u task.c中找到以下代码:
case GAPM_RESET:
{
//设置设备配置
struct gapm_set_dev_config_cmd* cmd = KE_MSG_ALLOC(GAPM_SET_DEV_CONFIG_CMD,
任务\u GAPM,任务\u APP,GAPM \u set \u dev \u config \u cmd);
应用程序配置功能(dest\u id,cmd);
ke_msg_send(cmd);
}
//--------------------------------------------------------
I added these, seems not working:
案例GAPM\u SET\u DEV\u NAME:
attmdb\u att\u set\u value(GAPM\u GET\u att\u HANDLE(GAP\u IDX\u DEVNAME)),7,
"da14580"); // I don't know how to get the name form below msg, so ...
中断;
在应用程序中添加:
void app_set_dev_name(const uint8_t * name)
{
struct gapm_set_dev_name_cmd* cmd = KE_MSG_ALLOC(GAPM_SET_DEV_NAME_CMD,
任务\u GAPM,任务应用程序,gapm_set_dev_name_cmd);
cmd->operation=GAPM\u SET\u DEV\u NAME;
cmd->length = 7;
memcpy(&cmd->name, &name, 7);
ke_msg_send(cmd);
}
按钮回调将调用app\u set\u dev\u 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.
谢谢您!
嗨,安东尼42,
Please try the following,
只需在项目中放置如下函数:
void set\设备\名称(void)
{
结构gapm\u set\u dev\u name\u cmd*req=KE\u MSG\u ALLOC(gapm\u set\u dev\u name\u cmd,
任务\u GAPM,
任务应用程序,
gapm_set_dev_name_cmd
);
请求->操作=GAPM\u SET\u DEV\u NAME;
req->length = 6;
memcpy(req->name,"Dialog",6);
发送消息(请求);
}
在文件app\u task.c中捕获完成事件GAPM\u SET\u DEV\u NAME:
案例GAPM\u SET\u DEV\u 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\u dialog,
thank you for your reply,
我试过了,成功了!谢谢您!
我需要从智能手机配置信标,
and these data should be stored in the flash.
我在CFG\u PRF\u DEVICE\u CONFIG中找到:
struct app_beacon_config_tag
{
uint8_t uuid[16];
uint16_t major;
uint16 t小调;
uint16_t company_id;
uint16高级集成;
uint8_t power;
uint8\t垫;
};
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.
谢谢你的对话
请注意,在分配gapm\u set\u dev\u name\u cmd时,可能应该使用KE\u MSG\u ALLOC\DYN而不是KE\u MSG\u ALLOC,以避免损坏内存,例如(对于长度为6的名称):
KE_MSG_ALLOC_DYN(GAPM_SET_DEV_NAME_CMD, TASK_GAPM, TASK_APP, gapm_set_dev_name_cmd,6);你好,乔奇姆,
感谢您的回复,
you are right!
到day I test the set_dev_name func,sometimes the system corruped,
然后我记得你的答案,用KE\ u MSG\ u ALLOC\ n工作正常。
why ?
在参考代码中,keu MSG\u 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.