How do you send an extended-ascii AT-command (CCh) from Android bluetooth to a serial device?

Posted by softex on Stack Overflow See other posts from Stack Overflow or by softex
Published on 2011-01-10T19:50:28Z Indexed on 2011/01/10 19:53 UTC
Read the original article Hit count: 163

Filed under:
|
|
|
|

This one really has me banging my head. I'm sending alphanumeric data from an Android app, through the BluetoothChatService, to a serial bluetooth adaptor connected to the serial input of a radio transceiver.

Everything works fine except when I try to configure the radio on-the-fly with its AT-commands. The AT+++ (enter command mode) is received OK, but the problem comes with the extended-ascii characters in the next two commands: Changing the radio destination address (which is what I'm trying to do) requires CCh 10h (plus 3 hex radio address bytes), and exiting the command mode requires CCh ATO.

I know the radio can be configured OK because I've done it on an earlier prototype with the serial commands from PIC basic, and it also can be configured by entering the commands directly from hyperterm. Both these methods somehow convert that pesky CCh into a form the radio understands.

I've have tried just about everything an Android noob could possibly come up with to finagle the encoding such as:

private void command_address() {
    byte[] addrArray = {(byte) 0xCC, 16, 36, 65, 21, 13};                   
    CharSequence addrvalues = EncodingUtils.getString(addrArray, "UTF-8");  
    sendMessage((String) addrvalues);
}

but no matter what, I can't seem to get that high-order byte (CCh/204/-52) to behave as it should. All other (< 127) bytes, command or data, transmit with no problem. Any help here would be greatly appreciated.

-Dave

© Stack Overflow or respective owner

Related posts about android

Related posts about bluetooth