Switch mode from BLE to Bluetooth Classic and back - bluetooth

I have two Bluetooth 4.0 dual mode devices. Is it possible to do the following
1) Connect via BLE to transfer state information
2) Switch connection to Bluetooth Classic to transfer large file (to be done without user interaction)
3) Back to BLE
Thanks in advance.

Related

Should a BLE device be paired or not ? or what are the conditions a device should have to be paired?

When connection to a custom BLE device from an app (android and ios) I have two options
a) first pair the device on the phone (like a headset or other devices) and then use it from the app to read and write data
b) without pairing on the phone, go inside the app, search for a device with a specific name or address, and just connect to it and read and write data.
when is one preferred over the other one ?
Its just when it needs to interact in the background or am I missing something?
The devices you see in your phones Bluetooth settings are Bluetooth Classic devices. There are some devices using both BLE and Bluetooth Classic which show up in the settings too, but the settings page is only for the Bluetooth Classic part of the device. Headphones for example are streaming music trough the Bluetooth Classic profile A2DP but might offer BLE services for additional features.
You always have to use a special app to communicate with the BLE part of a device. This could be an app provided by a manufacturer or a generic BLE scanner app such as nRF Connect.
As alexander.cpp already told you in his answer pairing (the exchange of keys) and bonding (saving of said keys) is not required for the communication with BLE devices and only needed if the device requires a secured connection.
Bonding (technically correct term for BLE, often called Pairing in non-technical speech) is mostly for security, we can send sensitive information because the receiver is verified and data is transferred in encrypted form.
Prefer to use bonding if the data is sensitive (means users feel uncomfortable if somebody they don't know receive their data). For example, I consider "current temperature = 25" as NOT sensitive. For detailed explanation, find "Bonding with a BLE device" in BLE guide by PunchThrough.
Also this is a good answer to a similar question: https://stackoverflow.com/a/42916081/10380092.
Your second question about background - no, bonding is not related to interaction in background.

Multiple BLE devic connection using gatttool

To monitor multiple BLE devices and record the incoming data.
In order to achieve this I should be able to connect to multiple ble devices. Right now I can open one interactive mode using gatttool and connect to the ble device (On raspberry pi). If I want to connect to one more ble device I have to open a new terminal window.
Can anyone help me on how to connect to multiple ble devices keeping the target in mind.

Bluetooth profile info in linux

As bluetooth device has a number of bluetooth profiles. when want to do communication is bluetooth device, first pair bluetooth device and then starts sending data using bluetooth.
In linux, hcitool is used to scan nearby bluetooth devices.
Questions:
1) How can i know which bluetooth profile is supported by selected nearby bluetooth device?Is there any particular command to know bluetooth profile supported by selected nearby bluetooth device in linux?
2) suppose, i come to know selected nearby bluetooth device support abcd and xyz bluetooth profiles. How can i select particular bluetooth profile in linux?, example abcd out of supported profiles.
2) How can i connect to that selected bluetooth device as SPP profile for transferring data as serial port in linux?
Regards,
Sukhdeep Singh
In linux, sdptool utility is provided with which you can search your own device supported profiles and other devices supported profiles(sdptool browse local/).
Since you know the peer device support abcd/xyz profile, you dont have to select any profile, you have to intiate a profile level connection request(pairing/authentication also needs to be taken care)
For SPP connection, rfcomm tool is provided by bluez

Android Bluetooth LE Chat example

I am trying to read serial data over Bluetooth LE but can't find any code examples for this type of bluetooth and api19. Does any one have an example?
There is no profile defined for serial data communication over Bluetooth Low Energy till now. For this one can use the Bluetooth classic only.
In any case, Android devices can not broadcast for advertising packets. They can only scan the advertising packets. Hence, these devices will be in Central mode only. But can act as either server or client.
For Bluetooth chat related app example one can refer Android SDK as,
sdk/samples/android-19/legacy/BluetoothChat
The above example is based on Bluetooth classic based on RFCOMM channel for serial communication.
Android 5.0 let mobile to be peripheral. So chat will be possible:
https://developer.android.com/about/versions/android-5.0.html
Bluetooth Classic got the SPP profile. This is not how Bluetooth Low Energy works.
In BLE you have 1 or more Services each with 1 or more Characteristics which are basically just bytes in a predefined format which by default can be max 23 bytes.
To send data from one device to another one must be the Master and the other must be Slave.
Android API19 does not support the Slave (Peripheral) role, it seems Google still doesn't understand the importance of Bluetooth Low Energy. It's so much more than just Pulse-readers.
You can send from an Android API19 phone to e.g. an iPhone which can be Slave/Peripheral.
You cannot send from an Android API19 phone to another API19 phone. For this you must use Bluetooth Classic SPP profile.

Get device handle of a Bluetooth Low Energy device

I have a Bluetooth Low Energy device to which I need send some values from the PC.I need to connect this device to the Windows 8 PC and should be communicate with it from my application (Visual C++, win 32 application). I already know the hardware ID and friendly name of the device.
Is there any API to establish connection to the device using this ID/ friendly name, and give a device handle so that I can use GATT APIs to send values to the device. http://msdn.microsoft.com/en-us/library/windows/hardware/hh450825(v=vs.85).aspx
http://code.msdn.microsoft.com/windowshardware/Bluetooth-Generic-4f4ea968
Bluetooth low energy is considered Network.Proximity just as NFC.

Resources