My Google Glass and Mobile supports Bluetooth LE.Can I use the Bluetooth LE for two way communication between Glass and mobile.I try to send an image from Glass to mobile and again send response to Glass using bluetooth LE.Is it possible to do this?
Yes it is possible. First, decide which device is Central; usually the smartphone should be, as it's got more resources and power. Then when the two connect, their GATT roles (Client and Server) are interchangeable at any time, because GATT roles are independent of GAP roles (Central and Peripheral). Simply issue a GATT request from any of the two applications.
Sidenote: BLE is not designed for sending images. Each radio packet contains maximum 23 bytes of application data, so imagine how many packets you need for an image.
Related
What I have read from many documents of Android Developer and lectures that I searched on the internet is: Advertising is sending signals to a broadcasting device so that the device could be found and Broadcasting is scanning the advertising devices to connect/send data.
Is what I understood correct?
Then is it true that BluetoothLeAdvertiser should be implemented first before scanning activity?
I am keep researching on the internet to find information in order to create an app that can broadcast a short word to other nearby devices through BLE.
However, when I was doing research people do not use class LeAdvertiser that was introduced as an example on Android Developer page. Why is it??
As Emil said, broadcaster/advertiser is the device that sends out BLE adverts. Broadly speaking, there are 4 main (GAP) roles in Bluetooth Low Energy:-
Broadcaster - A devices that just advertises data.
Peripheral - A device that advertises data but can be connected to by remote devices as well.
Observer - A device that just scans for data.
Central - A device that can scan for data as well as connect to them.
When BLE was first introduced, beacons/sensors (e.g. Heart Rate, Thermometer) occupied the first two categories and phones/computers occupied the other two. However, BLE has since evolved and a lot of devices now support all four roles and a device can operate in one or more roles at the same time.
And yes, if you want your device to be found by other observers/scanners, then you should first use LeAdvertiser in order to send out BLE adverts. Have a look at the links below that show how this is used:-
How to advertise Android as a BLE peripheral
Sample Bluetooth LE GATT server
BLE: send data to iOS from Android
Is it possible for an iOS/Android app to transmit data to a remote server when it picks up an iBeacon signal. The app will run in the background.
Lets assume the iBeacon is equipped with an internet connection as well. Will the beacon be able to pick up the data transmitted from the smartphone app?
What I'm trying to achieve is this:
An IoT device works as an iBeacon (and motion sensor)
The IoT device picks up motion via the sensor
The IoT contacts a remote server to find out if a given smartphone is within close range of it.
The IoT performs some sort of operation based upon if the smartphone is close or not.
Would this be possible?
Yes and No.
Yes, an iOS/Android app in the background can transmit data to a remote server when it detects an iBeacon signal. This is a very common use case, and I have built several apps that do this.
No, an iBeacon cannot send data to a server for two reasons:
An iBeacon is a transmit only device. It does nothing more than regularly send out an advertisement packet with a unique identifier. By design, it does not listen or receive. While you could certainly build some other custom Bluetooth LE device that does this, it would not be a standard iBeacon.
Typically iBeacon devices do not have internet connections.
What you describe is certainly possible if you build a general purpose computer with an internet connection that also sends out an iBeacon transmission as a small part of what it does. I have built such systems out of Raspberry Pi computers, and stationary Android/iOS devices. But you could also do this with a laptop, desktop, or smaller embedded device.
The key distinction in being able to do this is recognizing that you can't just buy an off-the-shelf iBeacon and make this work. You have to build your own IoT device based on a small computer with an internet connection that is augmented to transmit an iBeacon advertisement.
I had been wondering how wireless earbuds work and came across this image. I do not know how to replicate what is shown in the following image and would like to learn how to do it.
My end goal is to be able to have the smartphone connect to a device, while still being able to play music to a Bluetooth Headphone. I read into BLE 4.1 mesh and I am not sure if that would help either.
I have made images for the possible ways the multiple devices could communicate but I don't have enough reputation to attach the xD. I will try my best to describe them.
1) All devices manage to simultaneously communication with the smartphone.
2) All devices connect to a hub which relays data to the smartphone.
3) One device is the hub itself and relays data for all other devices while sending its own data.
4) The devices relay information for each other till the smartphone receives the data it called for.
5) Another possibility is to have a mesh structure where the devices relay all messages broadcast-ed over the network until the device for which the message is meant for, receives it.
I hope to make a project where a Bluetooth device I make does not hinder the user from connecting and using other Bluetooth devices simultaneously.
Thanks for reading and I look forward to any and all responses.
IMAGE 1:
IMAGE 2:
IMAGE 3:
IMAGE 4:
You need to consider few things first.
Since version 4.0 Bluetooth specification contains "Classic
Bluetooth, Bluetooth high speed and Bluetooth low energy (BLE)
protocols."
Bluetooth Classic provides profiles like A2DP, AVRCP that
are usually implemented by Bluetooth earbuds or speakers.
BLE on the other hand communicates using GATT (a general specification for
sending and receiving short pieces of data known as attributes over a
low energy link).
BLE is not designed to handle high bandwidth scenarios like Audio.
Now getting to a point
You can have a smartphone connected to your earbuds with A2DP profile
and simultaneously connected to several BLE devices.
One or more of these BLE devices can realize mesh connectivity
Background
I have an idea for an app on vacation that needs to communicate to other phones with the same app. While on vacation those phones might not all have internet as roaming can be very expensive. The data is not a lot: like 500 kB max would suffice (in json).
Every phone has a bit of info that all the other phones would like to know, but if it helps the info can be stored on 1 phone (master phone from now on) and shared later to the other phones when back home over internet.
Phones
Android, iPhone and Windows Phone
We can't assume they have NFC, IR or zigbee. Just the hardware almost every phone has like bluetooth, camera, microphone etc.
My ideas
QR codes that changes, based on new info: If the first phone is scanned the second phones QR code has data from the 1st phone and itself and the 3rd phone has data from the 1st, 2nd and 3rd (itself) until it reaches that master phone that holds all data.
Data transmission trough sound that we can't hear (or we can). Con is that I don't know if something like this exists for mobile platforms and writing it is like a 3 year master thesis project.
http://nearbytes.com
https://applidium.com
https://developer.chirp.io/
Bluetooth. Can we connect like 8 devices? Would it work consistent (connecting even my headphones can be a hassle, what about 8 phones who try to connect simultaneously)
All of these ideas have big cons. Maybe I'm overlooking a better way.
I will add a bounty to the question for the best solution
An answer that explains it with a little bit of code reference (link is ok) is always better than just: "use bluetooth man"
TL;DR
The easiest (and most supported) way of getting multiple devices to connect to each other is using WiFi. Since your goal is to achieve data transfer with no internet, the most appealing solution would be to use a Peer-to-Peer network structure.
The two major smartphone OS's (Android and iOS) have API's and documentation on creating and transferring data over a Peer-to-Peer network.
Android WiFi P2P
Apple Multipeer Connectivity
These two also have a means to encrypt the data being transferred.
Windows doesn't seem to have an API to allow multiple peers connected, but their Proximity Class will work for one device at a time.
I can give a few outlines over the different options in each major OS:
Android
Android's WiFi P2P (peer-to-peer) API was created for transferring data without internet or another network.
From their documentation:
The Wi-Fi peer-to-peer (P2P) APIs allow applications to connect to nearby devices without needing to connect to a network or hotspot (Android's Wi-Fi P2P framework complies with the Wi-Fi Directâ„¢ certification program). Wi-Fi P2P allows your application to quickly find and interact with nearby devices, at a range beyond the capabilities of Bluetooth.
Google even has Documentation and training on this API.
iOS
Apple's Multipeer Connectivity.
Very similar to Android's P2P API, they claim:
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).
Here is a decent looking tutorial on using Multipeer Connectivity.
--EDIT--
Another iOS way of doing this, which is a bit of a mis-utilization(?) of the tool, is by using GameKit.
However, I think that to get it to work for your purposes might result in a bit of a hack, since the "players" have to be using Game Center.
Windows
The only way (apparently) to connect phones in Windows Phone, is by using Proximity, however, that only gives you the option of connecting no more than two phones together.
They state:
Proximity is a great way to create a shared app experience between two instances of your app running on two different devices.
Those are options in each of the major mobile device OS's.
App usage could be something like:
Decide which device was going to be the "master", so that other devices can connect to it. It isn't required to know this before deploying the app, but there should be a way for the user to decide whether he is going to be a client (receiving data) or the server (pushing data).
Once it was decided between the group of devices which was going to be pushing data, that device would have to be registered as the server (in the Android P2P API, you can establish a "group owner"), and then start looking for peers by initializing the service.
Then, once the devices are connected to the master device, you can start pushing data. An additional bonus is that when using Android WiFi P2P, all communication is encrypted with WPA2, and with iOS, you can enable encryption using MCEnableEncryption (however they state that is slows down data transfer rate).
Now you would just have to pick one method to go with, and make sure that all the phones ran that OS. Because these three methods of connectivity won't work together.
All of the three methods listed are done programmatically, so there should be no strange or odd things that your user will have to do. Searching for other devices, connecting, and transferring data can all be done within your app.
More help can be provided if the question is narrowed down to specific problems, but this should be enough data to get you started.
Don't try QR or sound. I think it would be very painful to transmit 500kb of data.
Bluetooth seems like a good solution but maybe, as you already said, hard to configure.
What do you think about wifi?
At least every Android and iPhone device can create a mobile wifi hotspot. By using this, you can easily setup a environment where 8 devices are in the same LAN (without using the internet by any of your devices).
Now your "master phone" runs a simple server to synchronize data (just like an internet server would do). Every of the seven clients could receive the ip adress of you master by scanning a simple QR code or sending a short message and afterwards configure itself accordingly.
Have you checked Alljoyn?
As quoted:
"Developers can write applications for interoperability regardless of transport layer, manufacturer, and without the need for Internet access"
You can create a Wifi connection between your devices. Than after connection it creates local network between your devices. Inside this network you, of course, can interact between your devices using TCP/IP connection. It works both on Android and iOS. Simply lauch your app as server on the one device
EDIT
Note, you have to connect your devices using any network. It is possible to connect the devices by initializing your device as WiFi-router. It can be both Android and iOS. If it is possible, you can connect your devices to any wifi connection.
Than, launch your app as Server-socket, the others as clients.
for Android (java) server use this link:
https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html
try (
ServerSocket serverSocket = new ServerSocket(portNumber);
Socket clientSocket = serverSocket.accept();
PrintWriter out =
new PrintWriter(clientSocket.getOutputStream(), true);
BufferedReader in = new BufferedReader(
new InputStreamReader(clientSocket.getInputStream()));
) {
for android device client:
try (
Socket kkSocket = new Socket(hostName, portNumber);
PrintWriter out = new PrintWriter(kkSocket.getOutputStream(), true);
BufferedReader in = new BufferedReader(
new InputStreamReader(kkSocket.getInputStream()));
)
The same idea is for iOS (Objective-C):
server
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/UsingSocketsandSocketStreams.html#//apple_ref/doc/uid/CH73-SW8
and client:
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/UsingSocketsandSocketStreams.html#//apple_ref/doc/uid/CH73-SW4
A better way could be use Ble.
It's easiers to connect the phones because you don't need user confirmation.
Seems like you can connect up to 20 devices Maximum number of peripherals on CoreBluetooth?.
To transfer 500KB should require few minutes (may be between 2 and 5).
You can track an Android device without Internet via GPS.
Connection without The Internet:
SMS
USSD
DTMF (very slow)
How to design a tracking device on USSD is mentioned at
M2M IoT Cookbook
How to develop a device based on Wireless Wide Area Network modules
You also can use the Android phone as a data logger and store under the Micro SD Card and read the card by:
Replacing the SD card to your PC
Streaming the data local by Bluetooth
Forwarding the data at home by Wi-Fi
Or Possibly:
Your app can use SMS API to transmit the DATA or other SOURCES.
I have to make an application to pair an iOS and Android device (iPhone 5, iPad 3, Galaxy S3, Nexus 7 they all use Bluetooth 4.0) and then send data to each other.
Is this amount of data limited ? Can we send something like a photo or a PDF?
I've already done the pairing and sending data between 2 iOS devices using CoreBluetooth and the sample code from Apple BTLE_Transfer
Of what i understood, a Peripheral (Server) can Advertise to a Central (Client).
This central is scanning around itself, and then try to find the Server by looking for the UUID of the service advertised.
When i make a Server on Android, it is waiting for a connection (listening), i know the UUID and the mac address of my Server.
But when i scan with my iPhone (scanning for the same UUID of course), i can't find the server.
So is there a possibility for the android server to advertise like the Peripheral on iOS?
Or maybe a possibility for my iPhone client to connect using the mac address of the server?
Q: Is this amount of data limited ? Can we send something like a photo or a PDF?
Bluetooth Low Energy was not optimised for sending large amounts of data, nor is it optimised for streaming. It is more suitable for sending small chunks of data periodically (e.g. temperature readings, time, etc). Please have a look at this answer to understand how BLE transfer is different from classic Bluetooth. That being said, you can still send large amounts of data over BLE, and the amount of data is unlimited. However, this might end up being unreliable and relatively slow.
Q: So is there a possibility for the android server to advertise like the Peripheral on iOS?
Being a server/client is a completely different thing from being a peripheral/central:-
Peripheral/central dictates how the connection is made. A central device should initiate the connection. A peripheral device should advertise and wait for a connection request.
Client/Server dictates how the data is distributed. The Gatt Server holds the data. The Gatt Client can read, write or be notified (getting a continuous stream of readings) of this data. In most cases, the server is also the peripheral, but this is not mandatory.
So to answer your question, yes, the server can advertise like the peripheral on iOS. However, for Android, this feature is not yet available and will be part of the next version (Android L) release. Please see this answer for more information.
Q: Or maybe a possibility for my iPhone client to connect using the mac address of the server?
As far as I know, in coreBluetooth you would need the UUID, not the MAC Address, of a peripheral device to connect to it. You do not need to know the services being advertised from the peripheral device. Your best bet would be to scan for peripheral devices, and then connect to the one with the UUID and/or the advertising data that u know belong to your peripheral.
I hope this helps.
I'm not sure. Bluetooth LE isn't good idea to transfer large files. In one request phone you have only 18 bytes.
Nexus 7 bluetooth chip has some defect - not work correctly.
Try free application for IPhone - Light Blue.
so...
First question: yes.
Second: Yes but it's not good idea. MAc address in Iphone is alternating every 10 minutes and all turn on/off bluetooth.
In general, sending large files is best done using an internet connection (over the cloud), there are many frameworks that can cut down the overhead for you.
However, the main question is still how to discover to which device you would want to send the data.
There could be multiple ways of doing that on your own such as using BLE or even sound.
To be honest, its a lot of work so if your app is end-user driven, i would suggest using a framework that can do cross platform discovery for you such as: http://p2pkit.io or google nearby.
Disclaimer: i work for Uepaa developing p2pkit for iOS and Android