RE: CBPeripheralManager Implementation
RE: CBPeripheralManager Implementation
- Subject: RE: CBPeripheralManager Implementation
- From: Jonathan Rosen <email@hidden>
- Date: Mon, 20 Aug 2012 08:31:42 -0700
Hi Justin-
Have you added services and characteristics to your CBPeripheral? I have some code that is working with the TI Dev Kit.
Note that "Discover Characteristics BY UUID" doesn't seem to work as expected with CBPeripheralManager, in that it won't return a handle for a specific UUID, as far as I can tell. However, you can dump a list of Characteristics, and then access their handles in a predictable way from there.
If you paste some code to iOS 6 Apple Developer Forums, I can possibly help debug.
Thanks,
Jon
On Mon, Aug 20, 2012 at 8:01 AM,
<email@hidden> wrote:
Send Bluetooth-dev mailing list submissions to
email@hidden
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.apple.com/mailman/listinfo/bluetooth-dev
or, via email, send a message with subject or body 'help' to
email@hidden
You can reach the person managing the list at
email@hidden
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Bluetooth-dev digest..."
Today's Topics:
1. CBPeripheralManager Implementation (R. Justin)
2. Re: Running timers in background of BLE app (Joakim Linde)
3. Re: Not receiving BLE events in background (m.kroll)
----------------------------------------------------------------------
Message: 1
Date: Sun, 19 Aug 2012 22:26:48 -0700
From: "R. Justin" <email@hidden>
To: email@hidden
Subject: CBPeripheralManager Implementation
Message-ID:
<CAJvzaDbOiX8NtHtPOh9Vw0fqmUiuP7k=email@hidden>
Content-Type: text/plain; charset="iso-8859-1"
Hi,
We're having some trouble implementing CBPeripheralManager. We have
studied the slides and video from WWDC, the api diffs, and the docs of
course. We are still running into a few problems:
1) Using the nordic 8002 dev kit client hw, we are able to discover our
advertising ipad running iOS6, however we are unable to bond to the device.
The hw reports the iOS server is in advertising mode and is not bondable.
2) When trying to connect from another ble iPhone running a
cbcentralmanager, we are unable to discover our advertising iPad. Our
cbcentralmanager code has been successful at connecting to other hw ble
peripherals however the code is unable to discover our iPad with the
cbperipheralmanager advertising.
On our iPad that is acting as the server, we are trying just to implement
the 0x1811 alert notification service. Do we need to also advertise other
required services and build a full tree? Are there limitations on what an
iphone running cbcentralmanager will discover? Are there some tricks that
are not explained in the wwdc slides and video?
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.apple.com/mailman/private/bluetooth-dev/attachments/20120819/dc4f8ecf/attachment.html>
------------------------------
Message: 2
Date: Tue, 14 Aug 2012 23:09:27 -0700
From: Joakim Linde <email@hidden>
To: Nick Moen <email@hidden>
Cc: bluetooth-dev Bluetooth <email@hidden>
Subject: Re: Running timers in background of BLE app
Message-ID: <email@hidden">email@hidden>
Content-Type: text/plain; charset="utf-8"
Hi Nick,
The app will only get killed if it's memory is needed for something else. Otherwise, it will continue to live, although in a suspended state.
-- Joakim
On Aug 13, 2012, at 10:08 AM, Nick Moen <email@hidden> wrote:
> Hi Joakim,
> Does that mean that the app will not be killed after a 10 minute background period? I have read that if you are not connected to a BLE device, iOS will kill the BLE app after 10-15 minutes in the background. Sorry about all the questions, I am just trying to gain a thorough understanding of the background process.
>
> Nick
>
> From: Joakim Linde [mailto:email@hidden]
> Sent: Friday, August 10, 2012 11:33 AM
> To: Nick Moen
> Cc: Michael Kroll; bluetooth-dev Bluetooth; Glenn Bachmann
> Subject: Re: Running timers in background of BLE app
>
>
> Hi Nick,
>
> It will run as long as the App is running (foregrounded or backgrounded). The method startScanForPeripheralWithServices does not have a timeout, it will run as long as the app is alive.
>
> Thanks,
> Joakim
>
>
> On Aug 10, 2012, at 6:38 AM, Nick Moen <email@hidden> wrote:
>
>
> Thanks Joakim,
> Let me ask another question then. If in a app the subscribes to Core Bluetooth I start a longtime background running task, what are the time running time limits on this background task? Thanks again.
>
> Nick
>
> From: Joakim Linde [mailto:email@hidden]
> Sent: Thursday, August 09, 2012 12:05 PM
> To: Nick Moen
> Cc: Michael Kroll; bluetooth-dev Bluetooth; Glenn Bachmann
> Subject: Re: Running timers in background of BLE app
>
>
> Nick,
>
> Core Bluetooth will allow you to run in the background in order for the app to handle events from Core Bluetooth. It does not give the App a 'carte blanche' to run in the background. Meaning, timers will not fire when the App is in the background.
>
> Thanks,
> Joakim
>
>
> On Aug 9, 2012, at 9:42 AM, Glenn Bachmann wrote:
>
>
>
> Local notifications won't by themselves keep your app perpetually alive and running in the background. They will give you an opportunity to do a short burst of processing when they fire, but then your app will go right back to sleep. If just accomplishing this meets the original posters needs, then it may be something of interest.
>
> Glenn
>
> On Aug 9, 2012, at 11:48 AM, Michael Kroll wrote:
>
>
>
> What about local notifications?
>
> Regards,
> Dr. Michael Kroll.
> --------------------
> Blog: http://www.mkroll.mobi
> Forum: http://forum.mkroll.mobi
>
> Sent from iPhone.
>
> On 09.08.2012, at 17:29, Nick Moen <email@hidden> wrote:
>
>> Hi All,
>> I have an app that is currently scanning for BLE devices in the background. This part is working well, but I now need to trigger an event every 15 minutes or so. If the app subscribes to bluetooth-central, can Timers be run in the background? If not does anyone have any recommendations? Thanks in advance for any information.
>>
>>
>> Nick
>>
>> _______________________________________________
>> 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
>
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.apple.com/mailman/private/bluetooth-dev/attachments/20120814/671eace4/attachment.html>
------------------------------
Message: 3
Date: Mon, 20 Aug 2012 08:08:03 +0000 (GMT)
From: "m.kroll" <email@hidden>
To: Joakim Linde <email@hidden>
Cc: email@hidden
Subject: Re: Not receiving BLE events in background
Message-ID: <email@hidden">email@hidden>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Hello Joakim,
what I did so far, running on an iPhone4S with iOS5.1.1 installed:
1. Created an Xcode Project with *-Info.plist settings as follows:
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
<string>bluetooth-le</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
</array>
2. In the method - (void)applicationDidEnterBackground:(UIApplication *)application of my AppDelegate I'm calling:
NSArray *uuidArray = [NSArray arrayWithObjects:[CBUUID UUIDWithString:myUUIDtoScanFor], nil];
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
[centralManager scanForPeripheralsWithServices:uuidArray options:options];
where the central is initialized like this:
centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_main_queue()];
but
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
is never called.
I reprogrammed my peripherals using a BlueGiga BLE112 module to use a 20ms advertising interval, but I still can't see them in my app.
Is point 2. the problem, that I need to invoke the scan method before?
Any help appreciated.
Kind Regards/Mit freundlichen Grüssen,
Dr. Michael Kroll.
---
Blog: http://www.mkroll.mobi
Forum: http://forum.mkroll.mobi
On Aug 17, 2012, at 05:47 PM, Joakim Linde <email@hidden> wrote:
Hi Michael,
Not sure I got all the details of your issue.
Scanning for advertising peripherals is boosted then the app is in the foreground compared to a backgrounded app. A good "rule of thumb" for how long it will take to discover a device when the app is in the background is 55 times the advertising interval of the peripheral. So, if a peripheral is advertising every 20 ms it would be discovered in about 1 second on average. However, it it is only advertising once a second it would take a whole minute for it to be discovered.
Also, please note that you will only be able to discover the device when in the background, not track it. The app will only get the advertising packet the first advertising packet when backgrounded, the rest will be filtered out in order to save power.
Hope this helps.
Thanks,
Joakim
On Aug 17, 2012, at 6:45 AM, m.kroll <email@hidden> wrote:
Ah ok thanks!
@Joakim: Could you please confirm, that the background scanning issues I'm dealing with are based on the fact, that I'm trying this on iOS5.1.1 ?
Thank you very much in advance,
Michael.
---
Blog: http://www.mkroll.mobi
Forum: http://forum.mkroll.mobi
On Aug 17, 2012, at 03:40 PM, Andras Kovi <email@hidden> wrote:
iOS6 beta 4 and Xcode 4.5 DP4
Cheers,
Andras
On Aug 17, 2012, at 3:31 PM, Michael Kroll <email@hidden> wrote:
> So are you running iOS5.1.1 or a beta seed if iOS6?
>
> Regards,
> Dr. Michael Kroll.
> --------------------
> Blog: http://www.mkroll.mobi
> Forum: http://forum.mkroll.mobi
>
> Sent from iPhone.
>
> On 17.08.2012, at 15:04, Andras Kovi <email@hidden> wrote:
>
>> Yes, I'm NSLogging and breakpointing and whatever to get an idea of what is going on in the app. I'm not sure about the advertisement delay of my module but if I turn it on and the app is in foreground, the didDiscoverPeripheral is almost immediately invoked. This is what takes about 1 minute when the app is in the background.
>>
>> Thanks,
>> Andras
>>
>>
>> On Aug 16, 2012, at 10:30 PM, Michael Kroll <email@hidden> wrote:
>>
>>> Hi guys,
>>>
>>> are you logging the didDiscover calls to the console using NSLog() ?
>>> What is your setup look like?
>>> Is the app still connected to Xcode while you pushed them into the background using the home button?
>>> Is there something logged into the Xcode console or where are you seeing that something goes well while scanning in the background?
>>>
>>> I'm still getting nothing.
>>> I changed the implementation of the advertisement interval on my peripheral to 20ms now, but it seems that nothing has changed.
>>>
>>> Cheers,
>>> Michael.
>>>
>>> On Aug 16, 2012, at 9:58 PM, Andras Kovi <email@hidden> wrote:
>>>
>>>> Hi,
>>>>
>>>> It seems the scanning is really happening in the background but it is ridiculously slow. It took about 1 minute to find the accessory. Anyway, at least I received the didDiscover and didConnect callbacks. didDisconnect is immediately called if the accessory is powered off. So it's more or less Ok on this side.
>>>>
>>>> However, I also use the peripheral manager and implement an attribute that is updated by the accessory. Now, this does no happen at all. I left it hanging for minutes and the app did not receive any attribute write requests.
>>>>
>>>> What do I miss?
>>>>
>>>> Thanks,
>>>> Andras
>>>>
>>>> On Aug 16, 2012, at 11:32 AM, András Kövi <email@hidden> wrote:
>>>>
>>>>> Hi Arthur,
>>>>>
>>>>> thank you for the response. I'll try what you suggest. However, it
>>>>> seems to be odd that my app does not (or with significant delay)
>>>>> receive attribute write requests while connected in the background.
>>>>> This would not be good at all. A few hundred milliseconds delay is ok
>>>>> but 10s is intolerable.
>>>>>
>>>>> The reason why I think something is still missing from the whole
>>>>> picture is that heart rate monitors and similar are also target
>>>>> applications. Those devices send the data at a constant pace and I
>>>>> can't think that the framework would buffer it for my app.
>>>>>
>>>>> Anyway, it would be good to hear the official Apple opinion as well.
>>>>>
>>>>> Best regards,
>>>>> Andras
>>>>>
>>>>> 2012/8/16 Arturs Vonda <email@hidden>:
>>>>>> Hi,
>>>>>>
>>>>>> I have done some tests in recent days and here is what I've found:
>>>>>>
>>>>>> 1) It takes a while to discover devices in background mode. Usually it takes
>>>>>> 10-30 seconds till first discovery, but can be a more. If you allow
>>>>>> duplicate peripherals (notification for each ad package), it interval
>>>>>> between those notifications can be minutes.
>>>>>> 2) I haven't tested this, but as far as I understand, you can only scan for
>>>>>> specific services in background mode. If you scan for all devices, this
>>>>>> might not work.
>>>>>>
>>>>>> I did the tests with two iPhones 4s -- one as peripheral and on as central.
>>>>>>
>>>>>> Also I noticed that events in background more might take a while to execute.
>>>>>> I had timer to fire 10 seconds after the peripheral was found and the events
>>>>>> in method took couple of minutes to execute (including making request to
>>>>>> server).
>>>>>>
>>>>>> Hope this helps somehow.
>>>>>>
>>>>>> Sincerely,
>>>>>> Arthur
>>>>>>
>>>>>> On Aug 16, 2012, at 10:41, "m.kroll" <email@hidden> wrote:
>>>>>>
>>>>>> Hi Andras,
>>>>>> I have the same issues here.
>>>>>>
>>>>>> In my app delegates method:
>>>>>>
>>>>>> - (void)applicationDidEnterBackground:(UIApplication *)application
>>>>>>
>>>>>> I'm calling:
>>>>>>
>>>>>> - (void)scanForPeripheralsWithServices:(NSArray *)serviceUUIDs
>>>>>> options:(NSDictionary *)options;
>>>>>>
>>>>>> But the delegate method:
>>>>>>
>>>>>>
>>>>>> - (void)centralManager:(CBCentralManager *)central
>>>>>> didDiscoverPeripheral:(CBPeripheral *)peripheral
>>>>>> advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI;
>>>>>>
>>>>>>
>>>>>>
>>>>>> Seems to be never called.
>>>>>> "bluetooth-central" is in my UIBackgroundModes array as well.
>>>>>>
>>>>>> I changed the ADV Interval of my peripherals to 20ms in order to meet the
>>>>>> Apple BLE Peripheral recommendations but this changed nothing.
>>>>>>
>>>>>> Kind Regards,
>>>>>> Dr. Michael Kroll.
>>>>>>
>>>>>>
>>>>>> On Aug 16, 2012, at 09:24 AM, Andras Kovi <email@hidden> wrote:
>>>>>>
>>>>>> Hi!
>>>>>>
>>>>>> Do I have to add anything to the app to indicate iOS that BLE events must be
>>>>>> delivered to it while backgrounded? I declared the UIBackgroundModes /
>>>>>> bluetooth-central in the info.plist file, so in theory I should be able to
>>>>>> receive the events.
>>>>>>
>>>>>> 1. The app scans for the BLE accessory and connects to it. Connection is
>>>>>> reestablished automatically if the didDisconnect is received.
>>>>>> 2. Go back to the home screen.
>>>>>> 3. No callbacks while the app is in the background.
>>>>>> 4. Bring the app back to foreground, and the didConnect, didDiscover and
>>>>>> other callbacks are immediately called.
>>>>>>
>>>>>> Thanks in advance,
>>>>>> Andras
>>>>>> _______________________________________________
>>>>>> 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
>>>>>>
>>>>>>
>>>>
>>>
>>
_______________________________________________
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.apple.com/mailman/private/bluetooth-dev/attachments/20120820/b621587b/attachment.html>
------------------------------
_______________________________________________
Bluetooth-dev mailing list
email@hidden
https://lists.apple.com/mailman/listinfo/bluetooth-dev
End of Bluetooth-dev Digest, Vol 9, Issue 172
*********************************************
_______________________________________________
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