Issues fixed
This commit is contained in:
@@ -39,7 +39,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
private var currentDeviceData: DeviceData? = null
|
private var currentDeviceData: DeviceData? = null
|
||||||
private var resultData: String = ""
|
private var resultData: String = ""
|
||||||
private var deviceSerialNo: String = ""
|
private var deviceSerialNo: String = ""
|
||||||
private var coeffiCients: String? = ""
|
private var coefficients: String? = ""
|
||||||
private var isUsingExistingBuffer = false
|
private var isUsingExistingBuffer = false
|
||||||
private var isTestOngoing = false
|
private var isTestOngoing = false
|
||||||
private var startListening = MutableLiveData<Boolean>(false)
|
private var startListening = MutableLiveData<Boolean>(false)
|
||||||
@@ -327,7 +327,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
val result = validString.split(" ")
|
val result = validString.split(" ")
|
||||||
val deviceLog = resultData
|
val deviceLog = resultData
|
||||||
if (result.size == 8) {
|
if (result.size == 8) {
|
||||||
deviceSerialNo = result[2]
|
val deviceSerialNo = result[2]
|
||||||
with(sharedPreferences.edit()) {
|
with(sharedPreferences.edit()) {
|
||||||
putString(Constants.DEVICE_ID, deviceSerialNo)
|
putString(Constants.DEVICE_ID, deviceSerialNo)
|
||||||
apply()
|
apply()
|
||||||
@@ -361,11 +361,11 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
if (isOnline) {
|
if (isOnline) {
|
||||||
// Online mode, use coefficients from the server
|
// Online mode, use coefficients from the server
|
||||||
coeffiCients = currentDeviceData?.coefficients?.get(0)
|
coefficients = currentDeviceData?.coefficients?.get(0)
|
||||||
.toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
.toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
||||||
} else {
|
} else {
|
||||||
// Offline mode, provide default coefficients or handle as needed
|
// Offline mode, provide default coefficients or handle as needed
|
||||||
coeffiCients = Constants.COEFFICIENTS[deviceSerialNo]?.get(0)?.get(0).toString() + "," + Constants.COEFFICIENTS[deviceSerialNo]?.get(1)?.get(0).toString()
|
coefficients = Constants.COEFFICIENTS[loginId]?.get(0).toString() + "," + Constants.COEFFICIENTS[loginId]?.get(1).toString()
|
||||||
}
|
}
|
||||||
// if (led1BufferForDevice!! > 20000 && led1BufferForDevice < 24000 && led2BufferForDevice!! > 20000 && led2BufferForDevice < 24000) {
|
// if (led1BufferForDevice!! > 20000 && led1BufferForDevice < 24000 && led2BufferForDevice!! > 20000 && led2BufferForDevice < 24000) {
|
||||||
// if (led1Sample!! < led1BufferForDevice && led1Sample < 24000 && led2Sample!! < led2BufferForDevice && led2Sample < 24000) {
|
// if (led1Sample!! < led1BufferForDevice && led1Sample < 24000 && led2Sample!! < led2BufferForDevice && led2Sample < 24000) {
|
||||||
@@ -396,7 +396,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
this.deviceRatio = deviceRatio
|
this.deviceRatio = deviceRatio
|
||||||
this.calculatedRatio = calculateRatio(deviceRatio)
|
this.calculatedRatio = calculateRatio(deviceRatio)
|
||||||
// this.coefficients = currentDeviceData?.coefficients?.get(0).toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
// this.coefficients = currentDeviceData?.coefficients?.get(0).toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
||||||
this.coefficients = Constants.COEFFICIENTS[deviceId]?.get(0).toString() + "," + Constants.COEFFICIENTS[deviceId]?.get(1).toString()
|
this.coefficients = coefficients
|
||||||
this.classificationResult = findResult(calculatedRatio)
|
this.classificationResult = findResult(calculatedRatio)
|
||||||
hemoCubeViewModel.messages.postValue(this.classificationResult)
|
hemoCubeViewModel.messages.postValue(this.classificationResult)
|
||||||
this.resultData = deviceLog
|
this.resultData = deviceLog
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class UsbService : Service() {
|
|||||||
fun connect(driver: UsbSerialDriver, connection: UsbDeviceConnection) {
|
fun connect(driver: UsbSerialDriver, connection: UsbDeviceConnection) {
|
||||||
mPort = driver.ports[0] // Most devices have just one port (port 0)
|
mPort = driver.ports[0] // Most devices have just one port (port 0)
|
||||||
mPort.open(connection)
|
mPort.open(connection)
|
||||||
mPort.setParameters(9600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
mPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||||
isUsbConnected = true
|
isUsbConnected = true
|
||||||
Log.d(TAG, "My Usb Connected ${mPort.driver}")
|
Log.d(TAG, "My Usb Connected ${mPort.driver}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user