Pokazywanie postów oznaczonych etykietą bluetooth. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą bluetooth. Pokaż wszystkie posty

wtorek, 2 stycznia 2018

Connect to the bluetooth serial port in linux

From time to time I use my bluetoth module HC-05 to communicate with microcontroller. Every time I have the same problem because I don't remember how to do that. Short receipe working for me (at least for openSUSE):
 sudo bluetoothctl  
 power on  
 agent on  
 scan on  
 pair <MAC>  
Then:
 sudo killall rfcomm  
 sudo rfcomm connect /dev/rfcomm0 <MAC> 1  

/dev/rfcomm0 is ready to use now.

source

niedziela, 3 lipca 2016

Android - how to communicate with PC using serial port over bluetooth

One time I needed to simulate a device which communicates with PC over bluetooth. I thought that I can use my smartphone with Android because this is faster way than creating new device using microcontroler and bluetooth module. I needed only my phone, Android Studio and a USB cable. I used code from Bluetooth Android Guide.
The most important line is:
 tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord(NAME, MY_UUID);
Name parameter can be any value, but in the UUID you should pass correct value if you want to use serial port. This value is:
UUID.fromString(00001101-0000-1000-8000-00805F9B34FB)

Where base UUID is "00000000-0000-1000-8000-00805F9B34FB" and 0x1101 is the UUID of "SerialPort" service class. You can check service classes here.
After uploading application to the device and running application, you have to pair your phone with a PC. Sometimes COM port (on Windows) is binded just after pairing, but often you must do it manually. To do this you have to open bluetooth settings.


Then go to the "COM Ports" tab and click "Add". Select outgoing type and also your device from listbox. You should also see your application name below.



Click OK and you should get your COM port number.