1

I'm trying to send a command to a device over my Bluetooth RFCOMM socket Connection. -Connection is successful. -As soon as it gets connected i tried reading the DataInputStream and i continuously get data from the device. -My problem is i'm trying to send a Serial command to the device and on doing that my device doesn't respond to the command.

Is there something wrong in the way i'm sending commands ? Here is the code i used ...

 DataOutputStream Dos = new DataOutputStream(BTsocket.getOutputStream());
 ...........

String message = "SET TIME XXX";
    byte[] msgBuffer = message.getBytes();
    try {

        Dos.writeInt(msgBuffer.length);
        Dos.write(msgBuffer); 
        Dos.flush();

   } 
   catch (IOException e) {
        Log.e(TAG, "Exception during write.", e);
    }
m4n07
  • 2,267
  • 12
  • 50
  • 65
  • In the DataInputStream the device continuosly sends data. So if i send a command over DataOutputStream how can i know the return status of the command. – m4n07 Mar 18 '11 at 15:36
  • could you please provide your code. –  Dec 26 '11 at 16:59

1 Answers1

0

I figured it out that i have to have proper Escape Sequence while sending the command. It worked after correcting the Escape Sequence.

m4n07
  • 2,267
  • 12
  • 50
  • 65