public class DatalogicDevice
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
DatalogicDevice.Callback
Callback to manage DatalogicDevice's events
|
Modifier | Constructor and Description |
---|---|
protected |
DatalogicDevice(DatalogicCoreSDK datalogicCoreSDK,
java.lang.String mac) |
Modifier and Type | Method and Description |
---|---|
void |
bond()
Creates the bond with Datalogic device.
|
void |
connect(DatalogicDevice.Callback callback)
Start connection with a Datalogic device
|
void |
disconnect()
Disconnection request to Datalogic device
|
java.lang.String |
getAddress() |
java.lang.String |
getName() |
boolean |
isBonded() |
boolean |
isBonding() |
boolean |
isConnected()
Check if Datalogic device is connected
|
boolean |
isConnecting()
Check if Datalogic device is in connecting phase
|
boolean |
isSdkProtocolEnabled()
Returns true if SDK protocol is enabled
|
boolean |
isSPP() |
protected void |
onConnected()
Default event callback for DatalogicDevice object, called when the device is connected.
|
protected void |
onConnecting()
Default event callback for DatalogicDevice object, called when the device is connecting.
|
protected void |
onConnectionFailed()
Default event callback for DatalogicDevice object, called when the connection fails.
|
protected void |
onDisconnected()
Default event callback for DatalogicDevice object, called when the device is disconnected.
|
protected void |
onMsgWrite(java.lang.String data)
Default event callback for DatalogicDevice object, called when sending message to device.
|
protected void |
onReadData(java.lang.String data)
Default event callback for DatalogicDevice object, called when reading the data.
|
boolean |
send(java.lang.String data)
Send a string to Datalogic device.
|
boolean |
sendAndReceive(java.lang.String data,
DatalogicDeviceResponse.Callback responseListener)
Send a string to Datalogic device.
|
void |
sendCommand(DatalogicCommand command)
Send a command that doesn't expect a response to Datalogic device
|
void |
sendCommand(DatalogicCommand command,
DatalogicDeviceResponse.Callback responseListener)
Send a command to Datalogic device and set the callback used to work on the answer
|
void |
setCallbackDeviceBSdk(DatalogicDevice.Callback callback)
Set the callback to manage DatalogicDevice's events
|
void |
setSdkProtocol(boolean isSdkProtocolEnabled)
Enables or disables the SDK protocol
|
void |
setSdkProtocolEnabled(boolean enable)
Set true to enable SDK protocol
|
void |
unbond()
Removes the bond (pairing) with Datalogic device
|
protected DatalogicDevice(DatalogicCoreSDK datalogicCoreSDK, java.lang.String mac)
public java.lang.String getName()
public java.lang.String getAddress()
public boolean isBonded()
public boolean isBonding()
public void bond()
public void unbond()
public boolean isSPP()
public void setSdkProtocol(boolean isSdkProtocolEnabled)
isSdkProtocolEnabled
- true to enable SDK protocol, false to disable itpublic boolean isSdkProtocolEnabled()
public void setSdkProtocolEnabled(boolean enable)
enable
- true to enable SDK protocolpublic void connect(DatalogicDevice.Callback callback)
callback
- used to manage events of DatalogicDevicepublic void setCallbackDeviceBSdk(DatalogicDevice.Callback callback)
callback
- called on DatalogicDevice's eventspublic void disconnect()
public boolean isConnected()
public boolean isConnecting()
public void sendCommand(DatalogicCommand command, DatalogicDeviceResponse.Callback responseListener)
command
- command to be sent to Datalogic deviceresponseListener
- callback to manage answer from devicepublic void sendCommand(DatalogicCommand command)
command
- command to be sentpublic boolean send(java.lang.String data)
Send a string to Datalogic device. If the device has SDK protocol enabled, the data will be encapsulated in it. Use for messages that don't expect answer from device.
data
- data to be sent to Datalogic devicepublic boolean sendAndReceive(java.lang.String data, DatalogicDeviceResponse.Callback responseListener)
Send a string to Datalogic device. If the device has SDK protocol enabled, the data will be encapsulated in it. Use this method for messages that expect answer from device.
data
- data to be sent to Datalogic deviceresponseListener
- listener object for the responseprotected void onReadData(java.lang.String data)
data
- received dataprotected void onMsgWrite(java.lang.String data)
data
- data to be sentprotected void onConnected()
protected void onDisconnected()
protected void onConnecting()
protected void onConnectionFailed()