public class GNetPackage extends java.lang.Object implements ProtocolPackage
| Modifier and Type | Class and Description |
|---|---|
static interface |
GNetPackage.IOnPackageListener
The GNetPackage will call this interface object when receive a package
|
| Modifier and Type | Field and Description |
|---|---|
static int |
GNET_CODE_ACK
a GNet acknowledge package
|
static int |
GNET_CODE_NAK
a GNet negative-acknowledge package
|
static int |
GNETPLUS_CODE_ACK
a GNetPlus acknowledge package
|
static int |
GNETPLUS_CODE_EVENT
a GNetPlus event package
|
static int |
GNETPLUS_CODE_EVENT_B |
static int |
GNETPLUS_CODE_NAK
a GNetPlus negative-acknowledge package
|
| Constructor and Description |
|---|
GNetPackage(byte[] bBuffer,
int iOffset,
int iLength)
create a package from a byte array.
|
GNetPackage(byte bAddress,
byte bCode,
byte[] bParams)
create a GNetPlus package.
|
GNetPackage(byte bCode,
java.lang.String szParam,
boolean bIsAddCheckSum)
create a GNet package.
|
GNetPackage(char bCode,
java.lang.String szParam,
boolean bIsAddCheckSum)
create a GNet package.
|
GNetPackage(int iBufferSize,
GNetPackage.IOnPackageListener oOnPackage)
create a receiver of the GNetPlus or GNet.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendData(byte[] bBuffer)
the receiver will call the appendData method to append a byte array to package buffer.
|
static java.lang.String |
BytesToHexString(byte[] bDatas,
int iLength,
java.lang.String szDelimter) |
boolean |
doGNetCheck()
check package checksum is correct.
|
int |
getAddress()
get address of package, the address is a machine ID.
|
byte[] |
getBytesData()
get a data of package by byte array
|
int |
getCode()
get code of package
|
int |
getCommandSet() |
int |
getEventID()
get ID of event of package
|
int |
getIntegerData()
get a data of package by integer value
|
int |
getLength()
get data length of package
|
byte[] |
getParameters() |
java.lang.String |
getStringData()
get a data of package by string
|
boolean |
isACK()
it's a acknowledge package.
|
boolean |
isCheckError()
the package is has a incorrect checksum, or not.
|
boolean |
isEvent()
it's a event of the GNetPlus package.
|
boolean |
isGNetPackage()
it's a complete GNet package.
|
boolean |
isGNetPlusPackage()
it's a complete GNetPlus package.
|
boolean |
isNAK()
it's a negative-acknowledge package.
|
boolean |
isPackage()
it's a complete package.
|
byte[] |
toBytes()
get a byte array from package buffer.
|
public static final int GNETPLUS_CODE_ACK
public static final int GNETPLUS_CODE_EVENT
public static final int GNETPLUS_CODE_EVENT_B
public static final int GNETPLUS_CODE_NAK
public static final int GNET_CODE_ACK
public static final int GNET_CODE_NAK
public GNetPackage(int iBufferSize,
GNetPackage.IOnPackageListener oOnPackage)
iBufferSize - set the receive buffer size.oOnPackage - set a IOnPackageListener interface object to receive packages.public GNetPackage(byte[] bBuffer,
int iOffset,
int iLength)
bBuffer - specifies the byte array to create.iOffset - pointer to the offset address of the byte array to create.iLength - specifies the length, in bytes, of the byte array to create.public GNetPackage(byte bAddress,
byte bCode,
byte[] bParams)
bAddress - The address of the device.bCode - The request code.bParams - The parameters of the request code.public GNetPackage(char bCode,
java.lang.String szParam,
boolean bIsAddCheckSum)
bCode - The request code.szParam - The parameters of the request code.bIsAddCheckSum - send command include the check sum.public GNetPackage(byte bCode,
java.lang.String szParam,
boolean bIsAddCheckSum)
bCode - The request code.szParam - The parameters of the request code.bIsAddCheckSum - send command include the check sum.public boolean doGNetCheck()
public boolean isPackage()
public boolean isGNetPackage()
public boolean isGNetPlusPackage()
public int getAddress()
public int getCode()
public int getEventID()
getEventID in interface ProtocolPackagepublic int getCommandSet()
getCommandSet in interface ProtocolPackagepublic boolean isEvent()
isEvent in interface ProtocolPackagepublic boolean isACK()
isACK in interface ProtocolPackagepublic boolean isNAK()
isNAK in interface ProtocolPackagepublic int getLength()
public boolean isCheckError()
isCheckError in interface ProtocolPackagepublic java.lang.String getStringData()
public byte[] getBytesData()
public int getIntegerData()
public byte[] toBytes()
toBytes in interface ProtocolPackagepublic byte[] getParameters()
getParameters in interface ProtocolPackagepublic void appendData(byte[] bBuffer)
public static java.lang.String BytesToHexString(byte[] bDatas,
int iLength,
java.lang.String szDelimter)