Using BLE in android - android

I need some guidance on a project im currently working on - I work on a project to communicate with a BLE device s.t. the device is connected to an android phone and transmits some data once in a while. I saw some lectures on BLE communication with android devices and read some information on the android 4.3 bluetooth API but there are some things I didnt got yet
In case I want my app to be compitable backward (up to 2.3) is that possible? did they (Google) include the new features on the support package?
Where can I find some good code example of using the android as a client?
When communicating with an android device I need the charestirestic of the bluetooth device to have UUID, do I generate some UUID's on the run? (and in that case how) or do I hard-code them on the app? (since on that case two people using this app and close to each other basically can read each other's signal, don't they?)

In case I want my app to be compitable backward (up to 2.3) is that possible? did they (google) include the new features on the support package?
Bluetooth low energy needs to be supported by the HW and there are only a handful of devices with the necessary Bluetooth radio running an older version of Android. For sure no device running 2.3 will be able to run BLE.
Where can I find some good code example of using the android as a client?
The examples provided on developer.android.com is actually quite good
When communicating with an android device I need the charestirestic of the bluetooth device to have UUID, do I generate some UUID's on the run?
Bluetooth Special Interest Group has already created a bunch of assigned numbers. These have a well defined meaning across all BLE devices and services. Then businesses can apply for a range of UUID's that they can use to defined there own services.
On top of that there are some free ranges where everyone can define and use UUID's. These will not be well defined across devices, meaning other applications will not understand the UUID's you've defined.

Related

Android bluetooth settings show duplicate names for same bluetooth device

I am working with a firmware team that writes firmware on a QCC3056 Qualcomm chipset that supports earbuds and I develop an android application that supports the BLE earbud Bluetooth device. The earbuds also support google fast pair and this feature requires the BLE mac address to be rotated every 15 min.
So the issue I am seeing here is the android Bluetooth settings recognize two Bluetooth devices with the same name(one is classic and the other one is BLE). I can tell by the mac addresses that one belongs to classic and the other belongs to the BLE address. We are able to connect to the classic instance. However, we are unable to connect to the BLE instance. We would like just one name to show up and the user should be able to connect to it. The firmware team thinks this is expected behavior(two names showing up). As far as I know, from the android end, we don't have any control over the Bluetooth settings. So I wanted to understand if this behavior is expected. I have tested this scenario with SONY WF-1000XM3 which supports Google Fast Pair and I have noticed only one name showing up.
It would be great if anyone can suggest the best possible approach I can take here.

Communcation between devices using only BLE

I want to connect two android phone only via BLE. Is it possible? because as per my understanding using Android API I can only connect with BLE enabled devices like smartwatches headphones etc. If I run startLescan() method it only shows my fitness band and headphone.
It does not show other android phones.
Yes its possible. As the hardware equally supports to act as a master or slave, but it depends on whether the OS has provide you the required interface to make a device act as master as well as slave. THe BLE in android phone is equally capabale of becoming a master or peripherical but it depends on whehter android has exposed some interface to make it work ortherwise if not you have to root/reflash your device and make changes at OS level.
Yes, two BLE devices can communicate and has been ever since the original 4.0 release.
The change in 4.1 states that a single device can act as both a master and as a slave simultaneously to two different devices. Once device has to act as periphiral and other as master.
See this: http://www.blemobileapps.com/ble-mobile/
For android this link might be helpful for you: https://code.tutsplus.com/tutorials/how-to-advertise-android-as-a-bluetooth-le-peripheral--cms-25426
Reference: Chipsets/Devices supporting Android 5 BLE peripheral mode
Let me know if this answers your question.
It is possible to connect to Android phone with BLE.
One of the phones has to be a BLE Server and must advertise itself
(a role usually performed by devices like smartwatches and headphones) to be discovered by the other phone.
To advertise itself the app uses the BluetoothLeAdvertiser class.
Such API was added starting from level 21 Lollipop so your server phone should be at least a 5.0 Android device.
Personally I found this tutorial by Andrew Lunsford very useful for understanding how to realize such functionality.

Is it possible to use a BLE enabled Android/iPhone as a BLE beacon?

I'm working on a BLE proximity sensing feature based on Android and need some information.
Currently I see there are no BLE beacons manufacturers for android. I found 2 so far for iPhone.
1) http://www.estimote.com
2) http://www.gimbal.com
Estimote claims that their devices are generic but mainly they are publicized for iBeacons. So I'm not sure whether I should order them for a feature on Android.
Secondly gimbal explicitly mentions that their devices won't be enabled for android for proximity sensing.
So if any of you know where can I order BLE beacons compatible with Android please let me know.
Another thing, for prototype testing I was wondering whether I could use a Android BLE capable tablet or smartphone as a beacon to emit BLE signals?
Till now the documentation for android only suggests how to detect a beacon, But I'm not sure whether an Android device can be used as a beacon.
Any insights?
There is a BLE Beacon manufacturer for Android: Radius Networks
You can detect any standard iBeacon on Android using our Android iBeacon Library.
You can try it out yourself with our free iBeacon Locate app, which is based on this library. My company also sells both software and hardware iBeacons that I guarantee work with Android. But again, any standard iBeacon will work, too. Don't take my word for it -- just download our free app and use it to see one of our iBeacons. (We even have a free virtual machine you can use!)
It is currently not possible to make an iBeacon out of a stock Android device because the Bluetooth LE APIs, introduced in Android 4.3, do not support the peripheral mode needed to transmit advertisements like an iBeacon.
EDIT: It is now possible to make rooted Android 4.4.3 devices transmit as an iBeacon. See here.
I tried simple BLE scan app on Android, but the callback for LeDevices always returned null for UUID[]. Also, finding based on know UUID didnot work.
To add to David's reply. I have tried Radius Networks SDK, pretty clean. I like it.
Also, Estimotes has released their Android SDK today(1/7), which is good. The sample App shows notification, Distance, Major-Minor. I tested with 3 Estimotes & also with iPhone's app (making the iPhone as iBeacon). It works well, give it a try.
Note that you have to modify the code
change the ESTIMOTE_PROXIMITY_UUID value to the UUID that you are watching for.
Hope it helps.

