Bluetooth framework for older iOS devices - ios

My question is related with Bluetooth technology around iOS.
I've watched WWDC about Bluetooth Low Energy 101, what's new, the basics etc, and about using the CoreBluetooth framework available in iOS 5 and later.
I've looked through different sites and documentations trying to find more information about Bluetooth 2.1 and 4, but there is so few.
GameKIt is not an answer, I am developing an app to work with an non-iOS device.
Some of the topics I've went through:
Connecting to a Bluetooth device from iOS, no MFi
iOS - How to integrate bluetooth devices in my app
http://www.bluegiga.com/files/bluegiga/Presentations/BT4_0_for_Apple.pdf
Bluetooth 4.0 with older Bluetooth
IPhone Bluetooth Connectivity to Non IOS Devices
But the supported devices are just 4S and up and latests iPads...
1) will the latest CoreBluetooth framework just fail on older devices?
2) Did apple have any frameworks for BT 2.1 or something? What to do, there are still so many ipad2 and iphone4 users, I can't just ignore them.. So what framework actually to use?
Any help, advice, idea,link will be highly appreciated!

Well...
You need to understand one thing: CoreBluetooth framework is used for Bluetooth Low Energy and ExternalAccessory framework for the "Classic" Bluetooth. It is really two kind of different approchs of what we usually call Bluetooth (as a simple user/consumer).
Only recent iDevices support Bluetooth Low Energy (iPhone from 4S, MacBook Air from 2011, etc.). That's why it doesn't support iOS4 for example.
For your information, Bluetooth Low Energy is kind of a fork of Bluetooth which appears only in Bluetooth 4.0. Even if having a Bluetooth 4.0 device does not ensure that it supports Bluetooth Low Energy (as I said, it's a fork which is not always include).
As a simplistic vision, Bluetooth Low Energy works like a NSDictionnary with a NSDictionnary in it. You get a Peripheral, which as one of more Services which has one or more Characteristics. Quite different from a common device, right ?

Did apple have any frameworks for BT 2.1 or something? What to do, there are still so many ipad2 and iphone4 users, I can't just ignore them.. So what framework actually to use?
To talk to a Bluetooth 2.1 device, you need to be in the Made for iPhone accessory program. The details of it are under NDA, but you should expect things like Apple reviewing your manufacturing processes and auditing your accounts, and putting a custom chip into the accessory. If you don't make the accessory yourself, you're probably out of luck.
The only exceptions are the classes of device that iOS supports natively: keyboards, audio output, car stereos, other iPhones etc. However, you still can't send and receive arbitrary data, you're limited to using whatever APIs exist for the specific functions (e.g. for audio output, Core Audio lets you set a few properties for how Bluetooth devices behave).

Related

iOS 9 an 10, Bluetooth connection with Bluetooth 3 device

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.

If I don't have a Bluetooth LE device am I just out of luck with trying to write a program?

I see questions surrounding issues such as "Device Unsupported" in many posts on this website and on the internet, so I feel like the problems I am having are not unique.
What perplexes me (and trust me I have searched all day) is that I recently bought a new Macbook Pro computer (surely the BT on this thing is LE), upgraded to Mavericks, and am using Xcode 5. But no matter, what sample code I download, whether from the BT SIG or CSR, etc., I always get the same basic errors (on the iOS Simulator):
Something to the effect of "Device Unsupported" AND
Something about how it can't run because it's not powered on (and I did try to work around by wrapping the central.state call in an if block)
So, are the people like me who are starting to code Bluetooth today just screwed if we don't have LE devices? Did all of the BT code prior to 4.0 fall off the face of the earth or get deprecated?
Is there a simple way to force my code to run in some type of "non-LE" mode?
As for the code I'm using, I downloaded the Quick Start kit from the BT SIG, but nothing works, even simple scan programs that I have found. Ugh, any ideas out there?
My ultimate goal is to write something that will run without errors, load on my iPhone 4, and scan and pair with my car's stereo and grab all of the peripheral advertisements that it is sending out to see what all I can do with (to) the stereo.
Thanks all.
While your computer does have Bluetooth Low Energy/Bluetooth 4.0/Bluetooth Smart (they are all different names for the same thing) capabilities, these are not available to the simulator. A while ago you could add an additional BT4.0 dongle to the Mac and then access that from the simulator, but this is no longer supported - see Does the iPhone simulator in Xcode support Bluetooth Low Energy?
You can develop BT4.0/BLE code in Xcode for OSX with just your computer, but if you want to develop and test iOS code you will need a BLE capable iOS device (iPhone 4S or later, iPad mini/3rd gen/Air or an iPod Touch 5th generation)
Access to non BT4 devices is only via the Apple MFI program, with the exception of a few generic profiles, such as handsfree & A2DP streaming - but these are exposed to your program as audio devices, not as Bluetooth devices.
If you have an iPhone 4S (not iPhone 4) then you can use the LightBlue app from the App Store to see if your car stereo is advertising any BLE services (which it probably isn't).
crawdaddy18, Bluetooth Smart/4.0/LE are fundamentally different technologies then what we'll call Bluetooth Classic (2.0/2.1/EDR/BR...this is the stuff you are referring to with your car audio example). If you want to see what's going on with your car stereo, see what profiles it supports (should be listed in the documentation). Then take a look here:
https://developer.bluetooth.org/TechnologyOverview/Pages/Profiles.aspx#Profiles
This page lists all of the 'classic' profiles. You should find the ones that match your car on the list. You'll then know what functionality your car stereo supports.
Then, it's off to the races with OS documentation to look at the object models for classic Bluetooth. Usually these are either supported by an object model that represents the profile or are wrangled through RFCOM somehow...but each OS is a bit different.
But most of the tools that are out there, including the Application Accelerator, are geared to let you explore LE (Smart) devices out there. If you want to use something like the Application Accelerator to view non-LE devices, you'll have to re-jigger the code to switch the object models that you use in the OS' SDK. The reason that most recent tools you are finding now are geared towards the LE side of things is that that is where the massive growth in appcessories (and the Bluetooth industry) is heading. But there are TONS of sample code out there to help to create an app to scan and connect to classic Bluetooth devices as well.

iOS PKPKT BLE concept

I understand that the iOS App "PKPKT" is using BLE (Bluetooth Low Enery). But what I am curious about it is, is it purely using BLE only? Or does it switching between BLE and Classic Bluetooth?
I tested with a iPhone 5 and a iPhone 5s with both installed the app. I turned on bluetooth on both devices. And then i checked the "DEVICES" list to see if the other iPhone is paired with one another, I found that they are not. Until i launched the PKPKT on one of the device, and the i check the "DEVICE" list again, now they are paired and connected. So, i'm thinking is this pairing done by the BLE pairing? Meaning one of "Just works", "Out of Band", or "Passkey entry" methods.
There is also a "Chat" functionality in that app. This make me curious if the chatting function using BLE or Classic Bluetooth?
So my question is actually "Is switching between BLE and Classic bluetooth possible?". This is part of the study on this BLE technology. Hopefully someone could help me and other newbie on this new technology.
Thanks in advance!
I wrote PKPKT. I only use BLE. No classic. iBeacon is cool but doesn't have the background scanning needed to discover other players. I use game center, but only for scores, no sessions. It's optional in the app to enable game center (those banners can be distracting!)
The chat is also over BLE.
Because the connections are not encrypted, you don't need to manually pair the devices, and "just works"
I think you might find this link helpful. It implements something that looks to be a simpler version of PKPKT. I believe the app uses a combination of GameKit/iBeacon. The app requires iOS7.0+ and states, "PKPKT does the hard work of finding other players by detecting them using Bluetooth Low Energy (BLE) in the background." iBeacon would be the most battery-efficient way of accomplishing this and is a new feature in iOS 7. There is a wealth of information online(particularly on SO) about peer to peer bluetooth gaming using GameKit, if you are interested.
We can't say for sure unless the developer lets us know. If one were to attempt to recreate the application, GameKit and iBeacon would be the technologies that I believe most would recommend.
You might find this project helpful as an overview of how to use Bluetooth LE to communicate between two devices. You don't need to pair the devices, and unlike iBeacons, it works when the app is in the background.
SimpleShare - Easy Proximity-based Sharing for iOS
You can use the delegate methods of the SimpleShare project to easily share arrays of strings between nearby users running your app, such as user IDs, which you could then use to get more info, photos, etc, about that user from a web service.

Is it possible to implement this bluetooth feature in iOS

I am considering implementing in an app the bluetooth feature to read and display the battery life of a connected bluetooth peripheral (i.e. keyboard, headset...)
Is there an API or objects that can implement this in the iOS SDK or can someone tell me how this can be done, if it can be done ?
Yes, but more than likely you will need to be a member of the Made for iOS program. You can connect to a device that is Bluetooth Low Energy without being part of the MFi program but it only available for peripherals that support and the iOS device must be the iPhone 4S or the new iPad. Also reference this stackoverflow question.

Is it possible to develop an iOS app with bluetooth capabilities?

Would the following be possible?
Let's say I have a scale with Bluetooth capabilities, when I turn it on, it sends the weight via BT.
Is it technically possible to develop an iOS app which pairs with the scale and receives the data from it?
According to Apple:
Technical Q&A QA1657: Using External
Accessory framework with Bluetooth
devices.
Q: I understand that the External Accessory framework in iOS 3.0 and later will allow my application to communicate with Bluetooth devices. So why doesn't my application see the Bluetooth accessory sitting next to my iPhone?
A: The External Accessory framework is designed to allow iOS applications to communicate only with hardware accessories that are developed under Apple's MFi licensee program. MFi compliant accessories can be implemented as wired devices, meaning they plug in to the Apple device's 30-pin or Lightning connector, or as wireless devices, whereby they use Bluetooth as the communication channel. Either way, an application that uses the External Accessory framework will not be notified of an accessory's presence unless the accessory identifies itself as being MFi compliant, i.e., it was specifically designed to interface with an iOS application.
Yes, we can connect Bluetooth devices with iOS application through Core bluetooth framework. This framework is supported on the iPhone 4s, iPhone5,iPhone 5S ,iPad3. We can use BLE 4.0 for the communication between scale and iOS application. Here, iOS application become the client and scale become the peripheral. You Can set as well as get data from the weighing scale.
While the External Accessory Framework with Bluetooth is one of the possible solutions, it has additional requirements to be built as per Apple MFi, here Bluetooth reference is to the Classic Bluetooth (Version 3.x and below)
The best solution for the use case you have defined is to use the Bluetooth Low Energy (LE) (aka Bluetooth Smart) technology (Bluetooth 4.0) and it is available to applications as part of the Core Bluetooth Frameworks
Here are the APIs for Core Bluetooth that applications can use.
While currently Bluetooth Low Energy is supported on the latest iPhone 4S, New Mac Mini & Macbook Air - its expected most new Apple & Others hardware will have this standard.

Resources