PSoC BLE comparing data field in scan response CYBLE_GAPC_ADV_REPORT_T

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
rotu_3236376
Level 3
Level 3
First like received

Hello,

Im trying to write a simple IF condition based on some values or length of the data in the scan response result.  My question is about the dataLen field, should I be comparing this field as an int or hex? This is what my condition looks like.  Notice the "OR" statement.

  if(((advReport->eventType == CYBLE_GAPC_SCAN_RSP) && (advReport->data[1] == 0xff) \

  && (advReport->data[2] == 0x31) && (advReport->data[3] == 0x01) \

  && (advReport->data[4] == 0x3b) && (advReport->data[5] == 0x04)) || (advReport->dataLen == 0x0b))

  {

    ....

}

I was to check if the dataLen field is "11".  How should that portionof the statement should be written:

this

(advReport->dataLen == 0x0b)

or this

(advReport->dataLen == 11)

Also, what is the dataLen property actually counting? Is it the length of the entire response packet including headers or is it just the response data? According to the documentation it is the length of the data for each device that responded to scanning. I am not sure what this means but I would like to check the specific length of the data I am sending in the advertising packet.

Thanks,

Rohan

0 Likes
1 Solution
VenkataD_41
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi,

The data length is 8 bit unsigned integer value (uint8). Please go to the definition of the variable advReport and check the structure.

In the BLE peripheral GUI, in the GAP settings--> Scanresponse packet you can see that the data length is mentioned in hexadecimal format. You can use the hexadecimal format "0x__" for checking.

Question>>"Also, what is the dataLen property actually counting? Is it the length of the entire response packet including headers or is it just the response data? According to the documentation it is the length of the data for each device that responded to scanning. I am not sure what this means but I would like to check the specific length of the data I am sending in the advertising packet."

Answer--> Data Length includes the entire advertisement packet. It is the combination of user name data as well as other data like Manufacturer data. We recommend you to check data length field also as advReport->data to avoid confusion.

Please ensure whether you are doing active scanning or passive scanning at central side. If you are doing active scanning you have to check scan response packet. Or if you are using passive scanning you have to check the advertisement packet.

Thanks

Ganesh

View solution in original post

0 Likes
4 Replies
VenkataD_41
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi,

The data length is 8 bit unsigned integer value (uint8). Please go to the definition of the variable advReport and check the structure.

In the BLE peripheral GUI, in the GAP settings--> Scanresponse packet you can see that the data length is mentioned in hexadecimal format. You can use the hexadecimal format "0x__" for checking.

Question>>"Also, what is the dataLen property actually counting? Is it the length of the entire response packet including headers or is it just the response data? According to the documentation it is the length of the data for each device that responded to scanning. I am not sure what this means but I would like to check the specific length of the data I am sending in the advertising packet."

Answer--> Data Length includes the entire advertisement packet. It is the combination of user name data as well as other data like Manufacturer data. We recommend you to check data length field also as advReport->data to avoid confusion.

Please ensure whether you are doing active scanning or passive scanning at central side. If you are doing active scanning you have to check scan response packet. Or if you are using passive scanning you have to check the advertisement packet.

Thanks

Ganesh

0 Likes

Thank you Ganesh this response is very helpful.  I just have a couple of follow up questions.

1) You mention that I should check the data length field also as advReport->data to avoid confusion.  What is x?

2) I am using this sample project for the Central side.   How do I know if this is passive or active mode? I have not changed anything from the sample.

https://raw.githubusercontent.com/cypresssemiconductorco/PSoC-4-BLE/master/100_Projects_in_100_Days/...

Regards,

Rohan

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Rohan,

>>"1) You mention that I should check the data length field also as advReport->data to avoid confusion.  What is x?"

--> 'x' is the byte position. It is the postion of the byte inside the array. So what I recommended is instead of reading the "Data Length", you can use the position of Data Length inside the advertisement packet.

>>"I am using this sample project for the Central side.  How do I know if this is passive or active mode? I have not changed anything from the sample."

--> In central project, In the GAP settings--> Scan settings--> scanning mode you can find this setting.

Thanks

Ganesh

0 Likes

Thank you Ganesh!  I will try these recommendations and let you.

0 Likes