iOS - CoreBluetooth - ios

Is there a way to find out what type of device it is that I have scanned?
After iOS 7?
For instance, APPLE, DELL, LENOVO, ect.
Thanks

You can check to see if the device you have connected to implements the Device Information service. If it does then you can read the Manufacturer Name characteristic.
There is no way of determining this information without actually connecting to the peripheral.

This would only be possible if the product developer included this in the advertisement data or within a GATT service.
You can observe advertisement data when CBCentralManager discovers peripherals, see documentation here.
Information like this might be found under the CBAdvertisementDataManufacturerDataKey dictionary key.

Related

OBD2 BLE communication from iOS

I will be using OBD2 device to get data form a car. I don't have the dongle yet, but am reading into how things should be done. As far as I understand the device should be with BLE on and should scan for peripherals with some specific service.
For example I need to get the speed of the vehicle. How should I know what is the UUID of the service I am looking for and what are the UUIDs of its characteristics and possibly some details about the data that should be received. For devices using GATT profiles for example they could be found here: https://www.bluetooth.com/specifications/gatt/services . But I don't find any such documentation for OBD2. I found this answer: here and the first one here. As far as I understand they suggest I need to look through all peripherals and all services there and try all characteristics to find the needed ones and distinguish them by the response. Is this the only way to do this? I found also this project: here where some UUID is used but I cannot understand where it comes from. Any suggestions how to get the needed UUID-s?

How to ask for authentication before connect to devices using bluetooth?

I want to make demo application, which contains following features.
search and show device list in my device Bluetooth range.
connect(pair) selected devices.
then share string data.
For doing that I am using core Bluetooth framework(Central and peripheral classes). using that I am able to search devices, connect devices and transfer string data also.
but I am not able to authenticate devices before pairing(when I call connect method it is directly shown me connected status). how is it handled in ios?
also please suggest me I am on the right path or I need to use another library to implement this functionality.
For anyone else beating their head against a wall, I have the solution to this issue. It's as simple as setting the AUTHENTICATION required flag for a characteristic on your BLE device. Once that flag is set, you need to attempt a READ from that service / characteristic using the iOS device. Once the read is requested, the BLE device will send back a failure message which then prompts iOS to display the PAIRING / BONDING popup. After that, you're golden.
Here is an example of a Cypress BLE device permission group. The settings are similar for most BLE embedded devices out there.
yes it is possible to ask pairing request from BLE device to ios.
I followed below steps to make ios app to ask for pairing.
edited my ble app to return error code 'RBLE_ATT_ERR_INSUFF_AUTHEN' using gatt write response function.
attempted a write from ios app then i got a prompt to enter pairing key.
used the randomly generated pairing key by BLE device to pair.
Paulw11's comment also helped me to solve that problem,
Regards
Bharath GK

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.

How do I program a bluetooth module to broadcast a text string to an iOS device?

I'm trying to figure out how to send a simple text string from a BlueGiga BLE112 bluetooth module to an iOS device using BGScript. Is this possible? If so, what steps do I need to take to get this to work. Any help will be greatly appreciated.
One way would be to create a custom GATT service with a characteristic containing your string. Then the iOS device could connect and read it. There is also the standard Device Information service which contains various string characteristics such as manufacturer name, serial no., device id etc. Maybe you could use that if it is suitable for your application. Your BGSript code among other things could set the value of the characteristic at run time if it is not constant. You can create the service using Bluegiga's Profile Development Kit. Documentation can be found here BLE112 Documentation and Software.

Bluetooth Low Energy unique identifier

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

Resources