Is a Bluetooth profile always required to be used when sending data between an iOS device and a Bluetooth device? - ios

I'm new to Bluetooth, but searching the web, I've found the following description of Bluetooth profiles:
"A Bluetooth profile is a specification regarding an aspect of Bluetooth-based wireless communication between devices. In order to use Bluetooth technology, a device must be compatible with the subset of Bluetooth profiles necessary to use the desired services. A Bluetooth profile resides on top of the Bluetooth Core Specification and (optionally) additional protocols. While the profile may use certain features of the core specification, specific versions of profiles are rarely tied to specific versions of the core specification. For example, there are Hands-Free Profile (HFP) 1.5 implementations using both Bluetooth 2.0 and Bluetooth 1.2 core specifications."
So, I have an MSP430 board with the CC256X Bluetooth module on it, and I want to transfer data between that device and my iOS device. Does that device always have to communicate with my iOS device using a Bluetooth profile? If so, could you please shed some light as to what the simplest profile to make this happen is? As far as my design constraints, all I want to do is press a button on my iOS application, and have that turn an LED on my board. Thus, I just need the board to react to a simple characteristic change.

Please check
profiles/SimpleProfile/simpleGATTProfile.c
and
profiles/SimpleProfile/simpleGATTProfile.h
That's as simple as it ever gets. Once you write a profile with service and characteristics, you just have to include it in your code and use them just like any other service and characteristic.
Coming to your requirement, you need to have a characteristic with write permission in your profile. When you press the button in iOS application, write a value 1 to this characteristic. This will trigger writeCB to your embedded application code. You can use
HalLedSet( HAL_LED_2, HAL_LED_MODE_ON );
to turn on the LED in this callback.

Related

Does Bluetooth Low Energy devices still not show under iOS Bluetooth settings (My Devices)?

I'm trying to set up a hobby project and I'm wondering - if my device uses Bluetooth Low Energy module, will this device show under the list of Bluetooth Devices under Settings for iOS? Or will my app have to search for this device specifically before connecting? If it doesn't show in the Settings, what type of Bluetooth module would I need for that?
No, you will not see your LE devices under Settings for iOS.
See LE best practices - your app should search for the LE device.
You only see the BT classic devices in that settings. However, only few protocols could be used without a required MFi chip, which is out of your scope for your Hobby project.
Use The CoreBluetooth on the iOS side for your app.
UPDATE per #Brejuro request in the comment below:
MFi coprocessor is required to be in your custom HW, which wants to communicate using the majority of profiles/protocols defined for Bluetooth Classic (not LE), e.g the pure RFCOMM. Coprocessor is used for the initial authentication - then, iOS knows that your custom HW is certified and allows to use it.
However, Apple will ask you for big money and your device needs to pass through Apple certification - that's why I told that this is out of the scope for any hobby project. You will also need to sign very restrictive NDA. However, you will get very very good documentation describing many details.
Built-in Bluetooth panel in iOS Settings app is actually a merge of two different things:
a list of known (paired) devices whatever the profile they use (so that you have a central place to unpair them),
a tool for discovering nearby devices to pair to.
Unpaired devices will only show in discovery list if they actually implement at least one profile that is recognized by core bluetooth services of iOS. Other devices are masked (user would not be able to do anything useful with them anyway).
If you hobby project is to do something related to built-in supported devices, like HID (keyboard, mouse, remote control, etc.), you will actually see them during discovery from Settings app.
If you create a device with a custom service, with your own Service Type UUID, it will not show in built-in panel, and your app will have to look for it for pairing. Once paired, device will show in settings.
Out of core services, you can also make compatible devices without being MFi. For instance, MIDI over BLE profile is such thing that gets recognized transparently by garageband and other music apps.
Using BLE and not BR/EDR, Authentication chip is only required for very specific profiles, like HomeKit.

Is it possible to send text files to a peripheral device using CoreBluetooth?

