Xcode 9 - Bluetooth module HC-06 - ios

I am currently attempting to code for an iOS application on XCode and am currently having some issues.
Our group is connecting LED lights through a microcontroller and we need our iOS application to connect to the HC-06 Bluetooth module in order to control the LED lights on and off.
I only need to worry about the iOS side of the code not the microcontroller. I was just wondering how would I go about coding this on Xcode to send either a '1' or a '0' through Bluetooth to signal either 'on' or 'off' to the microcontroller?

You can't use HC-06 BT or any Bluetooth 2.0 module because Apple uses MFi license Program
You can use HM-10 BT module to control your microcontroller via Bluetooth Low Energy.
You can read about BLE technology this.

Related

Ios BT Connectivity & Raspberry Pi

I have a idea that requires connecting an ios device to a Raspberry Pi without the end user having to do anything special. The device will not be connected to an existing wifi network so BT or wifi hotspot seem to be my only options, BT preferred.
I'm aware that Apple does require some sort of BT hardware approval which I wont have I'll be using generic BT hardware. Once a connection is established I then want to be able to request data or call API's running on the Raspberry PI.
Does any of this sound achievable and are there any links that may help.
There are two flavours of Bluetooth: the so-called Bluetooth Classic, and the newer Bluetooth Low Energy (also called Smart Bluetooth or Bluetooth 4.0, though this is actually incorrect as BT 4.0 includes both Classic and Low Energy).
On iOS, Bluetooth Classic devices do indeed need to go through specific processes (MFi), or use an existing BT protocol supported by iOS to be used.
However, you can connect to any Bluetooth Low Energy (BLE) device, without any need for MFi, approval, or support by iOS. This is done though the Core Bluetooth framework.
As long as Bluetooth is enable in the iDevice, you can connect to a BLE device without any user interaction (though UX usually dictates doing so, so a user can actually select a specific device if there are many "matching" devices in range).

Test Bluetooth on iOS

I'd really like to start testing my iOS apps Bluetooth capabilities, but have run into a few problems:
I have a device made with a RN-42 module, but it's not the Apple version and I don't have the Apple authentication module at the moment (I ordered it, but shipping from China can take a while). I know what the messages will look like, but can't send them to my iPhone!
I can use the module with my Macbook, but not in the iOS simulator! Apple has taken down all of the documentation related to getting the iOS < 7.0 to use a separate bluetooth dongle, and my efforts have left my 6.1 simulator endlessly spinning on the bluetooth screen.
I'm new to using Bluetooth, so this may be a dumb question...
Is there a way of getting a bluetooth client device (I have a Mac, another iPhone, and an Android tab) to act as a server module that can send (and receive) Bluetooth data to my iPhone?
Client/Server as per developer.bluetooth.org
Thanks!
Not 100% sure your meaning of "server module". But in CoreBluetooth, you can use CBPeripheralManager to broadcast data to other iOS or Mac apps.
https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/CBPeripheralManager_Class/Reference/CBPeripheralManager.html
If you're using standard Bluetooth (i.e. not Bluetooth LE or Bluetooth Smart or whatever you want to call it), you'll need to enroll in the MFI program or work with an MFI certified device (such as a Redpark cable) and use the External Accessories library provided by Apple. If you're using Bluetooth LE, you can use the Core Bluetooth library provided by Apple. If you fall into neither of those cases, sorry, you can't use Bluetooth on iOS.

Arduino and iPhone connection with Bluetooth 3.0

I would like to build an app that requires bluetooth connection. The Bluetooth HC05 module is connected to Arduino. I want to know what framework (or other related things) that I need to build an app that can connect to this Bluetooth module.
Still have no idea how to start. Anyone could help?
Unfortunately the answer might be "you can't do that".
iOS only supports the following Bluetooth profiles: HFP, PBAP, A2DP, AVRCP, PAN, HID and MAP. None of those can be used inside an app to communicate to your Arduino.
For the useful profiles like Serial Port Profile (SPP) and all arbitrary bluetooth communication you have to add an authentication chip to your Arduino. Unfortunately you can't buy these chips unless you have a MFi membership. And you won't get into the MFi program unless you are a company with a concrete product (mass market scale) in mind.
Fortunately, we now have Bluetooth Low Energy. Bluetooth LE can easily be used in iOS apps, without all the MFi hassle. So you should get a Bluetooth 4.0 module for your Arduino.
The framework that is used for Bluetooth 4.0 communication is called CoreBluetooth. You will find documentation, sample code and WWDC videos in the iOS Developer Center. Start with the Core Bluetooth Programming Guide

Programming on Bluetooth module

Now I have a Bluetooth module which support SPP, I want it to support BLE 4.0. Can I program on it? How can I start? In fact I want it to connect to iOS app, but I don't want to be included in MFI, that's the only solution I figured out.
You can connect bluetooth module to jailbroken iOS device without MFI program membership.
I used this BT stack library to establish BT connection
If I understand the question right you have a module which supports SPP and you want it to support BLE? I don't believe that is possible. The serial port profile is not part of the BLE spec. I am guessing you have a BT 2.0 module.
You need to have a module that supports BLE or is running the BLE stack before you can connect to it to begin with. To use the module you have now, you need MFI to connect to an iPhone over SPP.
In summary, the two options you have are:
Keep the module you have (BT 2.0), join the MFI program or jailbreak to use SPP
Get a BLE module and use CoreBluetooth without the need to join the MFI

Can CoreBluetooth framework pair and talk to a slave bluetooth 2.0 serial module?

I would like to write an app for iPhone 4s that can talk to a slave bluetooth 2.0 serial module such as the HC-06, BC417, or EGBT-046S. Is this possible? Can anyone provide some sample code?
No, CoreBluetooth is for Bluetooth Low Energy. The External Accessory Framework can be used for Classic Bluetooth connection. But to be able to open on a serial link from the iPhone, you need a peripheral that complies with the Made For iPhone (MFi) program, and you need to be an MFi member to be able to buy one. Look at this question for more info: What's needed to use the Apple Accessory Protocol?

Resources