Gemalto is now part of the Thales Group, find out more.

You are here

HOW TO SEND AT COMMANDS TO ASC0 INTERFACE WITH MIDLET? | Thales IoT Developer Community

May 21, 2018 - 7:21pm, 1016 views

Hi,
I am triying to create a Midlet that start a transparent TCP/Serial bridge on ASC0 interface, how can I send at commands to this interface, in order to use it as a Transparent Bridge?

Here is my code:
public class GemaltoExtreme extends MIDlet {
    private ATCommand ATC;

    private String sendCommand(String command){

        try{

            if (ATC == null){

                ATC = new ATCommand(false); // no at comand send to the method

            }
            //System.out.println(command+"\n");
            String answer = ATC.send(command + "\r");

            Thread.sleep(100); // Remember at least to implement 100 ms sleep in
            // order to recevie any URC
            System.out.println(answer);
            return answer; // Return the AT command execution answer

        }

        catch (Exception e){

            return("Error Enviando Comando AT");// implemment the treatment for the exceptions in this block

        }

    }
    public GemaltoExtreme() {
        // TODO Auto-generated constructor stub
    }

    protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
        // TODO Auto-generated method stub
        notifyDestroyed();

    }

    protected void pauseApp() {
        // TODO Auto-generated method stub

    }

    protected void startApp() throws MIDletStateChangeException {
        // TODO Auto-generated method stub
        System.out.println("Iniciando programa");
        sendCommand("AT^SPOW=1,0,0");
        sendCommand("AT^SCFG=\"Userware/Stdout\",\"asc0\"");
        sendCommand("AT^SICS=0,conType,\"GPRS0\"");
        sendCommand("AT^SICS=0,\"apn\",\"extreme.comcel.com.co\"");
        sendCommand("AT^SISS=0,srvType,\"Socket\"");
        sendCommand("AT^SISS=0,conId,0");
        sendCommand("AT^SISS=0,\"address\",\"socktcp://166.210.129.237:2001;etx=26\"");
        sendCommand("AT^SISS=0,\"tcpMR\",\"3\"");
        sendCommand("AT^SISS=0,\"tcpOT\",\"5555\"");
        sendCommand("AT^SISS=1,srvType,\"Socket\"");
        sendCommand("AT^SISS=1,conId,0");
        sendCommand("AT^SISS=1,\"address\",\"socktcp://listener:2001;etx=26;autoconnect=1\"");
        sendCommand("AT^SISS=1,\"tcpMR\",\"3\"");
        sendCommand("AT^SISS=1,\"tcpOT\",\"5555\"");
        sendCommand("AT^SISO=1");
        sendCommand("AT^SISO=1,1");
        sendCommand("AT^SCFG=\"Userware/Stdout\",\"null\"");
        destroyApp(true);
    }
}