swift how to develop an app performing an actual bluetooth pair - ios

The actual bluetooth pair I am talking about is: let the app shows up in the searching list of Bluetooth of System Settings and other devices can pair to it (like we pair our device to Apple Air Pods).
But all articles I find online are talking about BLE/CoreBluetooth, I don't think these methods could make a device name shows up in the Bluetooth of System Settings.So how to develop an app performing an actual bluetooth pair? Any ideas?

The Bluetooth preferences screen only shows legacy Bluetooth peripherals. Devices advertising BLE services do not appear.
Apps on iOS do not have the ability to create and advertise legacy Bluetooth services.
If you create an app that acts as a BLE peripheral, using Core Bluetooth, and specify that encryption is required for a characteristic then you will trigger a pairing process when an app acting as a Bluetooth central on the other device connects and attempts to read/write that characteristic. Note that this requires cooperating apps on both devices.

Related

HM-10 bluetooth pairing with iPhone

I am using a HM-10 bluetooth to pair with my iPhone but I noticed that HM-10 can't be paired with iPhone using the "settings". It just won't show up in my bluetooth list. I will need a special app like "Lightblue" or "Bluecap" to pair it.
My question is, if I need a certain app to pair the bluetooth module with my iPhone, why is that many devices such as bluetooth speakers could be paired using the "settings" even without having an app?
Are there any bluetooth modules that could be paired without having an app like "Lightblue" or "Bluecap"?
Pairing through settings is only available for devices that use legacy profiles such as handsfree or A2DP.
Bluetooth Low Energy devices, such as the HM-10 are discoverable by any app using Core Bluetooth. Apps, like LightBlue, are just general purpose BLE apps that let you explore available BLE devices.
BLE devices only require pairing if they are using encryption on their characteristics. In this case, iOS will show the pairing dialog and complete the pairing process when the app attempts to read the encrypted characteristic.
To use the HM-10 you will need to write your own app to perform whatever communication task you are trying to achieve.
You can use nrf52832 as Bluetooth module.
If you are not making hobby project hm10 is very bad choice
I shifted from hm10 to nrf52832 before 6 months

Can an iOS app receive data from any bluetooth device?

So my question is can we create an iOS app that can receive data from any bluetooth devices? Even the devices we buy it form eBay?
Any encoding when the data sent from the devices make us can not decode them? Or another description : Can the bluetooth device limit the app that can connect to them ?
Thank you very much.
An iOS app can receive data from any bluetooth device which must confirm the protocol of Bluetooth(GATT, ATT, L2CAP).
Bluetooth device can limit the device to connect by the data format(such as CRC, XOR), the device even can limit the special MAC address of bluetooth to connect if your app not sale on App Store
Below is a simple description to Core Bluetooth, please check the detail Core Bluetooth Programming Guide
The bluetooth device is a Peripheral to produce data, iOS app is a Central that can receive data or send limited data to Central.
When the Peripheral begins advertise, the Central can search and connect to it, when the connection is build, Central can notify or read the Characters in Services of Peripheral
An iOS app can connect to any device that supports the GATT profile with Bluetooth Low Energy/Bluetooth Smart using the Core Bluetooth framework.
Generally, a peripheral cannot prevent your app from connecting to the device, but your ability to read/interpret the data offered by the device will be limited by:
The documentation provided by the device vendor
Your ability to "reverse engineer" the information if documentation is not provided
Any handshake/security methods that the vendor may have implemented; For example the device may require your app to respond with specific data in response to data from the device - see point 2.
Devices that use legacy Bluetooth (i.e. not BLE) are only supported if they offer generic services such as audio - these are supported by the AV framework, or if they are MFi certified - these are supported by the External Accessory framework.

iOS BLE Supported Connection Types

I'm working on a BLE device that part of its requirements is that it'll only use connect mode between the iPhone and the peripheral (no pairing nor bonding).
According to Apple documentation Bluetooth Accessory
Design Guidelines for
Apple Products
section 3.7 Apple is using Random device address. As much as I know, when using Random device address one need to pair (in order to get the IRK).
Is there a way to have a BLE device who works with iOS and only does connect with no pairing or bonding?

IOS scan for classic bluetooth - get addresses - IBeacons

I understand the external accessory framework needs to be used to work with Classic Bluetooth on IOS, as a fallback for non BLE phones (i.e Iphone4) , is it possible to scan for devices using the external accessory framework to list Bluetooth addresses that are in range ?
I have Kontakt IBeacons and on android using classic Bluetooth scan i can see all the device addresses, while i cant get UUID's / major and Minor this the Bluetooth device address could still serve to identify some form of proximity to the Beacon...
Is it possible to list devices in range in IOS as well in a similar manner ? i understand the external accessory framework only allows you to pair with complaint devices, but does scanning work for anything in range ?
No, you don't have any access to the visible devices using the External Accessory Framework and classic Bluetooth devices.
The External Accessory Framework handles both cabled and Bluetooth connections and hides the discovery process. Essentially an application provides the supported device information in the info.plist file. When iOS discovers a matching device then the app is advised - the app doesn't play an active role in scanning for or identifying the device.
As an iBeacon won't have the Apple MFi chip in it, it won't be detected by the External Accessory Framework discovery process.

Can you pair a bluetooth LE device in an iOS app

Can you pair a bluetooth LE device in an iOS app, i.e. not via Settings. Trying to make it easier on the user to pair with a specific device.
If so how?
You don't pair Bluetooth LE devices through system settings. Generally you don't pair with Bluetooth Low Energy devices at all. The only time that pairing is required is when the device has an attribute that is marked as encryption required - attempting to read this attribute will trigger a pairing process, but before you can read you need to discover and connect to the device.
Discovery and connection is handled by the Core-Bluetooth framework.
The Core Bluetooth Programming Guide goes through the steps required to use a CBCentralManager to discover and connect to a BLE peripheral.
According to the BT SIG Security Manager documentation you can pair/Bond ble devices if they respond to the message that is.
You can also wait and do it as previously explained from the peripheral side. Some devices like HipKey does this automatically when connecting first time.
Look at BTSIG Security Manager specifications.
On Android this also works from BT settings menu IF the peripheral supports it.
Bonding and Authenticating are usually confused but om most platforms it means the same.
A good way to try this out is by buying the TI ble development kit. Its cheap. It comes with a USB dongle and SW which can be used to initiate pairing like from the settings menu.
To do it from iOS just connect and read a known encrypted characteristic.
Cases where you want to "pair" (remember a Bond) includes Pulse meters, hearing aid, keyboard and other private units.

Resources