Is it possible in Android to transmit broadcast mode in BLE ?
And to add my own data on the transmission.
I know that BLE has a mode of transmiting in broadcast (not to a certain UUID).
This way it has very short connection time, which is what I need.
I failed to find how to do it in Android.
Any relevant link to the API ?
Look like the answer for android 4.3 and 4.4 is no.
Android 4.3 and 4.4 does not support BLE peripheral/broadcaster role
see
https://code.google.com/p/android/issues/detail?id=59693
and
https://code.google.com/p/android/issues/detail?id=58582
allow see this stackoverflow thread about the same issue
Android 4.3 as a Bluetooth LE Peripheral
The Android 5.0.X will only allow you to use the new API for BLE. This new API comes with a new feature, which you mentioned in your question: The possibility of advertising, from your own Android device, using it in Peripheral mode. However, the disadvantaged of this new feature is that it is hardware dependent.
Related
I need to pair two BLE devices(one device is android phone [central app - discovers services] and other devices BLE [peripherals - advertise the services] support hardware) with secure passkey method in android.
I googled it but no luck, I got no references about secure pairing in BLE android.
I have developed an Android Application in phone - connection, bonding is working fine but not able to find out how to do PASSKEY pairing.
I have found some links in internet regards this but in BLUETOOTH not in BLE devices.
Any suggestions?
This is all handled by the Bluetooth stack when you bond.
Per the Bluetooth specification, the security level chosen will always be the highest one supported by both devices. So just make sure the peripheral supports the desired level and Android will use that (since Android supports all security levels). There is no API in Android to select a lower level.
I'm trying to build a messenger that requires no bluetooth pairing. The message will be broadcast by the user who adds it and can be received by the listeners in the neighborhood.
I have read in several places that Bluetooth 4.0 has support for this. However most examples involve reading from a ibeacon or a similar device.
Can I use Bluetooth 4.0 to build both a broadcaster and a receiver android app?
I thought of leaving this here because it might be helpful for someone else.
Bluetooth 4.0 broadcast mode requires special hardware and it's only present in a few mobile devices. (Bluetooth peripheral mode) Therefore, instead of using bluetooth low energy, I used SDP (Service Discovery Protocol). The messages are limited to 13 characters.
However due to security restrictions, the app doesn't work for platforms above Jellybean.
Here's my development work. https://github.com/malithj/Seeder
I'm trying to use NFC in order to pair two Android BLE devices. I followed latest specifications released from NFC Forum & BT SIG, called Bluetooth Secure Simple Pairing Using
NFC and I'm interested in static handover. This means I'd to write an NDEF message on an NFC tag (formatted according to specifications above) with one device, then the other one reads this tag and keep information to start BLE pairing. I'm using Android 4.4.2. and this approach works fine with Bluetooth, with no need to have specific app to manage handover, Android does the work!
But with BLE this approach doesn't work. I think the problem is related to MIME-type that I'd to write in NDEF message. For Bluetooth is application/vnd.bluetooth.ep.oob while for BLE is application/vnd.bluetooth.le.oob. When I tap device/tag, Android detects that there's a new tag with BLE MIME-type but doesn't perform any action, just shows me the screen "New tag collected", like it was unknown MIME-type. I noticed that NFC Forum specifications was released on 2014-01-09 and in Compatibility document for Android 4.4 there aren't references about BLE handover, just Bluetooth.
Does someone know if BLE pairing by NFC is supported and works on Android 4.4? And on Android 5?
I managed to test NFC/BLE handover on a Nexus 6 running Android 5 and the MIME-type application/vnd.bluetooth.le.oob has been recognised! Therefore the limit is in the Android version ...
If you want to read characteristic, you need to use read method of that property. Sample given with the SDK 4.3 works good. Also connectivity problem exists in all other devices except Samsung.
I'm trying to make an application which uses the new Bluetooth Low Energy API of Android. For this, I started with the BLE sample coming with API level 18.
As I read that Android can not act as a Peripheral, I put the Android phone in central mode, scanning for BLE devices around it. For this purpose, I made some testing with a Nordic Platform simulating a Heart Sensor. Everything works in a perfect way!
After this, I try to pick an iPhone (iOS 7 beta 4) and put it in a Peripheral way and simulating a Heart Rate sensor as the previous testing. The Android app is able to see the device and connect to it. But after the connection is active, the 2 devices disconnect from each other in 3-4 seconds. In addition to that, when I call discoverServices() on Android side, no callback is triggered! In some cases the Android device receives the "Connected" event even if iOS Bluetooth chip is Off. This is very strange. To prove that, I put the Nordic Board in Central mode and I was correctly able to connect to the iOS device with no problems.
What could it be? There are some limitations on Android or iOS that don't permit to connect from an Android to an iOS or viceversa?
Thanks.
EDIT: After some hard testing, I raised an issue on the AOSP page. It can be checked here
Adding a summary for reference:
What could it be? There are some limitations on Android or iOS that don't permit to connect from an Android to an iOS or viceversa?
When connecting to a GATT server that is advertised as dualmode (BLE and BR/EDR) device by calling connectGatt(...), the TRANSPORT_AUTO flag that is internally added makes Android to default to the BR/EDR mode (link).
Following workarounds are possible:
Peripheral side: Stop advertising BR/EDR capabilities by adjusting
the appropriate flags (link)
Central side: Set the transport parameter explicitely to
TRANSPORT_LE by calling the hidden version of connectGatt() using
reflection
Example:
public void connectToGatt(BluetoothDevice device) {
...
Method m = device.getClass().getDeclaredMethod("connectGatt", Context.class, boolean.class, BluetoothGattCallback.class, int.class);
int transport = device.getClass().getDeclaredField("TRANSPORT_LE").getInt(null); // LE = 2, BREDR = 1, AUTO = 0
BluetoothGatt mGatt = (BluetoothGatt) m.invoke(device, this, false, gattCallback, transport);
...
}
Edit 4/2016
As Arbel Israeli pointed out in the comment, Google introduced an overloaded version of connectGatt(...) which allows to specify the transport in Android M.
I've written a simple working example, well relatively simple, and included it open-source on Github: https://github.com/GitGarage. So far it has only been tested with an Android Nexus 9 and an iPhone 5s, but I presume it would also work with a Nexus 6 and various iPhone types. So far it is set up explicitly to communicate between one Android and one iPhone, but I presume it is tweakable to do much more.
Maybe a bit delayed, but perhaps your pain can be relieved slightly ;)
We have been experimenting a lot with cross platform BLE connections (iOS<-> Android) and learned that there are still many incompatibilities and connection issues. Aside to the instability of Android you should also consider that still, as of today, not that many Android devices actually support the BLE Peripheral mode.
Therefore, if your use case is feature driven and you only need basic data exchange 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 can now pass in TRANSPORT_LE via BluetoothDevice.connectGatt as of API 23.
Please see Android Documentation references below:
TRANSPORT_LE
Bluetooth.connectGatt
iOS Devices always be a peripheral or central but Android devices cant be rarely.In this case your iOS device must be a peripheral and android must be a central.We can think peripheral is a server and central is a client.This is simple.
My application needs to connect to a a2dp device over bluetooth and I want to "be able to query for the visible bluetooth devices, then, select a a2dp device and have it 'connect via a2dp' so that audio starts playing through the connected device" but my phone is running gingerbread (2.3.3).
I went through the basic bluetooth tutorial at http://developer.android.com/guide/topics/wireless/bluetooth.html and got to the part I need to connect to the bluetooth device and then I read the bottom of the page:
"Starting in Android 3.0, the Bluetooth API includes support for working with Bluetooth profiles." -> does this mean that I am S.O.L.? Is there any way to programmatically (why does stackoverflow mark programmatically as being misspelled?!) connect to a a2dp device using a pre-3.0 version of Android? Is my only option to direct the user to go into their settings/pull up the settings programmatically?? Because I'm able to do it through the settings, I guess I just assumed it would be possible via my application as well.
Help?
Some of the Bluetooth classes (profiles like BluetoothA2dp) are hidden in Gingerbread. It means that their declaration is annotated by #hide, and they are not included into the SDK (Android.jar). This is done intentionally, since these APIs are likely to be changed in newer Android versions. Generally it is not a good idea to use hidden APIs, since your App can stop working on newer Android versions, but if you are sure you want to, follow
http://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction/
Once you get access to them do something like (just a hint):
BluetoothA2dp mBluetoothA2dp = new BluetoothA2dp(context);
BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().
// Loop through paired devices
for (BluetoothDevice device : mBluetoothAdapter.getBondedDevices()) {
if (device.getName().contains("whatyouwant")) {
mBluetoothA2dp.addSink(device);
}
}
So, after much more research, it seems that it is impossible to programmatically connect to a A2DP device on a pre-3.0 Android device. I am going mark this as the answer but, if someone finds otherwise, please correct me on this as I would really like to do it programmatically.