Re: BLE central device as GATT server
Re: BLE central device as GATT server
- Subject: Re: BLE central device as GATT server
- From: Chris Miles <email@hidden>
- Date: Wed, 13 Nov 2013 10:28:45 +1100
So you suggesting a scenario where the iOS device discovers and connects to an external device for the purposes of informing the external device that the iOS device is nearby. Then the intention is for the external device to immediately initiate a connection back to the iOS device, connecting to some service published by the iOS device.
I believe that kind of scenario is possible, it is similar to the test scenarios I had described. When the iOS app successfully connects to the external device, it can publish its service and wait for the external device to connect back to it.
Perhaps there is a bit more to it, though. Can you describe a real world use case, that may better explain the complexities to solve?
Cheers,
Chris
On 13 Nov 2013, at 10:16 am, Andras Kovi <email@hidden> wrote:
> I guess what Sergey is proposing is a little more convoluted and impossible to simulate with solely iOS devices. So as I see the scenario in question is the following:
>
> 1. the iOS device connects to an external peripheral (key fob, BLE112 module, anything)
> 2. the peripheral stats acting as GATT client and starts discovering the iOS device’s (now acting as GATT server) services (battery, time, ANCS)
> 3. use CBPeripheralManager to extend the services provided in GATT server mode
>
> 2 and 3 need to be confirmed or confuted. Unfortunately, this is impossible to carry out with iOS devices as the Core Bluetooth API does not allow it but other BLE modules should be able to try as long as their stack supports.
>
> So far I’ve been thinking of peripherals as receivers and centrals as initiators, I have never thought the roles could change once the connection is established. Brilliant!
>
> Sergey, you’ve got my respect for coming up with this scheme! I’m looking forward to hearing from someone implementing it as I may not have enough time in the near future to do it.
>
> Regards,
> Andras
>
> On 2013.11.12., at 23:50, Chris Miles <email@hidden> wrote:
>
>> Yes, case 2 as you describe it is certainly possible. iOS can act in both Central and Peripheral roles simultaneously.
>>
>> In fact, an application can be both Central and Peripheral simultaneously. I have tested an iOS application that acts effectively as a BLE proxy. It connects to a peripheral (heart rate monitor in my test case) and reads values continuously (via notifications) while also publishing the HRM values as a service of its own. Another device could connect to the iOS device and read the proxied HRM values (via notifications).
>>
>> I have also tested another iOS application which acted as both Central and Peripheral. Two iOS devices could connect to each other, both servicing the other, responding to read/write requests simultaneously.
>>
>> I hope that helps.
>>
>> Cheers,
>> Chris Miles
>>
>> On 13 Nov 2013, at 7:59 am, Mozhaev Sergey-BDP687 <email@hidden> wrote:
>>
>>> 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.
>>>
>>>
>
_______________________________________________
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