public class DataTransporter
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
DataTransporter.DIAL_MODE
The Enumeration of the dialing modes.
|
static class |
DataTransporter.PIN_STATUS
The Enumeration of the states for PIN entering.
|
static class |
DataTransporter.STORAGE_TYPE
The Enumeration of the message storage types.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
commaSpace
A String with a comma followed by a space.
|
static java.lang.String |
commaStr
A String with a single comma character.
|
static java.lang.String |
CRStr
A String with a single Carriage Return character.
|
static java.lang.String |
defaultEncoding
The default encoding for commands.
|
static java.lang.String |
dot
A String with a single dot.
|
static java.lang.String |
dquot
A String with a single "double quote" character.
|
static java.lang.String |
dquotCR
A String with a quotation character and a Carriage Return.
|
static java.lang.String |
emptyStr
An empty String.
|
static int |
MAX_TRIALS
Maximum number of attempts to establish communication.
|
static java.lang.String |
semicolon
A String with a single semicolon.
|
Constructor and Description |
---|
DataTransporter(gnu.io.CommPortIdentifier id)
Creates a new instance of DataTransporter.
|
Modifier and Type | Method and Description |
---|---|
int |
addAlarm(PhoneAlarm al)
Adds the specified alarm to the phone.
|
int |
answer()
Answers the phone (receives any incoming call).
|
void |
close()
Closes the port.
|
int |
deleteAlarm(int number)
Deletes the specified alarm from the phone.
|
int |
deleteFile(PhoneElement el)
Deletes the specified object from the phone.
|
int |
deleteMessage(int number)
Deletes the specified message from the phone.
|
int |
dialNumber(java.lang.String number,
boolean isVoice,
DataTransporter.DIAL_MODE dialMode)
Dials the specified number.
|
java.util.Vector<PhoneAlarm> |
getAlarms()
Gets the list of current alarms from the phone.
|
int |
getAvailableBytes()
Gets the number of currently-available bytes.
|
java.lang.String |
getCapabilities(java.lang.String type)
Gets the given capabilities from the phone.
|
java.lang.String |
getDeviceType()
Gets the phone type.
|
java.lang.String |
getExtraDeviceType()
Gets the additional phone type data.
|
int |
getFile(java.io.File f,
PhoneElement el)
Gets the specified object and saves it to a file.
|
java.lang.String |
getFirmwareVersion()
Gets the firmware version from the phone.
|
java.lang.String |
getIMEI()
Gets the IMEI number from the phone.
|
java.util.Vector<PhoneElement> |
getList(java.lang.String ofWhat)
Gets the list of objects from the phone.
|
PhoneMessage |
getMessage(int number)
Retrieves the specified message from the phone.
|
java.util.Vector<PhoneMessage> |
getMessages()
Gets the list of current messages from the phone.
|
int |
getNumberOfAlarms()
Tells how many alarms are supported by the phone.
|
DataTransporter.PIN_STATUS |
getPINStatus()
Tells which PIN the phone is waiting for.
|
int |
getSignalPower()
Reads the signal power from the phone.
|
java.lang.String |
getSubscriberNumbers()
Gets the subscriber phone numbers from the phone.
|
int |
getVolume()
Gets the current volume level.
|
int |
hangup()
Hangs the phone up (stops the current call).
|
boolean |
isCD()
Gets the state of the Carrier Detect signal.
|
boolean |
isCTS()
Gets the state of the Clear To Send signal.
|
boolean |
isDSR()
Gets the state of the Data Set Ready signal.
|
boolean |
isDTR()
Gets the state of the Data Terminal Ready signal.
|
boolean |
isRI()
Gets the state of the Ring Indicator signal.
|
boolean |
isRTS()
Gets the state of the Request To Send signal.
|
void |
open(int speed,
int dataBits,
float stopBits,
int parity,
int flowControl)
Opens the port for communications.
|
void |
poweroff()
Switches off the phone.
|
int |
putFile(java.io.File f,
java.lang.String newName)
Sends the specified file to the phone.
|
byte[] |
recv(java.lang.Object[] extraTerminators)
Receives data from the port (waits at most 5 seconds).
|
void |
reopen()
Reopens the transmission port used by thie DataTransporter,
saving its parameters.
|
void |
send(byte[] b)
Sends data to the port.
|
void |
send(byte[] b,
int start,
int length)
Sends data to the port.
|
int |
sendMessage(PhoneMessage msg)
Sends the specified message with the phone.
|
int |
sendPIN(int PIN,
int newPIN)
Sends the given PIN and new PIN to the phone.
|
int |
sendPIN(java.lang.String PIN,
java.lang.String newPIN)
Sends the given PIN and new PIN to the phone.
|
void |
setDTR(boolean on)
Sets or clears the DTR line in the port.
|
int |
setMessageStorage(DataTransporter.STORAGE_TYPE stor)
Sets the specified message storage type the phone.
|
void |
setRTS(boolean on)
Sets or clears the RTS line in the port.
|
int |
setVolume(int vol)
Sets the volume level.
|
int |
test()
Tests the port to determine if something is connected.
|
public static final int MAX_TRIALS
public static final java.lang.String defaultEncoding
public static final java.lang.String CRStr
public static final java.lang.String emptyStr
public static final java.lang.String dot
public static final java.lang.String dquotCR
public static final java.lang.String commaStr
public static final java.lang.String dquot
public static final java.lang.String commaSpace
public static final java.lang.String semicolon
public DataTransporter(gnu.io.CommPortIdentifier id)
id
- Port identifier for the port which will be used to
transfer data.public void open(int speed, int dataBits, float stopBits, int parity, int flowControl) throws java.lang.Exception
speed
- Communication speen, in bauds (bits per second).dataBits
- Number of data bits (5, 6, 7 or 8).stopBits
- Number of stop bits (1, 1.5 or 2).parity
- Parity checking type (0 - none, 1 - even, 2 - odd,
3 - space, 4 - mark).flowControl
- Flow control type (0 - none, 1 - software XON/XOFF,
2 - hardware CTS/RTS).java.lang.Exception
- in case port opening or registering an
event listener failed.public byte[] recv(java.lang.Object[] extraTerminators)
extraTerminators
- Any extra elements that are a mark of transmission end.public void send(byte[] b) throws java.io.IOException
b
- The bytes to send.java.io.IOException
- in case of an I/O problem with the port.public void send(byte[] b, int start, int length) throws java.io.IOException
b
- The bytes to send.start
- The starting offset in the array.length
- The number bytes to send, starting from the start offset.java.io.IOException
- in case of an I/O problem with the port.public void close()
public int putFile(java.io.File f, java.lang.String newName)
f
- The file to send.newName
- Name of the object to be sent to the phone.public int getFile(java.io.File f, PhoneElement el)
f
- The file for the object.el
- The element to retrieve.public java.util.Vector<PhoneElement> getList(java.lang.String ofWhat)
ofWhat
- The type of the object, e.g. "PICTURES".public int deleteFile(PhoneElement el)
el
- The element to delete.public void reopen()
public int test()
public java.lang.String getFirmwareVersion()
public java.lang.String getDeviceType()
public java.lang.String getExtraDeviceType()
public java.lang.String getIMEI()
public java.lang.String getSubscriberNumbers()
public java.lang.String getCapabilities(java.lang.String type)
type
- The type of the capabilities to get.public void poweroff()
public DataTransporter.PIN_STATUS getPINStatus()
public int sendPIN(java.lang.String PIN, java.lang.String newPIN)
PIN
- The PIN to send.newPIN
- The new PIN to send (in case when PIN is a PUK or PUK2 code).public int sendPIN(int PIN, int newPIN)
PIN
- The PIN to send.newPIN
- The new PIN to send (in case when PIN is a PUK or PUK2 code).public int getNumberOfAlarms()
public int deleteAlarm(int number)
number
- The number of the alarm to delete.public int addAlarm(PhoneAlarm al)
al
- The alarm to add.public java.util.Vector<PhoneAlarm> getAlarms()
public int deleteMessage(int number)
number
- The number of the message to delete.public java.util.Vector<PhoneMessage> getMessages()
public PhoneMessage getMessage(int number)
number
- The number of the message to retrieve.public int sendMessage(PhoneMessage msg)
msg
- The message to send.public int setMessageStorage(DataTransporter.STORAGE_TYPE stor)
stor
- The storage to use.public void setDTR(boolean on)
on
- If TRUE, the DTR signal will be set, otherwise it will be cleared.public void setRTS(boolean on)
on
- If TRUE, the RTS signal will be set, otherwise it will be cleared.public boolean isCD()
public boolean isCTS()
public boolean isDSR()
public boolean isDTR()
public boolean isRI()
public boolean isRTS()
public int getSignalPower()
public int dialNumber(java.lang.String number, boolean isVoice, DataTransporter.DIAL_MODE dialMode)
number
- the number to dial. Must be non-null.isVoice
- whether the connection is for voice or data. Voice connections
will be initiated by adding a semicolon to the end of the number.dialMode
- The dial mode (tone, pulse, auto). Defaults to "auto" if null.public int hangup()
public int answer()
public int getVolume()
public int setVolume(int vol)
vol
- The volume level to set.public int getAvailableBytes()