How to connect BLE multiple devices at the same time in Swift
I'm working on iOS application project using BLE to transfer some data between them. The concept is one device is the main device that broadcast the data to other devices, then device that get data from bluetooth send data back to the main device.
How to connect multiple devices at the same time using core bluetooth? (1-to-many topology)
Is that possible to send and receive data in the same time?
There are two different roles: peripheral and central.
A peripheral typically has data that is needed by other devices. A central typically uses the information served up by a peripheral to accomplish some task.
The central can discover and connect to multiple peripherals.
See Core Bluetooth Programming Guide for details. Even it is archived, it has the good overview of the feature.
Related
I am developing two apps in swift which should communicate with another iPhone device and waiting for their response over Global.
I am using remote push notification and it's working fine, but its not receiving notification while the app in foreground state and has some push notification related issues.
If I used web service for sending and receiving. My app gets struck due to the lag response
Is any method available for iPhone communication over internet without using APNs?
You can use MultipeerConnectivityFramework, which has support for discovering services provided by nearby iOS devices using infrastructure Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth personal area networks and subsequently communicating with those services by sending message-based data, streaming data, and resources (such as files).
I am adding sample code here, it is an example application which builds on the Multipeer Connectivity framework for discovering, connecting, and sharing data between "nearby" peers. This application uses framework based UI for connecting to local peers and the framework convenience API for exhanging text messages and image resources between devices.
I'm trying to determine what functionality I can add to a BT accessory by paying for the MFI authentication coprocessor. For example, could I...
A. Pass location data to the accessory?
B. Push incoming SMS messages to the accessory?
C. Launch my app on the phone from the accessory?
As Dennis mentioned, all information regarding the MFi program is covered under a VERY water tight NDA. However, what can be said is that all devices that connect to the iPad through Bluetooth or the docking connector port are accessed through the External Accessory framework. Documentation on the External Accessory framework is easily accessibly from Apple's documentation pages and can also be easily googled.
Communication with devices through the External Accessory framework is fairly simple once you've established a connection with a device. In short, the process is to find the desired connected accessory from an array of devices, establish a connection session and the session object contains a input and output stream. Data by creating a delegate that with the device and finally, monitor the associated input and output streams which you use to communicate with the device.
Again, the majority of the information associated with MFi is tightly sealed. However, as far as connecting to devices (that you have the right to connect to) is simple, well documented and is easily searchable since the framework is part of the standard, iOS library.
One other note on Bluetooth. There is also a Core Bluetooth framework that is available with iOS 5.0 and up. This is a much simpler framework that you can use to discover and auto pair with Bluetooth Low-Energy devices (which are part of the new Bluetooth 4.0 spec.)
If you are planning on making an iPad application or desire to have a fairly high level of backwards compatibility with earlier iOS devices, I wouldn't recommend using the new CoreBluetooth framework. The reason is because only the iPhone 4S and the soon to be released "New iPad" have the necessary Bluetooth chipset to connect with Bluetooth LE devices.
All Mfi information is under NDA.
It dosent cost anything to sign up and get access to the information , you can do it here.
https://developer.apple.com/programs/mfi/
I need to communicate my app with 2 devices. A restriction is that I can't use a server but all iOS devices will be in one Wi-Fi network. What options do I have? How I can send a message to another copy of my app running on another device?
I dont know whether its a correct approach or not but as you cannot use server,so the approach i can think of is we can create a socket connection using TCP/IP or UDP(based on reliability) for data exchange.
I dont think you can communicate between 2 devices running the same application without having some kind of server application in-between.
Even if you could find the other device over the WIFI I dont think you can tell if the other device is running the app or not.
I think you may be referring to MultipeerConnectivity
The Multipeer Connectivity framework provides support for discovering
services provided by nearby iOS devices using infrastructure Wi-Fi
networks, peer-to-peer Wi-Fi, and Bluetooth personal area networks and
subsequently communicating with those services by sending
message-based data, streaming data, and resources (such as files).
Source: https://developer.apple.com/library/ios/documentation/MultipeerConnectivity/Reference/MultipeerConnectivityFramework/
Apple Sample:
https://developer.apple.com/library/ios/samplecode/MultipeerGroupChat/Introduction/Intro.html
I am trying to connect multiple iPhones using bluetooth. I was thinking of having a server/client system. I just want to know upto how many devices can be connected using bluetooth? I am not able to find a reliable answer online.
Also If you know of any good tutorials regarding this it would great if you could point me to it.
Thanks
AC
A single Bluetooth device can connect with upto 7 devices in a piconet. If a device can do scatternet it can be connected to even more devices..
Application level connection can happen only if both devices supports the required profiles and corresponding role.
If you are trying to stream music , the profile to be used is A2DP , one device will need to be the A2DP source and other A2DP sink,
In case of Iphone it supports only A2DP source. So 2 iPhone will not connect with each other.
you can implement the bluetooth profile for this (A2DP), the big issue here is not the music streaming but the roles, you iPhones are going to play, for instance, you can be a "sound-source" and transfer audio to a "sound-sink" device, those roles have to be previously defined on the handshake and paring action, furthermore, if you are able to browse the properties of an iPhone you will get what port and what roles are supported, sadly muss I said, there is no sink role supported jet for iPhones, so the most that you can get till now is stream audio from iPhone to another bt capable device (speakers, pc, headset unit, etc) more info can be reached on the official bluetooth web site and what iOS until now supports.
Can iphone use as a receiver ? Let's say, there will be one app which can connect with a hardware that can send RDF signal. Is that possible iphone to receive signal without any additional hardware ? Thanks.
It's not possible without any additional hardware.
In order to make peripherals work with iPhone you need to contact Apple and become a registered peripheral developer, the membership that allows manufacturers to use the "Made for iPhone" etc labels.
Once you're a member you can get access to the peripherals SDK which allows you to develop for devices that connect to the iPhone using the 30 pin dock connector.
Without developing a device that receives RDF signal that can connect to the iPhone either using the dock connector or a network connection, there's no other way to make the iPhone receive that signal.
If the RDF hardware is able to communicate using standard UDP or TCP/IP based methods then the iPhone can communicate with it using network communication classes. This could be CFNetwork or higher level classes such as NSURLConnection.