CBCentralManager setNotifyValue: not working

大兔子大兔子 提交于 2019-12-12 22:34:32

问题


I am attempting to connect two iPhones using Core Bluetooth. One is running a peripheral, the other a central. It seems the two devices are connected. And every method is getting called in the typical control flow up until peripheralManager:central:didSubscribeToCharacteristic: does not get called on the peripheral side and peripheral: didUpdateValueForCharacteristic: error: does not get called on the central side. However, If I call readValueForCharacteristic: it works and grabs the first value, but it does not seem to register for notifications and we get an "unknown error 2" in the updateValueForCharacteristic: method. I have been going through all the sample code I could find (heart monitor, business card, etc.) and my code is the exact same yet I cannot get it to work.

Anyone have any ideas on what the issue could be?


回答1:


I resolved this a while ago but I thought I would post a solution since it may be useful to people going forward... The solution to this problem had to do with the bluetooth caching. Basically, the issue was that something had cached improperly... I restarted my phone, which clears the BLE cache, and did the same for the phone that I was testing it with and voila it worked. I recommend if people have these sorts of BLE issues (especially if you have been registering your phone as both a peripheral and a central for similar code) that you clear your cache by restarting!



来源:https://stackoverflow.com/questions/17360347/cbcentralmanager-setnotifyvalue-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!