How to find out which Bluetooth profile is used for communication - android

I need to use Bluetooth for communication with another application which sends data via bluetooth SPP profile. I use the Bluetooth Chat app from Android developer site. I am using real phone (HTC Desire) as there is no Bluetooth API in Android emulator. I use a BlueSoleil bluetooth dongle.
When the other application tries to connect to my phone via Bluetooth and send data via SPP, it is not possible to connect the phone to the application. So I tried Windows Hyperterminal to send data and connect the phone through the dongle. In this situation, I can receive the data and display on the phone.
I would like to know how to find out which bluetooth profile was used when communicating with Hyperterminal.
I have read that bluetooth stack has a buggy implementation in HTC Desire and the SPP profile doesn't work consistently always.
Appreciate any suggestion and time spent on this.
Cheers,
Madhu Nandan

In the case of your Hyperterminal communication - SPP profile that was most likely used.
SPP profile is a generic profile that just establishes the RFCOMM data channel and sets up a virual COM port for applications to open and connect to and send data.
SPP does not specify any data formats or application level communication protocol to be used by application.
So applications at both end should establish the required format/protocol for communication.
Applications sets it selfs up on a virtual COM (over SPP) and advertises itself (on SDP) via a unique UUID (And Service Names)
So I would suggest that you use the chat application as a starting point, and start with connection / reading data etc, then modify it and complete the application that talks to your application on the device.
(The chat example is meant to work with a remote chat of the same type and is not a generic usage for SPP profile application)
Hope this helps you.

Related

send data using android Bluetooth to Arduino

Good day.
I want to send Accelerometer readings from the Android to Arduino using Bluetooth communication. I don't want to write the code to discover devices around and connect or connect to them through program interface . I can connect to the other device manually by the android setting.all I want to do is to send the string through output buffer or anything while i connect manually to the Arduino bluetooth but the tutorials out there shows how to connect and discover device.
I have been struggling to know how to send data (string or int) and i really don't care about discover and connect because i can do this manually from my android settings
thank you in advance
Sensors, Arduino devices and other hardware systems typically work on SERIAL PORT PROFILE (SIP). You may wanna double check this with the specific hardware you are dealing with. But I am quite sure it is SIP. If that is the case, you can literally copy and paste android chat sample code and change UUID to default UUID of Serial Port.
Just replace UUID of the sample with this: 00001101-0000-1000-8000-00805F9B34FB
The UUID is the chat example is defined in BluetoothChatService.java. You can change both secure and insecure UUIDs.
This is the sample: https://android.googlesource.com/platform/development/+/eclair-passion-release/samples/BluetoothChat

how to connect an embedded device to bluetooth chat application in android?

I have a bluetooth hardware device ( embedded one ) that is acting as a client and connecting with pairing permissions automatically to any device whose bluetooth is ON. But it is not connecting to the BT chat application installed on my android phone. The BT chat application works fine when it connects to my hardware device as a slave. But in case of my hardware device acting as a client and BT chat acting as a listening server, connection fails.
Does the AcceptThread code works only on application level and not on system level?
The hardware device connects my android phone at system level but not to bluetooth chat application.
Is there any solution?
Bluetooth chat app basically supports only classic bluetooth.
Please check the bluetooth profile of your embedded device. Does your embedded device supports classic bluetooth?
I suspect your chat application is using createRfcommSocketToServiceRecord().
Use the createInsecureRfcommSocketToServiceRecord instead. Insecure socket allows the RFCOMM to communicate with a non-authenticated paired device. Embedded devices like the RN42 or KC2114 have a difficult time performing authenticated pairing, because user interaction is required (numeric comparison, yes-no response). The "Just Works" automatic pairing will not produce an authenticated pairing. KC2114 supports both automatic authenticated pairing (with a small hack) and Just Works non-authenticated pairing.

Is there a way to isolate and control the Bluetooth pairing process programmatically in Android?

My applications connects my Android phone to a health device. The health device is capable of connecting using either Bluetooth SPP or HDP profile while my app can only support SPP.
The health device's documentation states that I have to send a special command to the it during the pairing process to make sure that Bluetooth communication uses SPP profile instead of HDP.
Note that I'm not concerned about connection after pairing at all. I need to:
Separate the pairing process from the connections after pairing - I don't mind if users have to authorise pairing through a popup
Be able to send some data to the health device during the pairing process (so that following connections will actually happen)
The Android documentation seems to imply that pairing is implicitly handled as an integrated part of the Bluetooth connections as you call connect() or accept(). However, this and this gives me some hope.
I'd like to support as many devices as possible but 4.0 and above are more important. The health device I'm using supports Bluetooth 2.1 so no worries about PIN.

Connect and send data from Android device to computer with Bluetooth?

Is there some way I can send data from an Android device to a computer over Bluetooth?
Thanks
Yes. Perhaps the most straightforward way to get started would be to use the Bluetooth Chat example, which you will hopefully find in the Samples directory of your SDK installation, or can of course be downloaded from Google.
The Bluetooth Chat demonstrates exchanging bytes of data from one Android device to another over the Bluetooth Serial Port Profile (SPP).
To exchange data between the Android device and your computer, you could use a Bluetooth driver on your computer that provides you with a virtual COM port when a remote Bluetooth SPP device connects. This way, you could simply launch Bluetooth Chat on your Android device, and exchange data with something that reads and writes to a COM port on your computer. For example, on a Windows machine you could simply use HyperTerminal.
The Bluetooth Chat example is then an excellent base upon which to create your own custom Bluetooth Android application.

Activate Bluetooth SPP in Android?

I am trying to use Bluetooth SPP to communicate over it. In some Android phones, SPP profile is not activated. I faced the problem in the application that SPP was not activated and so the connection could not be established over bluetooth and when I started another app that is 3g hotspot which I think activates SPP and I was able to connect over bluetooth in my app.
So, how can we actually activate SPP profile of bluetooth in Android devices? And does all the android devices has SPP profile?
In developer.android.com BluetoothSocket:
The most common type of Bluetooth
socket is RFCOMM, which is the type
supported by the Android APIs. RFCOMM
is a connection-oriented, streaming
transport over Bluetooth. It is also
known as the Serial Port Profile
(SPP).
This might answer your question ..
https://source.android.com/devices/bluetooth/services
SPP (or ability to use Java API's to establish RFCOMM channels) is available from Android (2.0/2.1) release (Eclair) onwards
On the Android phone you will probably need to run an application that initiates the service over SPP.
**
public BluetoothServerSocket
listenUsingRfcommWithServiceRecord
(String name, UUID uuid)
** API can be used to create a service with specified UUID to listen,
Doing this should make this service visible to other devices which can then connect to it.
I just called Samsung help regarding bluetooth SPP on an S8+ phone. They tell me wait for Android Oreo as it isn't available till then. My previous Sony Xperia used Ntrip Client to talk to an external Geneq GPS to receive corrected coordinates and worked really well. Seems we went backwards somewhere?
Ntrip client on the phone collects an internet data stream of GPS corrections every five seconds and sends these to the GPS. The GPS uses the corrections and sends back adjusted coordinates to the phone to use in any application.
I would appreciate someone brighter than me pointing out a quick fix I just load and run to bring back this functionality.

Categories

Resources