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

HID Ble Keyboard + LBS(button service) question

Hi All,

I'm new in developing BLE 4.0 device, now have a project is adding LBS(led button service) to a standard ble HID keyboard application in SDK 9.0, the reason why I need HID service is this is only way that the iOS can discover my BLE device in [setting] -> [Bluetooth], otherwise, a BLE device can only be dsicovered by the APP which works with it.

Now the problem is, I can connect my device in iOS [setting] -> [Bluetooth] and when press the button, the lbs function works(I send a button characteristic of read value of 1 when pressed and send 0 when button is released), so that the App on the iPhone side work as expected. But if I turn off the Bluetooth in iPhone and turn on again, it re-connects the device automatically, this looks good, but at the moment, the lbs service no longer works, App on the iPhone stops reacting when the button is pressed.

I'm sure the button is working because the LED toggled the status when button is pressed, just the function "ble_lbs_on_button_change" seems not working anymore. The only way to let it work again is in iPhone's Bluetooth setting, "forget" my device and connect again then everything backs to normal.

Can anyone tell me how to fix this? Anything I did wrong in my code? Any help will be appreciated.

Thanks,

  • It's not. I assume you are getting an error message from a function call which is not handled and therefor defaulting to the app error handler.

  • Hi,

    I use a clean hid keyboard example to do the test, and found the system goes to reset when the iPhone's Bluetooth is turned off, so i think it is not my code which causes the reset. If the system is reset, then the gatt service context my be cleared, so even I call sd_ble_gatts_sys_attr_get i get an error, actually i call dm_service_context_get and get x 0x8008 error, and when i press the button, i still get 0x3401, any help?

    Thanks,

  • Hi,

    I did another test and I found as long as the device is not reset, the button will behave normal, but with SDK9.0, if iOS's Bluetooth is turned off, the device will reset every few minutes, this will result my BLE device can't work.

    I search the forum and found this reset issues is fixed in SDK11.0 and I have a test with the HID_keyboard example, it doesn't reset but SDK11.0 comes another problem, iOS7.0/9.0 can not find my BLE keyboard in Bluetooth, only iOS 8.4. is able to discover it, also SDK11.0 has only Softdevice 130, no 110, does the Softdevice version has to do with the discovery from iOS? Any idea to help?

    Thanks,

  • The HID example uses a whitelist when it has devices in it's device table. So other devices won't be able to connect to it. So to connect to another device you need to either purge the device table or disable the whitelist.

Related