David
David

Reputation: 7466

Using BLE for two-way communication versus client/server

Let's say I have two users A and B on their respective android devises androidA and androidB. I want both to be able to open an app, press a button in that app, which starts up BLE and will then have each send the other their respective user_id. So, androidA receives b and androidB receives a. I understand this could happen via the callback, and that I could get this to happen for one-way communication. That is, I could have androidB as the peripheral, and androidA as the central, so a receives the user_id of b.

Is two-way communication possible? If not, would it be wise to wait for the callback, and once the callback happens have them switch roles? In that regard, I just need to check to make sure that when androidA gets the callback for being in range of androidB that androidB also gets some sort of response to act on.

Upvotes: 2

Views: 3451

Answers (2)

AllDayAmazing
AllDayAmazing

Reputation: 2383

I have found that the above answer is partially incorrect, basically, it depends on the type of communication you are looking to achieve, OS of each device, etc.

Starting in Lollipop, we have a new set of APIs that allow us to advertise and have a true two way communication between two devices as answered here and defined in the API docs android.bluetooth.le. To quote Google,

As of December 2014, only Nexus 6 and Nexus 9 devices are known to have firmware that supports Bluetooth Low Energy Peripheral Mode.

Also when building with the Lollipop API beware the caveat outlined in a few of the iBeacon compatibility libs and ensure that:​

BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
boolean isHardwareLCompat bluetoothAdapter != null
            && bluetoothAdapter.isOffloadedFilteringSupported()
            && bluetoothAdapter.isOffloadedScanBatchingSupported();

to test if there is true L support. For example, the HTC One M8 developer edition has L, but it does not have full support for the new APIs.

I hope this helps

Upvotes: 1

ajitksharma
ajitksharma

Reputation: 2019

Actually, two way communication is not possible in Android. Only it can read the advertisements packet. So you need some other device which transmits BLE advertisement packets either any beacon provided by companies like estimote, radiusnetwork etc or an iOS device. Chek this link

http://developer.radiusnetworks.com/2013/12/15/why-android-devices-cant-act-as-ibeacons.html

However, Samsung claims some of devices can be configured as a device who transmits BLE advertisement packets. Check this link

http://developer.samsung.com/ble

Check question 12.iBeacon compatible devices in this document?

http://www.cisco.com/c/dam/en/us/solutions/collateral/enterprise-networks/connected-mobile-experiences/ibeacon_faq.pdf

Hope this helps you with your question.

Upvotes: 1

Related Questions