SMSLib 3.5.3

org.smslib.modem
Class ModemGateway

java.lang.Object
  extended by org.smslib.AGateway
      extended by org.smslib.modem.ModemGateway
Direct Known Subclasses:
IPModemGateway, SerialModemGateway

public class ModemGateway
extends AGateway

Class representing GSM modems or phones. Extends AGateway with modem specific operations.


Nested Class Summary
static class ModemGateway.IPProtocols
           
static class ModemGateway.ModemTypes
          Class representing different types of GSM modems / phones.
 
Nested classes/interfaces inherited from class org.smslib.AGateway
AGateway.AsyncEvents, AGateway.GatewayAttributes, AGateway.GatewayStatuses, AGateway.Protocols
 
Constructor Summary
ModemGateway(ModemGateway.ModemTypes myType, java.lang.String id, java.lang.String myModemDevice, int myModemParms, java.lang.String myManufacturer, java.lang.String myModel)
           
ModemGateway(java.lang.String id, java.lang.String myModemDevice, int myModemParms, java.lang.String myManufacturer, java.lang.String myModel, AModemDriver myDriver)
           
 
Method Summary
 boolean deleteMessage(InboundMessage msg)
           
 AATHandler getATHandler()
           
 int getBatteryLevel()
          Returns the battery level (0-100).
 java.lang.String getCustomInitString()
          Returns the custom modem init string (if any).
 java.lang.String getImsi()
          Returns the IMSI (International Mobile Subscriber Identity) number.
 boolean getIpEncryption()
          Check if the encryption of IP modem transmission is enabled
 ModemGateway.IPProtocols getIpProtocol()
           
 java.lang.String getManufacturer()
          Returns the Manufacturer string of the modem or phone.
 java.lang.String getMessageByIndex(int msgIndex)
           
 java.lang.String getModel()
          Returns the Model string.
 AModemDriver getModemDriver()
           
 int getQueueSchedulingInterval()
          Returns the Gateway Queue sending internal (in milliseconds).
 java.lang.String getSerialNo()
          Returns the Serial Number of the modem.
 int getSignalLevel()
          Returns the signal level (RSSI).
 java.lang.String getSimPin()
          Returns the SIM PIN.
 java.lang.String getSimPin2()
          Returns the SIM PIN 2.
 java.lang.String getSmscNumber()
          Returns the SMSC number used by SMSLib.
 java.lang.String getSwVersion()
          Returns the modem's firmware version.
 InboundMessage readMessage(java.lang.String memLoc, int memIndex)
           
 void readMessages(java.util.Collection<InboundMessage> msgList, InboundMessage.MessageClasses msgClass)
           
 int readPhonebook(Phonebook phonebook)
           
 java.lang.String sendCustomATCommand(java.lang.String atCommand)
          Send a custom AT command to the modem and returns the response received.
 boolean sendMessage(OutboundMessage msg)
           
 java.lang.String sendUSSDCommand(java.lang.String ussdCommand)
          Send an Unstructured Supplementary Service Data command.
 java.lang.String sendUSSDCommand(java.lang.String ussdCommand, boolean interactive)
          Send an Unstructured Supplementary Service Data command.
 boolean sendUSSDRequest(USSDRequest request)
           
 void setCustomInitString(java.lang.String myCustomInitString)
          Sets the custom modem init string.
 void setDisplayIllegalReceivedMessages(boolean b)
           
 void setIpEncryption(boolean ipEncryption)
          Set the IP modem transmission encryption status
 void setIpProtocol(ModemGateway.IPProtocols myIpProtocol)
           
 void setSimPin(java.lang.String mySimPin)
          Sets the SIM PIN.
 void setSimPin2(java.lang.String mySimPin2)
          Sets the SIM PIN 2.
 void setSmscNumber(java.lang.String mySmscNumber)
          Sets the SMSC number used by SMSLib.
 void startGateway()
           
 void stopGateway()
           
 
Methods inherited from class org.smslib.AGateway
getAttributes, getDeliveryErrorCode, getFrom, getGatewayId, getInboundMessageCount, getMyself, getOutboundMessageCount, getProtocol, getRestartCount, getStatus, incInboundMessageCount, incOutboundMessageCount, isInbound, isOutbound, queryBalance, queryCoverage, queryMessage, queryMessage, sendMessages, setAttributes, setDeliveryErrorCode, setFrom, setInbound, setOutbound, setProtocol, setStatus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModemGateway

public ModemGateway(ModemGateway.ModemTypes myType,
                    java.lang.String id,
                    java.lang.String myModemDevice,
                    int myModemParms,
                    java.lang.String myManufacturer,
                    java.lang.String myModel)

ModemGateway

public ModemGateway(java.lang.String id,
                    java.lang.String myModemDevice,
                    int myModemParms,
                    java.lang.String myManufacturer,
                    java.lang.String myModel,
                    AModemDriver myDriver)
Method Detail

setIpProtocol

