2

I am using an RPi3 and has Ubuntu MATE running on it. I connected a Bluetooth device and I want to read data from the rfcomm0 port.

Since the device uses a special protocol, "cat /dev/rfcomm0" can show something but it is not readable. I want to write a java file that can read byte[] from rfcomm0. Is there any ways to reach this?

Thanks!

1 Answers1

0

The device /dev/rfcomm0 will behave like a serial device. So you might want to use a Java Serial library to handle the settings of baud rates and the like. See Is there Java library or framework for accessing Serial ports?

The other option is to set the serial parametes via commandline eg. with stty see Set stty parameters

The the device has been prepared you can then read and write to the device just as with any other file. Just open the device with a FileInputStream to do so.

Community
  • 1
  • 1
Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186