I have a request of implementing an iOS application which will be able to communicate with bluetooth device. The chip on that device has Bluetooth 3. The App will be privately distributed, so we don't need AppStore review and we can use anything - the only requirement is, no iPhone jailbreaking. The purpose of the application in reading diagnostic data from the device and sending a few commands to it - like turn left, turn right, setValue - nothing special (it is a special valve, which can be remotely controlled).
Now if a learned correctly the options with using Bluetooth on iOS are:
CoreBluetooth: library for Bluetooth 4.0 LE devices. It cannot be used, because Bluetooth chip is 3.0
ExternalAccessory: the device must be MFI certified, if this option is about to be used. Quite hard that hardware producer will go into the MFI certification, so at the moment not an options.
Bluetooth.framework: private framework which sounded like a good option (I have managed to make it run on iOS9 and iOS10) but the communication with devices on iOS10 does not work anymore. On iOS 9.3.5 on iPhone5 I made it work, but only iOS9 is not an option
BTStack: available via Cydia, but this packages if I have learned correctly require iPhone jailbreaking. Sadly again not an option
The situation clearly does not look good here. I have also read rumors, that it might be possible to use HID bluetooth profile for communication (anyone tried that). is there any C Bluetooth library which could be run on iOS device and work with iOS10?
Thanks for any iadeas.
Related
I'm trying some iOS test applications on the new Mac mini, that supports Bluetooth Low Energy. The CoreBluetooth framework is used in those. However, I'm not able to get Bluetooth working in the iPhone simulator, that is part of Xcode.
When I allocate a new CBCentralManager, centralManagerDidUpdateState: receives CBCentralManagerStatePoweredOff which stands for Bluetooth is currently powered off.
The first time I ran the text application, a box was then opened up that looked pretty bugged (only language variables were used, not the actual texts) and with two buttons. The first led me to the settings panel where there was an option to enable Bluetooth. However, after I told it to enable Bluetooth, it just shows the spinning animation, and it won't either complete or cancel. Even after rebooting the Mac, there is still only the spinning animation. The box also does not open up anymore.
Essentially, I think that the iPhone simulator should support Bluetooth Low Energy. Otherwise, it does not really make sense that there is an option in the settings application on the simulator. Also, the central manager state is CBCentralManagerStatePoweredOff but not CBCentralManagerStateUnsupported which would stand for The platform doesn't support Bluetooth Low Energy. This gives also hope that support could exist.
Does the iPhone simulator support Bluetooth Low Energy?
If yes, how can I enable it?
The simulator does support Bluetooth Low Energy (4.0) according to this appnote from Apple. The only problem is that even if you have a computer with BLE inside, you will not be able to use the simulator together with it, because (I think) you occupy the availability on BLE for other devices to discover your computer, thereby restricting the functionality of the Mac.
So if you go get yourself a BLE USB dongle you will be able to use it in simulator.
EDIT: Adding information from #JoeShaw:
Unfortunately it appears as though Core Bluetooth support has been dropped from the simulator for iOS 7. Reference: doubleencore.com/2013/09/whats-new-in-bluetooth-le-ios-7. In addition, the linked technote seems to have been removed.
I have been using the simulator to test BLE apps - but you need to be on OSX 10.7. As Wilhelmsen mentioned, you also need a BLE USB dongle. In addition, you need to set an NVRAM setting:
$sudo nvram bluetoothHostControllerSwitchBehavior="never"
See this Technical Note from Apple for more details on using the simulator to test BLE apps: http://developer.apple.com/library/ios/#technotes/tn2295/_index.html
According to http://www.doubleencore.com/2013/09/whats-new-in-bluetooth-le-ios-7/, Core Bluetooth support has been dropped from the simulator as of iOS 7. I haven't figured out why yet, but it means you will need to test on real hardware in the future.
It also appears as though Apple has removed Tech Note 2295, as I get redirected when I hit the URL.
I've found that Apple writes in their own samples that the simulator cannot be used to test Core Bluetooth-based applications.
Important:
This project requires a Bluetooth LE Capable Device (Currently only the iPhone 4S) and will not work on the simulator.
I've been working on a BLE app for the past week and can say with confidence that no, the simulator does not support BLE unless the mac that your using has BLE(Macbook Air) - but even then i'm not 100% sure how to enable this(most likely by just turing on BLE on your mac and on the simulator).
If you don't have a BLE enabled mac, have to find yourself a 4s to do testing with!
One alternative approach to using CoreBluetooth in the Simulator is to use Nordic Semiconductor's CoreBluetooth-Mock library, which allows you to stub-out CoreBluetooth and provide simulated/mock peripherals for use when working with the simulator:
https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock
It does require some minor code changes, but the interface it provides is almost identical to that of CoreBluetooth.
It's also great for writing integration tests too.
Actually I tried in the simulator and does not work.
The simulator does not recognize if you have a Bluetooth 4.0 in your computer but if you are using Command line tool projects in Xcode then it works. just for the cases you want to create something in Command line tool.
I am doing a project that uses BLE(CoreBluetooth).
In the mean time we use a mock in the form of android device.
My question is this:
Why does the CoreBluetooth doesn't recognise the android device? (i read about BLE GATT but still didn't understand it).
Also if i go in the iPhone to settings->bluetooth it recognises it and even connect to the android device ,how can i implement this in my app?
Programming with CoreBluetooth
IMHO, CoreBluetooth is quite cumbersome. I suggest using a library like RxBluetoothKit which takes away a lot of the boilerplating involved with handling the GATT profiles yourself.
Devices, mockups
Cool BLE devices are around 30$ nowadays. I use PuckJS - a JS supporting programmable BLE board.
Apple requires MFI certification for devices that connect to iOS devices via Bluetooth.
The exceptions are:
BLE devices.
Bluetooth devices which exclusively support either of these profiles.
So your Android mockup would have to advertise itself as one of these.
I'm trying some iOS test applications on the new Mac mini, that supports Bluetooth Low Energy. The CoreBluetooth framework is used in those. However, I'm not able to get Bluetooth working in the iPhone simulator, that is part of Xcode.
When I allocate a new CBCentralManager, centralManagerDidUpdateState: receives CBCentralManagerStatePoweredOff which stands for Bluetooth is currently powered off.
The first time I ran the text application, a box was then opened up that looked pretty bugged (only language variables were used, not the actual texts) and with two buttons. The first led me to the settings panel where there was an option to enable Bluetooth. However, after I told it to enable Bluetooth, it just shows the spinning animation, and it won't either complete or cancel. Even after rebooting the Mac, there is still only the spinning animation. The box also does not open up anymore.
Essentially, I think that the iPhone simulator should support Bluetooth Low Energy. Otherwise, it does not really make sense that there is an option in the settings application on the simulator. Also, the central manager state is CBCentralManagerStatePoweredOff but not CBCentralManagerStateUnsupported which would stand for The platform doesn't support Bluetooth Low Energy. This gives also hope that support could exist.
Does the iPhone simulator support Bluetooth Low Energy?
If yes, how can I enable it?
The simulator does support Bluetooth Low Energy (4.0) according to this appnote from Apple. The only problem is that even if you have a computer with BLE inside, you will not be able to use the simulator together with it, because (I think) you occupy the availability on BLE for other devices to discover your computer, thereby restricting the functionality of the Mac.
So if you go get yourself a BLE USB dongle you will be able to use it in simulator.
EDIT: Adding information from #JoeShaw:
Unfortunately it appears as though Core Bluetooth support has been dropped from the simulator for iOS 7. Reference: doubleencore.com/2013/09/whats-new-in-bluetooth-le-ios-7. In addition, the linked technote seems to have been removed.
I have been using the simulator to test BLE apps - but you need to be on OSX 10.7. As Wilhelmsen mentioned, you also need a BLE USB dongle. In addition, you need to set an NVRAM setting:
$sudo nvram bluetoothHostControllerSwitchBehavior="never"
See this Technical Note from Apple for more details on using the simulator to test BLE apps: http://developer.apple.com/library/ios/#technotes/tn2295/_index.html
According to http://www.doubleencore.com/2013/09/whats-new-in-bluetooth-le-ios-7/, Core Bluetooth support has been dropped from the simulator as of iOS 7. I haven't figured out why yet, but it means you will need to test on real hardware in the future.
It also appears as though Apple has removed Tech Note 2295, as I get redirected when I hit the URL.
I've found that Apple writes in their own samples that the simulator cannot be used to test Core Bluetooth-based applications.
Important:
This project requires a Bluetooth LE Capable Device (Currently only the iPhone 4S) and will not work on the simulator.
I've been working on a BLE app for the past week and can say with confidence that no, the simulator does not support BLE unless the mac that your using has BLE(Macbook Air) - but even then i'm not 100% sure how to enable this(most likely by just turing on BLE on your mac and on the simulator).
If you don't have a BLE enabled mac, have to find yourself a 4s to do testing with!
One alternative approach to using CoreBluetooth in the Simulator is to use Nordic Semiconductor's CoreBluetooth-Mock library, which allows you to stub-out CoreBluetooth and provide simulated/mock peripherals for use when working with the simulator:
https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock
It does require some minor code changes, but the interface it provides is almost identical to that of CoreBluetooth.
It's also great for writing integration tests too.
Actually I tried in the simulator and does not work.
The simulator does not recognize if you have a Bluetooth 4.0 in your computer but if you are using Command line tool projects in Xcode then it works. just for the cases you want to create something in Command line tool.
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.
The vibe I'm getting from Stackoverflow and the internet at large is that unless I'm using an LE device, any Bluetooth device I make for an iOS app must be MFi certified.
However, on the MFi FAQ page, I found this line:
...developers of accessories that rely solely on standard technology
(e.g., Bluetooth Low Energy or standard Bluetooth profiles) do not
need to join the MFi Program.
My device will be able to use the standard Bluetooth profile File Transfer Protocol (FTP).
Now this sounds like some conflicting advice to me, or perhaps I'm just not understanding correctly. So, having provided the above evidence, I'm just going to ask outright: Can I write and publish an iOS app that connects to a proprietary Bluetooth device using the standard Bluetooth profile FTP without certifying my device as MFi? And if so, what details, caveats, etc do I need to know?
The new Bluetooth 4.0 Low Energy (hereafter BLE 4.0) specification which is implemented in Apple's latest iOS devices does allow one to create app-specific profiles and connect to BLE 4.0 devices without jailbreaking, using an approved Bluetooth 2.1 profile, or becoming part of Apple'd MFI program and using the previously required MFI cryptographic chips.
In other words with the proper BLE 4.0 compatible bluetooth radios you can create wireless devices that connect to iOS apps without having the device pre-approved by Apple. However, you must write a custom app for the device, and Apple still holds the ability to reject that app if they want to. So they still control this to a great degree. This is essentially Apple's answer to the Android ADK, while not fully relinquishing the ability to shut down apps and devices they don't like.
Your app must include specific XML schema for your app's bluetooth profile, and use CoreBluetoothFramework APIs, so it's very obvious to Apple during the app approval process that your app connects to a device. If your app does not work without the device present, then it's likely to be rejected if you are not part of the MFI program, as Apple cannot test the app without your device. The apps that appear to be successful in passing this test use the device as an accessory to app functionality, rather than a requirement. For instance an exercise app might connect to a BLE 4.0 heart rate monitor, but the app doesn't depend on it.
Some apps seem to be getting around this by displaying simulated, or online information in place of the device information when no device is present. Thus the app can be tested without the device, and functionally works when the device is present.
You can find out some successful efforts online:
http://blog.makezine.com/2012/03/19/bluetooth-4-0-from-arduino-to-iphone-no-jailbreaking-no-mfi/
BlueGiga in particular has been pushing their devices specifically for this use, so there are probably forums and support for this elsewhere.
Keep in mind that the devices that currently support BLE 4.0 are limited, and currently only include
iPhone 4S and later iPhones
recent MacBook Air, Mac Mini
iPad (3rd generation and later, and iPad mini)
Macbook Pro Retina
There may be other Apple devices that support this standard, it's something Apple is advertising openly on each product's technical specifications page so it's easy to find for current products.
That line is referring to standard profiles supported natively by ios devices, such as HFP or A2DP. If you build a headset device that does HFP, the iphone will be able to connect to it and route your call to the headset without the headset being part of MFi.
If you want to write an app that does other things with bluetooth, inlcuding FTP, you would have to use MFi.