I'm having trouble figuring out how to receive Bluetooth LE peripheral device advertisements while my app is running in the background. That is, when my app is in the background it never reaches the didDiscoverPeripheral() method--where the advertisement lies.. Does anyone know how I need to configure my app such that I can get Bluetooth LE advertisements while my app is in the background? Can this be done with a thread polling while my app is in the background? Note: I want to get advertisements from all BLE devices, not a defined number of BLE devices.
Appreciate the help,
Casey
Device modes Peripheral mode lets devices send advertisement packets. Central mode lets devices scan for advertisements. An Android device acting as both a peripheral and central device can communicate with other BLE peripheral devices while sending advertisements in peripheral mode.
The code-based examples that follow will assist you in developing your app to implement the peripheral role on your local device. So: yes, it's possible. There are probably apps that make your iPhone act like a peripheral, since the ability has been supported since iOS 6.0.
The Core Bluetooth framework provides the classes needed for your apps to communicate with Bluetooth-equipped low energy (LE) and Basic Rate / Enhanced Data Rate (BR/EDR) wireless technology. Don't subclass any of the classes of the Core Bluetooth framework.
On your iOS device go into "Settings-> Bluetooth" and turn on your BLE device. You should see the device listed in your available devices.
I am doing this from my app.
in background mode CoreBluetooth is said to be up to 55 times slower than the advertisement interval of the peripheral. To speed it up I programmed the peripheral to advertise every 20ms for the first 30s.
Also you must define "Requires background mode" with "App communicates using CoreBluetooth" in your project Targets -> Info.
It does take a while for the app to find peripherals in the background mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With