HOW TO SEND AT COMMANDS TO ASC0 INTERFACE WITH MIDLET? | Telit Cinterion IoT Developer Community
May 21, 2018 - 7:21pm, 1229 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);
}
}
Hello,
If I understand you correctly you want to open a socket connection and send data from ASC0 interface. And you try to use IP services over AT commands.
Generally it is recommended to use Java classes for Internet connections inside a MIDlet. So if you'd like to place all the logic in the Java MIDlet you could create the socket connection using Connector class and SocketConnection interface instead of AT commands. Then you could open ASC0 in Java with Connector class and CommConnection interface and create some kind of pipe between them.
You will find some short examples for socket and serial connection in API and some example MIDlets in our Knowledge Base:
https://iot-developer.thalesgroup.com/knowledge-base?field_kb_category_t...
For example please see this (should be close to your scenario):
https://iot-developer.thalesgroup.com/showcase/uart-ftp-pipe-example-jav...
You can also use AT commands if you want to implement the logic in an external MCU, which will connect to ASC0 and set-up the transparent socket connection with AT commands and then send data.
Best regards,
Bartłomiej