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

It keeps malfunctioning when I want to send scan response data

Hi

I followed below tutorial, and I tried to send scan response data

https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-advertising-a-beginners-tutorial?CommentSortBy=CreatedDate&CommentSortOrder=Descending

My code is like below

static void advertising_init(void)
{
    ret_code_t  err_code;
//    uint32_t               err_code;
    ble_advertising_init_t init;
    memset(&init, 0, sizeof(init));

    uint8_t data[] = "SomeData!";

    ble_advdata_manuf_data_t manuf_data;
    manuf_data.company_identifier = 0x0059;
    manuf_data.data.p_data = data;
    manuf_data.data.size = sizeof(data);
    init.advdata.p_manuf_specific_data = &manuf_data;

    init.advdata.name_type          = BLE_ADVDATA_SHORT_NAME;
    init.advdata.short_name_len     = 3;
    init.advdata.include_appearance = true;
    init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    init.srdata.uuids_complete.p_uuids  = m_adv_uuids;
    int8_t tx_power_level = 4;
    init.advdata.p_tx_power_level = &tx_power_level;

    ble_advdata_manuf_data_t manuf_data_response;
    uint8_t data_response[]="Many_bytes_of_data";
    manuf_data_response.company_identifier=0x0059;
    manuf_data_response.data.p_data=data_response;
    manuf_data_response.data.size=sizeof(data_response);
    init.srdata.name_type = BLE_ADVDATA_NO_NAME;
    init.srdata.p_manuf_specific_data=&manuf_data_response;

    init.config.ble_adv_fast_enabled  = true;
    init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
    init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;

    init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&m_advertising, &init);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}

but when I run this code, It makes error at app_error_weak.c

and ends at the line NRF_BREAKPOINT_COND;

I don't know why It keeps happening.

Everything is same with the tutorial.

Without this line

init.srdata.p_manuf_specific_data=&manuf_data_response;

It runs very well, but of course I can't get the scan response data.

What should I do?

Best regards,

Parents Reply
  • Hi Simonr!

    Thank you for advisement! The problem was uuid and uuid type! When I changed it like below, It works well

    static ble_uuid_t const m_nus_uuid =
    {
        .uuid = BLE_UUID_DEVICE_INFORMATION_SERVICE,
        .type = BLE_UUID_TYPE_BLE
    };

    Then, Is it not the problem for using different service UUID(not using BLE_UUID_NUS_SERVICE in uart project)? Just, the sameness of uuid between central and peripheral is important?

    Best regards

Children
Related