2

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.

David
  • 7,028
  • 10
  • 48
  • 95
  • Further searching shows that I might not even be able to make a device act as a peripheral... – David May 20 '14 at 06:21

2 Answers2

1

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.

Justin Slade
  • 500
  • 2
  • 7
ajitksharma
  • 4,523
  • 2
  • 21
  • 40
  • iBeacons can't send unique information though. The point of me delving into BLE and not iBeacons (which are built on BLE) is that I want to be able to transfer more than just alerts like "Hey, I'm here!!!". That being said, I might have to sadly use Bluetooth. Bluetooth is fine, but if I *have* to pair with devices it will become cumbersome and I'll have to explore different avenues. – David May 20 '14 at 06:34
  • Yeah iBeacons couldnt send, but based on central-peripheral and using server you can achieve your objective I think. However BLE is much more preferrable over normal Bluetooth. But yeah for data transfer it hasnt dependendecy on network – ajitksharma May 20 '14 at 06:40
  • Yeah. If I could find a hackish way through using two centrals to somehow send data to one another, I'll do that... but not being able to have an android device as a peripheral doesn't help. – David May 20 '14 at 06:49
  • David, centrals only connect to peripherals, so the stock implementation on Android isn't going to let you have two centrals talk to each other. Have you thought about using class Bluetooth to set up a PAN or using NFC? Also, when the peripheral is possible on Android you won't be able to send large amounts of data (quickly). It will take anywhere from 60 seconds to 15 minutes to send 130kb-ish of of information (based on connection interval, packets allowed per connection interval, etc). – Zach Dennis May 21 '14 at 15:28
1

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

Community
  • 1
  • 1
AllDayAmazing
  • 2,383
  • 1
  • 24
  • 25