device to android - android

Can I setup a pc to act as a virtual serial port to mimic a device using SPP bluetooth profile that I need to talk to an android phone?
The device would not have no way receiving the UUID that it needs to be listening for to connect to my phone.
I saw the "reflection" method being used to avoid UUID. Is this how to communicate with devices agnostic to android's communication process?

I don't really understand the final part of your question.
For the first part however, you can. You just need a BT adapter inside your PC/laptop, Windows,Python installed, and a little library called PyBluez.
After installing everything, you can communicate via SPP with client-server roles established as you like (PC server & Android client or viceversa). You have examples for both those:
PyBluez server example and client example
Android examples here
You have to have a UUID, but, in the examples above, it is the standard UUID for SPP. Basically SPP is RFCOMMM with this UUID:
00001101-0000-100­0-8000-00805F9B34FB
Don't forget to vote if useful!

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

Bluetooth communication between an Android phone and a hardware device supporting bluetooth

I'am trying to make an app that receives some binary data from a other device which is not running android. The Android phone should not transfer any data to this device. So over to my questions:
Should the phone act as the server which establishes the RCOMM channel?
Is it possible to connect the phone and this device without paring, as long as I know the MAC-address of the device? If so, how?
And yes, I have read http://developer.android.com/guide/topics/connectivity/bluetooth.html so no need to only answer with that link. :)
Thanks in advance!
1)
Phone should act as a receiver.
I found that the tricky part is to use correct UUID.
If you connect two phones you should be generating those and everything work fine, but on your hardware you can't change UUID that easily.
Take a look at these reserved UUIDs.
For a Serial Port Profile's (SPP) communication use UUID 00001101-0000-1000-8000-00805F9B34FB.
2)
You can connect to a device without pairing if you already know the MAC address, you don't even need to use BlueTooth discovery.
To get device using MAC address call getRemoteDevice(String)
and then createRfcommSocketToServiceRecord(UUID) to get BlueToothSocket.
Also take a look at checkBluetoothAddress(String) to validate MAC address.

How to find out which Bluetooth profile is used for communication

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.

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.

Android Bluetooth

If I wanted to connect to another device via bluetooth how would I do it?
Nothing I've done seems to work. The phone I'm trying to connect to is non android and has bluetooth on and discoverable.
Bluetooth API is realy poor in this case... let's have look at java-doc:
Hint: If you are connecting to a
Bluetooth serial board then try using
the well-known SPP UUID
00001101-0000-1000-8000-00805F9B34FB.
However if you are connecting to an
Android peer then please generate your
own unique UUID.
from: link text
According to this, your peer should be visible under the 00001101-0000-1000-8000-00805F9B34FB service record.
Now, if you want to create an app which need to connect to Bluetooth devices, I advice you to use Cordova platform and install a plugin that let you connect via bluetooth, list devices, send data, disconnect etc...
In Bluetooth, there is a concept of service profile for an application layer. An application on a peer 1 willing to talk to same application on peer 2 must be discoverable and connectable, the master initiating the connection.
The application is given a unique service/application identifier so that peers can discover each other. If you write a custom application yourself, you are expected to create a new UUID so that the corresponding SDP protocol can perform the necessary discovery.
Instead of connecting with brute force using the BT_ADDR, you would essentially initiate connection via graceful service discovery and then connection follows once the underlying UUID is identified. This, of course, assumes that you would have done the pairing process early, or that your lower layer stack will include pairing process as well.

Categories

Resources