Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- import javax.microedition.io.CommConnection;
- import javax.microedition.io.Connector;
- import javax.microedition.midlet.*;
- import SerialHandler;
- import SocketServidor;
- import SocketServidorC;
- import com.cinterion.io.ATCommand;
- import com.cinterion.io.ATCommandFailedException;
- import com.cinterion.io.ATCommandListener;
- public class SMSHandler extends MIDletStateChangeException
- {
- String numero = null;
- String mensagem = null;
- private ATCommand atc;
- public SMSHandler()
- {
- }
- public void run() throws IllegalStateException, IllegalArgumentException, ATCommandFailedException
- {
- atc = new ATCommand(false);
- ATCommandListener listener = new ATCommandListener() {
- public void RINGChanged(boolean SignalState) {
- }
- public void DSRChanged(boolean SignalState) {
- }
- public void DCDChanged(boolean SignalState) {
- }
- public void CONNChanged(boolean SignalState) {
- }
- public void ATEvent(final String Event) {
- System.out.println("received URC: " + Event);
- // search for SMS related URCs
- if (Event.indexOf("+CMTI") > 0) {
- //String content = getSmsContent(Event, false);
- //System.out.println("Sms content: " + content);
- System.out.println("Sms content: ");
- }
- }
- };
- // add (activate) the listener
- atc.addListener(listener);
- // switch to the text mode
- System.out.println(atc.send("at+cmgf=1\r"));
- // ENVIO DA SMS
- String at_cmd_response = atc.send("AT+CMGS=\""+ "00" + numero +"\"\r");
- System.out.println(at_cmd_response);
- // provide the message text & confirm (terminate)
- at_cmd_response = atc.send( mensagem + (char) 26);
- // show the response on the screen
- System.out.println(at_cmd_response);
- // activate the SMS URCs
- //System.out.println(atc.send("at+cnmi=2,1\r"));
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement