changes in HomeFragment added deviceId global and added default values
This commit is contained in:
@@ -1016,6 +1016,7 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun getDeviceId() {
|
||||
Log.d("HomeFragmentUSb","getDeviceId")
|
||||
val handler = activity as? DeviceCommunicationHandler
|
||||
handler?.sendAndListenToDevice(
|
||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||
@@ -1023,9 +1024,9 @@ class HomeFragment : Fragment() {
|
||||
override fun onUsbRead(data: ByteArray?) {
|
||||
data?.let {
|
||||
val receivedData = String(it, Charset.forName("UTF-8"))
|
||||
Log.d("HomeFragment","USB data"+receivedData)
|
||||
// Assuming the device ID is the full content of the received data. Adjust if needed.
|
||||
deviceId =
|
||||
extractDeviceId(receivedData) // Implement this method based on your data format.
|
||||
deviceId = extractDeviceId(receivedData) // Implement this method based on your data format.
|
||||
if (deviceId.isNotEmpty()) {
|
||||
// Store the deviceId in SharedPreferences
|
||||
with(sharedPreference.edit()) {
|
||||
@@ -1042,6 +1043,7 @@ class HomeFragment : Fragment() {
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
// Handle USB communication error
|
||||
Log.d("HomeFragment","USB read error"+e.toString())
|
||||
}
|
||||
|
||||
})
|
||||
@@ -1057,8 +1059,8 @@ class HomeFragment : Fragment() {
|
||||
private fun checkForUpdate() {
|
||||
try {
|
||||
val db = Firebase.firestore
|
||||
//val deviceId = deviceId
|
||||
|
||||
val deviceId="HHH-AAA-ZZZ"
|
||||
val deviceRef = db.collection("deviceUpdate").document(Constants.DOCUMENT_ID_FOR_UPDATE)
|
||||
|
||||
deviceRef.get().addOnSuccessListener { documentSnapshot ->
|
||||
|
||||
@@ -116,7 +116,10 @@ class DeviceProvisionFragment : Fragment() {
|
||||
password = response.data.data?.credentials?.password.toString(),
|
||||
deviceProvisionResponse = response.data.data.toString(),
|
||||
natsToken = response.data.data?.device?.deviceUser?.natsToken.toString(),
|
||||
natsTokenExpiry = response.data.data?.device?.deviceUser?.natsTokenExpiry.toString()
|
||||
natsTokenExpiry = response.data.data?.device?.deviceUser?.natsTokenExpiry.toString(),
|
||||
globalUpdateIgnore = false,
|
||||
globalUpdateDone = false,
|
||||
deviceUpdateAvailable = false
|
||||
)
|
||||
)
|
||||
// viewModel.addDeviceId(DeviceData(deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString()))
|
||||
|
||||
Reference in New Issue
Block a user