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 Reply Children
  • Hi jorgen,

    thanks for the answer. i see the uart example, it's very simple.

    static ble_uuid_t                       m_adv_uuids[] = {{BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE}};  
    
    /**< Universally unique service identifier. */
    
    /**@brief Function for initializing the Advertising functionality.
     */
    
    static void advertising_init(void)
    {
        uint32_t               err_code;
        ble_advdata_t          advdata;
        ble_advdata_t          scanrsp;
        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 = false;
    advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    
    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(&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;
    
    err_code = ble_advertising_init(&advdata, &scanrsp, &options, on_adv_evt, NULL);
    APP_ERROR_CHECK(err_code);
    

    }

    my problem is the define of BLE_UUID_NUS_SERVICE is not simple 0xXXXX but it's somethink like that

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

    and i don't know how meange it

  • thx, very helpful. For use a UIID 128 i set the advdata.include_appearance = false; because the size is limited. I think that is not a problem- But i would understand what means.

    Thanks, Anna

  • Appearance allows you device to appear as a predefined type for your computer/phone etc. when scanning for Bluetooth devices. Some more information can be found here and here. It is no problem to turn this off if you do not require this feature.

Related