public void doIt() throws Exception {

    OutboundNotification outboundNotification = new OutboundNotification();
    InboundNotification inboundNotification = new InboundNotification();
    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.com5", "COM5", 460800, "MobiData", "");
    gateway.setInbound(true);
    gateway.setOutbound(true);
    gateway.setSimPin("");
    // Explicit SMSC address set is required for some modems.
    // Below is for VODAFONE GREECE - be sure to set your own!--- i set my own
    gateway.setSmscNumber("+8801700000600");
    Service.getInstance().setOutboundMessageNotification(outboundNotification);
    Service.getInstance().setInboundMessageNotification(inboundNotification);
    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("+8801718847772", "Hello from SMSLib!");
    // Service.getInstance().sendMessage(msg);
    System.out.println("log1");
    // System.out.println(msg);
    System.out.println("log2");
    // Or, send out a WAP SI message.
    // OutboundWapSIMessage wapMsg = new OutboundWapSIMessage("306974000000",  new
    // URL("http://www.smslib.org/"), "Visit SMSLib now!");
    // Service.getInstance().sendMessage(wapMsg);
    // System.out.println(wapMsg);
    // You can also queue some asynchronous messages to see how the callbacks
    // are called...
    // msg = new OutboundMessage("309999999999", "Wrong number!");
    // srv.queueMessage(msg, gateway.getGatewayId());
    // msg = new OutboundMessage("308888888888", "Wrong number!");
    // srv.queueMessage(msg, gateway.getGatewayId());
    System.out.println("Now Sleeping - Hit <enter> to terminate.");
    System.in.read();
    Service.getInstance().stopService();
  }
示例#2
0
  public void doIt() throws Exception {
    System.out.println("Example: Send an encrypted message from a serial gsm modem.");
    System.out.println(Library.getLibraryDescription());
    System.out.println("Version: " + Library.getLibraryVersion());
    SerialModemGateway gateway =
        new SerialModemGateway("modem.com1", "COM5", 57600, "Nokia", "E60");
    gateway.setInbound(true);
    gateway.setOutbound(true);
    gateway.setSimPin("0000");
    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();

    // Create a new AES Key with a known key value.
    // Register it in KeyManager in order to keep it active. SMSLib will then automatically
    // encrypt / decrypt all messages send to / received from this number.
    Service.getInstance()
        .getKeyManager()
        .registerKey(
            "+306948494037", new AESKey(new SecretKeySpec("0011223344556677".getBytes(), "AES")));

    OutboundEncryptedMessage msg =
        new OutboundEncryptedMessage("+306948494037", "Hello (encrypted) from SMSLib!".getBytes());
    Service.getInstance().sendMessage(msg);
    System.out.println(msg);

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