2016-06-09 82 views
0

什麼是最好的方法?我已經閱讀了它,但大多數主題已經過時。大多數示例都使用「COM」端口,但我無法在COM連接(設備管理器)中找到我的USB調制解調器,而不是它位於「網卡」中。用Java通過USB gsm modem發送短信

+0

什麼[SMSLib(http://smslib.org/)? – vojta

+0

這裏是例子:[鏈接](https://github.com/tdelenikas/smslib-v3/blob/master/src/java/examples/modem/SendMessage.java),但我不知道這裏放的是什麼'SerialModemGateway網關= new SerialModemGateway(「modem.com1」,「COM4」,115200,「Huawei」,「」);' – user1967089

回答

1

希望這個代碼可以幫助:

package logic; 

import com.harshadura.gsm.smsdura.GsmModem; 

public class TestSMS { 

    private static String port = "COM3"; //Modem Port. 
    private static int bitRate = 115200; //this is also optional. leave as it is. 
    private static String modemName = "ZTE"; //this is optional. 
    private static String modemPin = "0000"; //Pin code if any have assigned to the modem. 
    private static String SMSC = "+9477000003"; //Message Center Number ex. Mobitel 

    public static void main(String[] args) throws Exception { 
     GsmModem gsmModem = new GsmModem(); 
     GsmModem.configModem(port, bitRate, modemName, modemPin, SMSC); 
     gsmModem.Sender("+94712244555", "Test Message"); // (tp, msg) 
    } 
} 

完整的答案和細節at this article