APP_ADV_DATA_LEN (0) on DISS profile

14个帖子/ 0新
Last post
Giuseppe.
Offline
Last seen:4 years 9 months ago
专家
加入:2015-03-25 13:34
APP_ADV_DATA_LEN (0) on DISS profile

Hi,
I create a new project from template sdk. I enabled DISS profile.
Undef CFG_NVDS on da14580_config.h and edit APP_DEVICE_NAME on app_myapplication_proj.h.
Run the application, the device appear on android app DSPS scan search.

关于我在app_myapplication_proj.h上看到的广告字符串这个定义:

#define app_adv_data“\ x07 \ x01 \ x03 \ x18”
#define app_adv_data_len(0)

#define app_scnrsp_data“\ x02 \ xff \ x00”
#define APP_SCNRSP_DATA_LENGTH (0)

我不明白为什么APP_ADV_DATA_LEN and APP_SCNRSP_DATA_LENGTH are difined with 0. In other examples de value was the lenght of the databytes.
如果我修改4和3的值,则设备上不会显示DSPS搜索。为什么?

设备:
MT_dialog
Offline
Last seen:1 month 3 weeks ago
工作人员
加入:2015-06-08 11:34
嗨guiseppe,

嗨guiseppe,

Please place a valid length flag, and also change the data type to a UUID service declaration value....for instance change the"\x07\x01\x03\x18" to "\x03\x03\xFA\x18" for instance.

Thanks MT_dialog

Giuseppe.
Offline
Last seen:4 years 9 months ago
专家
加入:2015-03-25 13:34
Now it works. So...

Now it works. So...
\ x03 - 长度
\x03 - Complete List of 16-bit Service Class UUIDs
\xFA\x18 - ????

我在这个网站上看到了https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
对于设备信息,正确的代码是\ x0a \ x18?

而且......我无法自定义广告字符串?例如,如果我想要仅包含标志描述,为什么此字符串(\ x02 \ x01 \ x06)不起作用(未显示在DSPS扫描中)?

MT_dialog
Offline
Last seen:1 month 3 weeks ago
工作人员
加入:2015-06-08 11:34
Hi giuseppe,

Hi giuseppe,

这只是一个随机的例子,您必须在广告字符串中放置有效的16位UUID,您提到的设备信息代码。

The flags field are populating the advertising string by default according to the mode of your peripheral, you can use an application like BlueLoupe in order to read the advertising string. If you do, you will see that the first bytes the advertising string has is the default \x02\x01\x06. And then after that you can place the data you want to the advertising string.

Thanks MT_dialog

Giuseppe.
Offline
Last seen:4 years 9 months ago
专家
加入:2015-03-25 13:34
Yes ok, I understand. Thanks.

Yes ok, I understand. Thanks.

但如果我自定义app_scnrsp_data,它就不工作。这是代码:

//IT'S OK!
#define APP_ADV_DATA "\x03\x03\x15\x18"
#define APP_ADV_DATA_LEN (4)

//DOESN'T WORK!
#define APP_SCNRSP_DATA "\x09\x09\x41\x41\x41\x41\x41\x41\x41\x41"
#define APP_SCNRSP_DATA_LENGTH (10)

where
\x09 - lenght
\x09 - complete local name
\x41 - 'A' charcater ascii code

MT_dialog
Offline
Last seen:1 month 3 weeks ago
工作人员
加入:2015-06-08 11:34
Hi giuseppe,

Hi giuseppe,

The Advertising string is auto populated with the device name and you must be placing an extra device name in the scan response data. If you want this string to work you should not place the "\x09" flag in the string in the app_adv_func. You can test it by commenting the part of the code that places the name in the string. Or you can use the manufacturer data flag "\xFF".

Thanks MT_dialog

yuhua64
Offline
Last seen:4 years 10 months ago
加入:2015-05-04 08:25
Hi,

Hi,
Regarding to "If you want this string to work you should not place the "\x09" flag in the string in the app_adv_func.", If we used "\x09", what happened with it? And why?

MT_dialog
Offline
Last seen:1 month 3 weeks ago
工作人员
加入:2015-06-08 11:34
Hi yuhua64,

Hi yuhua64,

If you use the \x09 you are placing duplicate flags in the advertising message and in the response message. The stack does not allow such thing.

Thanks MT_dialog

