Examples of IPModemGateway


Examples of org.smslib.modem.IPModemGateway

      System.out.println("Example: Read messages from a serial gsm modem.");
      System.out.println(Library.getLibraryDescription());
      System.out.println("Version: " + Library.getLibraryVersion());

      // Create the Gateway representing the serial GSM modem.
      IPModemGateway gateway = new IPModemGateway("modem.com1", "127.0.0.1", 2000, "Nokia", "");
      gateway.setIpProtocol(IPProtocols.BINARY);

      // Set the modem protocol to PDU (alternative is TEXT). PDU is the default, anyway...
      gateway.setProtocol(Protocols.PDU);

      // Do we want the Gateway to be used for Inbound messages?
      gateway.setInbound(true);

      // Do we want the Gateway to be used for Outbound messages?
      gateway.setOutbound(true);

      // Let SMSLib know which is the SIM PIN.
      gateway.setSimPin("0000");

      // Set up the notification methods.
      Service.getInstance().setInboundMessageNotification(inboundNotification);
      Service.getInstance().setCallNotification(callNotification);
      Service.getInstance().setGatewayStatusNotification(statusNotification);

      // Add the Gateway to the Service object.
      Service.getInstance().addGateway(gateway);

      // Similarly, you may define as many Gateway objects, representing
      // various GSM modems, add them in the Service object and control all of them.

      // Start! (i.e. connect to all defined Gateways)
      Service.getInstance().startService();

      // Printout some general information about the modem.
      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();

      // Read Messages. The reading is done via the Service object and
      // affects all Gateway objects defined. This can also be more directed to a specific
      // Gateway - look the JavaDocs for information on the Service method calls.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.