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

HID and NUS

Hello,

I am attempting to incorporate NUS example (app_uart) into the HID keyboard example. The whole thing compiles with no warning, but when I add {BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE} to m_adv_uuids, the adverstising never starts. I was able to locate where it fails through the debugger. When it enters the line APP_ERROR_CHECK(err_code) it fails.

static void advertising_init(void)
{
    uint32_t               err_code;
    uint8_t                adv_flags;
    ble_advertising_init_t init;

    memset(&init, 0, sizeof(init));

    adv_flags                            = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    init.advdata.name_type               = BLE_ADVDATA_FULL_NAME;
    init.advdata.include_appearance      = true;
    init.advdata.flags                   = adv_flags;
    init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    init.advdata.uuids_complete.p_uuids  = m_adv_uuids;

    init.config.ble_adv_whitelist_enabled          = true;
    init.config.ble_adv_directed_high_duty_enabled = true;
    init.config.ble_adv_directed_enabled           = false;
    init.config.ble_adv_directed_interval          = 0;
    init.config.ble_adv_directed_timeout           = 0;
    init.config.ble_adv_fast_enabled               = true;
    init.config.ble_adv_fast_interval              = APP_ADV_FAST_INTERVAL;
    init.config.ble_adv_fast_timeout               = APP_ADV_FAST_DURATION;
    init.config.ble_adv_slow_enabled               = true;
    init.config.ble_adv_slow_interval              = APP_ADV_SLOW_INTERVAL;
    init.config.ble_adv_slow_timeout               = APP_ADV_SLOW_DURATION;

    init.evt_handler   = on_adv_evt;
    init.error_handler = ble_advertising_error_handler;

    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);
}

I have tried the same with OTS and altough I wasn't able to communicate trough it I was able to advertise it. I have defined the following in sdk_config.h :

#define BLE_NUS_ENABLED 1

Any idea on what could cause an advertising failure?

Parents
  • well you could just debug through to find out where the error is returned or look at the error code to see which one it is. Most likely you've put too much in the advertising packet and overfilled it so you're getting an error that there's no space. 

  • Hello, the error code is 0x07, which if I get right is NRF_ERROR_INVALID_PARAM. If I am not mistaken, since the NUS is a vendor defined UUID, it has a length of 128 bits, while the HID has 16 bits, right? I'm not quite sure how I am supposed to merge these two.

    I attempted to replicate the ble_app_uart example where it uses a NUS profile, and temporarily commented out the HID part to see if I could make it work alone, but with no success. When you say "Too much in the advertising packet", you're talking about the advertising uuid list, correct?

Reply
  • Hello, the error code is 0x07, which if I get right is NRF_ERROR_INVALID_PARAM. If I am not mistaken, since the NUS is a vendor defined UUID, it has a length of 128 bits, while the HID has 16 bits, right? I'm not quite sure how I am supposed to merge these two.

    I attempted to replicate the ble_app_uart example where it uses a NUS profile, and temporarily commented out the HID part to see if I could make it work alone, but with no success. When you say "Too much in the advertising packet", you're talking about the advertising uuid list, correct?

Children
No Data
Related