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

change advertisement index in advertise packet

advertise.pnghello there

in advertising packet i want something like first name of device and then service data and then manufacture data ??

how can i do that??

from screenshot , i want AD Data 3 first then AD Data 2 in advertisement packet means i want complete local name before complete list of 16 bit service uuids

  • ok thanks.

    static void advertising_init(void)
    {
        uint32_t      err_code;
        ble_advdata_t advdata;
        ble_advdata_t scanrsp;
    	  ble_advdata_service_data_t service_data;
        uint8_t data1[3] ={0x01,0x03,0x04};
        // Build advertising data struct to pass into @ref ble_advertising_init.
        memset(&advdata, 0, sizeof(advdata));
        advdata.name_type          = BLE_ADVDATA_SHORT_NAME;
    	  advdata.short_name_len = 1;
        advdata.include_appearance = false;
    
        advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    		service_data.service_uuid =0x0018;
        service_data.data.p_data = data1;
    		service_data.data.size = sizeof(data1);
        
        ble_adv_modes_config_t options = {0};
        options.ble_adv_fast_enabled  = BLE_ADV_FAST_ENABLED;
        options.ble_adv_fast_interval = APP_ADV_INTERVAL;
        options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;
    
        err_code = ble_advertising_init(&advdata,NULL, &options, on_adv_evt, NULL);
        APP_ERROR_CHECK(err_code);
    }
    

    after writing this function, i am not getting service data in advertisement packet. can you help me?? what is my problem??

  • FormerMember
    0 FormerMember

    All you need to do to change the order of the advertised data is to change the order that the data is being encoded in adv_data_encode(..)

  • FormerMember
    0 FormerMember

    If the problem with the encoding order is solved. This thread should be marked as "solved", and the new question should be placed in a new question, due to readability for others with the same questions.

    From what I can see, service data is not in the advertising data because service_data is not added to advdata. If that is not the reason, please create a new question instead of continuing in this thread.

Related