⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 SMS send example program for xt-65 cinterion modem
💻 JAVA
字号:
package src;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import com.siemens.icm.io.ATCommand;
import com.siemens.icm.io.ATCommandListener;

public class main extends MIDlet 
{
	
    ATCommand atc;
    ATList atl;
	
	
	protected void startApp() throws MIDletStateChangeException 
	{
		int cont=0;
		
		//Creamos una clase ATCommand y un listener
        try 
        {
            atc = new ATCommand(false);
            atl = new ATList();
            atc.addListener(atl);  
            setConfigInicial();
        } 
        catch (Exception e) 
        {
            e.printStackTrace();
        }
        
        //Bucle infinito
        while (true)
        {
            try 
            {
            	//Pausamos 1 segundo ...
            	Thread.sleep(1000);
            	cont++;
            	//Cada vez que pase 1 minuto enviamos un SMS
            	if (cont==60)
            	{
            		enviarSMS("Prueba de SMS","666774646");
            		cont=0;
            	} 
            } 
            catch (Exception e) 
            {
                e.printStackTrace();
            }
        }
	}
	
	
	
	
	
	
    //M閠odo para enviar los comandos AT
    String sendAT(String str) 
    {
        try 
        {
            str = atc.send(str + "\r".toUpperCase());
        } 
        catch (Exception e) 
        {
        	e.printStackTrace();
        }
        return str;
    }	
	
    
    
    
    //M閠odo para inicializar el m骴em para esta aplicaci髇.
	int setConfigInicial()
	{
		String respuestaAT;
		int hayError=0;
		
	    //Miramos si es necesario enviar PIN al m骴ulo
		respuestaAT=sendAT("at+cpin?");
		if (respuestaAT.indexOf("READY")<=0)
		{
			System.out.println("Enviamos el PIN al m骴ulo\r");
			//Enviamos el PIN al m骴ulo. El pin lo tendremos almacenado en el fichero .jad
			respuestaAT=sendAT("at+cpin=" + getAppProperty("pin"));
			if (respuestaAT.indexOf("OK")<=0)
				hayError=1;
			else
				hayError=0;
		}
		else
			System.out.println("La SIM no est

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -