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

How to put the device name to the Advertising scan response ?

Hi

Now I'm using sdkv12.2 and S132 on nRF52832. All the examples in the SDK put the device name in the advertising data packet. However, for our applicaiton, we need to put some special data in the advertising data packet and limit to the 31 bytes length, so I have to put the put the device name to the Advertising scan response data packet. Could you tell me how to do it? Thanks a lot.

  • Hi,

    This can be done in the advertising_init() function.

    Code snippet:

    static void advertising_init(void)
    {
    	.
    	.
        ble_advdata_t          scanrsp;
    
        memset(&scanrsp, 0, sizeof(scanrsp));
        scanrsp.name_type               = BLE_ADVDATA_FULL_NAME;
    	.
    	.
        err_code = ble_advertising_init(&advdata, &scanrsp, &options, on_adv_evt, NULL);
        APP_ERROR_CHECK(err_code);
    	.
    	.
    }
    

    Remember to remove the advdata.name_type = BLE_ADVDATA_FULL_NAME; that is used to place the name in the advertising data packet.

Related