public abstract class AbstractCommunicationLayer extends java.lang.Object implements java.io.Serializable, ICommunicationLayer
Constructor and Description |
---|
AbstractCommunicationLayer() |
Modifier and Type | Method and Description |
---|---|
boolean |
closeConnection()
Closes this layer and calls closeConnection() on the layer below.
|
ICommunicationLayer |
getAbove() |
ICommunicationLayer |
getBelow() |
boolean |
getConnectionState() |
byte[] |
getRawBytes() |
boolean |
openConnection(CommLayerParams params)
Opens the connection and sets up the communication stack.
|
byte |
readByte()
Reads a byte from the communication layer below or the connected device if this layer is the bottom layer.
|
double |
readDouble()
Reads 8 bytes from the communication layer below or the connected device if this layer is the bottom layer.
|
float |
readFloat()
Reads 4 bytes from the communication layer below or the connected device if this layer is the bottom layer.
|
long |
readLong()
Reads 4 bytes from the communication layer below or the connected device if this layer is the bottom layer.
|
void |
recvData()
Performs the necessary actions for receiving data.
|
void |
sendData(byte[] data)
Performs the necessary actions for sending data.
|
void |
sendData(byte[] data,
int off,
int len)
Performs the necessary actions for sending data.
|
void |
setAbove(ICommunicationLayer layer)
Sets the communication layer above this layer.
|
void |
setBelow(ICommunicationLayer layer)
Sets the communication layer below this layer.
|
public boolean openConnection(CommLayerParams params) throws java.io.IOException
ICommunicationLayer
openConnection
in interface ICommunicationLayer
params
- CommLayerParams object holding the connection infojava.io.IOException
public boolean closeConnection() throws java.io.IOException
ICommunicationLayer
closeConnection
in interface ICommunicationLayer
java.io.IOException
public void sendData(byte[] data, int off, int len) throws java.io.IOException
ICommunicationLayer
sendData
in interface ICommunicationLayer
data
- Byte array containing the datalen
- Length of the data to be sentjava.io.IOException
public void sendData(byte[] data) throws java.io.IOException
ICommunicationLayer
sendData
in interface ICommunicationLayer
data
- Byte array containing the datajava.io.IOException
public void recvData() throws java.io.IOException
ICommunicationLayer
recvData
in interface ICommunicationLayer
java.io.IOException
public ICommunicationLayer getAbove()
getAbove
in interface ICommunicationLayer
public ICommunicationLayer getBelow()
getBelow
in interface ICommunicationLayer
public void setAbove(ICommunicationLayer layer)
ICommunicationLayer
setAbove
in interface ICommunicationLayer
public void setBelow(ICommunicationLayer layer)
ICommunicationLayer
setBelow
in interface ICommunicationLayer
public byte readByte() throws java.io.IOException
ICommunicationLayer
readByte
in interface ICommunicationLayer
java.io.IOException
public long readLong() throws java.io.IOException
ICommunicationLayer
readLong
in interface ICommunicationLayer
java.io.IOException
public double readDouble() throws java.io.IOException
ICommunicationLayer
readDouble
in interface ICommunicationLayer
java.io.IOException
public float readFloat() throws java.io.IOException
ICommunicationLayer
readFloat
in interface ICommunicationLayer
java.io.IOException
public boolean getConnectionState()
getConnectionState
in interface ICommunicationLayer
public byte[] getRawBytes()
getRawBytes
in interface ICommunicationLayer
ICommunicationLayer.recvData()