This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ios iphone setting scan window and scan interval

Other Parts Discussed in Thread: CC2540

hi,

I want to add setting scan interval and scan window options as it is available in BlueGiga BLEGUI software. However according to iOS mail lists:

The Core Bluetooth framework does not provide a method for changing the scan interval or scan window. The OS selects an interval and window considering performance and power consumption. In iOS, more scanning is performed when the App is in the foreground and reduced when the App goes in the background. 
We have tried to design the algorithm so it works in most use case scenarios. As always, we are interested in feedback so if you experience any issues, please let us know.  

How do you deal with this in your ios apps? I am not sure using NSTimers would be a robust solution.
I need to set these intervals for power consumption measurements. 
Thanks in advance for your contributions.
Regards,
  • Hi Cagatay,

    Are you referring to iOS App development only, as in working on power consumption measurements on an "i-Device"? Otherwise, I don't think scanning parameters on "iDevices" affects power consumption on the connectible Peripheral devices. At least not significantly. So why would you need to control scanning?

    Best Regards

  • Thank you for the answer Joakim,

    I remember your name from Apple Mailing List. I guess you are in the development group of CoreBluetooth. First of all, thank you very much because you are amazingly contributing to the community by patiently answering undocumented issues related to CoreBluetooth. 

    Indeed, we want to be able to modify the scan parameters because we're doing power measurements and analysis of the iDevice (iPhone in our case), not the peripheral. Scan parameters are very important because we are working on BLE assisted discovery. We are also focussing on different scanning scenarios for example BLE enabled access points and smartphones. Hence, setting scan interval and scan window is crucial for us.

    I read almost all the emails from Apple Mailing list. Here are the important notes for other developers who may also be interested in discovery process of CoreBluetooth

    • It takes 55 times longer to discover a peripheral in the background.  
    • In  order  to  scan  from  the  background  you  need  to  specify some addressing (or sevice UUID I am not sure) of the device  you want  to  discover.  API  does  not  let  discovery  of  all devices  if  you  are  working  in background
    • The CoreBluetooth isn't listening continuously. It is sharing HW resources with bluetooth classic FM and Wifi.
    • When the App goes in the background, the scanning parameters are changed in order to reduce power consumption.
    • iOS will kill a background app whenever a foreground app needs memory.

    Unfortunately we are also considering switching to Android although the API is not robust and supplied by 3rd parties. I have to check the current available APIs.

    In short, I am suprised that Apple engineers tried to be `helpful` in "optimizing" the scanning procedure so that app developers don't have to worry about it. As a result, we cannot control the scanning parameters and app developers are scratching their heads because they observe too long discovery latencies. I would really appreciate If you can answer the reasoning behind this.

    Regards,

  • Hi Cagatay,

    Your not the first one to believe I'm that Joakim (If you look closer we actually have different surnames). 

    I really appreciate your detailed response. Unfortunately, I cannot help you regarding the iOS limitations you are seeing, you should direct those towards Apple support.

    Good luck in the search for the answer, although I believe you have already answers it yourself (optimizations during background runtime).

    Feel free to post any findings.

    Best Regards

    Joakim Lindh

  • hi Joakim,

    I have scanned the cc2540 using the MotoRazr running on Gingerbread. To my knowledge to scan the BLE device you do not want to install any extra app provided by Ti.

    we have changed advertisement configuration such as advertising channel (3 channels), interval, pdu, 4 data type, now both ios and android still can not use system provided scanning.

    joakim, can you help, what's else i need to focus to ?

    cheers,

    danny

  • Hi - I understand how the scanning works on an iOS device, but how about the iphone/iPad simulator? I am running the TISensorTag App in the iOS simulator on my MAC. I couldn't determine the scanning interval & windows at all. It just scans only once even though I did not stop the scan programatically. Any thoughts/experiences?

    Thanks

    Ashok