Is there a way to uniquely identify a BTLE device (something like hardware ID)? I have 2 hardware BTLE devices and 2 soft BTLE devices (using CBCentralManager). All these devices are sending same UUID.
I want to identify the exact BTLE device when all the devices are lying near me. Any clue?
The devices should have unique Bluetooth addresses. If they don't then you wouldn't be able to properly connect to them without them interfering with each other. However, with BTLE it's possible for a device to have a randomized address for privacy (but those conform to a particular pattern so you can detect if you get that kind of address). The address is 6 bytes and is usually displayed in hex (ex A1-B2-C3-D4-E5-F6). The first 2 bytes usually indicate the manufacturer.
UPDATE: My answer is valid for most BLE usage, but as the question is tagged ios you may want to look at this other answer about getting a unique id on ios as a possible way to get the bluetooth address
Related
I would like to get notified when ios app is in range of other ios app even if they are both in the background mode. I know that I cannot advertise successully as a ibeacon after my ios app has gone to background because advertisement data is put in 'overflow' area. But the question is if we can extend the time that it is possible to advertise/simulate iBeacon? Are there any workarounds for this?
For example can I connect the devices in range by knowing their proximity UUID without user even knowing it? That would allow me exchange data between devices because my plan is that every user device will advertise with the same proximity UUID and the way I will identify users will be mix of major and minor ids.
Thanks in advance!
While iOS devices may not advertise iBeacon in the background, they can advertise what is known as the Overflow Area advertisement, which contains 128 bits of data. These Overflow Area advertisements are readable by backgrounded apps on other iPhones in the vicinity, provided those iPhones have their screen illuminated. (This happens even when phones are unused, as screens are typically illuminated briefly after a notification comes in.)
This makes it possible for one backgrounded iPhone app to read another backgrounded iPhone app's unique identifier passively in the background with no user interaction.
Advanced techniques are needed to configure Overflow Area advertisements, and to encode/decode unique identifiers inside them. Fortunately, I wrote up a detailed blog post of how this works, and created an open-source reference app you can use as a starting point to building your own app. This way, you don't need to master the complexities yourself to get this working.
If you build and run the reference app on two iPhones, it will assign a unique numeric identifier to each phone, and then you will see that Phone A detects the unique identifier of phone B and vice versa.
I'm writing some code (C++) for ESP32, to act as a BLE beacon. The problem is this: the iPhone doesn't send out its real MAC address, but does a random-generated MAC address, for security. The thing I'm confused about is how do you know if it's a device you've previously paired with?
So let's say I detect a new BLE MAC address, and looking at the manufacturer data I can determine it's an Apple device (first 2 bytes are "4C").
Now I need to know if I've previously paired with that device, so that I can allow the ESP32 to initiate an action (for simplicity let's just say turn on an LED). If that MAC address is in a list of known devices, then I can continue, and if not, I ignore it.
The problem is, if the iPhone is not giving up the real MAC address, the detected MAC address will never match anything. As this is a security situation I'm sure the algorithm for generating those MAC addresses is not known.
To be clear: this code is being written for the ESP32, not the iPhone.
It is in fact not possible to tell if a device has been previously seen, unless you pair and establish a bond with it. Once you pair with the device, long-term keys are exchanged and are used to quickly re-establish the connection.
This is by design. MAC addresses were originally unique, but this allowed tracking people and devices without their consent. You can read more about this in the following ESP-IDF guides:
GATT security server walkthrough
GATT security client walkthrough
So are you using esp32 as a beacon? This dose not involve any pairing or iOS MAC addresses. iOS will just be able to listen and the esp32 will not even know someone is "listening" to its broadcast.
Probably iOS application can store which services it is interested to hear to; may looks like pairing.. but it is a high level application managed technique and not any related to what BT standard calls pairing.
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.
My current project use bluetooth printer and i use EAAccessory framework for connect with the external device(printer). the problem is when i discover the bluetooth device, i get the all the devices paired with the iOS device. i need filter printers from the paired devices.
I really do not think this is possible. If you want exact information on the actual type of the bluetooth device connected, such as whether it is a printer or a wireless headset, the EAAccessory framework will not be able to deduce this for you nor is it really EAAccessory's job. All the EAAccessory framework will give you is very basic metadata information on the currently connected devices, generally speaking you can use some combination of the meta data, such as [name, protocol string] OR [manufacturer, name] to identify what you have connected to.
If you need any richer metadata like what you are asking, you need to directly ask the device yourself, which means the device should have some API's available for you to communicate with it. From my personal experience though, the information returned and boxed into an EAAccessory framework is more than enough for me to understand the device I am connecting to, specific type information will than be deduced off of that in code. If you want dynamic reader type info, that is tough and you will need to query the device for that info yourself once establishing a logical session.
I am looking for a unique id accessible for a bluetooth low energy device from iOS.
I have 10 devices and i placed it in 10 different places. I exactly need to know to which device i am communicating irrespective of the iOS device i am using to connect.
In the iOS core bluetooth, a new UUID is assigned by iOS for my device. I am not able to uniquely identify the device.
I have used the MAC address of the peripheral to generate a unique name in SCAN RESP. I guess you could also use this approach and maybe also put it in the advertisement data or in a message. (My peripheral was based on TI's 2540 SoC.)
To my knowledge MAC/BDADDR is not accessible via CoreBluetooth, but I noticed that the "Device Information Service" profile (0x180A) contains a "System ID" attribute (0x2A23) which encodes the device's unique MAC/BDADDR address. I don't know if it is mandatory for a BLE device to expose this service, however.
Use Major and Minor properties in CLBeacon. Both are 4 char hex values.
They are located in advertisement data with UUID.
More info:
https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLBeacon_class/Reference/Reference.html#//apple_ref/occ/instp/CLBeacon/major