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
  • Hi,

    The BLE UART example shows how to add a custom UUID to the scan response data. You can also find a detailed explanation of how you do this in the BLE Services, a beginner's tutorial. Note that you can add it to the advertising data if you have enough available space, but the maximum payload of one advertising packet is 27 bytes.

    Best regards,

    Jørgen

  • 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

Reply
  • 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

Children
No Data
Related