5

I am having some major trouble with my Bluetooth Low Energy application sometimes dont manage to connect to my device (described in thread).

I need to wipe out all stored data from previous connections before running my application, and as far as I know, this can only be done by rebooting the phone. Is there any other way, preferably programatically, to do this?

Thank you

Community
  • 1
  • 1
chwi
  • 2,752
  • 2
  • 41
  • 66
  • Data the iPhone appearently stores when connecting to a bluetooth peripheral, since rebooting clears some cache/memory that affects my app – chwi Jul 25 '12 at 22:16
  • When you call cancelConnection, any cached data should be reset. Are you seeing something different? – yuklai Jul 26 '12 at 01:14
  • I do not know what it is storing, but something is stored since rebooting works for my problem, don't you think? – chwi Jul 26 '12 at 07:32
  • Sorry I'm confused. I assume you don't want to reboot. But I'm not sure how rebooting solves your other problem, ie devices are duplicated when being discovered on multiple discovery callbacks. Are u saying you don't see the above behavior when you reboot the phone in between each discovery? – yuklai Jul 26 '12 at 16:00
  • That's correct, and don't worry, I am confused as well :) – chwi Jul 27 '12 at 02:49
  • Ok, again, cancel connection should clear cached data. You didn't mention if you tried it or not. Anyways, I posted a question on your other problem about code that you set in your discover parameters as I'd like to give that a try and see if I can repro that problem. Thx. – yuklai Jul 27 '12 at 03:33
  • Sorry, forgot to say that I have been using cancel connection all the time. On your other comment, I have answered that the code is already in the post. Thank you for your interest in this, really appreciated – chwi Jul 27 '12 at 05:27
  • I've been fighting with this. iOS maintains BLE state behind the scenes, independently of any apps. Due to bugs, it sometimes gets in bad states. I've found cases where CoreBluetooth would no longer discover services, and I've had to fully reboot the iPhone/iPad to recover. I don't know of any workaround. This is system-level state, not data stored within the app; there's not a whole lot you can do about it except to try to avoid triggering the bugs in the first place (which is challenging). – Glenn Maynard Jul 30 '12 at 23:50
  • @Wilhelmsen I am wondering what is the current status of this problem? I am a BLE peripheral firmware developer, not an iOS developer. But we now have similar issues where BLE peripheral clears itself and disconnected from iOS. In iOS, we also go to settings->bluetooth and choose to forget that device. Yet, iOS still thinks it knows this device when it is broadcasting and simply connects to it without issuing a pairing message. – foresightyj May 16 '13 at 10:17
  • @foresightyj If you can forget the device in bluetooth settings, you are not developing BLE. The only way to see BLE devices is programatically, and not in iOS. The problem on my side still persists, and I haven't found a solution. – chwi Jun 05 '13 at 09:04
  • @Wilhelmsen Have you solved your issue?. If solved please post as an answer. – Suresh Jul 29 '14 at 07:27
  • @suresh, unfortunately not – chwi Jul 29 '14 at 12:37
  • It happens to me as well. It seems the CBPeripheral services are stored in the iPhone until I turn the BT OFF and ON again. – marcelosalloum Nov 18 '15 at 17:54

1 Answers1

3

I am having the same issue and have found the steps to reproduce it.

It is 100% reproducible when you transmit data to the peripheral with

[peripheral writeValue:x forCharacteristic:y type:CBCharacteristicWriteWithoutResponse];

while the peripheral goes out of range and disconnects. After this happens no more services are returned by BLE devices, and only a reboot fixes the problem. This doesn't happen if the peripheral goes out of range and comes back in without transmitting data to it or if

[peripheral writeValue:x forCharacteristic:y type:CBCharacteristicWriteWithResponse];

is used...

Other disconnects don't seem to affect it, such as powering down the peripheral and powering it back up while in range even while transmitting data...

I know this isn't an answer but it looks like I can't comment for some reason.

Hope this helps debugging though.

peterson79
  • 31
  • 3
  • Thank you! I experienced the exact same thing. Only problem is that I don't think I have time to `WriteWithResponse` since my application is flying a helicopter, but I will try it in the near future and give you my respons. Also, I guess you can't comment until you have enough rep. – chwi Jul 02 '13 at 11:39
  • I tried writing with `...WithResponse` but it didn't help me much :\ – chwi Jul 31 '13 at 11:56
  • Could someone tell me where to put the writevalue statement of this answer, and what are the values of x and y? Thanks – KiloOne Feb 16 '17 at 01:01