MathDLR MathDLR - 1 year ago 139
Android Question

Send data from an android app to a Serial COM Port via Bluetooth

I would like to send and receive data from my phone to an application on my computer that just connect to a PORT COM and can also send and receive data (like an UART). An exemple of such software (on the computer) is Termite.

For the Android app, I tried with the Bluetoothchat that Android support provides but when I try to connect to my computer, it says it is unable to connect.

I don't know if I am doing it correctly because on the computer software, you have to choose the Baud rate for the UART communication but BT has no baudrate.

Could someone enlighten me?

Answer Source

I had actually 2 problems going on :

  • I had to go in the settings of my Bluetooth dongle and create a Bluetooth COM Port associated with it
  • I had to change in the code the UUID (Universally Unique Identifier): the UUID for the SPP (Serial Port Service) is defined by the Bluetooth SIG to be 0x1101. If you are connecting to a Bluetooth serial board, then try using the "well-known" SPP UUID : 00001101-0000-1000-8000-00805F9B34FB with this code line:

private static final UUID MY_UUID_SECURE = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");

(I put the same for both MY_UUID_SECURE and MY_UUID_INSECURE just to check if it was working)

And then this solved my problem. Hope it can help some people who have the same problems.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download