Can't get full adv & scan response packet in use DSPS host

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
6 posts / 0 new
Last post
Oliver_Zero
Offline
Last seen:2 years 10 months ago
Joined:2017-04-05 07:00
Can't get full adv & scan response packet in use DSPS host

I use DSPS host project to make a scanner. But,I can't get a full packet in .
我有一个外围设备与27个字节长Packet. But, every time it goes to , I got 18 bytes data. Device name was cut off.

Here's the data I captured from BLE Tools:
02 01 06 07 03 0F 18 0A 18 D0 ED 13 09 45 44 44 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 --- 08 FF 44 4C 54 20 50 3A 4E
And what I get form param->report.data:
02 01 06 07 03 0F 18 0A 18 D0 ED 13 09 45 44 44 30 08

How do I get the full packet like BLE Tools get?
Thanks!

Device:
MT_dialog
Offline
Last seen:3 months 1 day ago
Staff
Joined:2015-06-08 11:34
Hi Oliver_Zero,

Hi Oliver_Zero,

There is no switch or special handling in order to get all the advertising data from the advertising string, all the data should be reported in the user_on_adv_report_ind(), how do you get the values that you are describing ? Are you printing the values or you watch then through the debug window ? The second report that you mentioned seems that it has the advertising data chopped off, since i can see that the length is 0x13 but not all the data, so are you sure that you are printing this correctly ?

Thanks MT_dialog

Oliver_Zero
Offline
Last seen:2 years 10 months ago
Joined:2017-04-05 07:00
Hi MT_dialog,

Hi MT_dialog,

I got the values in user_on_adv_report_ind(), and code I use below:

void user_on_adv_report_ind(struct gapm_adv_report_ind const * param)
{
uint8_t buf[128];

memcpy(buf, ¶m->report.data[0], 31);
write_bytes(buf, 31);
write_string("\r\n");
}

Here's the 2 function I used:

void write_string(uint8_t *buf)
{
uint8_t len = 0;
while(buf[len++] != 0);
uart2_write(buf, len, NULL);
}

void write_bytes(uint8_t *buf, uint8_t len)
{
uart2_write(buf, len, NULL);
}

I can't guarantee that the write_bytes() works well. Because I didn't get the complete data from UART output.

//--------------------------------------------------------------------updated-------------------------------------------------------------
I use Watch Window to watch buf, it contains the complete data of Advertising Packet.
But, what's the reason why uart2_write() didn't output a full buf values?

And, how do I do to get Scan Response Data?

Thanks!

Oliver_Zero
Offline
Last seen:2 years 10 months ago
Joined:2017-04-05 07:00
//---------------------------

//------------------------------Summary---------------------------//
What I made now:
The reason why it don't give me a complete Advertise data is due to uart2_write().

The function should be like this:
void write_bytes(uint8_t *buf, uint8_t len)
{
uart2_write(buf, len, NULL);
uart2_finish_transfers();
}

uart2_finish_transfers() is import to be call after uart2_write()!

//------------------------------------TO-DO-------------------------------//
I still have a question need to be solve.

How can I get the Scan Response data?
If scan response data could be gotten in user_on_adv_report_ind(), I believe Adv data and Scan Resp data were contains in 2 variables.
So, How can I associate Adv packet with Scan Resp packet?

Thanks!

MT_dialog
Offline
Last seen:3 months 1 day ago
Staff
Joined:2015-06-08 11:34
Hi Oliver_Zero,

Hi Oliver_Zero,

The scan response data should come immidiatelly after you get the advertising data, once the central gets the advertising data and its performing an active scan it will automatically send a scan request and the peripheral is obligated to send the scan response before transmits the next advertising packet on the next channel and before the central scans on the next channel. So it should come right after the advertising data from the device that has the same bd address with an evt_type on the gapm_adv_report_ind as 0x04.

Thanks MT_dialog

Oliver_Zero
Offline
Last seen:2 years 10 months ago
Joined:2017-04-05 07:00
Hi, MT_dialog

Hi, MT_dialog

Thanks for your help.

BR
Oliver