I am modifying the DSPS example code and am running into issues with changing the name that the device advertises as. The name constant is listed under .NVDS_TAG_DEVICE_NAME and there seems to be a length limitation of 8 bytes but I need 10. I tried changing the
#define avd_data_len 0x1f(在co_bt.h中)
to something with 2 more bits but this breaks the code
特别是31字节广告消息的内容是什么?
I can only see the
device name
device_name_length
另外,我认为BLE堆栈有限的数据包到20个字节,广告是否有一个不同的规则,或者它只是发送了两个数据包吗?
你好,
A BLE advertisement package can actually carry 31bytes of payload in addition to the 6bytes Bluetooth Device Address - total of 37bytes.
在DSP实现中,3个字节用于标记,18个字节用于唯一的服务ID(包括长度的一个字节和类型为一个字节)。这将留出10字节的名称(1字节),名称的数据类型(1byte)和名称本身。正如您所能将此限制为8Bytes /字符。
但不要惊慌;o)
You don't have to put a unique service ID in the advertising data. You can just go ahead and remove it. In app_sps_device_project.h change
#define APP_DFLT_ADV_DATA "\x11\x07\xb7\x5c\x49\xd2\x04\xa3\x40\x71\xa0\xb5\x35\x85\x3e\xb0\x83\x07"
#define APP_DFLT_ADV_DATA_LEN (18)
to
#define app_dflt_adv_data“\ x04 \ xffhi!”
#define app_dflt_adv_data_len(5)
This changes the advertised data to a manufacturer specific data set of the phrase "Hi!". And you can extend the Bluetooth Device name in NVDS like this:
.nvds_tag_device_name =“da1458x123”,//这是10个字符长
.nvds_tag_bd_address = {0xcc,0x00,0x00,0xca,0xea,0xcc},
。adv_data_tag_len = 27,
.SCAN_RESP_DATA_TAG_LEN = 10,
.device_name_tag_len = 10,
我希望有所帮助。
Thank you MHv_dialog! That definitely helps clarify my problem and I was able to get that to work. I was curious about the second byte of the APP_DFLT_ADV_DATA definition. Before this was marked as 0x07 which is commented in the code as "* x07 - Complete list of 128-bit UUIDs available" and you changed it to 0xFF and described that as a manufacture specific data set. Could you explain a little more about why you changed that and what it means? Thanks for your help, ~Chris
你好,
You can put different segments of data in your advertising. Sometimes it is useful to tell the world what kind of services your device offers. This allows, say, a smartphone to scan for devices and only list devices that offer a specific service applicable to the smartphone application - like a heart rate service. You can have as many data segments as space allows. Each segment is organized as follows:
<段长度> <段>
The length of the segment includes the one byte of the type and the data. The type can be 0x02 for flags, 0x09 for Bluetooth Device name or 0xFF for manufacturer specific data. You can see all the data types on the website of the BT SIG:https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile.
因此,为了允许您为您的设备名称提供更多空间,我必须用不需要多个字节的东西替换“128bit ...”的完整列表。我们也可以将您的BD名称放在扫描响应数据包中。在这样做时,您必须按照如上所述的格式遵循格式,并且只有在活动模式下扫描的设备只能检测到BD名称。
你好,
How to change .NVDS_TAG_DEVICE_NAME from smart phone app?
when da14580 receive data from app, eg: new dev name, how to replace the old one?
Thank you!
Hi redbear
您可以使用以下CMDS到BLE低层(您可以在GAPM_TASK.H中找到所有命令列表)
GAPM_SET_DEV_NAME_CMD;
GAPM_GET_DEV_NAME_CMD;
gapm_get_dev_bdaddr_cmd;
Details of commands can be found in following link:
http://support.dialog-semicondiondiondum/resource/gap-Interface-pecification.
Following is some code for your reference:
1. following function set_device_name from HCI host ====================
/* Internal */
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->operation = GAPM_SET_DEV_NAME;
req->长度= 10;
sprintf ((char *)请求- > name, "DialogDemo");
BlesendMsg((void *)REQ);
}
==============================.
For BleSendMsg, BleMsgAlloc please check code in file ble_msg.c
==============================.
Our code of handle GAPM_SET_DEV_NAME is as follow:
========================================
case GAPM_SET_DEV_NAME:
{
UINT8_T status =(uint8_t)gap_err_not_supported;
#if (BLE_ATTS)
/* update name */
status = attmdb_att_set_value(gapm_get_att_handle(gap_idx_devname),param->长度,
(UINT8_T *)&(param-> name [0]));
#endif /* BLE_ATTS */
/ *使用状态代码发送命令完成事件* /
gapm_send_complete_evt(gapm_cfg_op,status);
}
Thanks MT_dialog
嗨,谢谢你的回复。
我在SDK中找到了BLE_MSG.C,而不是在DA14580_DIALOGBEACON_3.40.6中,
Do I need to copy all needed files to the current proj? any other way?
I found these code from app_task.c:
案例GAPM_RESET:
{
// set device configuration
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);
}
// --------------------------------------------------------------
我加了这些,似乎不起作用:
case GAPM_SET_DEV_NAME:
attmdb_att_set_value(GAPM_GET_ATT_HANDLE(GAP_IDX_DEVNAME), 7,
“da14580”);//我不知道如何在msg下面获取名称表格,所以......
break;
in app_dia_xx_proj.c add:
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->operation = GAPM_SET_DEV_NAME;
cmd->长度= 7;
Memcpy(&cmd->名称,名称,7);
ke_msg_send(cmd);
}
a button callback will call app_set_dev_name(name);
// -------------------------------------------------------------
而且,即使在关闭电源之后,我需要保存新的配置数据(Dev Name,Adv Interval,UUID,用户定义CMD等)。
期待你的回复。
Thank you!
Hi antony42,
请尝试以下内容,
Just place a function in your project like this:
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->operation = GAPM_SET_DEV_NAME;
req->长度= 6;
memcpy(req-> name,“对话框”,6);
ke_msg_send(req);
}
And in file app_task.c catch the completition event GAPM_SET_DEV_NAME:
case GAPM_SET_DEV_NAME:
{
app_set_dev_name();
}
break;
使用void app_set_dev_name(void){return}
在实现中,我使用了一个计时器而不是在连接后一段时间触发的按钮。
Thanks MT_dialog
Hi MT_dialog,
谢谢您的回复,
I tried and it works! Thank you!
I need to configure the beacon from a smart phone,
这些数据应存储在闪存中。
I found in CFG_PRF_DEVICE_CONFIG:
struct app_beacon_config_tag.
{
UINT8_T UUID [16];
uint16_t专业;
uint16_t minor;
UINT16_T 雷电竞下载appCOMPANY_ID;
uint16_t adv_int;
uint8_t力量;
uint8_t pad;
};
我可以将一些物品添加到这个结构吗?
例如:DEV名称,LED控件和几个用户定义的参数。
谢谢安东尼
嗨Antony42,
是的,您可以在struct中添加其他字段,以便将它们存储在Flash中,还应在App_Dialog_Beacon_Proj.c文件中添加Beacon_Params数组中的结构的特定字段。
Thanks MT_dialog
Note that you should probably use KE_MSG_ALLOC_DYN instead of KE_MSG_ALLOC when you allocate the gapm_set_dev_name_cmd to avoid corrupting the memory, like this (for a name of length 6):
ke_msg_alloc_dyn(gapm_set_dev_name_cmd,task_gapm,task_app,gapm_set_dev_name_cmd,6);
Hi Joacimwe,
Thank you for your reply,
你是对的!
今天我测试set_dev_name func,有时系统被诅咒,
then I remember your answet, use KE_MSG_ALLOC_DYN works fine.
为什么 ?
in the ref code KE_MSG_ALLOC was used a lot.
在API文档中,您可以看到一些消息结构以动态大小的阵列结束,例如GapM_Set_Dev_name_cmd,GapM_White_List_mgt_cmd等,因为SizeOf(这样的结构)假定阵列中的0个元素,它们占用必须添加以及为消息分配的大小。