How to make a BLE mesh network? - android

I had been wondering how wireless earbuds work and came across this image. I do not know how to replicate what is shown in the following image and would like to learn how to do it.
My end goal is to be able to have the smartphone connect to a device, while still being able to play music to a Bluetooth Headphone. I read into BLE 4.1 mesh and I am not sure if that would help either.
I have made images for the possible ways the multiple devices could communicate but I don't have enough reputation to attach the xD. I will try my best to describe them.
1) All devices manage to simultaneously communication with the smartphone.
2) All devices connect to a hub which relays data to the smartphone.
3) One device is the hub itself and relays data for all other devices while sending its own data.
4) The devices relay information for each other till the smartphone receives the data it called for.
5) Another possibility is to have a mesh structure where the devices relay all messages broadcast-ed over the network until the device for which the message is meant for, receives it.
I hope to make a project where a Bluetooth device I make does not hinder the user from connecting and using other Bluetooth devices simultaneously.
Thanks for reading and I look forward to any and all responses.
IMAGE 1:
IMAGE 2:
IMAGE 3:
IMAGE 4:

You need to consider few things first.
Since version 4.0 Bluetooth specification contains "Classic
Bluetooth, Bluetooth high speed and Bluetooth low energy (BLE)
protocols."
Bluetooth Classic provides profiles like A2DP, AVRCP that
are usually implemented by Bluetooth earbuds or speakers.
BLE on the other hand communicates using GATT (a general specification for
sending and receiving short pieces of data known as attributes over a
low energy link).
BLE is not designed to handle high bandwidth scenarios like Audio.
Now getting to a point
You can have a smartphone connected to your earbuds with A2DP profile
and simultaneously connected to several BLE devices.
One or more of these BLE devices can realize mesh connectivity

Related

Bluetooth connection like wearable devices

I am searching for some way that can connect to Bluetooth devices without pairing. Or at least make a connection first and then it does not need to be established all the time. Like how wearable devices work (i.e. mi band 6 or Huawei band 6). Can someone please guide me towards some helpful demo or documentation for this somewhere?
Also, I was wondering how was the security managed since my Bluetooth is always on to communicate to the wearable device. Though, turning off discoverability does not seem to create any issues in order to communicate with the device.
Most wearables nowadays use Bluetooth Low Energy (BLE), and with BLE you don't need to pair in order to exchange data - i.e. only a connection is needed. That being said, it is recommended to pair as the data exchanged between the wearable device and the phone will be encrypted, in addition to some other benefits in terms of privacy and security, Have a look at the links below that will go over connection/pairing in more detail:-
Should one create a bond with BLE device
The Ultimate Guide to Android Bluetooth Low Energy
Making Android BLE work

Switch model from BLE to Bluetooth Classic in Android

I'm setting up a mobile application to support bluetooth communication between an android phone and one dual-mode bluetooth module. Two devices must init a BLE connection and transfer sound through HandsFree profile. At any time, two device must be able to re-establish these communications.
Should application shut down the Classic bluetooth process after sound transferring is done and always connect by BLE??
If I understood your question correctly, you don't need Bluetooth Low Energy (BLE) for your application. If you just want to transfer sound through the HandsFree profile, then this can be accomplished with classic Bluetooth alone and you can even turn BLE for the entirety of the application.
Please see this Android Developer page which gives a step-by-step guide on how to do this and provide sample code:-
https://developer.android.com/guide/topics/connectivity/bluetooth#Profiles
Finally, please note that for the most part BLE and classic Bluetooth are mutually exclusive; even though they are part of the same specification, they are like two different wireless technologies and in almost all cases your application will need one or the other, but not both. Please see this post for more details:-
Can a Bluetooth LE powered device discover a classic Bluetooth device and vice-versa?
I hope this helps.

Bluetooth proximity scan while paired

