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,

    Thanks for your reply, I check the err_code of sd_ble_gatts_hvx and found when it is 0(no error), the button is working, and turn Bluetooth off and on again, sometime I found the whole device is reset because I output a string in main.c, and the sd_ble_gatts_hvx returns ox3401 after reset. What does that mean and can you help? the other problem is the reset, why BT turned off then on will cause my device reset?

    Thanks,

Reply
  • Hi,

    Thanks for your reply, I check the err_code of sd_ble_gatts_hvx and found when it is 0(no error), the button is working, and turn Bluetooth off and on again, sometime I found the whole device is reset because I output a string in main.c, and the sd_ble_gatts_hvx returns ox3401 after reset. What does that mean and can you help? the other problem is the reset, why BT turned off then on will cause my device reset?

    Thanks,

Children
No Data
Related