• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

java program to send AT-Commands to my bluetooth modem(quectel m66) using RXTX java library.

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone. I'm trying to build a java program using RXTX java library  to send AT-Commands to my bluetooth modem(quectel m66) from my windows PC. I am using Eclipse JAVA programming software in my windows PC.

I've looked up through google, but cant seem to find a working example which I can use as a reference.

What I'm trying to do for my project is to able to send a AT command using RXTX java library from my windows PC to a bluetooth modem(quectel m66) and received the response from modem and vice versa. At this point, I've already found the AT-Commands. However, I'm only able to run the commands through putty serial terminal.

How can do java program send AT command from eclipse software in my PC to the bluetooth modem and received the replay from the modem.

Thanks in advance for your help.
Posts: 24594
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sayu, welcome to the Ranch!

As I recall from many years ago, the RXTX product is designed so that Java code can communicate with serial ports. But now that computers don't come with serial ports in their hardware any more, it probably doesn't get much use.

Anyway the point is that it communicates with serial ports. So your Bluetooth modem would have to look like a serial port for RXTX to be able to find it. Maybe there's some configuration which needs to be done?

Edit: It looks like I assumed that your Java code plus RXTX can't find the Bluetooth modem. But now that I reread your post I see that you didn't actually describe your problem. Perhaps I assumed wrong?
Ranch Hand
Posts: 562
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it was a Linux system I'd guess you could open the device (/dev/bluetooth or whatever), then just read/write it.  I don't know how devices work under Windows.

In other words, figure out if Windows has the equivalent to /dev/bluetooth (or whatever) and try to open/read/write it.  Sounds like you might already be doing this with putty.

Once that works you can figure out how to get RXTX in the mix.

Never underestimate the power of talking directly to the hardware with no intermediate libraries when at all possible.

Posts: 20842
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most popular way to do Bluetooth these days is via a USB dongle (although I have some direct-wire devices for working with Arduino-style controllers).

That's assuming that you don't have Bluetooth build into the hardware, as many laptops and Raspberry Pi systems do.

Bluetooth control via "AT" commands tells me, however, that you're using USB. And your OS should automatically register the USB dongle as a "serial device". So no problem there. You just open it the same way you would a COM port (or in Linux, /dev/ttyUSBx) and in theory you're good to go.

Alas, in real life, serial programming can be very frustrating, because modern-day serial interfaces don't just jam stuff out via a UART, they have automatic handling of line endings, flow control characters, and that most aggravating characteristic at all: buffering.

So in some cases you have to adjust hardware parameters (stty). And in languages like Java, you'll probably have to forcibly flush buffers. Unless you use a PrintWriter, which is supposed to flush the buffer automatically every time you do a println().
Ranch Hand
Posts: 167
MS IE Notepad Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although Paul, Jim and Tim wanted to help, all needed informations are already posted by OP: Using RxTx to use a virtual COM with Java. Also an additional very helpful information was given: It works with Putty. TLDR: It's not an issue the system can't communicate with the device but rather the Java code used to "open" the COM port and/or for transmitting / receiving data has issues: Either the port is opened with wrong parameters (baud rate, parity, stop-bits, flow control) or passing data into or retreiving data from the maybe correct opened port doesn't work as it need to.

It all comes down to: We need code to see what you're doin to try to help spot what's maybe wrong.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!