How to introduce Device name in the SDK example ble_app_beacon

Hi ,

nRF52810, SDK : 15.2.0, using SES, 

I have two questions;

I am trying to add DEVICE NAME to the advertising beacon, in the ble_app_beacon example and following this link to add the code

https://devzone.nordicsemi.com/f/nordic-q-a/4067/add-device-name-to-ble_app_beacon-example

but for some reasons the app crashes , my advertisement data is default data in the example here and name of beacons is also3 letters, not sure what is happening here.

Second question, I want to customize the advertisement data based on a condition in my application, in order to do so I need to make the adv data variable so that it can be changed based on condition, so I want to introduce below code instead of using the #define constants mentioned in the example;

typedef struct 
{
  uint8_t DEVICE_TYPE;
  uint8_t ADV_DATA_LENGTH;
  uint8_t BEACON_UUID[16];
  uint8_t MAJOR_VALUE[2];
  uint8_t MINOR_VALUE[2];
  uint8_t MEASURED_RSSI ;
} beacon_data_t ;

 beacon_data_t beacon_info;

beacon_info.DEVICE_TYPE =  0x02;
beacon_info.ADV_DATA_LENGTH =             0x15    ;                       /**< Length of manufacturer specific data in the advertisement. */
beacon_info.DEVICE_TYPE     =             0x02    ;                     /**< 0x02 refers to Beacon. */
beacon_info.MEASURED_RSSI   =             0xC3    ;                      /**< The Beacon's measured RSSI at 1 meter distance in dBm. */
beacon_info.MAJOR_VALUE[]   =  {0x01, 0x02};                         /**< Major value used to identify Beacons. */
beacon_info.MINOR_VALUE[]   =  {0x03, 0x04};                         /**< Minor value used to identify Beacons. */
beacon_info.BEACON_UUID[] =    {0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0};

But I get  errors while I initialize the struct variable beacon _info.

error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token

Not really sure what is happening, I did not miss any colon, semi colon before these statements , but looks like SES is not considering the beacon_info a variable type of beacon_data_t

I have been using struct variables in similar manner in my other apps but never encountered this error before.

Please help.

Thanks

Abhi

Parents
  • Hello Abhi,

    but for some reasons the app crashes , my advertisement data is default data in the example here and name of beacons is also3 letters, not sure what is happening here.

    Could you elaborate what you mean when you say that the app crashes? Does the device become stuck, or does it reset, for instance?
    Please make sure to have DEBUG defined in your preprocessor defines, like shown in the included image.

    This will make your logger output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK. Please check this error message against the API reference for the function that returned the error code, to see why it was generated.

    If you are seeing that device names are shorter than what you provided, the name might have been concatenated or shortened by the SoftDevice if it otherwise would have exceeded the 31 byte limit of the advertising data. Try to remove some other part of your advertising payload and see if this increases the length of the advertised device name.

    For your second question, you could take a look at the Dynamically updating advertising data blogpost, which details how you could do this, along with providing an example application that updates the advertising data every so often.
    The example uses the BLE Advertising library rather than the direct calls to the SoftDevice API.

    Best regards,
    Karl

Reply
  • Hello Abhi,

    but for some reasons the app crashes , my advertisement data is default data in the example here and name of beacons is also3 letters, not sure what is happening here.

    Could you elaborate what you mean when you say that the app crashes? Does the device become stuck, or does it reset, for instance?
    Please make sure to have DEBUG defined in your preprocessor defines, like shown in the included image.

    This will make your logger output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK. Please check this error message against the API reference for the function that returned the error code, to see why it was generated.

    If you are seeing that device names are shorter than what you provided, the name might have been concatenated or shortened by the SoftDevice if it otherwise would have exceeded the 31 byte limit of the advertising data. Try to remove some other part of your advertising payload and see if this increases the length of the advertised device name.

    For your second question, you could take a look at the Dynamically updating advertising data blogpost, which details how you could do this, along with providing an example application that updates the advertising data every so often.
    The example uses the BLE Advertising library rather than the direct calls to the SoftDevice API.

    Best regards,
    Karl

Children
No Data
Related