1

I'm trying to learn how to send commands via Bluetooth using this Library : https://github.com/akexorcist/Android-BluetoothSPPLibrary

But when I try to send these commands in this form :

(Send: "$$$"                           Receive: "CMD"    
Send: "S&,0404\r"                       Receive: "AOK"   
Send: "S&,0400\r"                      Receive: "AOK"    
Send: "---\r"                          Receive: "END")

I need put this commands to code down,

But I don't know how.

I want to get connected to an android device via Bluetooth and send Text.

    void teplotahore() {
        STup.setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        teplotad++;
                        prevodst(teplotac, teplotad);
                        bt.send("Text", true);
                    }
                }
        );
    }



public void send(String data, boolean CRLF) {
        if(mChatService.getState() == BluetoothState.STATE_CONNECTED) {
            if(CRLF) 
                data += "\r\n"; 
            mChatService. write(data.getBytes());
        }
    }

Please Tell me how (Send: "S&,0404\r" Receive: "AOK" ) rewrite to Byte form for send via Bluetooth.

Or If someone have similar project, please send it to me. I want to learn it.

I leer more and more theory of these prolem, but it's no run for me.

Lawa Fazil
  • 161
  • 1
  • 14

1 Answers1

0

Bluetoothchat is a sample project provided by google. You can check this to understand the data transfer by using Bluetooth.

  • 1
    Instead of sending some text or data, you can send your commands too. you will have yo make little modification in the code. – CodeWarrior101 Jan 31 '16 at 12:26