0

SMSLib を使用して、PC から携帯電話に SMS を送信しようとしています。Nokia 5130 GSM 電話を使用してメッセージを送信していますが、機能していません。私が使用しているコードはこちらです。

package sms;
import org.smslib.AGateway;
import org.smslib.IOutboundMessageNotification;
import org.smslib.Library;
import org.smslib.Message.MessageEncodings;
import org.smslib.OutboundMessage;
import org.smslib.Service;
import org.smslib.modem.SerialModemGateway;

public class SendMessage
{
public void doIt() throws Exception {
 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());
 SerialModemGateway gateway = new SerialModemGateway("modem.com12", "COM12", 115200, "Nokia", "Nokia 5130 XPressMusic USB Modem");


gateway.setInbound(true);
gateway.setOutbound(true);
gateway.setSimPin("0000");

gateway.setSmscNumber("+919886005444");
Service.getInstance().setOutboundMessageNotification(outboundNotification);
Service.getInstance().addGateway(gateway);
Service.getInstance().startService();
System.out.println();
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() + " dBm");
System.out.println("  Battery Level: " + gateway.getBatteryLevel() + "%");
System.out.println();
// Send a message synchronously.
OutboundMessage msg = new OutboundMessage("+917829903913", "Sample msg");
msg.setEncoding(MessageEncodings.ENC7BIT);
msg.setSrcPort(0);
msg.setDstPort(66500);
Service.getInstance().sendMessage(msg);

System.out.println(msg);

System.out.println("Now Sleeping - Hit <enter> to terminate.");
System.in.read();
Service.getInstance().stopService();
}

public class OutboundNotification implements IOutboundMessageNotification {

public void process(AGateway gateway, OutboundMessage msg) {
System.out.println("Outbound handler called from Gateway: " + gateway.getGatewayId());
System.out.println(msg);
 }
}

public static void main(String args[]) {
SendMessage app = new SendMessage();
try {
app.doIt();
} catch (Exception e) {
e.printStackTrace();
}
}
}

そして、ここに私が得ているエラーメッセージがあります。あまり詳しくないので教えてください。

run:
Example: Send message from a serial gsm modem.
SMSLib: A Java API library for sending and receiving SMS via a GSM modem or other supported   gateways.
This software is distributed under the terms of the Apache v2.0 License.
Web Site: http://smslib.org
Version: 3.5.1
log4j:WARN No appenders could be found for logger (smslib).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
org.smslib.GatewayException: Comm library exception: java.lang.RuntimeException: javax.comm.PortInUseException: Port currently owned by Unknown Windows Application
    at org.smslib.modem.SerialModemDriver.connectPort(SerialModemDriver.java:102)
    at org.smslib.modem.AModemDriver.connect(AModemDriver.java:114)
    at org.smslib.modem.ModemGateway.startGateway(ModemGateway.java:189)
    at org.smslib.Service$1Starter.run(Service.java:276)
 BUILD SUCCESSFUL (total time: 6 seconds)
4

3 に答える 3

1

他のアプリケーションがリッスンしていないことを確認してくださいCOM12javax.comm.PortInUseException:コードが利用できない登録を試みたために発生しましたCOM12

必要なすべてのjarファイルとdllファイルを正しい場所にコピーすると、これが機能するはずです。32ビットのJDKも必要なので、他にJDKがない場合は、32ビットのJDKをダウンロードする必要があります。java.lang.UnsatisfiedLinkError:

このコードを実行すると、機能します。また、setSmscNumberをSIMプロバイダーに設定することを忘れないでください。デフォルトのものがまだあるようです(例1)

乾杯PB

于 2012-08-17T16:07:38.253 に答える