I have a bluetooth device which connects to my iphone and i can perform all sorts of operations on the device. Its a tracking device and I log all sensor based data in the device. Since the device have a data limit, I want to read data from the device once every hour and dump it into a file through the app.
Now I have gone through all the documentation from Apple and other medium blogs and stack overflow questions, but I didnt find the correct solution on how to run a process in background. Also it has to be periodic. I need something that will trigger my code once every hour and I can connect to the bluetooth device and download the data.
I know for security reasons and for extended battery life apple doesnt support running background process infinitely. But I have to solve this problem.
Related
I am working with ibeacon. I created an application for tracking devices. But I am facing a problem with the application. The app works well in the terminated state for iPhone SE whereas it is not working (in the locked state) for iPhone 7+.In the unlocked state it is working for 7+ also but still it is very slow compared to iPhone SE. Is there any specific reason for this problem. If it can be solved, what could be the possible solution to this problem.
I am really helpless and clueless about this issue.Please do help me and assist me with your knowledge Sir. Thank you in advance.
When an iOS app is in the background, it relies on two different mechanisms to detect beacons:
Hardware filters. These are byte patterns stored on the Bluetooth chip that alert the OS when a BLE advertising packet is received that matches your beacon region. This mechanism is very fast and delivers results within a second, but it is a limited resource. Once all slots are full, it will no longer work. There is no documentation about the number of slots available on each iPhone model, but experiments suggest the number is ~30.
Software scans. A full BLE scan is performed to find all beacons even if they are not stored in a hardware filter. In the foreground with ranging active, software scans are constant. In the background they are periodic to save battery, so detections based on software scans are much slower. The rate is undocumented, but experiments suggest software scans are performed every ~10 minutes in the background in the typical phone state. An additiona softwarel scan is also performed when the screen is unlocked.
The problem description is consistent with hardware filters (1) not working on the iPhone 7+. This may not be a problem with the phone model, it could be a problem with the specific device, or more likely the software state on the phone. A typical cause is the installation of multiple beacon apps that use up all the slots. Each beacon app can register up to 20 beacon regions for monitoring, so just two apps could use up all the slots!. The first apps to run and register slots may hold them forever.
A few troubleshooting tips:
Uninstall any other apps you think may. be detecting beacons, then re-install yours.
Restart your device.
If the above does not help, you may have a hardware problem with your device. Try another iPhone 7+ to see if you can reproduce.
I'm new to mobile development, before eventually deciding where to develop (android/ iOS) a specific application I have a question (I'd prefer using an iPhone):
So the background is that I have a BLE device frequently sending data to the phone and let the phone app sync the data to the cloud. Now, it is really important that if for some reason the phone has to restart, it will automatically proceed receiving the BLE data.
Is it possible at all in iOS to start a background process (handling BLE packets) after reboot automatically. Thus e.g. when the respective BLE device pairs to the phone after a reboot, that the background process starts automatically, without the user having to start the app manually?
Doing some research I came up with mixed results regarding this scenario and would be grateful if someone with iOS experience could clarify.
(BTW: It does not have to be an Apple App Store Application)
A Few days ago I was working on BLE devices Beacons we supposed to make mobile application and start monitoring these beacons and send date monitoring to API.
This works fine in background, even the user was not running the application in foreground or reboot his iPhone.
All we should do is put the monitoring code at the appDelegate of the application to work in the background.
i have an application that is connected with a chip by bluetooth.
Device and phone are constantly connected to calculate the distance between them by bluetooth delay in reply.
App is working fine in foreground.
When i go background the app is still running, but cannot connect to the device.
I already tried to fix with this guide: Core Bluetooth Programming Guide
but i didnt made it.
Some suggestion?
You need to introduce more detail.
Your app will not run in background mode even bluetooth connection is on.
But your app still have a chance to execute some code in a short time if some bluetooth event happen.
Connection lost.
Notification received.
If your application work like anti-loss bluetooth tag, you need
Enable background in iOS app.
Write your code in core bluetooth delegate.
And One reminder: Calculate distance based on bluetooth relay is not smart. Bluetooth communication is not designed to support this kind of feature.
It work on license free 2.4G band and human body has big impact on it.
I am writing a Core Bluetooth App for IOS. It is connecting to a TI device With custom firmware. The firmware developer developed it to publish data 12 times a second. I am using the Notify Property to get the data, but it seems that we are grabbing the data 30 times per second. This is causing extra power consumption, and for specific reasons, I can't pull at my own rate I need to pull at the rate of the device is publishing.
The firmware developer created a Windows Application that doesn't have this problem without having a hard coded Read Rate. So it is On me to find the issue.
Does anyone have any recommendations?
For what you are describing, on your system the Swift side is just receiving notifications, so there is no control over the rate that your device is using to update that specific characteristic.
But, some devices may have a command on their own high level protocol to set the advertising interval. That's completely up to the manufacturer. If you think that the system is advertising at a different rate with that Windows app that you have mentioned, I would suggest to take a look to see if there is any initialization code that the app may be doing when it starts (thus setting the rate). But for that you will need the Windows app's source code, or at least the manufacturer's documentation about your device's protocol (if any).
Also, are you really sure that the updating rate when the device is connected to the Windows app is really lower than the one you are experimenting when connected your iOS app? How are you measuring that?
I got the bluetooth low energy Heart Rate Monitor working using corebluetooth.framework on IOS 5.0. But some times I get the following problems.
1) Sometimes when I start the scan (with scanForPeripheralsWithServices method), It can not discover any BLE(Bluetooth Low Energy) devices until I turn off and turn on the Iphone Bluetooth manually. Occasionaly I had to reboot the phone also if the bluetooth turn off and turn on did not work.
2) Sometimes When I try to connect to the device for which I have stored the UUID previously, I was able to connect to the device, i.e, didConnectPeripheral delegate method was called but It never discovers any services even though I call [peripheral discoverServices:nil] i.e, I am not getting any data from the device in the delegate method didDiscoverServices. For this also I had to reboot the phone.
Try checking the archives here:
http://lists.apple.com/archives/bluetooth-dev
and if you don't find it, send the question there. Many Apple Bluetooth engineers answer questions on that mailing list.
1) It has something to do with the pairing routine on bluetooth low energy and the iPhone. The iPhone changes its ID every interval, I don't know how often, but it does. Have you tried just resetting/rebooting the slave device? This often works for me.
The slave device also has a limited broadcast period, e.g 20-30 seconds.
2) Again, check that you have reset the slave. I don't know if you have built the device your self or bought a heart rate belt, but this is most often the solution.
Oh and by the way, I had an issue where the didDiscoverServices actually jumped over an if-sentence, where I checked for a specific service. This did not fix it self until I rebooted the phone. Really weird behaviour, but I haven't found any other solution to this yet.