Transfer data between iOS and Android via Bluetooth?

I've been reading up on how to transfer data between iOS devices over Bluetooth using GameKit. I'm not writing a game, per se, but do have a need to transfer a small amount of binary data between two devices. Between two iOS devices, this is easy enough. However, I was wondering if it is possible to transfer data between an iOS device and an Android device via the same mechanism.
Has anyone come across documentation/tutorial that would explain how to do this? Is it even technically possible? Or has Apple put in some sort of restriction that would prevent this?
The other option I discovered was Bonjour over Bluetooth. Would this be a more suitable option for this type of operation?
This question has been asked many times on this site and the definitive answer is: NO, you can't connect an Android phone to an iPhone over Bluetooth, and YES Apple has restrictions that prevent this.
Some possible alternatives:
Bonjour over WiFi, as you mentioned. However, I couldn't find a comprehensive tutorial for it.
Some internet based sync service, like Dropbox, Google Drive, Amazon S3. These usually have libraries for several platforms.
Direct TCP/IP communication over sockets. (How to write a small (socket) server in iOS)
Bluetooth Low Energy will be possible once the issues on the Android side are solved (Communicating between iOS and Android with Bluetooth LE)
Coolest alternative: use the Bump API. It has iOS and Android support and really easy to integrate. For small payloads this can be the most convenient solution.
Details on why you can't connect an arbitrary device to the iPhone. iOS allows only some bluetooth profiles to be used without the Made For iPhone (MFi) certification (HPF, A2DP, MAP...). The Serial Port Profile that you would require to implement the communication is bound to MFi membership. Membership to this program provides you to the MFi authentication module that has to be added to your hardware and takes care of authenticating the device towards the iPhone. Android phones don't have this module, so even though the physical connection may be possible to build up, the authentication step will fail. iPhone to iPhone communication is possible as both ends are able to authenticate themselves.
Maybe a bit delayed, but technologies have evolved since so there is certainly new info around which draws fresh light on the matter...
As iOS has yet to open up an API for WiFi Direct and Multipeer Connectivity is iOS only, I believe the best way to approach this is to use BLE, which is supported by both platforms (some better than others).
On iOS a device can act both as a BLE Central and BLE Peripheral at the same time, on Android the situation is more complex as not all devices support the BLE Peripheral state. Also the Android BLE stack is very unstable (to date).
If your use case is feature driven, I would suggest to look at Frameworks and Libraries that can achieve cross platform communication for you, without you needing to build it up from scratch.
For example: http://p2pkit.io or google nearby
Disclaimer: I work for Uepaa, developing p2pkit.io for Android and iOS.
You could use p2pkit, or the free solution it was based on: https://github.com/GitGarage. Doesn't work very well, and its a fixer-upper for sure, but its, well, free. Works for small amounts of data transfer right now.

Rhomobile, BLE112 Bluetooth device - iOS and android app

I have been searching for a while now and decided to post a question here to see if someone had already traveled down this specific road.
I am developing a bluetooth enabled device, using the Bluegiga BLE112 chip. They announce this chip to be easily used with iOS devices (and this was our main reason for choosing it)
The device will need to communicate with an App, that we need to be developed for iOS, Android, Windows Phone, and Blackberry. Due to this need, I've decided to use Rhomobile, as it seems to be the only one that supports developing BT apps for iOS without having to develop further plugins.
I only need to send small messages (like commands, small strings) and sometimes a bigger file to the device's internal memory.
On Rhomobile's BT documentation, they state that for iOS it is only possible to comunicate between iOS devices ( i'm thinking that they say this because of the MiFi limitations imposed by Apple, but that using Bluegigas chip are not a problem...)
My question is:
Since Bluegiga's documentation has examples of devices communicating with iOS using their chip, i should be able to develop using Rhomobile and not suffer from the limitation stated above. I wanted to be as sure as possible before making my company spend money ordering the chips and development board and what not..
Has anyone tried this, is my thinking missing something?
Thank you all for your time.
Daniel
Good Question, I think I can understand the reason for your confusion.
The main reason is many people/products/frameworks does not clearly mention if they are talking about Bluetooth Classic or Bluetooth Low Energy (BLE).
These are both 2 different things and even thougfh they are called "Bluetooth" one cannot talk to the other.
(Some devices can be both Classic and Bluetooth Low Energy, which allows it to connect to either types)
Ok now comming to your Question :
THE bluegiga dongle is BLE
The Rhomobile is refering to the Bluetooth Classic version of the API.
On iOS the BLE APIs are open to applications, but Classic is limited on iOS , one way for Apps to use Classic Bluetooth on iOS is via the Gamekit APIs but that is possible only when talking with iOS devices, so it wont connect to another Android or Win device that is also Classic.
Needless to say with BLE APIs you cannot connect to calssic anyways.
The bluegiga examples are BLE examples, and apple also has good documentation and examples / samples on how to use BLE so yes it is easy to build a device and app using BLE on iOS.
There is nothing special abut any particular chip yo ucan use any BLE chip - there are many vendors today.
BUT Android (and I guess Windows as well) does not yet have BLE APIs for applications to use :( (Bit I think is is comming soon :))
So I hope this clears things up a bit.

Categories

Resources