iosnode.jsbluetoothbluetooth-lowenergybleno

Unsubscribe any subscribed characteristics on disconnection event in bleno


I wrote simple iOS app to communicate with raspberry pi via Bluetooth Low Energy, the application subscribes to characteristic, to get new data every now and then. When I disconnect my app manually via dedicated methods, everything is ok, bleno gets characteristic unsubscribed and disconnected.

When the app was in foreground and the task switcher is engaged, I terminate the app, the applicationWillTerminate event is fired, then unsubscribe method is called and app disconnetcs because of termination.

The problem is when I terminate app from task switcher when the app was in background, as the applicationWillTerminate event isn't fired.

So, I want my bleno "server" to unsubscribe any subscribed characteristics by the device that was disconnected.

As it is node.js I suppose it can be done but i'm not node.js expert.

Please help! Thanks!


Solution

  • As I wasn't following the github repo of sandeepmistry/bleno I have missed the obvious solution and have emailed sandeepmistry himself. Today's morning he replied with an answer.

    On github adi1133 has opened the issue on Aug 10 and sandeepmistry has resolved the the issue on Oct 2.

    Solution is now incorporated into the bleno itself. Link to the issue below.

    Characteristic.onUnsubscribe not called on disconnect

    That's it. Thanks!