• 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: iOS peripheral as GATT Client
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iOS peripheral as GATT Client


  • Subject: Re: iOS peripheral as GATT Client
  • From: Martijn The <email@hidden>
  • Date: Tue, 13 Jan 2015 17:53:45 -0800

I think you always have to call -connectPeripheral: to "virtually" connect your app to it. Not 100% sure TBH.

Martijn

Pebble: E-Paper Watch for iPhone and Android
http://www.getpebble.com
Tel: +1 (650) 308-9383

On Tue, Jan 13, 2015 at 5:38 PM, Roland King <email@hidden> wrote:
That’s very clever, thanks for that. I was just thinking through that process, I assume that in this instance the CBPeripheral you retrieve counts as already connected and you just start calling discovery and other methods on it, you don’t, you can’t, call connectPeripheral:options: on it first. 

On 13 Jan 2015, at 00:42, Martijn The <email@hidden> wrote:

> I’m reasonably sure however looking at the iOS functions that you cannot have an iOS device be a peripheral and, when a central connects to it, use that connected central as a server, discover its characteristics, read and write to it.

Unfortunately, there is no "-centralDidConnect:" delegate method. So just letting the other device connect to the iOS device is not enough to get any delegate methods fired on your CBPeripheralManagerDelegate.

But... once you do get hold of a CBCentral object -- either through -peripheralManager:central:didSubscribeToCharacteristic: or via the CBATTRequest's `central` property that you get when receiving a read/write -- you can use the identifier of that CBCentral object and use it with CBCentralManager's -retrievePeripheralsWithIdentifiers: to get the CBPeripheral for the same device. Once you've got that you can do service discovery and read/write etc.

Agree it's extremely clumsy, but not impossible :)


Martijn

Pebble: E-Paper Watch for iPhone and Android
http://www.getpebble.com
Tel: +1 (650) 308-9383

On Sun, Jan 11, 2015 at 2:11 AM, Roland King <email@hidden> wrote:
On embedded hardware platforms it doesn’t actually matter which device is peripheral and which is central, once they’ve connected either or both can act as GATT server or client. On the Nordic platform I use for instance you can call GATT client and server functions whether you are running as central or peripheral.

I’m reasonably sure however looking at the iOS functions that you cannot have an iOS device be a peripheral and, when a central connects to it, use that connected central as a server, discover its characteristics, read and write to it. The only functions to perform that are on CBPeripheral and the only way to get a CBPeripheral is to be a CBCentralManager. If you are a peripheral, ie a CBPeripheralManager, you get the central (when it asks for something) but there’s no API on CBCentral which allows you to treat it as a GATT server, even though it is one.

Seems that iOS ties Central to Client and Peripheral to Server very tightly. Is this correct or is there a way to be CBPeripheralManager and still, when connected, be a GATT client of the connected central?

Regrettably in this particular instance the device the phone is connecting to has to be a central, so the phone needs to be a peripheral.


 _______________________________________________
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

References: 
 >iOS peripheral as GATT Client (From: Roland King <email@hidden>)
 >Re: iOS peripheral as GATT Client (From: Martijn The <email@hidden>)
 >Re: iOS peripheral as GATT Client (From: Roland King <email@hidden>)

  • Prev by Date: Re: iOS peripheral as GATT Client
  • Next by Date: Re: Maximum number of bonded devise / bonding keys
  • Previous by thread: Re: iOS peripheral as GATT Client
  • Next by thread: Maximum number of bonded devise / bonding keys
  • Index(es):
    • Date
    • Thread