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

HID over GATT on Android disconnects after 30 seconds

I am using nrf51822 with PCA 10001, SoftDevice S110 6.0 and SDK 5.2. I modified the HID example to send media keys, basically I just changed the report map and added a few functions for sending media keys. This all works great on iOS 7, I am able to connect and can send the media keys just fine. The iOS device will stay connected indefinitely.

However, on Android, I am seeing disconnection issues. I can connect just fine, and things work for about 30 seconds, but then it just disconnects. It does not matter if I press buttons (send media keys) or not, the connection is always lost after roughly 30 seconds. I looked at the ble_evt_t on disconnect and the reason code for disconnect is 8. As far as I can tell, that is HCI timeout.

I tried disabling the battery service, just to see if that helped. It didn't.

I tried using the sniffer application to capture the events. However, I must not be using it properly because nothing is captured once the android phone connects. I see the advertisements before the connection, but as soon as I connect, nothing. When the disconnect happens, I see hundreds of advertisements packets flood in from the nrf51822 to the Android phone, but I don't see anything while the connection is established.

Is there something different I need to do with Android to avoid this disconnection? Is there something else I can do to debug the problem? Right now, I am sort of stuck as I am not sure how to get more information about the problem. Please let me know. Thanks

Parents
  • I am getting the same thing on iOS (8.0b5 on iPhone 5S as well as 7.1.1 on iPad3). My application is based on the Nordic ble_lbs demo code which sets up the connection as follows:

    cp_init.p_conn_params                  = NULL;
    cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
    cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
    cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
    cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
    cp_init.disconnect_on_fail             = false;
    cp_init.evt_handler                    = on_conn_params_evt;
    cp_init.error_handler                  = conn_params_error_handler;
    

    FIRST_CONN_PARAMS_UPDATE_DELAY is 1s, NEXT_CONN_PARAMS_UPDATE_DELAY is 5s, and MAX_CONN_PARAMS_UPDATE_COUNT is 3. My disconnects occur almost exactly 15s (5s delay, 3 attempts) after connecting.

    Like the original poster, the soft device does NOT resume advertising.

    This doesn't appear to be an Android thing, but perhaps a soft device thing. I'm running s110 v6.0.0.

Reply
  • I am getting the same thing on iOS (8.0b5 on iPhone 5S as well as 7.1.1 on iPad3). My application is based on the Nordic ble_lbs demo code which sets up the connection as follows:

    cp_init.p_conn_params                  = NULL;
    cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
    cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
    cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
    cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
    cp_init.disconnect_on_fail             = false;
    cp_init.evt_handler                    = on_conn_params_evt;
    cp_init.error_handler                  = conn_params_error_handler;
    

    FIRST_CONN_PARAMS_UPDATE_DELAY is 1s, NEXT_CONN_PARAMS_UPDATE_DELAY is 5s, and MAX_CONN_PARAMS_UPDATE_COUNT is 3. My disconnects occur almost exactly 15s (5s delay, 3 attempts) after connecting.

    Like the original poster, the soft device does NOT resume advertising.

    This doesn't appear to be an Android thing, but perhaps a soft device thing. I'm running s110 v6.0.0.

Children
  • I see what the problem is, at least in my scenario which I don't know is the same.

    With my application, if I set the MAX_CONN_INTERVAL down to 25ms, I get the timeouts. If I leave it up at 40ms, I do not. It looks like the soft device is ignoring my "do not disconnect on failure to negotiate the connection parameters" setting.

  • I'm having this problem too with the SoftDevice 7...

    #define FIRST_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(20000, APP_TIMER_PRESCALER) /< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (15 seconds). */ #define NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER) /< Time between each call to sd_ble_gap_conn_param_update after the first (5 seconds). */ #define MAX_CONN_PARAMS_UPDATE_COUNT 3 /**< Number of attempts before giving up the connection parameter negotiation. */

    Ignore the comments, but I connect to the device on iOS 8, and after 35 seconds it just gets disconnected..

    Which is 20 + (3 * 5) seconds.

    cp_init.p_conn_params                  = NULL;
    cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
    cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
    cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
    cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
    cp_init.disconnect_on_fail             = false;
    cp_init.evt_handler                    = on_conn_params_evt;
    cp_init.error_handler                  = conn_params_error_handler;
    

    Any ideas?

Related