Interfaces
Summary
The CODiScan™ HS7600 SDK contains a series of interfaces, which when implemented, can be used to receive callbacks pertaining to the pairing with, or status of, a connected CODiScan™ HS7600 device.
Interfaces | Description |
---|---|
BatteryStatusListener | Interface to receive battery status callbacks. |
ConnectListener | Interface to receive connect callbacks. |
DeviceDetailsListener | Interface to receive device details callbacks. |
DisconnectListener | Interface to receive disconnect callbacks. |
GetConfigListener | Interface to receive get configuration values callback. |
PairingCodeListener | Interface to receive pairing code callback. |
ScanListener | Interface to receive scan callbacks. |
SetConfigListener | Interface to receive set configuration values callback. |
BatteryStatusListener
Interface to receive battery status callbacks.
Abstract Functions
onBatteryStatus(batteryData: BatteryData)
- triggered after triggerBatteryStatus is called, when battery data is received from the connected CODiScan device.
Example
Class MyClass : BatteryStatusListener {
override fun onBatteryStatus(batteryData: BatteryData) {
Log.i("MY_APP", "Remaining battery percentage of CODiScan device: ${batteryData.batteryCharge}")
}
}
ConnectListener
Interface to receive connect callbacks.
Abstract Functions
onConnect()
- triggered when a CODiScan device is connected with the Android device.
Example
Class MyClass : ConnectListener {
override fun onConnect() {
Log.i("MY_APP", "Connected to the CODiScan device.")
}
}
DeviceDetailsListener
Interface to receive device details callbacks.
Abstract Functions
onDeviceDetails(deviceData: DeviceData)
- triggered after triggerDeviceDetails is called, when device data is received from the connected CODiScan device.
Example
Class MyClass : DeviceDetailsListener {
override fun onDeviceDetails(deviceData: DeviceData) {
Log.i("MY_APP", "Connected CODiScan's device ID: ${deviceData.deviceId}")
}
}
DisconnectListener
Interface to receive disconnect callbacks.
Abstract Functions
onDisconnect()
- triggered when a CODiScan device is disconnected from the Android device.
Example
Class MyClass : DisconnectListener {
override fun onDisconnect() {
Log.i("MY_APP", "Disconnected from the CODiScan.")
}
}
GetConfigListener
Interface to receive get configuration values callback.
Abstract Functions
onGetConfig(ints: HashMap<Int, Int>, strings: HashMap<Int, String>)
- triggered after get is called, when configuration parameter values are received from the connected CODiScan device.
Example
Class MyClass : GetConfigListener {
override fun onGetConfig(ints: HashMap<Int, Int>, strings: HashMap<Int, String>) {
ints.entries.forEach { entry ->
Log.i("CODISCAN", "Property ID ${entry.key} has value: ${entry.value}")
}
strings.entries.forEach { entry ->
Log.i("CODISCAN", "Property ID ${entry.key} has value: ${entry.value}")
}
}
}
PairingCodeListener
Interface to receive pairing code callback.
Abstract Functions
onPairingCode(pairingData: PairingData)
- triggered after triggerPairingObject is called, when a pairing code is received from the CODiScan service.
Example
Class MyClass : PairingCodeListener {
private val dataMatrixViewModel: DataMatrixViewModel by viewModels()
override fun onPairingCode(pairingData: PairingData) {
Log.i("MY_APP", "Pairing code: ${pairingData.pairingCode}")
dataMatrixViewModel.setDataMatrix(pairingData.bitmap)
}
@Composable
fun DataMatrix(){
val image by dataMatrixViewModel.dataMatrixImage.observeAsState()
Image(image!!,"", modifier = Modifier.width(240.dp).height(240.dp))
}
}
class DataMatrixViewModel: ViewModel() {
private val _dataMatrixImage = MutableLiveData<ImageBitmap>()
val dataMatrixImage: LiveData<ImageBitmap> = _dataMatrixImage
fun setDataMatrix(raw: Bitmap){
viewModelScope.launch {
_dataMatrixImage.value = raw.asImageBitmap()
}
}
}
ScanListener
Interface to receive scan callbacks.
Abstract Functions
onScan(scanData: ScanData)
- triggered after a barcode is scanned from the connected CODiScan device.
Example
Class MyClass : ScanListener {
override fun onScan(scanData: ScanData) {
Log.i("MY_APP", "Scan data: ${scanData.barcodeData}")
}
}
SetConfigListener
Interface to receive set configuration values callback.
Abstract Functions
onSetConfig(status: Int, message: String)
- triggered after set is called, when status is received, regarding applying new configuration values, from the connected CODiScan device.
Example
Class MyClass : SetConfigListener {
override fun onSetConfig(status: Int, message: String) {
Log.i("MY_APP", "Set config status $status: $message")
}
}