Using CoreBluetooth is it possible to get the raw scan record of a Bluetooth LE device - ios

I'm trying to get a better understanding of Bluetooth LE and been playing around with both iOS and Android's bluetooth stacks and various beacons (StickNFind, Estimote etc...)
On Android, when a device is discovered I get a raw "scan record" - a blob of data that I can parse myself to get the device's advertised data.
On iOS, this is parsed by iOS and presented as a dictionary.
Fair enough, except I was trying to use CoreBluetooth (ie: not location services) to read the advertisement data from an iBeacon and noticed that iOS seems to strip out the manufacturer specific advertisement data for iBeacon devices.
I realise I should probably be using Apple sanctioned ways for detecting iBeacons but it doesn't really fit our use case and wondering if there's a way around it.

EDIT: iOS does let you access the raw data for any Bluetooth advertisement that does not match the iBeacon format.
Unfortunately, iOS blocks access to the raw data of all BLE advertisements, including those of iBeacons. This makes it impossible to access the iBeacon identifiers with CoreBluetooth.
See details in this blog post.

Related

How to change CBAdvertisementDataLocalNameKey value from objective C?

I have multiple accelerometer sensors and I need to update the advertisementData name (CBAdvertisementDataLocalNameKey) of the each sensors for the first time of starting to use that sensors. What is the best way to update that from iOS (Objective-C or Swift) app?
You cannot control this data from your app as this data arrives directly "as is" from the remote BLE device. In this case, this is the name of the device that you are scanning for. Have a look at this:-
CBAdvertisementDataLocalName Apple Developer page
The Ultimate Guide to Apple's Core Bluetooth
The only way you can actually change this is if you have access to the accelerometer sensors' source code, and then changing the name will be dependent on the specific software running on these sensors.

Does BLE Data Transfer require pairing (pairless bt data transfer)

For a project of mine I need a pairless bluetooth data transfer. I have first thought about doing it with BLE IBeacons but they can only advertise a very limited amount of data. I looked further through the Apple documentation and found this tutorial about Central/ Peripheral
BLE data transfer. I've implemented the code in my project but even though the devices were very close together they could not "see" each other. I have since looked up on the Internet and could not find a hint about whether the devices need pairing or not and what the problem of mine could be(the code is not throwing any errors nor warnings).
If it does require pairing, is there some way to do that in the background without requiring the user to perform an action, so that I could theoretically advertise some kind of pair request via. IBeacons to then transfer the data? If that's not the case, is there even a way to transfer data (mono directional, round about 512 bytes) between nearby bluetooth devices without user actions?
greets from germany!
To get started with Bluetooth Low Energy or any other protocol, it's best to learn how it works. At least basics.
Simplifying. BLE allows you to send data:
"Passive" (without conncetion) - over Advertisement Data. The size of the packages depends on the BLE version.
"Active" (requires connection with the device) - bidrirectional comunication. In this case size of the data package also depends on the BLE version.
Bonding and pairing is a separate issues.
I suggested you look at the following book:
https://www.oreilly.com/library/view/getting-started-with/9781491900550/
The websites of BLE module manufacturers also offer a lot of information about this technology. For example Nordic or TI. Very often with sample programs for various platforms.
For iOS:
https://developer.apple.com/videos/play/wwdc2017/712/
https://developer.apple.com/bluetooth/
You may also be interested in sending more data without connection using version BLE 5.0
https://www.bluetooth.com/blog/exploring-bluetooth5-whats-new-in-advertising/

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?
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.
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.
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.

HM-10 and iOS/iBeacon. Communicating between the two

I am trying to wrap my head around the possibilities of the HM-10 but am very new to a lot of how it works. I am only familiar with higher level things.
I originally thought I was going to use the hm-10 as an iBeacon but quickly found out it's limitations. Here was the original plan prior:
iBeacon(HM-10) broadcast in a particular room, when I walk in with my iPhone, it detects my iPhone and then does something, i.e Sets one of its Pins to High.
But based on my research now, this is not possible with iBeacon? I need to use iBeacon broadcasting in hand with regular bluetooth?
As in, upon my App/Phone detecting the iBeacon it then pairs with the HM-10 and sends an AT- command to set one of the pins HIGH.
Does all of this make sense? Could anyone provide some more input?
I am in the process of putting together an iPhone App but just wanted to know if I am on the right track.
Since the HM-10 is based on the CC2540, it should be possible to turn it into a Bluetooth LE beacon, including one that supports an iBeacon format.
A few thoughts to help your understanding:
Standard Bluetooth LE beacons (AltBeacon, iBeacon, URL beacon) are transmit only devices that don't detect phones -- phones detect them using a custom app. So when you say "it detects my iPhone and then does something" this is diverging from a standard Bluetooth LE beacon.
The concept of "pairing" with a Bluetooth device is typically related to Bluetooth classic (e.g. pre-4.0) technology. Bluetooth LE devices like the beacons mentioned above have the concept of connecting to read and write GATT characteristics.
If you do build a custom BLE device that out of a HM-10/CC2540, it would be possible to make it "detect" mobile phones, perhaps by advertising a GATT service, and then doing something upon connecting and/or writing to a characteristic. Since the CC2540 contains GPIO pins, it would be possible to make it "do something" by making a pin go high.
There are two big chunks of work to doing what you describe: (1) writing custom firmware for the CC2540 and (2) writing an iPhone app using CoreBluetooth and/or CoreLocation iBeacon APIs. Before starting on the iOS side, you need to figure out how the Bluetooth device is going to work.

Accessing battery level of battery powered iBeacon devices (mainly kontakt io ones)?

I am trying to find a way to access the battery levels from my beacons through an iOS application I am currently working on. I am using Kontakt's iBeacon devices. I browsed the Estimote iOS SDK and they provide a method to achieve this. I was wondering if it is at all able to access the raw beacon packet and manually extract the data since I know the beacon packet structure and the information is there.
Any thoughts on how to achieve this by the method mentioned here or any other way?
Thanks Guys.
This is Rafal from kontakt.io. Firstly, let me thank you for choosing us, it means a lot for us.
Propagation of battery level is not standard for iBeacons nor it is in any official iBeacon documentation, so that is why you cannot find the value using custom SDKs. Our iBeacons are propagating battery level in scan response packet which may be discovered using CoreBluetooth API in iOS. The level is one byte value at the 23rd byte in the packet.
Hope it helps :)
As far as I am aware there is nothing in the iBeacon advertisement itself that contains the battery level. Some beacons may expose additional BLE ATT services that contain this information. You could try using an application like LightBlue from the app store to explore the services available from your devices

Resources