I have been doing a ton of research on this project I want to do, probably read every SO post (bluejacking, RFCOMM, beacons, etc...) and my head is spinning.
I want to create a system at home, using Arduino (with bluetooth le) that will scan bluetooth and detect when my phone or any of my family members phones are in proximity. Whether this is a MAC scanner or simply getting the friendly name. I would also like to get the RSSI. I dont need to do accurate distance measurement but I would like to know approximately how close they are. Does anybody have any suggestions for this approach? I know I can create an app on the phone and have it become a beacon and this may be an option but I am concerned with Android, it would have to be Marshmallow 5.0 at a minimum. I would like support to be a little lower than that, like JB or KK. So, it seems like there should be a simple scan, just looking for the MAC or name. That is all I really need.
That said, the main question I have is, can you scan for and see bluetooth devices in range if they are already paired to something? Like a Bluetooth headset? I understand bluetooth is point to point but does it allow multiple connections or at least broadcast the mac or name when paired?
This question, along with any general suggestions will help me out tremendously!
Thanks!
Bluetooth Discovery from the Listener involves Listening for Bluetooth Inquiry packets(RX) and inquiry response (TX).if done continuously this will deplete the battery. Hence most devices (including Mobile Phones and Headsets) has a policy of when to be discover-able and connectable. Headsets in particular are discoverable only when they are instructed and connectable until one device is connected to it ( There are probably exceptions where the headset has the capability to be connected to multiple phones at the same time). Most Mobile Phones are discoverable only when they are in settings screen ( Android,IOS and Windows Phones), but unlike the headset case they are connectable.
so one option with the MobilePhone is to see if it is possible to connect to them after pairing once ( for example by trying a service search on the remote device and see if it returns the service attributes, this internally makes a connection and indirectly ensures the presence of the device).
if you are specific about a mobile phone which is already paired then you might need to establish a higherlayer connection ( such as SPP) with Authentication and encryption. This would force a two way check between devices to see whether they are already paired. other less secure option is to rely on the Phone (Android and IOS phones doesn't generally Allow a higher layer connection without encryption/pairing) and try to establish an SPP connection to the phone.
Another option is to use Bluetooth-LowEnergy. But Note that security in BT was superior to BLE till BTv4.1 and same on BTv4.2.

Is it possible to connect iOS and android device using Bluetooth?

I have to make an application to pair an iOS and Android device (iPhone 5, iPad 3, Galaxy S3, Nexus 7 they all use Bluetooth 4.0) and then send data to each other.
Is this amount of data limited ? Can we send something like a photo or a PDF?
I've already done the pairing and sending data between 2 iOS devices using CoreBluetooth and the sample code from Apple BTLE_Transfer
Of what i understood, a Peripheral (Server) can Advertise to a Central (Client).
This central is scanning around itself, and then try to find the Server by looking for the UUID of the service advertised.
When i make a Server on Android, it is waiting for a connection (listening), i know the UUID and the mac address of my Server.
But when i scan with my iPhone (scanning for the same UUID of course), i can't find the server.
So is there a possibility for the android server to advertise like the Peripheral on iOS?
Or maybe a possibility for my iPhone client to connect using the mac address of the server?
Q: Is this amount of data limited ? Can we send something like a photo or a PDF?
Bluetooth Low Energy was not optimised for sending large amounts of data, nor is it optimised for streaming. It is more suitable for sending small chunks of data periodically (e.g. temperature readings, time, etc). Please have a look at this answer to understand how BLE transfer is different from classic Bluetooth. That being said, you can still send large amounts of data over BLE, and the amount of data is unlimited. However, this might end up being unreliable and relatively slow.
Q: So is there a possibility for the android server to advertise like the Peripheral on iOS?
Being a server/client is a completely different thing from being a peripheral/central:-
Peripheral/central dictates how the connection is made. A central device should initiate the connection. A peripheral device should advertise and wait for a connection request.
Client/Server dictates how the data is distributed. The Gatt Server holds the data. The Gatt Client can read, write or be notified (getting a continuous stream of readings) of this data. In most cases, the server is also the peripheral, but this is not mandatory.
So to answer your question, yes, the server can advertise like the peripheral on iOS. However, for Android, this feature is not yet available and will be part of the next version (Android L) release. Please see this answer for more information.
Q: Or maybe a possibility for my iPhone client to connect using the mac address of the server?
As far as I know, in coreBluetooth you would need the UUID, not the MAC Address, of a peripheral device to connect to it. You do not need to know the services being advertised from the peripheral device. Your best bet would be to scan for peripheral devices, and then connect to the one with the UUID and/or the advertising data that u know belong to your peripheral.
I hope this helps.
I'm not sure. Bluetooth LE isn't good idea to transfer large files. In one request phone you have only 18 bytes.
Nexus 7 bluetooth chip has some defect - not work correctly.
Try free application for IPhone - Light Blue.
so...
First question: yes.
Second: Yes but it's not good idea. MAc address in Iphone is alternating every 10 minutes and all turn on/off bluetooth.
In general, sending large files is best done using an internet connection (over the cloud), there are many frameworks that can cut down the overhead for you.
However, the main question is still how to discover to which device you would want to send the data.
There could be multiple ways of doing that on your own such as using BLE or even sound.
To be honest, its a lot of work so if your app is end-user driven, i would suggest using a framework that can do cross platform discovery for you such as: http://p2pkit.io or google nearby.
Disclaimer: i work for Uepaa developing p2pkit for iOS and Android

How to make an Android phone as bluetooth headset

I have 2 Android Phones, and I want to connect them together via bluetooth, and make one of them a bluetooth headset.
So, my question is how to program the second phone to change its role profile to "Bluetooth Headset" when establishing the connection ?
I've found this post but my question is a little bit different
Thank for any advice or idea :)
You cannot on Android. At least using the built-in Bluetooth A2DP profile.
Your phone will only act as a transmitter (source), not a receiver (sink).
Please look at these two answers I gave on why this is not possible :
Is it possible to send/receive voice from PC to Android device over Bluetooth
Receive audio via Bluetooth in Android
You can, on the other hand, develop two apps each acting as a client/server using your own protocol. The server could be streaming audio content to the client via Bluetooth for instance.
Another way to consider this, since using an Android device as an A2DP sink is not feasible on every phone, is building these two apps using your wifi connection. It could be much more rapid and the sound sound be of a much better quality.

Categories

Resources