I want to develop an iOS app to control our device. So in our case, the iPhone(Central) has to send a text file(it's a configuration file) to our device(Peripheral). Is it possible ?
I checked the Apple Core Bluetooth Programming Guide, I don't see examples fit my requirement.
The GATT profile, which Core Bluetooth exposes, is able to send and receive raw data.
While there may be standard profiles built on top of the GATT profile that make file transfer easier, Core Bluetooth does not have built in support for these. You will have to implement any profiles above GATT on your own, or possibly find a third party library.
For some other (non BLE) profile support, use the ExternalAccessory framework.

Send data to BLE supported Non iOS device from iPhone using CoreBluetooth

I would like to implement one iOS app . The app functionality is When I click on the UIButton in the iOS app , one LED should be ON in the Non iOS device (It is supporting the BLE) . So I know how to read the data from the Non iOS device using the CoreBluetooth framework. But dont know how to send data to Non iOS device . So My doubt is
Is there any thing we need to implement in the Non iOS device for Understanding the commands which are sent from iOS app ?.
For example I am sending One string #"Start".
Any ideas or suggestion could be more helpful .
Well for starters there is not magic way for you to send data to your non-iOS device, and for it to magically understand what it needs to do with it.
Check the BTLETransfer Example from the sample code in the developer portal it shows how to transmit data between two iOS devices. Furthermore, the peripheral role in the example is the one you have to mimic on your non-iOS device so it understands how to receive data your sending from a CoreBluetooth Central Manager.
In the example they use a rudimentary form of communication by setting a EOM flag (END OF MESSAGE) but it is effective and it works, it is not bulletproof though, but feel free to experiment with it. It will be useful if you have some knowledge on Network Transfer protocols and packet transmission techniques, error checking, acknowledgement, synchronisation, etc. So you can build or chose one that suits your needs.

How to use bluetooth classic instead of LE

In reference to Dennis Mathews answer how do you specify Bluetooth Classic instead of LE on iOS? Is there a different api from Core Bluetooth Framework?
Joels there is a very clear way to use Bluetooth classic on iOS. It is with the External Accessory framework (it also includes direct hardware connections in addition to Bluetooth classic however).
You need to add the ExternalAccessory.framework and specify "App communicates with an accessory" in the required background modes inside your plist to get started. It should be noted however that with Bluetooth classic, the user must add your Bluetooth device from the System Bluetooth settings. It is only with Bluetooth LE that we are able to add devices from the app side.
Check out the docs on the External Accessory Framework
In response to your question regarding the MFi program, this should clarify:
I want to develop an iOS app that communicates with an MFi accessory. Do I need to join the MFi Program?
No. iOS app developers do not need to join the MFi Program. Everything app developers need is in the External Accessory Framework,
which is provided in the iOS SDK. To access the iOS SDK, please join
the iOS Developer Program: https://developer.apple.com/programs/ios/.
If you'd like to learn more, consult the MFi FAQ
If your external accessory doesn't need high bandwidth in the connection to iOS, and you wish to use (or must use) 2.x/classic BT, (instead of 4.x/LE/Smart, which is very low bandwidth but requires no MFi dancing) you may be able to communicate by emulating a BT HID keyboard in your accessory.
It's hardly optimal, especially since the HID reverse channel is pretty limited (I think to things like lighting the caps lock key in the basic keyboard configuration (HID page 7 mapping, if I recall correctly.) OTOH, if your primary task is to push data to the iOS device, sending the data as keystrokes would not be too awful. (and might even be seen as virtue during testing :)
HID devices can declare additional capabilities in table defined keymaps, but I'm not sure if an iOS app can get at those alternate mappings with sanctioned APIs.

iOS - How to integrate bluetooth devices in my app

I'm trying to create some application that connects to blue tooth devices. A simple thing like a bluetooth barcode scanner that scans and sends a number to my app. I want to know which framework or something to be used in my app that can integrate the barcode scanner with my app. Is there any API or examples or tutorials etc that can help me implement such things?
Apple provides an API called the External Accessory framework, which can be used to interact with paired Bluetooth devices or devices connected through wired, Apple Connector at the base of the device.
However, to be able to use a paired device from within your application as you desire, you will have to a device that is designed to be compatible with iOS devices (meaning, the manufacturer must be a member of the Apple MFi program) and the device manufacturer must provide a protocol that you must add to your applications info.plist file.
If you have bought an off-the-shelf, Bluetooth barcode reader, there is a fair chance that you can not do what you are trying to do. If the device states that it can be integrated into custom iOS applications, consult the device manufacturer for further support regarding setting up your application to interact with their hardware.

Resources