Re: Not receiving BLE events in background
Re: Not receiving BLE events in background
- Subject: Re: Not receiving BLE events in background
- From: Andras Kovi <email@hidden>
- Date: Fri, 17 Aug 2012 15:04:26 +0200
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