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

ADD UUID 128 custom service to advertising packet

Hi all,

is there an example to add the uuid 128 of a custom service on advertising data?

Parents
  • If you want you can use this one.

    drive.google.com/open

    Its an example I made which is based on the ble_app_template (SDK12.2) If you are on CodeLimitation just disable LRF_LOG in the config. If you only fokus on the advertising part it should be fine. I build this out of the template and the blinky app from their github

    If your code uses ble_advertising_init basically all you have to do is to add your service to the second parameter. If you get Error 0x07 it is often the case that you want to initialize advertising before the services are initialized. You have to change the order in the main of the ble_app_template from advertising_init(); services_init(); to services_init(); advertising_init(); Hope that helps you a little bit

    uint32_t               err_code;
    ble_advdata_t          advdata;
    ble_adv_modes_config_t options;
    
    // Build advertising data struct to pass into @ref ble_advertising_init.
    memset(&advdata, 0, sizeof(advdata));
    
    advdata.name_type               = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance      = true;
    advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    advdata.uuids_complete.p_uuids  = m_adv_uuids;
    
    memset(&options, 0, sizeof(options));
    options.ble_adv_fast_enabled  = true;
    options.ble_adv_fast_interval = APP_ADV_INTERVAL;
    options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;
    
    ble_uuid_t adv_uuids[] = {{LUXS_UUID_SERVICE, m_luxs.uuid_type}};
    
    ble_advdata_t srdata;
    memset(&srdata, 0, sizeof(srdata));
    srdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
    srdata.uuids_complete.p_uuids = adv_uuids;
    
    err_code = ble_advertising_init(&advdata, &srdata, &options, on_adv_evt, NULL);
    NRF_LOG_ERROR("%d\r\n", err_code);
    APP_ERROR_CHECK(err_code);
    
  • Mmmhh.

    i use a ble devloper studio and uuid of my service created is:

     ble_uuid128_t bds_base_uuid = {{0xB6, 0x9D, 0x21, 0x57, 0xA7, 0xA3, 0xFA, 0xA0, 0x97, 0x4A, 0x72, 0xA7, 0x00, 0x00, 0x20, 0xF3}};
    

    But i don't understand how pass this value to advdata.uuids_complete.p_uuids =

Reply Children
No Data
Related