RE: BLE central device as GATT server
RE: BLE central device as GATT server
- Subject: RE: BLE central device as GATT server
- From: Mozhaev Sergey-BDP687 <email@hidden>
- Date: Tue, 12 Nov 2013 20:59:26 +0000
- Thread-topic: BLE central device as GATT server
Hi all.
Let me share my thoughts on this question.
I'm not an iOS developer, mostly I'm embedded software engineer, and what I'm saying here about iOS is just my understanding based on knowledge of Bluetooth spec, not on iOS experience.
Stephan, you are asking: "I would like to know if it's possible in iOS to implement a GATT server when acting as a central". In my opinion, you don't have to do anything to implement GATT server, it's already implemented in iOS internals. And it already has Battery, Time and ANCS services available to any GATT client that wants to use them. You can use CBPeripheralManager to add/remove your own proprietary services if you wish.
But another question if how to make these services available? Two cases are possible here:
1) When iOS device is not yet connected to any Bluetooth LE device and wants to make its services available. Then you have to use CBPeripheralManager to start advertising. Then, some remote device can establish connection to iOS. So, iOS becomes Peripheral and GATT Server.
2) iOS device is already connected to an accessory, and iOS is Central in this connection. iOS is GATT Client and accessory is GATT Server. Nothing prevents accessory from taking the role of GATT Client and starting service discovery to find GATT services available on iOS. If iOS supports GATT Server (and it really does, according to documentation), it will respond with a list of supported services. Then, accessory can start using these services.
I think case 2) is more suitable to what you're trying to achieve.
Actually, when you say " from the nRF8001, I was able to connect to the Time Service published by iOS", I guess you have set Bluetooth LE link from iOS side (iOS being Central and nRF8001 - Peripheral) and then you established GATT connection from nRF8001 side. BTW, could you share more information about these steps and how it worked? and correct me if I am wrong in my assumptions.
My understanding of Central and Peripheral roles and GATT Client and Server is the following:
Cenral and Peripheral only pertain to the stage of connection establishment. Central initiates the establishment of a physical connection and becomes Master. Peripheral accepts connection requests and becomes Slave. Once this physical connection is established, both devices can be GATT Client and/or GATT Server. Though it is more natural for Peripherals to be Servers.
May be names of classes in Core Bluetooth are a bit misleading. Because actually CBCentralManager (and its associated delegate) also implements GATT client functionality and CBPeripheralManager (and peripheral delegate) also implements GATT server functionality. But, if you already has physical link in Central role, you can deploy CBPeripheralManager for only GATT server functionality without using any Peripheral role-specific things (like advertising). And vice versa, in Peripheral role you can use CBCentralManager to perform GATT service discovery and etc. Though, when you're Peripheral in a connection (i.e. you're Slave), you can't connect to any other device, you can only communicate with device you're already connected to. For more details, see Bluetooth Core Spec 4.0, Volume 6, Part B, chapter 1.1 - Link Layer States.
Hope it wasn't very boring and makes sense.
P.S. I would very much appreciate if someone could try case 2) and check that it really works as I said.
Best regards,
Sergey Mozhaev,
Senior Software Engineer,
Motorola Solutions Inc.
-----Original Message-----
From: bluetooth-dev-bounces+bdp687=email@hidden [mailto:bluetooth-dev-bounces+bdp687=email@hidden] On Behalf Of Walter Stephan
Sent: Monday, November 11, 2013 7:15 PM
To: email@hidden
Subject: AW: BLE central device as GATT server
András, thanks for being patient and explaining this to me!
So the answer to my original question is that iOS cannot act as a (proprietary) GATT server while in a Central role.
(I was confused because from the nRF8001, I was able to connect to the Time Service published by iOS.)
You are right that the nRF8001 cannot scan or initiate a connection.
In conclusion, I will have to implement my functionality as a service on the accessory.
Best regards,
--Stephan Walter
> Even thought the specification may allow you to create a GATT server
> on the central side (as I understood it from the specifiaction), the
> iOS Core Bluetooth does not provide this functionality. The DB is tied
> to the CBPeripheraManager which is the peripheral role. At the same
> time "The nRF8001 is a pure BLE Peripheral device, and it can not be
> used as a Central."
> (https://devzone.nordicsemi.com/index.php/can-the-nrf8001-
> be-used-as-a-central) So I suppose the nRF8001 cannot scan for devices
> or start a connection. As a consequence, it is not able to connect to
> the GATT server implemented by the CBPeripheralManager.
>
> So what you can do:
> - the mRF8001 must advertise
> - the iOS device must scan for the nRF8001
> - the iOS device must connect the nRF8001 and discover its services.
>
> At this point it's up to you how you implement the communication. It
> is possible to have a single service with a single characteristic on
> the
> nRF8001 side and implement a higher level protocol that implements a
> database in a GATT serverish way. This is not preferred for several
> reasons (this is not the usual way of doing things and you lose most
> of the optimizations provided by the underlying stacks) but it's your
> choice.
_______________________________________________
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