简体   繁体   English

取消订阅bleno中的断开连接事件的所有已订阅特征

[英]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. 我编写了一个简单的iOS应用程序,以通过Bluetooth Low Energy与树莓派进行通信,该应用程序订阅了该应用程序的特性,从而不时获取新数据。 When I disconnect my app manually via dedicated methods, everything is ok, bleno gets characteristic unsubscribed and disconnected. 当我通过专用方法手动断开我的应用程序时,一切正常,bleno变成典型的未订阅和断开连接。

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. 当应用程序处于前台并且使用了任务切换器时,我终止了该应用程序,触发了applicationWillTerminate事件,然后调用了unsubscribe方法,并且由于终止而导致应用程序断开连接。

The problem is when I terminate app from task switcher when the app was in background, as the applicationWillTerminate event isn't fired. 问题是当我在后台运行时从任务切换器终止应用程序时,因为未触发applicationWillTerminate事件。

So, I want my bleno "server" to unsubscribe any subscribed characteristics by the device that was disconnected. 因此,我希望我的bleno“服务器”取消订阅已断开连接的设备的所有已订阅特征。

As it is node.js I suppose it can be done but i'm not node.js expert. 由于它是node.js,我想可以做到,但我不是node.js专家。

Please help! 请帮忙! Thanks! 谢谢!

As I wasn't following the github repo of sandeepmistry/bleno I have missed the obvious solution and have emailed sandeepmistry himself. 因为我没有关注sandeepmistry / bleno的github存储库,所以我错过了明显的解决方案,并亲自给sandeepmistry发送了电子邮件。 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. 在github上,adi1133已于8月10日开放该问题,sandeepmistry已于10月2日解决了该问题。

Solution is now incorporated into the bleno itself. 现在,解决方案已合并到bleno本身中。 Link to the issue below. 链接到下面的问题。

Characteristic.onUnsubscribe not called on disconnect 在断开连接时未调用Characteristic.onUnsubscribe

That's it. 而已。 Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM