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

Can't read characteristics of BLE HID service example

I'm trying to implement the HID service on a custom nrf52832 board, unfortunately I'm running into problems.

Here's what happens: Advertising, connecting to the board, service discovery, GPIOs (buttons & LEDs), reading the battery level, etc. all work great. I use nRF Connect to test this. However when trying to read HID characteristics (except for the protocol mode), the operation never finishes (the spinner keeps spinning). The log does not show any errors or other entries, except for the battery service updates that keep coming in. When I hit disconnect the spinner stops and the device is discoverable again.

The same happens when I use the "enable all services" menu item like described in the example. The HID device also doesn't produce any input in Android, even when connecting through settings and enabling "use for input device").

At first I suspected problems in my code, but now I'm running the unmodified examples (with -DBOARD_CUSTOM though) and have the exact same issue. I tried both the HID mouse and keyboard example. I'm using version 12.2 of the nRF5 SDK, though I'm getting the same result with 12.0.

Any ideas what's going wrong? I'd also appreciate any hints on how to further debug this.

  • Did you look into the NRF_LOG problem I mentioned?

  • FormerMember
    0 FormerMember in reply to FormerMember

    Yes, the commented NRF_LOG(...) in app_error.h seems to be commented by a mistake. I think they can be uncommented.

  • Hi whats need to change for random passkey please help me i modified the code like below but central is not connecting.

    #define SEC_PARAM_BOND 1 /**< Perform bonding. */
    #define SEC_PARAM_MITM 1 /**< Man In The Middle protection not required. */
    #define SEC_PARAM_LESC 1 /**< LE Secure Connections not enabled. */
    #define SEC_PARAM_KEYPRESS 0 /**< Keypress notifications not enabled. */
    #define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_KEYBOARD_ONLY

    #define SEC_PARAM_OOB 0 /**< Out Of Band data not available. */
    #define SEC_PARAM_MIN_KEY_SIZE 7 /**< Minimum encryption key size. */
    #define SEC_PARAM_MAX_KEY_SIZE 16

    static void gap_params_init(void)
    {
    uint32_t err_code;
    ble_gap_conn_params_t gap_conn_params;
    ble_gap_conn_sec_mode_t sec_mode;

    // BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
    BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(&sec_mode);

    err_code = sd_ble_gap_device_name_set(&sec_mode,
    (const uint8_t *) DEVICE_NAME,
    strlen(DEVICE_NAME));
    APP_ERROR_CHECK(err_code);

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

    gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
    gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
    gap_conn_params.slave_latency = SLAVE_LATENCY;
    gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;

    err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
    APP_ERROR_CHECK(err_code);

    ble_gap_opt_t gap_opt;

    gap_opt.passkey.p_passkey = (uint8_t *)NULL;

    err_code = sd_ble_opt_set(BLE_GAP_OPT_PASSKEY,(const ble_opt_t *)&gap_opt);
    APP_ERROR_CHECK(err_code);
    }

Related