I want to change Peripheral's advertising information.

hello,

I want to change Peripheral's advertising information.

Looking at the Academy data in the link below, it seems that Manufacturer Specific Data / URI information can be modified...

I can't find a way through the code.

(I am currently developing based on the NUS example.)

Link : https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-2-bluetooth-le-advertising/topic/advertisement-packet/

thank,.

  • Hi David

    What spesific is it that you can to change? 

    For example the device name is set the following way

    #define DEVICE_NAME             CONFIG_BT_DEVICE_NAME //this name is set in prj.conf
    #define DEVICE_NAME_LEN	        (sizeof(DEVICE_NAME) - 1)
    
    
    static const struct bt_data ad[] = {
    	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
    	BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
    };
    
    The BT_DATA is macro that needs 3 inputs, type, data, and datalength
    /**
     * @brief Helper to declare elements of bt_data arrays
     *
     * This macro is mainly for creating an array of struct bt_data
     * elements which is then passed to e.g. @ref bt_le_adv_start().
     *
     * @param _type Type of advertising data field
     * @param _data Pointer to the data field payload
     * @param _data_len Number of bytes behind the _data pointer
     */
    #define BT_DATA(_type, _data, _data_len) \
    	{ \
    		.type = (_type), \
    		.data_len = (_data_len), \
    		.data = (const uint8_t *)(_data), \
    	}
    

    You can also see in lesson 6 how they set manufacturer data

    https://github.com/NordicDeveloperAcademy/bt-fund/blob/main/lesson6/blefund_less6_exer1/src/main.c

    Regards

    Runar

Related