Possible to hack BLE peripheral mode support in Android? - android

This blog post from radius networks discusses how Android devices can not yet be used as iBeacons (AKA: BLE peripheral mode) even if the device's hardware supports BLE, because Android has no APIs for BLE peripheral mode.
NOTE: BLE means Bluetooth Low Energy
After reading this section, I am gonna suggest something stupid
Because their SDK only supports the central role, “advertising” a
service as a central server means sitting their quietly, only
revealing (or “advertising”) its service characteristics to another
device in peripheral mode after a connection is already established.
This connection establishment requires another device to do the actual
radio advertising first. Samsung’s SDK isn’t going to do it.
Is it possible to trick the device in central mode (the Samsung phone) into thinking another device in peripheral mode has established a connection to it and then get the central mode to "advertise". Can you trick the phone by faking the connection in software?
Probably a stupid idea, probably it's possible to trick the device in central mode, but the "advertisement" is not the BLE peripheral mode advertisement and would not resemble an iBeacon in peripheral mode.
I very much need BLE peripheral mode support from Android and for the moment I would be ok with hacking something, in the hopes that Android is going to eventually support this feature-set, which BTW is already a feature request

I don't think this technique will work, even if it is possible to "trick" Android into thinking it has a connection to another BLE device. Although this question is about the Samsung BLE SDK, I think the same answer applies to the dedicated Android BLE APIs (android.bluetooth.BluetoothAdapter) that shipped starting with Android 4.3.
Let's put aside the tricking part for a minute -- even if Android's actually does have a connection to another BLE device, can you make it advertise? If by "advertising" you mean revealing its services to the other device, the answer is yes. But this radio transmission is over a private channel between the two devices, and could not be picked up by a BLE scan in the same way that iBeacon advertisements are. It really isn't an advertisement at all -- which is why I said in the blog post that the Samsung documentation is misleading. So if you can't do this with a real connection, then tricking a connection won't work either.
My understanding of bluetooth stacks is limited, but I think that the actual radio broadcast advertisements that scans can pick up are controlled by the hardware BLE chipset, which means you have to have access to the parts of the bluetooth stack that tell the hardware to make this happen. I don't think there is anything in Samsung BLE SDK or the Android SDK that intentionally allows this.
An alternative may be to make direct JNI calls to the BlueDroid stack. I'm not sure if Android permissions allow this, or if advertising is even implemented in the BlueDroid stack.
UPDATE: Transmitting as a pheripheral now possible in Android 4.4.3 and Android L. See here.

Related

Is it possible to use android phone in BLE peripheral role in reality?

My question is on Android capability, whether or not we can use the Android smartphone as a BLE peripheral device. Base on my efforts, the connection will be dropped very quickly and we can't establish a persistent connection in this mode. We are struggling with this issue for two weeks. While Android documentation is mentioning that is possible and Android devices are able to play the peripheral role but this is not happening in reality.

Can ios Bluetooth api discover android device?

I know, transferring is restricted and i do not need that. Also, i'm aware of BLE capabilities. However, ~35% of android devices out there do not support peripheral mode.
If someone ever tried this, could you tell me: does ios BT api allow to discover android devices? I need only mac (or whatever it called) address from android device, nothing else.
iOS (CoreBluetooth) can discover any Android BLE device as long as it supports the Peripheral role. If your Android device does not support Peripheral role then the iOS device needs to be the Peripheral in your connection scenario.
If you want to use Bluetooth Classic, that is a completely different story because in order to use Bluetooth Classic on iOS you need to be member of Apple's MFI program that comes with extra fees and an NDA.

How can I make my Android application to act as a Beacon?

