• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Invalid peripherals returned by CBCentralManager after reconnect?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Invalid peripherals returned by CBCentralManager after reconnect?


  • Subject: Re: Invalid peripherals returned by CBCentralManager after reconnect?
  • From: Anthony Stevens <email@hidden>
  • Date: Wed, 17 Apr 2013 10:09:09 -0700

Etan,

I tried a 5 second then 15 second delay between disconnect-reconnect, but the timeout errors were still happening on iOS 6.1. This seemed more than enough time.  I'm running a 35 second delay test right now and will report back.

Thanks,
Anthony

On Apr 17, 2013, at 8:24 AM, Etan Kissling <email@hidden> wrote:

Anthony,

iOS already gives you a didDisconnected confirmation when only the logical link between your app and the controller is disconnected. The physical link is only disconnected about 2-3 seconds after all apps disconnected logically on iOS 5/6.1 and after about 30 seconds on iOS 6.0 if I recall correctly.

I think that if you reconnect too fast, the last disconnect request may still be pending in some driver code when the logical link is already reconnected, and that it kills the connection because it could not be aborted in time by the system.

What happens if you add 5 sec delays after the didDisconnect callback before you reconnect again?

Etan

On 17.04.2013, at 16:26, "Anthony Stevens" <email@hidden> wrote:

We're developing an app using iOS's low energy bluetooth stack.  The app connects with a peripheral device to periodically read data. All's great except for a persistent, yet random, immediate peripheral timeout on re-connect.  This is the error detail from CBCentralManager at didDisconnectPeripheral.

> Domain=CBErrorDomain 
> Code=6 
> NSLocalizedDescription=The connection has timed out unexpectedly

Each disconnect happens as soon as we call discoverServices on the newly connected peripheral (which has [peripheral isConnected] == YES).  When looking at the peripheral's logs, it shows it is not receiving a connection request from iOS over bluetooth.  When placed in a bluetooth isolation chamber, our bluetooth sniffer sees no bluetooth connection request packets for these timed-out connections…implying that CBCentralManager is replying in didConnectPeripheral with a peripheral that cannot really be connected.

We've written a test harness to reliably reproduce this issue.  The harness establishes a connection, transmits/receives some data, explicitly writes a characteristic to have the peripheral terminate the connection, then attempts to reconnect.  For every 100 connect-then-reconnects, an average 10 of these will experience a peripheral timeout on re-connect.  After 2-3 timeout on re-connect attempts, a lasting connection is established and the harness proceeds with its cycling. 

Here are the steps followed by the test harness:

1. Scan for a peripheral.
2. Stop scan
3. Call [CBCentralManager connectPeripheral] 
4. CBCentralManager replies on didConnectPeripheral.
5. Call discoverServices on peripheral
6. Read/write data to/from peripheral
7. Explicitly disconnect peripheral by writing a characteristic
8. CBCentralManager replies on didDisconnectPeripheral 
> CBErrorDomain Code=7
> The specified device has disconnected from us
9. Perform a reconnect by returning to step 1

Roughly 10% of the time when we perform the reconnect in step 9, we see the below happen 2-3 times before a successful reconnect

1-5 as above
6. CBCentralManager replies on didDisconnectPeripheral 
   > Domain=CBErrorDomain 
   > Code=6 
   > NSLocalizedDescription=The connection has timed out unexpectedly
7. Perform a reconnect by returning to step 1

We have also tried scanning just the first time during the harness testing and reusing the original peripheral.  The results are the same.  Our issue sounds suspiciously similar to the one posted by Maxim in February: http://lists.apple.com/archives/bluetooth-dev/2013/Feb/msg00090.html

Any guidance would be greatly appreciated.

Thank you, 
Anthony
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Invalid peripherals returned by CBCentralManager after reconnect?
      • From: Etan Kissling <email@hidden>
References: 
 >Invalid peripherals returned by CBCentralManager after reconnect? (From: Anthony Stevens <email@hidden>)
 >Re: Invalid peripherals returned by CBCentralManager after reconnect? (From: Etan Kissling <email@hidden>)

  • Prev by Date: Re: Invalid peripherals returned by CBCentralManager after reconnect?
  • Next by Date: Re: Invalid peripherals returned by CBCentralManager after reconnect?
  • Previous by thread: Re: Invalid peripherals returned by CBCentralManager after reconnect?
  • Next by thread: Re: Invalid peripherals returned by CBCentralManager after reconnect?
  • Index(es):
    • Date
    • Thread