Re: Central and Peripheral at the same time?
Re: Central and Peripheral at the same time?
- Subject: Re: Central and Peripheral at the same time?
- From: Etan Kissling <email@hidden>
- Date: Fri, 18 Jan 2013 13:36:19 +0000
- Thread-topic: Central and Peripheral at the same time?
(resending as plain text to reduce message size)
On 18.01.2013, at 14:33, Etan Kissling <email@hidden> wrote:
> Allan,
>
> extra data can only be put in the CBAdvertisementDataOverflowServiceUUIDsKey.
>
> /*!
> * @constant CBAdvertisementDataOverflowServiceUUIDsKey
> *
> * @discussion A list of one or more <code>CBUUID</code> objects, representing <code>CBService</code> UUIDs that were
> * found in the "overflow" area of the advertising data. Due to the nature of the data stored in this area,
> * UUIDs listed here are "best effort" and may not always be accurate.
> *
> * @see startAdvertising:
> *
> */
> CB_EXTERN NSString * const CBAdvertisementDataOverflowServiceUUIDsKey NS_AVAILABLE(NA, 6_0);
>
> Regarding long names, the standard scheme is to put a truncated version into the advertisement data.
> In your case, the first 28 bytes of the name.
>
> As soon as you connect to the peripheral, iOS will read the Device Name characteristic to get the full name of your peripheral.
> This name is then cached - as long as your peripheral is using the same Bluetooth address, the name from the characteristic
> is displayed, even when not connected.
>
> Note that you cannot control this behavior using CoreBluetooth. In fact, you cannot even read the name characteristic yourself,
> and need to trust that the peripheral.name property is accurate.
>
> To know when the peripheral name has been fully loaded, you can use the peripheralDidUpdateName: delegate method.
> Have not used it, so no comment about whether it works.
>
> /*!
> * @method peripheralDidUpdateName:
> *
> * @param peripheral The peripheral providing this update.
> *
> * @discussion This method is invoked when the @link name @/link of <i>peripheral</i> changes.
> */
> - (void)peripheralDidUpdateName:(CBPeripheral *)peripheral NS_AVAILABLE(NA, 6_0);
>
>
> Etan
>
>
>
> On 18.01.2013, at 14:27, Allan Young <email@hidden>
> wrote:
>
>> Hi Etan,
>>
>> On iOS, I observed that if I put a 32-byte value into CBAdvertisementDataLocalNameKey, the Central was only able to see about 28 or 29 bytes of it. Is there a way in iOS to retrieve all of it?
>>
>> -Allan
>>
>> From: Etan Kissling <email@hidden>
>> Date: Fri, 18 Jan 2013 05:20:48 -0800
>> To: Allan Morgan Young <email@hidden>
>> Cc: "email@hidden" <email@hidden>
>> Subject: Re: Central and Peripheral at the same time?
>>
>> Allan,
>>
>> You could first scan and list the peripherals without the additional user interface.
>> After scanning for 5 seconds or so, connect to each one to retrieve additional info, and update the user interface.
>> This way, the user interface does not feel empty and one can see that something is happening (like a web browser -
>> it doesn't wait until all images are loaded to display a web page).
>>
>> Because I don't know the exact use case, I cannot recommend a specific behavior here.
>> It all depends on the user experience that you want to deliver.
>>
>> Advertising data is limited. A 32-byte object cannot be put there currently. Note that when using the CBPeripheralManager,
>> you can actually put more data in an advertising packet than is actually defined in the Bluetooth Core Spec.
>> However, this data can only be read by other iOS devices.
>>
>> Etan
>>
>> On 16.01.2013, at 18:57, Allan Young <email@hidden> wrote:
>>
>>> Hi Etan,
>>>
>>> > A solution for your problem would be to first build a list of devices to connect, then stop scanning and then connecting to all peripherals.
>>>
>>> So, for a Central that might want to connect to multiple Peripherals, would you advise scanning for some period of time, stop scanning, and then update the user interface with the list of discovered Peripherals?
>>>
>>> Currently, I'm connecting as I'm scanning. Indeed, I'm scanning/connecting while this particular user interface is showing, so that I can dynamically add newly discovered Peripherals to my UI…and I need to connect to them when found, so that I can query them for some information to show in the UI.
>>>
>>> The advertising data itself does not allow enough room for meaningful data for my UI…this is why I was connecting whenever I found a new peripheral…that is, in order to be able to read a characteristic so that my UI can show something meaningful about the peripheral.
>>>
>>> But perhaps this isn't a good approach.
>>>
>>> Maybe, then, I should scan for 5 seconds or so, building a list of CBPeripherals, then connect to each one to query for additional info, and to allow the user to interact with each one (via a writeable characteristic and notifications/indications).
>>>
>>> Thoughts?
>>>
>>> Also, is the custom data in the advertising packet really limited to something like 28 bytes or so? I have a 32-byte object that I would love to expose in the advertising packet.
>>>
>>> -Allan
>>>
>>> From: Etan Kissling <email@hidden>
>>> Date: Wed, 16 Jan 2013 09:26:35 -0800
>>> To: Allan Morgan Young <email@hidden>
>>> Cc: "email@hidden" <email@hidden>, Darren Jones <email@hidden>, Joakim Linde <email@hidden>
>>> Subject: Re: Central and Peripheral at the same time?
>>>
>>> Allan,
>>>
>>> Advertising does normally stop when a connection request is received. Not sure about iOS, but there is no way to stop advertising with the API currently. Have to check that with a sniffer.
>>>
>>> When you program the central side, connecting becomes very slow while scanning. A solution for your problem would be to first build a list of devices to connect, then stop scanning and then connecting to all peripherals.
>>>
>>> Etan
>>>
>>> On 16.01.2013, at 17:46, "Allan Young" <email@hidden> wrote:
>>>
>>>> Etan,
>>>>
>>>> Regarding your comment:
>>>>
>>>> > Also don't forget to stop scanning and advertising as soon as you establish a connection.
>>>>
>>>> …is it really necessary to stop scanning and advertising when the connection is established?
>>>>
>>>> From the peripheral side, what if multiple centrals want access to my data?
>>>>
>>>> And from the central side, what if I want to get data from a number of peripherals advertising the same service/characteristics? To use a medical/sports example, should I be able to monitor the heart rates reported by a number of different peripherals?
>>>>
>>>> Is this not possible?
>>>>
>>>> Thanks.
>>>>
>>>> -Allan
>>>>
>>>> From: Darren Jones <email@hidden>
>>>> Date: Tue, 15 Jan 2013 23:53:09 -0800
>>>> To: Joakim Linde <email@hidden>
>>>> Cc: "email@hidden" <email@hidden>
>>>> Subject: Re: Central and Peripheral at the same time?
>>>>
>>>> Hi Joakim,
>>>>
>>>> Bug number: 12963322
>>>>
>>>>
>>>> Sent from my iPhone 5
>>>>
>>>> On 16 Jan 2013, at 03:06, Joakim Linde <email@hidden> wrote:
>>>>
>>>>>
>>>>> Hi Darren,
>>>>>
>>>>> What's the bug report number for this?
>>>>>
>>>>> Thanks,
>>>>> Joakim
>>>>>
>>>>> On Jan 11, 2013, at 8:23 AM, Darren Jones <email@hidden> wrote:
>>>>>
>>>>>> Thanks Etan,
>>>>>>
>>>>>> I have actually filed a bug report for the backgrounding of bluetooth-central stopping.
>>>>>> I hope they fix it soon as there's so much more potential for apps when continuous background scanning is available.
>>>>>>
>>>>>> On 11 Jan 2013, at 16:21, Etan Kissling <email@hidden> wrote:
>>>>>>
>>>>>>> Darren,
>>>>>>>
>>>>>>> OK. If you want to enable background scanning and advertising, just add the bluetooth-central and bluetooth-peripheral keys
>>>>>>> to the UIBackgroundModes array in your Info.plist.
>>>>>>>
>>>>>>> http://developer.apple.com/library/ios/#documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW22
>>>>>>>
>>>>>>> bluetooth-central
>>>>>>> The app uses the CoreBluetooth framework to communicate with a Bluetooth accessory while in the background.
>>>>>>> This value is supported in iOS 5.0 and later.
>>>>>>> bluetooth-peripheral
>>>>>>> The app uses the CoreBluetooth framework to communicate in peripheral mode with a Bluetooth accessory.
>>>>>>> This value is supported in iOS 6.0 and later.
>>>>>>> You will then receive the callbacks for around 45-60 minutes of background mode. After this, a bug
>>>>>>> prevents to receive more callbacks, as the connection is terminated as soon as your app is purged
>>>>>>> from the memory. After relaunching the app, scanning should resume to function properly.
>>>>>>>
>>>>>>> Etan
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On 11.01.2013, at 17:14, Darren Jones <email@hidden>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Thank you. I want to use non pairing so CoreBluetooth is the way.
>>>>>>>> I'm glad it's possible. I wasn't sure if background scanning and advertising would be allowed.
>>>>>>>>
>>>>>>>>
>>>>>>>> On 11 Jan 2013, at 16:02, Etan Kissling <email@hidden> wrote:
>>>>>>>>
>>>>>>>>> Darren,
>>>>>>>>>
>>>>>>>>> If you want to perform iPhone to iPhone communication only, I suggest using GameKit for it.
>>>>>>>>> You will have an increased throughput, as classic Bluetooth is used as a transport, and don't have
>>>>>>>>> to worry about specifying who is master and who is slave.
>>>>>>>>>
>>>>>>>>> If you want to stay with CoreBluetooth: at least from the Bluetooth Core Specification, a device is
>>>>>>>>> allowed to scan and advertise at the same time. I have not yet tried it under iOS, but can tell for your
>>>>>>>>> background requirement that scanning times are pretty slow while backgrounded (around 55x
>>>>>>>>> advertisement interval). Also don't forget to stop scanning and advertising as soon as you establish
>>>>>>>>> a connection.
>>>>>>>>>
>>>>>>>>> Etan
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 10.01.2013, at 23:59, Darren Jones <email@hidden> wrote:
>>>>>>>>>
>>>>>>>>>> Is it possible to use CBCentral scanning and CBPeripheral advertising at the same time? (Also in the background)
>>>>>>>>>>
>>>>>>>>>> If I wanted 2 random iPhones to communicate and both where set to Central or both to Peripheral they wouldn't see each other. I'd like to remove that they would both have to know which method to activate.
>>>>>>>>>>
>>>>>>>>>> Is that possible?
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>>
>>>>>>>>>> Sent from my iPhone 5
>>>>>>>>>>
>>
>
_______________________________________________
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