I want to develop two Android applications out of which one application should act as a Beacon. That is, one of my application installed in one device should listen certain events from the other app installed in other device and should broadcast some information on listening those events.
I read many articles and I found that the Android device must have Bluetooth LE hardware and it must have peripheral mode enabled by the device manufacturer. But most of the manufacturer as well as Google itself has disabled peripheral mode.
So my question is there a way (a Beacon library available?), so that I can make my application to act as Beacon.
Thanks in Advance.
You can use the Android Beacon Library to make a device both transmit as a beacon and detect/decode beacon transmissions.
It is true that devices must have BLE hardware for this to work, Android 4.3+ to detect beacons and Android 5.x+ to transmit as beacons. While not all devices with 5.x+ support peripheral mode needed to transmit, most popular devices do. Google has not disabled this, and their newer Nexus and Pixel devices support transmission as well.
The library linked above has a list of devices known to support transmission, and includes example code showing how to determine this at runtime on a specific device.
If a device does not support peripheral mode, there is nothing you can do short of rooting the device and trying to write a new Bluetooth driver yourself.

What would it take to turn an Android mini PC and a Bluetooth dongle into an iBeacon?

When I connect the dongle to the Android mini PC it's obviously not going to be able to function as an iBeacon(and by iBeacon here I mean the actual hub that enables nearby devices to communicate) right away. What do I have to do to turn it into an iBeacon? Is there some library I can easily install? Or do I have to do something crazy like reverse engineer the "iBeacon protocol"?
Unfortunately, Android devices cannot act as iBeacons without heavy low-level modifications. See here.
The answer above is for Android phones, but the same obstacles apply to a mini PC. Connecting an external Bluetooth dongle is just the first challenge. You would then need to overcome these hurdles:
Root the device
Write and install a driver for the Bluetooth dongle
Install AOSP custom ROM to enable Peripheral mode support.
Write code to make the device send out the standard BLE iBeacon advertisement.
This is probably way more than you want to bite off!
There isn't really an "iBeacon protocol" - iBeacon is just a standard BLE advertisement packet with a known UUID (identifying it as the iBeacon service). It also is not a communication channel - as in centrals do not exchange information with the peripheral doing the advertising. See this answer for a really good breakdown of the packet you need to send to mimic iBeacon.
To answer your question - there are BLE dongles (like the Bluegiga BLED 112) that allow you to flash the BLE service onto the dongle, so it may just requires power from the host to begin advertising the service. I haven't tried this, but this kind of flashable BLE dongle seems like your easiest route - though the host being Android is rather irrelevant at that stage.

Are there any actual android cell phones that implement the bluetooth spp profile

Does anyone know of a current Android cell phone that actually supports the Bluetooth SPP Profile? I have spent days online trying to find one, and nowhere do I see any cell phones that say they support the SPP profile. Furthermore, I have noticed all kinds of postings where people cant get their applications to work correctly because the phone they are using does not support the SPP profile, or it has been disabled on their phone. Am I missing something here? Before I commit to developing my Bluetooth application for Android, I want to make sure it can actually be done.
I am hoping that the answer is that we implement the SPP profile via the Bluetooth API, and therefore we can use RFCOMM on any Android OS level that supports it, i.e., 2.0 or above. Is this correct?
SPP is RFCOMM, from the docs:
The most common type of Bluetooth socket is RFCOMM, which is the type supported by the Android APIs. RFCOMM is a connection-oriented, streaming transport over Bluetooth. It is also known as the Serial Port Profile (SPP).
So yes, any device at API level 5 (2.0) or above will support BluetoothSocket and therefore SPP.
#GAZ This does not appear to be true. Take the Droid Incredible S, for example, running Android 2.3. Now install an app called Bluetooth Remote Control. The app displays a list of all BT devices it finds but remarkably does not find those that advertise only SPP. I can use that same app on my Nexus S and it finds the same devices that the Incredible misses. I can only assume that it is the carrier that disabled serial Bluetooth on their phones - as a way of preventing tethering.
Since I first posted this answer I have discovered the probable cause of the failure to discover some Bluetooth devices. It appears that when the major device class is BluetoothClass.Device.Major.MISC (0), many phones simply skip this device during discovery, although I can't imagine why. If anyone has thoughts on a workaround, I would love to hear them.
Turns out that there is a workaround for this bug (device class 0 being skipped). Find it here: http://zornsoftware.talsit.info/blog/pairing-spp-bluetooth-devices-with-android-phones.html

Categories

Resources