Embedded Freaks..

November 3, 2008

Simple Hayes AT Command Parser

Filed under: java — Tags: — kunilkuda @ 1:33 pm

After a very long time, I finally have time to implement this idea: AT command parser. My first thought about AT command was how to separate the data from the OK/ERROR, and how to differentiate the URC from AT command.

So, here’s my idea (to be specific, the interface for the AT parser):


/**
* Send AT command to the serial port
*
* @param atCmd The AT command (ended with r or )
*/
void sendAtCmd(String atCmd) throws IOException;

/**
* Get the parser status
*
* @return true if parsing is done, false otherwise
*/
boolean isParsingDone();

/**
* Get the AT command's data
*
* @return Array of string consist of the AT command data
*/
String[] getAtCmdData();

/**
* Get the status of the executed AT command
*
* @return AtCmdStatus
*/
AtCmdStatus getAtCmdStatus();

The usage of the AT command parser will be something like this:


try {

    atParser.sendAtCmd("AT+CMGL=4r");

    // Wait until the parsing is done
    while (!atParser.isParsingDone()) {
        // Sleep for 1-s
        Thread.sleep(10);
    }

    if (atParser.getAtCmdStatus() == AtCmdStatus.OK) {
        for (String atCmdData : atParser.getAtCmdData()) {
            System.out.println("Data :" + atCmdData);
    }
    } else {
        System.out.println("AT Command Error");
    }
} catch (InterruptedException ex) {
} catch (IOException ex) {
    System.err.println(ex.getMessage());
    System.exit(1);
}

(more…)

October 9, 2008

Decoding GSM SMS Septets

Filed under: java — Tags: — kunilkuda @ 5:18 pm

Once encoding is done (refer to this post), decoding is easy.

First, we create two tables from the encoded data (like the encoding method), but for each 8-columns, we need to add empty column.

GSM Septet Decoding Tables

GSM Septet Decoding Tables

(more…)

Encoding GSM SMS Septets

Filed under: java — Tags: — kunilkuda @ 1:01 pm

One part of the annoying thing in SMS is that you need to send the data in GSM septets (you may want to read it more in here and here).

There’s a lot of approach to encode your message to 7-bits GSM septets, but this is my approach to encode it without relying on java utils too much (which means that it’s quite portable for MCUs, like AVR).

(more…)

Older Posts »

Create a free website or blog at WordPress.com.