   ҵҪjavaʵwavecomèŵĹܣ
ӦèĶοӿʵֵģ⼸̨èʱ
ûṩοӿڣҲòϣԼд˸ʵ˷ŵĹܡ

   ʵܣҪjar

ȣsmslib-3.3.0b2.jarcomm.jar빤libУjavax.comm.propertiesŵ%JAVA_HOME%/jre/lib£
win32com.dllŵ%JAVA_HOME%/jre/bin¡·Ŵˣͻᱨġ
úԺ󣬰examples\modemµSendMessage.javaReadMessages.javaĿ£
ͿԷˡ⣬οҵblog:
http://hi.baidu.com/%CB%CE%B9%E2%BB%D41/blog/item/e45d6b58d4ba4cdb9c8204a9.html 
ʼ tigerlion@126.comһظ

                               ʹjavawavecomèŵķ


     ҵҪjavaʵwavecomèŵĹܣӦèĶοӿʵֵģ⼸̨èʱ򣬾ûṩοӿڣҲòϣԼд˸ӿʵ˷ŵĹܡ
   ʵܣҪjarԵhttp://code.google.com/p/smslibsmslib-v3.3.0-B2-bin.zipjavacomm20-win32.zip
     ȣsmslib-v3.3.0-B2-bin.zip⿪smslib\dist\libĿ¼ҵsmslib-3.3.0b2.jar빤libУٰjavacomm20-win32.zip⿪comm.jarҪŵlib£javax.comm.propertiesŵ%JAVA_HOME%/jre/lib£win32com.dllŵ%JAVA_HOME%/jre/bin¡·Ŵˣͻᱨġ
úԺʹܼ򵥣ҵĴ룺
   // SendMessage.java - Sample application.
//
// This application shows you the basic procedure for sending messages.
// You will find how to send synchronous and asynchronous messages.
//
// For asynchronous dispatch, the example application sets a callback
// notification, to see what's happened with messages.
package song.test;
import org.smslib.IOutboundMessageNotification;
import org.smslib.Library;
import org.smslib.OutboundMessage;
import org.smslib.Service;
import org.smslib.Message.MessageEncodings;
import org.smslib.modem.SerialModemGateway;
public class SendMessage
{
public void doIt() throws Exception
{
   Service srv;
   OutboundMessage msg;
   OutboundNotification outboundNotification = new OutboundNotification();
   System.out.println("Example: Send message from a serial gsm modem.");
   System.out.println(Library.getLibraryDescription());
   System.out.println("Version: " + Library.getLibraryVersion());
   srv = new Service();
  
   SerialModemGateway gateway = new SerialModemGateway("modem.com1", "COM1", 115200, "wavecom", "17254");
   gateway.setInbound(true);
   gateway.setOutbound(true);
   gateway.setSimPin("0000");
   gateway.setOutboundNotification(outboundNotification);
   srv.addGateway(gateway);
   srv.startService();
   System.out.println("Modem Information:");
   System.out.println(" Manufacturer: " + gateway.getManufacturer());
   System.out.println(" Model: " + gateway.getModel());
   System.out.println(" Serial No: " + gateway.getSerialNo());
   System.out.println(" SIM IMSI: " + gateway.getImsi());
   System.out.println(" Signal Level: " + gateway.getSignalLevel() + "%");
   System.out.println(" Battery Level: " + gateway.getBatteryLevel() + "%");
   System.out.println();
   // Send a message synchronously.
  
   msg = new OutboundMessage("136****1175", "javaĶ!");//ֻ룬Ͷ
   msg.setEncoding(MessageEncodings.ENCUCS2);//仰ǷĶű
   srv.sendMessage(msg);
   System.out.println(msg);
   System.out.println("Now Sleeping - Hit <enter> to terminate.");
   System.in.read();
   srv.stopService();
}
public class OutboundNotification implements IOutboundMessageNotification
{
   public void process(String gatewayId, OutboundMessage msg)
   {
    System.out.println("Outbound handler called from Gateway: " + gatewayId);
    System.out.println(msg);
   }
}
public static void main(String args[])
{
   SendMessage app = new SendMessage();
   try
   {
    app.doIt();
   }
   catch (Exception e)
   {
    e.printStackTrace();
   }
}
}