Unsubscribe from indication before teardown? Is it notneeded/recommended/mandatory?

Folks,

I have my own implementation of controlling Nuki SL2.0 over Bluetooth GATT.

Everything is working as intended, but sometimes I have to restart the client’s bluetooth stack (ESP32).

My pseudo-procedure is:
1.) Connect to SL
2.) Subscribe to indication
3.) Send some command
4.) Retrieve some response
5.) Disconnect

Also, there is a BLE scanner, which queries the SL state in case it’s needed (based on TX power).

When I execute a Lock operation, after step5 above, client immediately tries to do a ReadState operation, which sometimes causes some UB in Bluetooth stack (esp32).

Something came into my mind: do I have to unsubscribe from indications before disconnect?

Thank you!

Hi Daniel,

No, it is not necessary to unsubscribe first.
The subscription is bound to the connection and invalidated once the connection is closed.

1 Like