BLE services not cleared during disconnection #ble


dhguja@gmail.com
 
Edited

Hello,
    I am using Zephyr's Bluetooth  stack for my BLE peripheral device which uses either HID services and custom service to send data to BLE Host.

The problem i face is as follows:
1) If i connect my device as HID device all the services except my custom service is subscribed (as expected)
2) Now i disconnect and connect my device as custom device (without device reset) through custom application in Android i am able to use my custom service to send data.
3) Now i disconnect my device from my custom application and again try to connect my device as HID (from android Bluetooth settings).
4) But now all the services (both HID and custom services) are subscribed. (unexpected)

Behavior:
  •  Whatever services were subscribed during disconnection, it will be subscribed automatically when the device is connected again from host. So when the device is connected as HID device second time (above), custom service is also subscribed automatically.
Observations:
  • For sure I don't see any service subscription requests from the BLE host devices. (verified using adb logcat).
  •  I observed the same behavior in the samples/peripheral examples and using nRF connect app. When device first connects to the phone all the available services are subscribed automatically. But now i manually unsubscribe from one of the service (for eg HRS) and then disconnect the device. If i now connect to the device again then all the services except HRS is subscribed automatically where as i would expect HRS also to be subscribed.
  • When power reset is done on the device, then everything is fine until i try the same procedure above. But i think reset initializes the BLE stack again but this affects switching between the services dynamically in the application. 

Should applications handle the clearing of subscribed services during disconnection? Is this expected behavior of the BLE stack with in a power cycle? 

Thank you,
Dhananjay G J

Join devel@lists.zephyrproject.org to automatically receive all group messages.