public void setIpProtocol(ModemGateway.IPProtocols myIpProtocol)

getIpProtocol

public ModemGateway.IPProtocols getIpProtocol()

setIpEncryption

public void setIpEncryption(boolean ipEncryption)
Set the IP modem transmission encryption status

Parameters:
ipEncryption - the status of encryption

getIpEncryption

public boolean getIpEncryption()
Check if the encryption of IP modem transmission is enabled

Returns:
true if IP encryption is enabled

startGateway

public void startGateway()
                  throws TimeoutException,
                         GatewayException,
                         java.io.IOException,
                         java.lang.InterruptedException
Overrides:
startGateway in class AGateway
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

stopGateway

public void stopGateway()
                 throws TimeoutException,
                        GatewayException,
                        java.io.IOException,
                        java.lang.InterruptedException
Overrides:
stopGateway in class AGateway
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

readMessages

public void readMessages(java.util.Collection<InboundMessage> msgList,
                         InboundMessage.MessageClasses msgClass)
                  throws TimeoutException,
                         GatewayException,
                         java.io.IOException,
                         java.lang.InterruptedException
Overrides:
readMessages in class AGateway
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

readMessage

public InboundMessage readMessage(java.lang.String memLoc,
                                  int memIndex)
                           throws TimeoutException,
                                  GatewayException,
                                  java.io.IOException,
                                  java.lang.InterruptedException
Overrides:
readMessage in class AGateway
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

sendMessage

public boolean sendMessage(OutboundMessage msg)
                    throws TimeoutException,
                           GatewayException,
                           java.io.IOException,
                           java.lang.InterruptedException
Overrides:
sendMessage in class AGateway
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

deleteMessage

public boolean deleteMessage(InboundMessage msg)
                      throws TimeoutException,
                             GatewayException,
                             java.io.IOException,
                             java.lang.InterruptedException
Overrides:
deleteMessage in class AGateway
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

readPhonebook

public int readPhonebook(Phonebook phonebook)
                  throws TimeoutException,
                         GatewayException,
                         java.io.IOException,
                         java.lang.InterruptedException
Overrides:
readPhonebook in class AGateway
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

setDisplayIllegalReceivedMessages

public void setDisplayIllegalReceivedMessages(boolean b)

getMessageByIndex

public java.lang.String getMessageByIndex(int msgIndex)
                                   throws TimeoutException,
                                          GatewayException,
                                          java.io.IOException,
                                          java.lang.InterruptedException
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

setSimPin

public void setSimPin(java.lang.String mySimPin)
Sets the SIM PIN.

Parameters:
mySimPin - The SIM PIN.

setSimPin2

public void setSimPin2(java.lang.String mySimPin2)
Sets the SIM PIN 2.

Parameters:
mySimPin2 - The SIM PIN 2.

getSimPin

public java.lang.String getSimPin()
Returns the SIM PIN.

Returns:
The SIM PIN.

getSimPin2

public java.lang.String getSimPin2()
Returns the SIM PIN 2.

Returns:
The SIM PIN 2.

getModemDriver

public AModemDriver getModemDriver()

getATHandler

public AATHandler getATHandler()

getManufacturer

public java.lang.String getManufacturer()
                                 throws TimeoutException,
                                        GatewayException,
                                        java.io.IOException,
                                        java.lang.InterruptedException
Returns the Manufacturer string of the modem or phone.

Returns:
The Manufacturer string.
Throws:
TimeoutException - The gateway did not respond in a timely manner.
GatewayException - A Gateway error occurred.
java.io.IOException - An IO error occurred.
java.lang.InterruptedException - The call was interrupted.

getModel

public java.lang.String getModel()
                          throws TimeoutException,
                                 GatewayException,
                                 java.io.IOException,
                                 java.lang.InterruptedException
Returns the Model string.

Returns:
The Model string.
Throws:
TimeoutException - The gateway did not respond in a timely manner.
GatewayException - A Gateway error occurred.
java.io.IOException - An IO error occurred.
java.lang.InterruptedException - The call was interrupted.

getSerialNo

public java.lang.String getSerialNo()
                             throws TimeoutException,
                                    GatewayException,
                                    java.io.IOException,
                                    java.lang.InterruptedException
Returns the Serial Number of the modem.

Returns:
The Serial Number.
Throws:
TimeoutException - The gateway did not respond in a timely manner.
GatewayException - A Gateway error occurred.
java.io.IOException - An IO error occurred.
java.lang.InterruptedException - The call was interrupted.

getImsi

public java.lang.String getImsi()
                         throws TimeoutException,
                                GatewayException,
                                java.io.IOException,
                                java.lang.InterruptedException
Returns the IMSI (International Mobile Subscriber Identity) number.

This number is stored in the SIM. Since this number may be used for several illegal activities, the method is remarked. If you wish to see your IMSI, just uncomment the method.

Returns:
The IMSI.
Throws:
TimeoutException - The gateway did not respond in a timely manner.
GatewayException - A Gateway error occurred.
java.io.IOException - An IO error occurred.
java.lang.InterruptedException - The call was interrupted.

