Dear Nordic,
I am using a pretty much unmodified version of the BLE HID Keyboard example from the Nordic BLE SDK (straight of github). I only modified pins, and disabled the sleep mode code (eg. after a timeout, it just starts advertising again, not part of my issue).
- Samsung S4 (Kitkat & Lollipop, occurs on both)
- Blend Micro with onboard nRF8001
Problem
The Android device is correctly bonded and connected to the BLE HID Keyboard. The entire Android BT stack crashes after a while of inactivity. This mainly happens when:
- we are NOT connected with ADB (don't ask me why pls, it just doesn't seem to happen when Eclipse is connected)
- we are connected to a charger (as opposed to connecting to my pc)
- the device is left as is (allowing screen to turn off etc. and disconnected from USB)
Very small snippet of logcat: (this goes on for miles of logging)
05-06 18:46:23.290: E/GKI_LINUX(16866): GKI_exception(): Task State Table
05-06 18:46:23.290: E/GKI_LINUX(16866): TASK ID [0] task name [BTU] state [1]
05-06 18:46:23.290: E/GKI_LINUX(16866): TASK ID [1] task name [BTIF] state [1]
05-06 18:46:23.290: E/GKI_LINUX(16866): TASK ID [2] task name [A2DP-MEDIA] state [1]
05-06 18:46:23.290: E/GKI_LINUX(16866): GKI_exception 65524 getbuf: out of buffers
05-06 18:46:23.290: E/GKI_LINUX(16866): ********************************************************************
05-06 18:46:23.290: E/GKI_LINUX(16866): * GKI_exception(): 65524 getbuf: out of buffers
05-06 18:46:23.290: E/GKI_LINUX(16866): ********************************************************************
Troubleshooting
The biggest problem is having to wait. It can take a considerable amount of time (10-20 mins) of inactivity for the problem to popup. And I try to test each scenario at least twice to make sure I'm not overlooking anything (resetting the bond, and rebooting android).
With the Serial Monitor connected, I have found one interesting thing that might be part of the problem. While connected, the HID Keyboard actually receives packets over Pipe #8 with length 0 at an irregular interval (but no longer than 60 seconds so far). Pipe 8 corresponds to PIPE_HID_SERVICE_HID_REPORT_OUTPUT_RX_ACK_AUTO according to services.h.
As soon as these messages stop appearing, I know the Android BT stack has crashed!
What I have tried The following is a list of what I tried in order to make the problem go away (to no avail):
- Not doing anything at all at loop (removed block sending the 'A' key every 4 seconds)
- Remove all timer1 stuff
- Send empty keypress (eg all of keypressA is 0x00, sending once)
Obviously, I used Google to try and narrow down the problem. Unfortunatly, almost any link regarding the subject is about problems with BLE scanning. I'm not doing that. In fact, I leave the whole BT thing up to Android. There is no application running to "open" or "connect" to the BT device. To be even more specific, as it's a HID Keyboard, I can't even DO anything with it inside Android at all (as it's managed by Android).
I would really like some help troubleshooting the problem further. At this stage, I am still uncertain if this problem is caused by Android, the Blend Micro or it's onboard nRF8001.
With kind regards, Rory