Giuseppe.
Offline
Last seen:4 years 9 months ago
专家
加入:2015-03-25 13:34
Hi,

Hi,
the problem is scan response packet. I was convinced that APP_SCNRSP_DATA was not included in advertise packet. Bluetooth protocol documentation specify that Scan response packet can be required by client with a specific request.
app_myproject_proj.c

// Scan Response Data
#if (NVDS_SUPPORT)
if(nvds_get(nvds_tag_app_ble_scan_resp_data,&cmd-> info.host.scan_rsp_data_len,
&cmd-> info.host.scan_rsp_data [0])!= nvds_ok)
#endif //(NVDS_SUPPORT)
{
cmd-> info.host.scan_rsp_data_len = app_scnrsp_data_length;
memcpy(&cmd->info.host.scan_rsp_data[0], APP_SCNRSP_DATA, cmd->info.host.scan_rsp_data_len);
}

Then with NVDS disabled scan response data are always included in advertise packet.

MT_dialog
Offline
Last seen:1 month 3 weeks ago
工作人员
加入:2015-06-08 11:34
Hi giuseppe,

Hi giuseppe,

主动扫描需要扫描响应数据包。它们不包含在广告数据包中,它们是对主机的扫描请求的回复。在大多数情况下,在大多数情况下,扫描处于活动状态,扫描响应数据由外围设备传输。

Thanks MT_dialog

Giuseppe.
Offline
Last seen:4 years 9 months ago
专家
加入:2015-03-25 13:34
好,谢谢

好,谢谢

Giuseppe.
Offline
Last seen:4 years 9 months ago
专家
加入:2015-03-25 13:34
好的,现在我试着添加一个“读取

好的,现在我试着添加一个“读取only" characteristic. Total three characteristics. I added the code below to profile_task.c (I modified SAMPLE128 code):

// Characteristic 3: ////////////////////////////////////////////////////////////////////////////////
status = attmdb_add_attribute( profile_env.profile_shdl,
ATT_UUID_128_LEN + 3,//数据大小= 19(ATT_UUID_128_LEN + 3)
ATT_UUID_16_LEN,//声明类型ID的大小
(uint8_t*) &att_decl_char, // 0x2803 for a characteristic declaration
perm(rd,启用),//权限
&(char_hdl) // Handle to the characteristic declaration
);

//将特征值声明属性添加到数据库
status = attmdb_add_attribute( profile_env.profile_shdl,
sizeof(uint8_t), // Data size = 1 Byte
ATT_UUID_128_LEN,// Size of custom declaration type = 128bit
(uint8_t*)&profile_3_val.uuid, // UUID of the characteristic value
PERM(RD, ENABLE),// Permissions
&(val_hdl)//句柄到值属性
);

// Store the value handle for characteristic 3
memcpy(profile_3_char.attr_hdl, &val_hdl, sizeof(uint16_t));

// Set initial value of characteristic 3
status = attmdb_att_set_value(char_hdl, sizeof(profile_3_char), (uint8_t *)&profile_3_char);

I modified GATT db data size:

nb_att_16 = 5;// 5 UUID16属性声明类型
nb_att_32 = 0;// 0 UUID32属性声明类型
nb_att_128 = 3; // 3 UUID128 Attribute declaration types

status = attmdb_add_service(&(profile_env.profile_shdl),
TASK_PROFILE,
nb_att_16,
nb_att_32,
nb_att_128,
78 ); // See calcualtion below

// GATT数据库的总数据部分= 78数据字节:
// 16主要服务声明
// + 19 Declaration of characteristic 1
// + 1个价值声明的特征1
// + 19 Declaration of characteristic 2
// + 1个价值声明特征2
// + 2 Client configuration declaration of characteristic 2
// + 19 Declaration of characteristic 3
// 1个价值表明特征3
// = 78数据字节总数

It doesn't work. After connection with device only the first two characteristics are visible.

Giuseppe.
Offline
Last seen:4 years 9 months ago
专家
加入:2015-03-25 13:34
I think that GATT data size

I think that GATT data size is wrong.
如果我用nb_att_16 = 4和nb_att_128 = 2显示列表中的特征1分解代码。

Giuseppe.
Offline
Last seen:4 years 9 months ago
专家
加入:2015-03-25 13:34
数据大小是对的。

数据大小是对的。
The problem is declaration of characteristic 2 descriptor, I had put her after characteristic 3 declaration.

Topic locked