Java Reference
In-Depth Information
if (portId.getPortType() ##
CommPortIdentifier.PORT_SERIAL) {
try {
open();
boolean result # isMobile();
close();
if (result){
return portId;
}
} catch (Exception e){}
}
}
return null ;
}
// Check if the CE connected to the current port is GSM
// enabled
synchronized boolean isMobile(){
String reply;
sendCmd("ATV1",500); // verbose result
sendCmd("ATQ0",500); // enables result codes
reply # sendCmd("AT",500);
if (reply.endsWith("OK\r\n")){ // there's an AT enabled
// modem
sendCmd("ATE0",500);
reply # sendCmd("AT ! CSMS # ?",500);
// check for SMS capabilities
if (reply.endsWith("OK\r\n") ||
reply.endsWith(" ! CSMS: (0,1)\r\n"))
return true ;
}
return false ;
}
// Send an SMS. Method open() must have been called before.
// @parameter dest destination address (tlf #)
// @parameter msg the text of the message
// (at most 160 chars)
public synchronized String send(String dest, String msg){
String reply;
try {
reply # sendCmd("AT ! CSMS # 0");
//System.out.print(reply);
reply # sendCmd("AT ! CMGF # 1");
//System.out.print(reply);
if (msg.length() > 160){
msg # msg.substring(0,160);
}
Search WWH ::




Custom Search