Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom BLE Advertisement on iOS

I'm hoping to create a BLE advertisement on iOS where I can control the advertisement on a byte level.

One use case would be to mimic an iBeacon advertisement. What is the iBeacon Bluetooth Profile (I want to advertise while my app is in the background which is why I'm not using CoreLocation)

I do not see a way to do this with the Core Bluetooth API. Is this correct? Are there alternatives using private API's or jailbreaking?

like image 670
HatAndBeard Avatar asked Sep 29 '16 13:09

HatAndBeard


People also ask

Can an iPhone be a ble peripheral?

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.

Which channels does ble use for advertising?

Channels 37, 38, and 39 are used only for sending advertisement packets. The rest are used for data exchange during a connection. We're interested in what's happening in these 3 channels, and that's what we'll cover here.

What is Bluetooth advertising mode?

Bluetooth advertising is permission based advertising, which means that when a mobile device has received a Bluetooth message, the recipient has the choice to either accept or decline the message. The recipient needs to positively indicate that they wish to receive marketing messages.

What is advertising interval in Ble?

The Advertising Interval is the period between two consecutive advertisements of a Bluetooth Low Energy peripheral. This interval can be customized in the file user_config. h . The default value is set to 687.5ms .


3 Answers

As the others already pointed out, there is no API on iOS that allows you to do this.

You can advertise as an iBeacon, but only when your app is in the foreground. When in background, the advertisement is removed and therefore cannot be discovered anymore (except for other iOS devices which explicitly scan for that service UUID). Also see the documentation here: Core Bluetooth Background Processing

If you would share your use case and what you want to achieve, maybe there are other ways to realise it.

like image 183
p2pkit Avatar answered Oct 19 '22 21:10

p2pkit


My experience with iOS is that if it is something is not exposed in the API, there is no way around, except jailbreaking. For Bluetooth low energy the API is at GAP/GATT level, and very little at the lower levels (if anything) is exposed. Advertising is a LL (link layer) feature.

To illustrate how restricted the access is: When scanning for BLE devices you will not have access to the advertiser's MAC address iOS. In Android you have it.

like image 41
Eirik M Avatar answered Oct 19 '22 22:10

Eirik M


I do not see a way to do this with the Core Bluetooth API. Is this correct?

Since you have to set Manufacture Specific Data in order to achieve this, if nothing has changed you will experience exactly the same issue that I did. Explained here:

The advertisement key 'Manufacturer Data' is not allowed in CoreBluetooth

It is not possible.

like image 26
Darko Djuric Avatar answered Oct 19 '22 21:10

Darko Djuric