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

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.

Related

Inter App Communication between iOS App and Atmega 1284 microprocessor via bluetooth

What I am trying to accomplish:
User enters a password on the iOS app. If the password is correct, then send a one bit value to the microprocessor that indicates the user got the right password. The microprocessor can then start up the step motor to open the door latch.
Has anyone tried to achieve this before? If so, can you please point me in a general direction. I don't know how to approach this problem. I couldn't really find a tutorial for this. My questions are:
Is there a specific Bluetooth I need to purchase? such as only BLE devices
I see a lot of examples of Bluetooth communication between iOS and Ardunio. Would the execution of events be similar for my needs?
Is there another approach to my problem? rather than using Bluetooth?
I think reading the Core Bluetooth Programming Guide is a great start. However, this assumes the device you're connecting to is using Bluetooth 4.x which is widely known as Bluetooth Low Energy (BLE). If the device you're connecting to is using Bluetooth 2.x, you'll have to use the External Accessories Framework.
EA supports only devices that have been certified MFI (Made for iPhone) by Apple.
To make a long story short, if the device you're trying to connect to is Bluetooth 2.x and it's not MFI, you're basically SOL.
Otherwise, you can start connecting to that device pretty easily. Check out LightBlue as a way to test if you connect to the device. It will work with any BLE device.
Here's a simple tutorial to get you going with Core Bluetooth.

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 a Bluetooth profile always required to be used when sending data between an iOS device and a Bluetooth device?

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.

Using custom/existing bluetooth HID with iOS Devices?

I am working on building or using an existing bluetooth HID device (something like this http://www.icontrolpad.com) and to get my iOS device to read the data coming from it. So i have some questions regarding this:-
Is it possible at all to do this, considering that the Bluetooth stack is not available on non jail broken devices.
Do i need to register with apples Mfi program? If i don't need to, what are the alternatives?
If i do register with Apple's Mfi program will i get access frameworks that will allow me to read data off the Bluetooth stack.
Considering that there will be a custom application sitting on the iOS device that needs to communicate with the HW im building, what are the implications w.r.t the approval of the app from Apple's side?
Thanks in advance, any help is greatly appreciated!
Core Bluetooth framework is available for Bluetooth Low Energy devices on iOS 5, no MFi membership is required.
With Made for iPhone, you basically get a serial pipe to your device using the ExternalAccesory Framework (in fact, it IS using the serial port profile plus some authentication). So you while you cannot use an actual HID device, you could send your data over.

iOS receive data from bluetooth and then send information to a database on another server through wi-fi

Which libraries should I look into for the following tasks?
I want to receive a string from another device via Bluetooth (this will require looking at a list of nearby devices and choosing the right one.
I then want to send the String to a database via Wi-fi
This is a simple version of what I actually want to do, but I need to know how to do those things first. Also, any design tips would be greatly appreciated (like having multiple screens, which classes to write, etc).
The ordinary iOS Bluetooth APIs are only available if you enter into Apple's "Made for iPod" program. See MFi Program
If your device can use the newer "low energy" Bluetooth LE, you can look in the corebluetooth framework
There is an example of a Bluetooth LE heart rate monitor program here.
For WiFi, you can use any of several APIs from Apple and others: Berkeley unix sockets, NSURLConnection, CFNetwork, AsyncSocket, etc.
If you mean receive a string from another iOS device, the statement here about needing to be a part of the "Made For iPod" program is incorrect. This would be required if you mean you are trying to build an accessory for iPhone, iPad, or iPod.
The easiest way to "discover" other iOS devices (running your app) and transfer data between them is GKSession from the GameKit Framework. Beam It! is pretty good example code for this.
Once you initialize a GKSession just set a GKSessionDelegate and set the session's available property to YES. Check out the four required GKSessionDelegate methods and the Beam It! sample code.
http://arctouch.com/beamit/ //Beam It! code
Your best bet is to study Apple's WiTap sample app. That will answer your question #1. For question 2, you can use Apple's coredata. If you are not familiar with coredata, check out this site's tutorials.

Resources