I am.a beginner in BLE embedded development, and I have a question regarding the following declaration that is going to be "the advertisement data"
In specific,
Thanks.
I am.a beginner in BLE embedded development, and I have a question regarding the following declaration that is going to be "the advertisement data"
In specific,
Hello,
Thank you for contacting DevZone at NordicSemi.
The line of code that you have mentioned:
static const struct bt_data ad[] = {}
is declaration of an array.
The name of array is ad
The type of array (or the type of data it can store) is bt_data
where bt_data is a struct that has been defined in header files.
In the sample code (e.g peripheral_uart) opened in the VS-Code, if you hover over the bt_data, it will show you its description
Moreover, you can right click on bt_data and goto the definition of where the struct is defined in the header file.
So here you see that the bt_data is struct defined in bluetooth.h and its subfields are as shown below:
Hope it answers your query.
BR,
Naeem
Thanks Naeem, I understand your points. However, why we need to declare the "struct" type two times if bt_data is already defined as a structure. As you said if you go to the definition, it says struct bt_data { }. Thanks.
Thanks Naeem, I understand your points. However, why we need to declare the "struct" type two times if bt_data is already defined as a structure. As you said if you go to the definition, it says struct bt_data { }. Thanks.
Hello,
Right. The question is related to the C language itself rather than NCS or Nordic solutions.
This could be the limitation posed by the language. Please have a look at this discussion, and following pages which talk about the same.
Different struct variable declarations
BR,
Naeem