|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ie.ncl.msg.impl.SimpleConnection ie.ncl.sms.modem.GsmModem
public class GsmModem
This class is used to establish a connection
with a GSM modem device, which can be
used to send and receive short messages.
IMPORTANT: Unless you are performing some GSM Modem specific operation
it is best to use the ie.ncl.msg.Factory class
to create instances of the GsmModem.
This allows you to dynamically create transport independent
software applications.
The Factory properties used by GsmModem configuration are:-
NAME | VALUE | DEFAULT |
class | The name of the implementing class - ie.ncl.sms.modem.GsmModem | mandatory |
pin | The PIN of the cellular device (string). | optional |
type | The type of cellular device (string). This can be one of; m20 tc35 mc35 premicell nokiacard a2 sonye 6310 s45 sl45 gm29 6310i | mandatory |
deliveryReports | Are delivery reports turned on | optional - false by default |
sendRetries | Number of times a message should be retried if sending it fails (number). | optional - 3 retries by default |
sendRetryPauseSeconds | The pause between retries (number of seconds) | optional - 1 second by default |
signalStrengthThreshold | Specifies the signal strength threshold (number). A warning is printed if the strength goes below this value. | optional - defaults to 10 of 30. |
smsc | Specifies the SMSC address (number) | optional |
ownNumber | Specifies the number of the modem. | mandatory |
loopbackAllowed | Specifies if a loop-back messages are allowed (true/false). Sometimes it can be dangerous to allow an application to send a message to itself as an infinite loop may occur which can be costly. | mandatory |
defaultTon | The default type of number (TON) set on out going messages addresses (number) | optional - not used by default |
defaultNpi | The default number plan indicator (NPI) set on out going messages addresses (number) | optional - not used by default |
type | The type of connection. This can be 'serial' in which case direct RS232 communication is established, or 'ip' in which case RAS server is used and accessed over IP. | mandatory |
host, port | Only if type is 'ip'. This specifies the host and port of the RAS server | depends on type |
device, speed | Only if type is 'serial'. This specifies the device such as COM1, COM2 (or /dev/ttyS0, /dev/ttyS1 for Linux) and the baud speed such as 9600, 19200 etc. | depends on type |
Factory
Field Summary | |
---|---|
static int |
INIT_TIMER
|
int |
resetTimeout
|
int |
RESPONSE_TIMEOUT
|
static int |
SEND_RESPONSE_TIMEOUT
|
static int |
SIGNAL_STRENGTH_MAX
Maximum signal strength is index 31 (-51 DBs). |
static int |
SIGNAL_STRENGTH_MIN
Minimum signal strength is index 0 (-113 DBs). |
static int |
SIGNAL_STRENGTH_UNKNOWN
Unknown signal strength value. |
static ie.ncl.sys.ModuleLog |
staticLog
|
Fields inherited from interface ie.ncl.msg.Connection |
---|
CONNECTED, NOT_CONNECTED, NOT_USED, RECONNECTING |
Fields inherited from interface ie.ncl.sms.MessageAttributeNames |
---|
CC, DCS, EOT_GSM_ESCAPE_CHARACTER, PID, PRIORITY, RECEIPT, RECEIPT_BYTES, RECEIPT_STATUS, RECEIPT_TEXT, REGISTERED, REPLACE, REPLY_PATH, SCA, SCHEDULE, SUBMIT_ERROR, TIMESTAMP, UDH, UDHI, VALIDITY |
Constructor Summary | |
---|---|
GsmModem()
|
|
GsmModem(java.lang.String pin,
java.io.InputStream in,
java.io.OutputStream out,
boolean testing)
Create a new Gsm Modem object specifying the input and output streams. |
|
GsmModem(java.lang.String pin,
java.lang.String host,
int port)
Create a new Gsm Modem object specifying a the IP address of a TCP/IP to RS232 gateway. |
|
GsmModem(java.lang.String pin,
java.lang.String comPortDevice,
java.lang.String speed)
Create a new Gsm Modem object specifying a the IP address of a TCP/IP to RS232 gateway. |
|
GsmModem(java.lang.String pin,
java.lang.String comPortDevice,
java.lang.String speed,
boolean testing)
|
Method Summary | |
---|---|
void |
acknowledge(Message m,
boolean success)
Acknowledge messages - Not implemented as messages are acknowledged immediately. |
static java.lang.String |
clean(java.lang.String s)
|
void |
close()
Close down the connection with the GsmModem device. |
void |
connect()
Connect with the device. |
ie.ncl.util.bin.Bytes |
constructPDU(Message m)
|
static ie.ncl.util.bin.Bytes |
constructSmsDeliver(Message m)
|
static ie.ncl.util.bin.Bytes |
constructSmsSubmit(Message m)
|
static ie.ncl.util.bin.Bytes |
constructTpud(Message m)
|
static GsmModemConfiguration[] |
detect()
|
void |
enableDeliveryReporting()
|
static GsmModemConfiguration[] |
find()
|
GsmModemConfiguration |
getConfiguration()
|
static GsmModem |
getDefault()
Get the default GsmModem object. |
boolean |
getDefaultToGsmAlphabet()
This indicates that the Gsm Default Alphabet is used when encoding 7bit messages (in accordance with data coding scheme). |
java.lang.String |
getIMEI()
Get the modem model. |
boolean |
getLoopbackAllowed()
This attribute allows the modem to send messages to itself. |
java.lang.String |
getMake()
|
java.lang.String |
getMakeModel()
Get the modem make and model concatenated with a single space in between. |
java.lang.String |
getModel()
Get the modem model. |
Address |
getOwnNumber()
Get this modem's telephone number. |
int |
getSendRetries()
This is used to specify how many times to attempt sending a message if an error occurs. |
int |
getSendRetryPause()
This is used to specify how many times to attempt sending a message if an error occurs. |
int |
getSignalStrength()
This returns the signal strength which is a decibel reading between SIGNAL_STRENGTH_MIN and SIGNAL_STRENGTH_MAX or is SIGNAL_STRENGTH_UNKNOWN if this is not defined. |
int |
getSignalStrengthThreshold()
Set the signal strength threshold. |
java.lang.String |
getVersion()
Get the modem version. |
void |
init(java.util.Properties props)
Initialise the object with settings specified in the properties. |
boolean |
isMakeModel(java.lang.String mm)
Check to see that this make an model matches the one specified. |
static void |
main(java.lang.String[] args)
|
void |
receive(ReceiverListener receiver)
Receive messages asynchronously. |
void |
run()
|
void |
send(Message m,
SenderListener listener)
Send a message asynchronously. |
static void |
setDebugMode(boolean on)
Turn debug on (true) or off (false). |
static void |
setDefault(GsmModem f)
Set the default GsmModem object. |
void |
setDefaultToGsmAlphabet(boolean val)
This indicates that the Gsm Default Alphabet is used when encoding 7bit messages (in accordance with data coding scheme). |
void |
setGPRS(GPRSSettings gprs)
|
void |
setLoopbackAllowed(boolean yn)
This allows the modem to send messages to itself. |
void |
setOwnNumber(Address dest)
Sets this modem's telephone number. |
void |
setReceiverListener(ReceiverListener listener)
Receive messages asynchronously. |
void |
setSendRetries(int newval)
This is used to specify how many times to attempt sending a message if an error occurs. |
void |
setSendRetryPause(int newval)
This is used to specify how many times to attempt sending a message if an error occurs. |
void |
setSignalStrengthThreshold(int sst)
Get the signal strength threshold. |
void |
setSmsc(java.lang.String addr)
Set the SMSC message centre number. |
void |
shutdown()
Shutdown the connection. |
Methods inherited from class ie.ncl.msg.impl.SimpleConnection |
---|
connected, getConnectionStatus, getErrorListener, getName, getTypeDefaults, init, mergeDefaultAttributes, putTypeDefaults, setErrorListener, setName |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface ie.ncl.msg.Connection |
---|
connected, getConnectionStatus, getTypeDefaults, init, putTypeDefaults, setErrorListener |
Field Detail |
---|
public static final int SIGNAL_STRENGTH_MAX
getSignalStrength()
,
Constant Field Valuespublic static final int SIGNAL_STRENGTH_MIN
getSignalStrength()
,
Constant Field Valuespublic static final int SIGNAL_STRENGTH_UNKNOWN
getSignalStrength()
,
Constant Field Valuespublic int RESPONSE_TIMEOUT
public static final int SEND_RESPONSE_TIMEOUT
public static final int INIT_TIMER
public int resetTimeout
public static ie.ncl.sys.ModuleLog staticLog
Constructor Detail |
---|
public GsmModem(java.lang.String pin, java.lang.String comPortDevice, java.lang.String speed) throws java.io.IOException, GsmModemException
java.io.IOException
GsmModemException
public GsmModem(java.lang.String pin, java.lang.String comPortDevice, java.lang.String speed, boolean testing) throws java.io.IOException, GsmModemException
java.io.IOException
GsmModemException
public GsmModem()
public GsmModem(java.lang.String pin, java.lang.String host, int port) throws java.io.IOException, GsmModemException
java.io.IOException
GsmModemException
public GsmModem(java.lang.String pin, java.io.InputStream in, java.io.OutputStream out, boolean testing) throws java.io.IOException, GsmModemException
java.io.IOException
GsmModemException
Method Detail |
---|
public void enableDeliveryReporting()
public void setLoopbackAllowed(boolean yn)
getLoopbackAllowed()
,
getOwnNumber()
public boolean getLoopbackAllowed()
setLoopbackAllowed(boolean)
,
setOwnNumber(ie.ncl.msg.Address)
public void setDefaultToGsmAlphabet(boolean val)
public boolean getDefaultToGsmAlphabet()
public void init(java.util.Properties props) throws ConnectionException
Connection
init
in interface Connection
ConnectionException
public void connect() throws ConnectionException
connect
in interface Connection
ConnectionException
public void setOwnNumber(Address dest)
getOwnNumber()
,
getLoopbackAllowed()
public Address getOwnNumber()
setOwnNumber(ie.ncl.msg.Address)
,
setLoopbackAllowed(boolean)
public GsmModemConfiguration getConfiguration()
public static GsmModem getDefault()
public static void setDefault(GsmModem f)
public static void setDebugMode(boolean on)
public static java.lang.String clean(java.lang.String s)
public void setGPRS(GPRSSettings gprs) throws java.io.IOException
java.io.IOException
public java.lang.String getIMEI() throws GsmModemException, java.io.IOException
GsmModemException
java.io.IOException
public java.lang.String getMake() throws GsmModemException, java.io.IOException
GsmModemException
java.io.IOException
public java.lang.String getVersion() throws GsmModemException, java.io.IOException
GsmModemException
java.io.IOException
public java.lang.String getModel() throws GsmModemException, java.io.IOException
GsmModemException
java.io.IOException
public java.lang.String getMakeModel() throws GsmModemException, java.io.IOException
GsmModemException
java.io.IOException
isMakeModel(java.lang.String)
public boolean isMakeModel(java.lang.String mm) throws GsmModemException, java.io.IOException
GsmModemException
java.io.IOException
public void send(Message m, SenderListener listener) throws MessageException, ConnectionException
send
in interface Sender
MessageException
ConnectionException
SenderListener
,
Message
public void receive(ReceiverListener receiver) throws ConnectionException
receive
in interface Receiver
ConnectionException
Message
public void setReceiverListener(ReceiverListener listener) throws ConnectionException
setReceiverListener
in interface Receiver
ConnectionException
Message
public void acknowledge(Message m, boolean success)
acknowledge
in interface Receiver
public void setSendRetries(int newval)
getSendRetries()
public int getSendRetries()
setSendRetries(int)
public void setSendRetryPause(int newval)
getSendRetryPause()
public int getSendRetryPause()
setSendRetryPause(int)
public int getSignalStrengthThreshold()
public void setSignalStrengthThreshold(int sst)
public int getSignalStrength()
public static ie.ncl.util.bin.Bytes constructSmsSubmit(Message m) throws ie.ncl.net.pdu.EncoderException, MessageException
ie.ncl.net.pdu.EncoderException
MessageException
public static ie.ncl.util.bin.Bytes constructSmsDeliver(Message m) throws ie.ncl.net.pdu.EncoderException, MessageException
ie.ncl.net.pdu.EncoderException
MessageException
public static ie.ncl.util.bin.Bytes constructTpud(Message m) throws ie.ncl.net.pdu.EncoderException, MessageException
ie.ncl.net.pdu.EncoderException
MessageException
public ie.ncl.util.bin.Bytes constructPDU(Message m) throws GsmModemException, MessageException
GsmModemException
MessageException
public void setSmsc(java.lang.String addr) throws GsmModemException, java.io.IOException
GsmModemException
java.io.IOException
public void close()
close
in interface Connection
close
in class ie.ncl.msg.impl.SimpleConnection
public void shutdown()
Connection
shutdown
in interface Connection
public void run()
run
in interface java.lang.Runnable
public static GsmModemConfiguration[] find()
public static GsmModemConfiguration[] detect()
public static void main(java.lang.String[] args)
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |