This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to change beacon pdu data from solar beacon code

Hi all I just want to use UUID advertisement in solar beacon code for advertising @ 100ms interval I don't need temperature and pressure data .I also want to change type to nrfbeacon how to do it in solar beacon code.

I am able to change timing to 100ms I need to change just advertise major and minor valu and 16byte UUID using beacon PDU where can I set that?

    p_beacon_pdu[0] = 0x42;
    p_beacon_pdu[1] = 0;
    p_beacon_pdu[2] = 0;

should I have to change here?

I am using nrf52832

  • Hi 

    Have you checked out the ble_app_beacon example in the nRF5 SDK?

    It contains all the code you need to set up a beacon advertiser, you just need to copy out the advertising init code, mostly found at the top of the main.c file:

    #define APP_BEACON_INFO_LENGTH 0x17    /**< Total length of information advertised by the Beacon. */
    #define APP_ADV_DATA_LENGTH 0x15       /**< Length of manufacturer specific data in the advertisement. */
    #define APP_DEVICE_TYPE 0x02           /**< 0x02 refers to Beacon. */
    #define APP_MEASURED_RSSI 0xC3         /**< The Beacon's measured RSSI at 1 meter distance in dBm. */
    #define APP_COMPANY_IDENTIFIER 0x0059  /**< Company identifier for Nordic Semiconductor ASA. as per www.bluetooth.org. */
    #define APP_MAJOR_VALUE 0x01, 0x02     /**< Major value used to identify Beacons. */
    #define APP_MINOR_VALUE 0x03, 0x04     /**< Minor value used to identify Beacons. */
    #define APP_BEACON_UUID 0x01, 0x12, 0x23, 0x34, \
    0x45, 0x56, 0x67, 0x78, \
    0x89, 0x9a, 0xab, 0xbc, \
    0xcd, 0xde, 0xef, 0xf0                 /**< Proprietary UUID for Beacon. */

     

    static uint8_t m_beacon_info[APP_BEACON_INFO_LENGTH] = /**< Information advertised by the Beacon. */
    {
      APP_DEVICE_TYPE,     // Manufacturer specific information. Specifies the device type in this
                           // implementation.
      APP_ADV_DATA_LENGTH, // Manufacturer specific information. Specifies the length of the
                           // manufacturer specific data in this implementation.
      APP_BEACON_UUID,     // 128 bit UUID value.
      APP_MAJOR_VALUE,     // Major arbitrary value that can be used to distinguish between Beacons.
      APP_MINOR_VALUE,     // Minor arbitrary value that can be used to distinguish between Beacons.
      APP_MEASURED_RSSI    // Manufacturer specific information. The Beacon's measured TX power in
                           // this implementation.
    };

    The array created above will have to be put into the advertising packet as a manufacturer specific advertising field (ad type 0xFF). 

    This means the first byte of the field (the length) will be 26, the second will be 0xFF, and the remaining bytes will be as defined by the m_beacon_info array. 

    A neat trick to look at the raw data of an advertiser is to use the nRF Connect application for desktop or Android. Then you can see the raw bytes of any advertiser in the area. 

    Best regards
    Torbjørn

     

Related