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

Initialising Advertising data and encoding them in SDK 15.2

Hello everyone!

I am a beginner and I need help in understanding advertising data. I am migrationg from SDK 13 to SDK 15.2. In SDK 13, the advertising data with manufacturer data for becon, ble device address, flag: LE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE and uuids_more_available were advertised without any ERROR. But, in SDK 15.2 the same data are exceeding 31bytes and i am getting ERROR Code 12. Could you please explain me how it worked in SDK 13.2, as these data altogether exceeds 31bytes?

Thanks in advance

Parents Reply Children
  • Hi,

    Thanks a lot for your response. I figured it out. I was advertising uuid both in adv_data and scan_response data.

  • Hi,

    I am happy to hear that you figured it out!

    Regards,
    Terje

  • Hi,

    Even after removing the uuid from adv data. I still get the error code 12.

    These are my settings in version 13.2 and 15.

    static void SDK_13_ble_advertising_init(void)
    {
                uint32_t              		err_code;
                ble_advdata_t          		advdata;
                ble_advdata_t          		scanrsp;
                ble_adv_modes_config_t 		options;
                ble_advdata_manuf_data_t 	manuf_specific_data;
    
    
                manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER_APPLE;
                manuf_specific_data.data.p_data 	   = (uint8_t *) m_beacon_info;
                manuf_specific_data.data.size   	   = APP_BEACON_INFO_LENGTH;
    
                // Build advertising data struct to pass into @ref ble_advertising_init.
                ble_uuid_t m_adv_uuids[] = {{SERVICE_P_SERVICE_UUID, m_service.uuid_type}};
    
                memset(&scanrsp, 0, sizeof(scanrsp));
                scanrsp.uuids_complete.uuid_cnt        = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
                scanrsp.uuids_complete.p_uuids  	   = m_adv_uuids;
    
                memset(&advdata, 0, sizeof(advdata));
                advdata.name_type               	  = BLE_ADVDATA_NO_NAME;
                advdata.include_appearance      	  = false;
                advdata.include_ble_device_addr 	  = true;
                advdata.flags                   	  = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
                advdata.p_manuf_specific_data 		  = &manuf_specific_data;
    
                memset(&options, 0, sizeof(options));
                options.ble_adv_fast_enabled  		= true;
                options.ble_adv_fast_interval 		= NON_CONNECTABLE_ADV_INTERVAL;
                options.ble_adv_fast_timeout 		= APP_CFG_NON_CONN_ADV_TIMEOUT;
    
                err_code = ble_advertising_init(&advdata,&scanrsp,&options, on_adv_evt, NULL);
                APP_ERROR_CHECK(err_code);
    
    }
    
    
    ************************************************************************************************************
    
    static uint8_t m_enc_scan_response_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX];         /**< Buffer for storing an encoded scan data. */
    static uint8_t m_enc_advdata[BLE_GAP_ADV_SET_DATA_SIZE_MAX];                    /**< Buffer for storing an encoded advertising set. */
    
    /**@brief Struct that contains pointers to the encoded advertising data. */
    static ble_gap_adv_data_t m_adv_data =
    {
        .adv_data =
        {
            .p_data = m_enc_advdata,
            .len    = BLE_GAP_ADV_SET_DATA_SIZE_MAX
        },
        .scan_rsp_data =
        {
            .p_data = m_enc_scan_response_data,
            .len    = BLE_GAP_ADV_SET_DATA_SIZE_MAX
    
        }
    };
    
    static void SDK_15_ble_advertising_init(void)
    {
            uint32_t                            err_code;
            ble_advdata_t 						advdata;
            ble_advdata_t 						scanrsp;
    //  ble_adv_modes_config_t 		options;
            ble_advdata_manuf_data_t 	        manuf_specific_data;
    
            /* Initialize structs. */
            memset(&advdata, 0, sizeof(ble_advdata_t));
            memset(&scanrsp, 0, sizeof(ble_advdata_t));
    
            manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER_APPLE;
            manuf_specific_data.data.p_data 	   	 = (uint8_t *) m_beacon_info;
            manuf_specific_data.data.size   	   	 = APP_BEACON_INFO_LENGTH;
    
            /// Build advertising data struct to pass into @ref ble_advertising_init.
            ble_uuid_t m_adv_uuids[] = {{SERVICE_P_SERVICE_UUID, m_service.uuid_type}};
    
            /* Prepare scan response data. */
            scanrsp.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
            scanrsp.uuids_complete.p_uuids  = m_adv_uuids;
    
            /* Prepare advertising data. */
            advdata.name_type          			= BLE_ADVDATA_NO_NAME;
            advdata.include_appearance 			= false;
            advdata.include_ble_device_addr     = true;
            advdata.flags              			= BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
            advdata.p_manuf_specific_data 	    = &manuf_specific_data;
    
    
    //  memset(&options, 0, sizeof(options));
    //  options.ble_adv_fast_enabled  	= true;
    //  options.ble_adv_fast_interval 	= NON_CONNECTABLE_ADV_INTERVAL;
    //  options.ble_adv_fast_timeout 	= APP_CFG_NON_CONN_ADV_TIMEOUT;
    
            err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
            APP_ERROR_CHECK(err_code);
           
            err_code = ble_advdata_encode(&scanrsp, m_adv_data.scan_rsp_data.p_data, &m_adv_data.scan_rsp_data.len);
            APP_ERROR_CHECK(err_code);
    
    }
    

    In version 15 the ble device address, flag and manufacturer data in p_len are 9, 3 and 25 respectively, which sums upto 37bytes.

    Thanks a lot in advance

Related