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,

Parents
  • Most likely iOS forgets the state of your CCCD's when you turn bluetooth off/on, so i suggest you enable it from your iOS application again. If this doesn't help please provide a sniffer trace showing the failing scenario, and also check for an error code when calling sd_ble_gatts_hvx (I would guess you are getting invalid state here).

  • 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,

Reply
  • 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,

Children
No Data
Related