APP_ADV_DATA_LEN (0) on DISS profile

14 posts / 0 new
Last post
giuseppe
Offline
Last seen:4 years 9 months ago
Expert
加入: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.

About advertise strings I see on app_myapplication_proj.h this definitions:

#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.
If I modify the values with 4 and 3, the device doesn't appear on DSPS search. Why?

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

Hi 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
Expert
加入:2015-03-25 13:34
Now it works. So...

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

I see on this websitehttps://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
For device information the right code is \x0A\x18?

And also... I can't customize advertising string? For example if I want include flags description only, why this string (\x02\x01\x06) doesn't works (doesn't appear in DSPS scan)?

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

Hi giuseppe,

This was just a random example, you must place in the advertising string a valid 16-bit UUID, the device information code you 've mentioned.

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
Expert
加入:2015-03-25 13:34
Yes ok, I understand. Thanks.

Yes ok, I understand. Thanks.

But it doesn't work if I customize APP_SCNRSP_DATA. This is the code:

//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
Expert
加入: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,

Scan response packets are required in active scanning. They are not included in the advertising packet, they are a reply to the scan request by the host. In most cases the scanning is active thus in most cases the scan response data are transmited by the peripheral.

Thanks MT_dialog

giuseppe
Offline
Last seen:4 years 9 months ago
Expert
加入:2015-03-25 13:34
ok, thanks

ok, thanks

giuseppe
Offline
Last seen:4 years 9 months ago
Expert
加入:2015-03-25 13:34
Ok now I try to add one "read

Ok now I try to add one "read 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, // Data size = 19 (ATT_UUID_128_LEN + 3)
ATT_UUID_16_LEN, // Size of declaration type ID
(uint8_t*) &att_decl_char, // 0x2803 for a characteristic declaration
PERM(RD, ENABLE), // Permissions
&(char_hdl) // Handle to the characteristic declaration
);

// Add characteristic value declaration attribute to database
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) // handle to the value attribute
);

// 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 Attribute declaration types
nb_att_32 = 0;/ / 0 t UUID32属性声明ypes
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

// Total Data portion of GATT database = 78 data bytes:
// 16 Primary service declaration
// + 19 Declaration of characteristic 1
// + 1 Value declaration of characteristic 1
// + 19 Declaration of characteristic 2
// + 1 Value declaration of characteristic 2
// + 2 Client configuration declaration of characteristic 2
// + 19 Declaration of characteristic 3
// + 1 Value declaration of characteristic 3
// = 78 Data bytes total

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

giuseppe
Offline
Last seen:4 years 9 months ago
Expert
加入:2015-03-25 13:34
I think that GATT data size

I think that GATT data size is wrong.
If I comment Characteristic 1 dichiaration code with nb_att_16=4 and nb_att_128=2 chrachterist 3 appear in the list.

giuseppe
Offline
Last seen:4 years 9 months ago
Expert
加入:2015-03-25 13:34
Data size is right.

Data size is right.
The problem is declaration of characteristic 2 descriptor, I had put her after characteristic 3 declaration.

Topic locked