- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
&& (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
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rohan,
>>"1) You mention that I should check the data length field also as advReport->data
--> '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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Ganesh! I will try these recommendations and let you.