Can bluetooth connect two same devices? - android

I'm working on a project that requires Bluetooth, however I need it to connect with Bluetooth from my app on one phone to my app on another phone.
Is there a way for Bluetooth to be used on two devices of the same type, or is is just different devices that can connect to each other? Could you please also provide me with a link to Android documentation, if possible?

When using BLE, an Android device can act as a peripheral device, a central device, or both. Peripheral mode lets devices send advertisement packets. Central mode lets devices scan for advertisements
See Device modes.
BluetoothLeAdvertiser enables to turn a supported phone into a peripheral.
See Bluetooth Low Energy Advertising for details.

Related

How to auto pair my BLE Peripheral on my device?

We are developing an application which needs the BLE Peripheral to be automatically paired with the smartphone when the smartphone is near the BLE Peripheral.
We are using RN4871 Microchip BLE Board,
First time when I pair the device from the settings, then power of the device and power on the device, it doesn't show in the Connected Device list, I mean Android doesn't automatically gets connected. Whereas this behavior is not seen in case of Bluetooth Headset.
What is the difference between a BLE Peripheral and Bluetooth Headset, how can i achieve this behavior
That a device is paired (or more correct, bonded) generally just means that the central and peripheral stores keys used for encryption etc. when they later connect.
FYI Peripherals can be programmed so that they advertise with a specific Bluetooth device address as target.
Back to your question. In Android, an "application" must initiate a connection to a device to make it connected (no matter if it's paired or not). That can either be a normal app you install or the built-in HID application in the Bluetooth stack. That said, the HID application will automatically connect to enabled bonded HID devices. So basically, if no application wants the peripheral connected, it won't stay connected.

When two Bluetooth devices are connected, does either of them reply to any Inquiry scan, or send an Inquiry?

I am trying to answer the following question?
When two Bluetooth devices are connected, does either of them reply to any Inquiry scan, or send an Inquiry?
I had a few experiments and my answer is no. I connected two BT devices and try to pick any BT device nearby by my other phone which it did not detect any of them.
It would be great if you could also support your answer by a referencable document.
I have looked at several docs like these:
http://essay.utwente.nl/59681/1/MA_scriptie_A_Franssens.pdf
https://link.springer.com/content/pdf/10.1007%2F978-0-387-75462-8_20.pdf
but could not find a straight answer.
Yes, Bluetooth device can scan/enquiry and send scan/enquery response when connected. However, most cells designed so that it can be discovered only when you have Bluetooth settings opened. This is not Bluetooth limitation but OS design.
If we are talking about headsets (or keyboard or any other HID device) then this is reasonable why manufacturer made it so it can pair/work with only single device. But this is just a manufacturer decition and made so by design. It is not Bluetooth limitations. If you need you can design such headset that can be paired and connected to few devices t the same time.
On high-level Bluetooth device can be in Discoverable and/or in Connectable modes. Discoverable mode makes device visible to other devices. Connectable mode allows to connect to the device.
Usually manufacturer design it so that is device is not paired (or when you press special button or open Bluetooth settings on cell) it stays in Discoverable mode. So other devices can discover (find) the headset/cell. Once you paired with your device the Discoverable mode switched off. So now you can connect to device (cause during pairing the MAC is stored and you do not need to rediscover the device).
Once you connected the device turns Connectable mode off so others can't find and connect to it.
But once again. This is how manufacturer designed device. It is not Bluetooth limitation.
Bluetooth Core Specification
I know that you can connect and interact with multiple bluetooth low energy devices without problems. I myself connected to at least three ble devices and could easily receive and send data.

Bluetooth Low Energy Device Simulator/Emulator

For quite some time now, I have had a keen interest with the Bluetooth Low Energy (BLE) Protocol version 4.0 and how it works. I have developed an android application that would serve as a central device to the BLE peripheral device. The problem is the BLE device is not yet ready and I would like to know if there is a simulator or an emulator for BLE devices that can interact with my android application installed in my smartphone.
The easiest way to do that without any specific additional HW is to use another Android or iOS mobile phone acting as a peripheral emulating the BLE device that's not ready yet. Thus, you'll be able to test your Central role Android app in a simple way.
All you have to do is download one of the following apps for example, set up your services and characteristics and start playing.
[Android]: nRF Connect for Mobile
[iOS]: nRF Connect for Mobile or LightBlue

Is it possible to connect BLE sensor device to android watch without a phone nearby?

Is it possible to connect BLE sensor device to android watch if the watch has BLE inside, without a phone nearby in the same manner like with a handheld device, i‘ve seen some questions on stackoverflow like this, for example
Is it possible to connect Android Wear device with another BLE device directly without interaction of phone device?
but they weren‘t answered, or the answers weren‘t clear.
Thanks in advance
BLE protocol only allows communication between a central and a peripheral device. The sensor surely is a peripheral device that advertises BLE packets and expose some services (for example the heart rate).
You need to figure out if the android watch support BLE in central mode.
In that case you will be able to scan for advertisement packets coming from peripheral devices (sensors), and connect to them.

Make communication between 2 android phones over BLE

I have two android smartphones (Xperia Z and Xperia Z1) and both have BLE capability.
Can I connect to one of them as a peripheral over BLE? In my application I can see and connect a BLE as peripheral (CC2541 device) and I can see all services and characteristics.
But same application can not see one of my phones??
Is there a way to achieve that??
As of Android 4.4 there is no support for peripheral mod in the Android BLE apis. You would need this to be able to make two phones talk over BLE setting one up as a peripheral and the other as central.
There is a feature request for the feature you may want to take notice of.
If you just want to be able to get the two phones connecting there is nothing stopping you from using classic Bluetooth which should be perfectly workable.
Android does not support peripheral mode till version 5.0(latest version) therefore you can not communicate with two smartphone over BLE.
You can communicate over BLE with sensor device and smart phone here smartphone app works as client and senser device as a server.
and if you want to communicate between two smartphone you have to use classic bluetooth.

Categories

Resources