getSwVersion

public java.lang.String getSwVersion()
                              throws TimeoutException,
                                     GatewayException,
                                     java.io.IOException,
                                     java.lang.InterruptedException
Returns the modem's firmware version.

Returns:
The modem's firmware version.
Throws:
TimeoutException - The gateway did not respond in a timely manner.
GatewayException - A Gateway error occurred.
java.io.IOException - An IO error occurred.
java.lang.InterruptedException - The call was interrupted.

getBatteryLevel

public int getBatteryLevel()
                    throws TimeoutException,
                           GatewayException,
                           java.io.IOException,
                           java.lang.InterruptedException
Returns the battery level (0-100).

Returns:
The battery level.
Throws:
TimeoutException - The gateway did not respond in a timely manner.
GatewayException - A Gateway error occurred.
java.io.IOException - An IO error occurred.
java.lang.InterruptedException - The call was interrupted.

getSignalLevel

public int getSignalLevel()
                   throws TimeoutException,
                          GatewayException,
                          java.io.IOException,
                          java.lang.InterruptedException
Returns the signal level (RSSI).

Returns:
The signal level.
Throws:
TimeoutException - The gateway did not respond in a timely manner.
GatewayException - A Gateway error occurred.
java.io.IOException - An IO error occurred.
java.lang.InterruptedException - The call was interrupted.

getSmscNumber

public java.lang.String getSmscNumber()
Returns the SMSC number used by SMSLib. If no SMSC number has been set with setSmscNumber() call, this method returns nothing.

Returns:
The SMSC number.
See Also:
setSmscNumber(String)

setSmscNumber

public void setSmscNumber(java.lang.String mySmscNumber)
Sets the SMSC number used by SMSLib.

Note that in most cases, you will not need to call this method, as the modem knows the SMSC it should use by reading the SIM card. In rare cases when the modem/phone cannot read the SMSC from the SIM card or you would like to set a different SMSC than the default, you can use this method.

Parameters:
mySmscNumber - The SMSC number used from now on.

getCustomInitString

public java.lang.String getCustomInitString()
Returns the custom modem init string (if any).

Returns:
the custom init string.
See Also:
setCustomInitString(String)

setCustomInitString

public void setCustomInitString(java.lang.String myCustomInitString)
Sets the custom modem init string. The init string (if defined) is sent to the modem right before the SIM PIN check.

Parameters:
myCustomInitString - The custom init string.
See Also:
getCustomInitString()

sendCustomATCommand

public java.lang.String sendCustomATCommand(java.lang.String atCommand)
                                     throws GatewayException,
                                            TimeoutException,
                                            java.io.IOException,
                                            java.lang.InterruptedException
Send a custom AT command to the modem and returns the response received.

Parameters:
atCommand - The AT Command.
Returns:
The modem's response.
Throws:
TimeoutException - The gateway did not respond in a timely manner.
GatewayException - A Gateway error occurred.
java.io.IOException - An IO error occurred.
java.lang.InterruptedException - The call was interrupted.

sendUSSDCommand

public java.lang.String sendUSSDCommand(java.lang.String ussdCommand)
                                 throws GatewayException,
                                        TimeoutException,
                                        java.io.IOException,
                                        java.lang.InterruptedException
Send an Unstructured Supplementary Service Data command. Default is assumed for whether the command is interactive.

Overrides:
sendUSSDCommand in class AGateway
Parameters:
ussdCommand - the USSD command to send
Returns:
the network's response to the command
Throws:
GatewayException
TimeoutException
java.io.IOException
java.lang.InterruptedException

sendUSSDCommand

public java.lang.String sendUSSDCommand(java.lang.String ussdCommand,
                                        boolean interactive)
                                 throws GatewayException,
                                        TimeoutException,
                                        java.io.IOException,
                                        java.lang.InterruptedException
Send an Unstructured Supplementary Service Data command.

Overrides:
sendUSSDCommand in class AGateway
Parameters:
ussdCommand - the USSD command to send
interactive - whether the USSD session should be left open
Returns:
the network's response to the command
Throws:
GatewayException
TimeoutException
java.io.IOException
java.lang.InterruptedException

sendUSSDRequest

public boolean sendUSSDRequest(USSDRequest request)
                        throws GatewayException,
                               TimeoutException,
                               java.io.IOException,
                               java.lang.InterruptedException
Overrides:
sendUSSDRequest in class AGateway
Throws:
GatewayException
TimeoutException
java.io.IOException
java.lang.InterruptedException

getQueueSchedulingInterval

public int getQueueSchedulingInterval()
Description copied from class: AGateway
Returns the Gateway Queue sending internal (in milliseconds). Should be defined in every actual Gateway implementation.

Specified by:
getQueueSchedulingInterval in class AGateway
Returns:
The scheduling interval (in milliseconds).

SMSLib 3.5.3

(c) 2002-2011, http://smslib.org