public abstract class BaseDevice
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
BaseDevice.Callback<T,R,C extends BaseDevice.Callback<T,R,C>> |
static interface |
BaseDevice.OnFailureListener<R> |
static interface |
BaseDevice.OnSuccessListener<T> |
Modifier and Type | Field and Description |
---|---|
protected BaseEventParser |
mEventParser |
protected Transceiver |
mTransceiver |
static java.lang.String |
VERSION |
Modifier | Constructor and Description |
---|---|
protected |
BaseDevice(Transceiver transceiver,
PackageSeeker packageSeeker,
BaseProtocolController protocolController,
BaseEventParser eventParser) |
Modifier and Type | Method and Description |
---|---|
void |
connect()
Connect to remote device.
|
void |
destroy()
This method should called at onDestroy method of Activity or Fragment to make sure the lifecycle of this object is safe.
|
void |
disconnect()
Disconnect to remote device.
|
boolean |
equals(java.lang.Object obj) |
CommunicationType |
getCommunicationType() |
ConnectionState |
getConnectionState() |
java.lang.String |
getDeviceID()
The return ID depends on the communication interface of below:
1.
|
java.lang.String |
getDeviceName() |
protected abstract void |
onCrcErrorReceived(java.lang.String errMessage) |
void |
send(byte[] cmd) |
void |
send(byte[] cmd,
java.lang.String channelId) |
<T extends BaseCommand> |
send(T command) |
void |
setCommunicationCallback(CommunicationCallback communicationCallback) |
void |
setDeviceDebugCallback(DeviceDebugCallback deviceDebugCallback) |
public static final java.lang.String VERSION
protected Transceiver mTransceiver
protected BaseEventParser mEventParser
protected BaseDevice(Transceiver transceiver, PackageSeeker packageSeeker, BaseProtocolController protocolController, BaseEventParser eventParser)
public void setCommunicationCallback(CommunicationCallback communicationCallback)
communicationCallback
- set the CommunicationCallbackpublic void setDeviceDebugCallback(DeviceDebugCallback deviceDebugCallback)
public void connect()
If the connection state if changed, CommunicationCallback
will called onUpdateConnection.
If a message if send, CommunicationCallback
will called onTransceiverSend
.
If a message if send, CommunicationCallback
will called onTransceiverReceive
.
public void disconnect()
If the connection state if changed, CommunicationCallback
will called onUpdateConnection.
public void send(byte[] cmd)
cmd
- Ths command which is going to send to remote device.public void send(byte[] cmd, java.lang.String channelId)
public java.lang.String getDeviceName()
public CommunicationType getCommunicationType()
public ConnectionState getConnectionState()
public java.lang.String getDeviceID()
public void destroy()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public <T extends BaseCommand> void send(T command)
protected abstract void onCrcErrorReceived(java.lang.String errMessage)