From d5b691040857277c05c274e5e9b505c0c1e2e7ef Mon Sep 17 00:00:00 2001 From: Mariya Date: Sat, 10 Feb 2024 17:37:07 +0530 Subject: [PATCH] Device provision response storing --- app/build.gradle | 6 +- app/google-services.json | 186 ++++++++++++++++-- .../hpostesting/data/api/PropertyProvider.kt | 9 +- .../data/repository/DatabaseRepository.kt | 18 +- .../hpostesting/data/repository/Repository.kt | 3 +- .../presentation/dashboard/HomeFragment.kt | 123 +++++++++--- .../DeviceProvisionActivity.kt | 9 +- .../DeviceProvisionFragment.kt | 26 ++- .../DeviceProvisionViewModel.kt | 6 +- 9 files changed, 324 insertions(+), 62 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c881eb0..e8912e3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,11 +16,11 @@ android { // dev - development, quality - qc, uat - User Acceptance Test, preprod - preproduction, prod - production defaultConfig { - applicationId "in.sminnovations.hpostesting.quality" + applicationId "in.sminnovations.hpostesting" minSdk 21 targetSdk 34 - versionCode 101 - versionName "2.1.101" + versionCode 102 + versionName "2.1.102" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/google-services.json b/app/google-services.json index 7f4a67b..a73fe1e 100644 --- a/app/google-services.json +++ b/app/google-services.json @@ -1,45 +1,205 @@ { "project_info": { - "project_number": "1004619739289", - "project_id": "hpos-qa", - "storage_bucket": "hpos-qa.appspot.com" + "project_number": "650071678820", + "project_id": "hpos-af3cc", + "storage_bucket": "hpos-af3cc.appspot.com" }, "client": [ { "client_info": { - "mobilesdk_app_id": "1:1004619739289:android:f669b47552748433e5c808", + "mobilesdk_app_id": "1:650071678820:android:f1435a1c07f710036c6471", "android_client_info": { - "package_name": "in.sminnovations.hposregistration.quality" + "package_name": "com.example.hposconsentform" } }, - "oauth_client": [], + "oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ], "api_key": [ { - "current_key": "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs" + "current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I" } ], "services": { "appinvite_service": { - "other_platform_oauth_client": [] + "other_platform_oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ] } } }, { "client_info": { - "mobilesdk_app_id": "1:1004619739289:android:8397cd1f0357bd89e5c808", + "mobilesdk_app_id": "1:650071678820:android:7865bef608cdee6f6c6471", "android_client_info": { - "package_name": "in.sminnovations.hpostesting.quality" + "package_name": "com.smi.counselling" } }, - "oauth_client": [], + "oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ], "api_key": [ { - "current_key": "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs" + "current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I" } ], "services": { "appinvite_service": { - "other_platform_oauth_client": [] + "other_platform_oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:650071678820:android:2925e9ce3417d2386c6471", + "android_client_info": { + "package_name": "in.sminnovations.hemocube" + } + }, + "oauth_client": [ + { + "client_id": "650071678820-srhm9spm9hjn4frcd3r6o02gdhdbtd15.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "in.sminnovations.hemocube", + "certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a" + } + }, + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:650071678820:android:7569c1cad4fc99916c6471", + "android_client_info": { + "package_name": "in.sminnovations.hposregistration" + } + }, + "oauth_client": [ + { + "client_id": "650071678820-70kp5jvjda4r5diqch2kn4lc40p4f42g.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "in.sminnovations.hposregistration", + "certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a" + } + }, + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:650071678820:android:f96be19e5d43102b6c6471", + "android_client_info": { + "package_name": "in.sminnovations.hpostesting" + } + }, + "oauth_client": [ + { + "client_id": "650071678820-l87dnr0bdj95get0khgnvfv2an1k6ogq.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "in.sminnovations.hpostesting", + "certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a" + } + }, + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:650071678820:android:a53292637abb7c0d6c6471", + "android_client_info": { + "package_name": "in.sminnovations.hpostesting.dev" + } + }, + "oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com", + "client_type": 3 + } + ] } } } diff --git a/app/src/main/java/com/example/hpostesting/data/api/PropertyProvider.kt b/app/src/main/java/com/example/hpostesting/data/api/PropertyProvider.kt index 5f55ac4..12486ec 100644 --- a/app/src/main/java/com/example/hpostesting/data/api/PropertyProvider.kt +++ b/app/src/main/java/com/example/hpostesting/data/api/PropertyProvider.kt @@ -1,6 +1,13 @@ package com.example.hpostesting.data.api +import com.example.hpostesting.data.constant.HemoCubeCommands +import com.example.hpostesting.presentation.UsbServiceListener + interface PropertyProvider { fun getProperty(key: String): String -} \ No newline at end of file +} + +interface DeviceCommunicationHandler { + fun sendAndListenToDevice(command: HemoCubeCommands, listener: UsbServiceListener) +} diff --git a/app/src/main/java/com/example/hpostesting/data/repository/DatabaseRepository.kt b/app/src/main/java/com/example/hpostesting/data/repository/DatabaseRepository.kt index 0812cd6..1329854 100644 --- a/app/src/main/java/com/example/hpostesting/data/repository/DatabaseRepository.kt +++ b/app/src/main/java/com/example/hpostesting/data/repository/DatabaseRepository.kt @@ -203,8 +203,7 @@ class DatabaseRepository @Inject constructor( return allDeviceDataList.find { it.deviceId == deviceId } } - - override suspend fun getDeviceResponse(data: DeviceData): Response? { + override suspend fun getDeviceResponse(data: DeviceData?): Response { return try { db.collection("devices").add(data!!).await() Response.Success(data.deviceProvisionResponse) @@ -213,7 +212,22 @@ class DatabaseRepository @Inject constructor( Response.Error(e) } } + + + + + override suspend fun uploadDeviceId(data: DeviceData): Response? { + return try { + db.collection("devices").add(data!!).await() + Response.Success(data.deviceId) + } catch (e: Exception) { + Firebase.crashlytics.recordException(e) + Response.Error(e) + } + } + override fun addTestToDatabase(testDetails: UserData): Any { TODO("Not yet implemented") } + } \ No newline at end of file diff --git a/app/src/main/java/com/example/hpostesting/data/repository/Repository.kt b/app/src/main/java/com/example/hpostesting/data/repository/Repository.kt index ecdad95..6576a5c 100644 --- a/app/src/main/java/com/example/hpostesting/data/repository/Repository.kt +++ b/app/src/main/java/com/example/hpostesting/data/repository/Repository.kt @@ -32,7 +32,8 @@ interface Repository { suspend fun uploadFileToStorage(patientID: String, filePath: String): Response suspend fun getDeviceDataById(deviceId: String): DeviceData? - suspend fun getDeviceResponse(data: DeviceData): Response? + suspend fun getDeviceResponse(data: DeviceData?): Response + suspend fun uploadDeviceId(data: DeviceData): Response? abstract fun addTestToDatabase(testDetails: UserData): Any // suspend fun addToDatabase(data: PatientDetails) diff --git a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt index 5778038..3538078 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt @@ -20,7 +20,9 @@ import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController import com.example.hpostesting.data.DataHolder import com.example.hpostesting.data.Result +import com.example.hpostesting.data.api.DeviceCommunicationHandler import com.example.hpostesting.data.constant.Constants +import com.example.hpostesting.data.constant.HemoCubeCommands import com.example.hpostesting.data.model.deviceprovision.ProvisionData import com.example.hpostesting.data.model.login.LoginRequest import com.example.hpostesting.data.model.login.LoginResponse @@ -32,6 +34,7 @@ import com.example.hpostesting.data.model.patient.UserData import com.example.hpostesting.data.model.updates.CheckUpdateRequest import com.example.hpostesting.data.model.updates.DeviceUpdateRequest import com.example.hpostesting.presentation.KitScanActivity +import com.example.hpostesting.presentation.UsbServiceListener import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter import com.example.hpostesting.presentation.adapter.UserListAdapter import com.example.hpostesting.presentation.assurance.AssuranceControlsActivity @@ -49,7 +52,9 @@ import com.google.gson.JsonSyntaxException import dagger.hilt.android.AndroidEntryPoint import `in`.sminnovations.hpostesting.R import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding +import org.json.JSONException import org.json.JSONObject +import java.nio.charset.Charset import java.text.SimpleDateFormat import java.util.Calendar import java.util.Date @@ -68,9 +73,10 @@ class HomeFragment : Fragment() { private val homeViewModel: HemoCubeViewModel by activityViewModels() private var isTokenAvailable = false - private var username:String ="" - private var passworD:String ="" - private var natsToken:String ="" + private var username: String = "" + private var passworD: String = "" + private var natsToken: String = "" + private var deviceId: String = "" private lateinit var sharedPreference: SharedPreferences @@ -120,7 +126,7 @@ class HomeFragment : Fragment() { binding.rvOrderOffline.adapter = adapter } } - hemoCubeViewModel.deviceData.observe(viewLifecycleOwner){ deviceData-> + hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) { deviceData -> val devicelist = mutableListOf() if (deviceData != null) { devicelist.add(DeviceData(deviceData.deviceId)) @@ -134,6 +140,7 @@ class HomeFragment : Fragment() { loadUserData() setSearch() checkForLocalDBData() + getDeviceId() checkForTokenAndUpdate() } else { binding.internetAvailableCL.visibility = View.GONE @@ -206,19 +213,14 @@ class HomeFragment : Fragment() { } private fun checkForTokenAndUpdate() { - val accessToken = sharedPreference.getString(Constants.ACCESS_TOKEN, "").toString() + var accessToken = sharedPreference.getString(Constants.ACCESS_TOKEN, "").toString() var password = sharedPreference.getString(Constants.DEVICE_PASSWORD_API, "").toString() var userID = sharedPreference.getString(Constants.DEVICE_ID_API, "").toString() - val deviceId = sharedPreference.getString(Constants.DEVICE_ID,"") - - if(userID.isEmpty() && password.isEmpty()){ - if (deviceId != null) { - fetchDeviceProvisionResponse(deviceId) - } - userID = sharedPreference.getString("username",username).toString() - password = sharedPreference.getString("password",passworD).toString() - hemoCubeViewModel.login(createLoginRequestData(userID, password)) - }else if (userID.isNotEmpty() && password.isNotEmpty()) { + deviceId = sharedPreference.getString(Constants.DEVICE_ID, "").toString() + Log.e("idpass", userID) + Log.e("idpass", password) + Log.e("idpass", deviceId) + if (userID.isNotEmpty() && password.isNotEmpty()) { if (accessToken.isEmpty()) { hemoCubeViewModel.login(createLoginRequestData(userID, password)) } else { @@ -231,7 +233,12 @@ class HomeFragment : Fragment() { hemoCubeViewModel.startPeriodicCheckUpdate() } } - }else{ + }else if (deviceId.isNotEmpty()) { + fetchDeviceProvisionResponse() + userID = username + password = passworD + hemoCubeViewModel.login(createLoginRequestData(userID, password)) + } else { Toast.makeText( requireContext(), "Contact Help and get your device provision done", @@ -393,10 +400,12 @@ class HomeFragment : Fragment() { } - private fun fetchDeviceProvisionResponse(deviceId: String) { + private fun fetchDeviceProvisionResponse() { val db = Firebase.firestore + val deviceId = sharedPreference.getString(Constants.DEVICE_ID, "").toString() val deviceRef = db.collection("devices").document(deviceId) + deviceRef.get() .addOnSuccessListener { document -> if (document.exists()) { @@ -411,15 +420,24 @@ class HomeFragment : Fragment() { } provisionData?.let { data -> // Assuming 'data' has the fields 'username', 'password', and 'natsToken' - username = data.username.toString() - passworD = data.password.toString() - natsToken = data.natsToken.toString() + username = data.username.toString() + passworD = data.password.toString() + natsToken = data.natsToken.toString() // Assuming 'sharedPreference' is correctly initialized SharedPreferences instance with(sharedPreference.edit()) { - putString("username", username) // Replace "username_key" with your actual key for username - putString("password", passworD) // Replace "password_key" with your actual key for password - putString("natsToken", natsToken) // Replace "natsToken_key" with your actual key for NATS token + putString( + "username", + username + ) // Replace "username_key" with your actual key for username + putString( + "password", + passworD + ) // Replace "password_key" with your actual key for password + putString( + "natsToken", + natsToken + ) // Replace "natsToken_key" with your actual key for NATS token apply() // Don't forget to call apply() to save the changes } } @@ -436,16 +454,21 @@ class HomeFragment : Fragment() { private fun parseDeviceProvisionResponse(responseString: String): ProvisionData? { return try { - val gson = Gson() - val type = object : TypeToken() {}.type - gson.fromJson(responseString, type) - } catch (e: JsonSyntaxException) { + val jsonObject = JSONObject(responseString) + + val credentials = jsonObject.getJSONObject("credentials") + val username = credentials.getString("username") + val password = credentials.getString("password") + + val deviceUser = jsonObject.getJSONObject("device").getJSONObject("deviceUser") + val natsToken = deviceUser.getString("natsToken") + + ProvisionData(username, password, natsToken) + } catch (e: JSONException) { null } } - - private fun loadUserData() { try { val dateFormat = SimpleDateFormat("yyyy-MM-dd") @@ -828,4 +851,44 @@ class HomeFragment : Fragment() { } } } -} \ No newline at end of file + + private fun getDeviceId() { + val handler = activity as? DeviceCommunicationHandler + handler?.sendAndListenToDevice( + HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND, + object : UsbServiceListener { + override fun onUsbRead(data: ByteArray?) { + data?.let { + val receivedData = String(it, Charset.forName("UTF-8")) + // 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. + if (deviceId.isNotEmpty()) { + // Store the deviceId in SharedPreferences + with(sharedPreference.edit()) { + putString(Constants.DEVICE_ID, deviceId) + apply() + } + // Optionally, you can update UI or proceed with further logic now that you have the device ID + activity?.runOnUiThread { + // Update your UI or trigger next steps here + } + } + } + } + + override fun onUsbError(e: Exception?) { + // Handle USB communication error + } + + }) + } + + fun extractDeviceId(receivedData: String): String { + // Example based on the format "SNS HPP1-3038 SNE" + val regex = "SNS (\\w+) SNE".toRegex() + val matchResult = regex.find(receivedData) + return matchResult?.groups?.get(1)?.value ?: "" + } + +} diff --git a/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionActivity.kt b/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionActivity.kt index 1e316ff..1e2c5bd 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionActivity.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionActivity.kt @@ -21,8 +21,11 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.core.view.get import com.example.hpostesting.data.DataHolder +import com.example.hpostesting.data.api.DeviceCommunicationHandler import com.example.hpostesting.data.constant.Constants +import com.example.hpostesting.data.constant.HemoCubeCommands import com.example.hpostesting.data.constant.LanguageManager +import com.example.hpostesting.presentation.UsbServiceListener import com.example.hpostesting.presentation.testRight.UsbService import com.hoho.android.usbserial.driver.UsbSerialDriver import com.hoho.android.usbserial.driver.UsbSerialProber @@ -31,7 +34,7 @@ import `in`.sminnovations.hpostesting.R import `in`.sminnovations.hpostesting.databinding.ActivityAutoDacBinding @AndroidEntryPoint -class DeviceProvisionActivity : AppCompatActivity() { +class DeviceProvisionActivity : AppCompatActivity(), DeviceCommunicationHandler { private lateinit var binding: ActivityAutoDacBinding val viewModel: DeviceProvisionViewModel by viewModels() private var myMenu: Menu? = null @@ -180,4 +183,8 @@ class DeviceProvisionActivity : AppCompatActivity() { viewModel.isServiceConnected = false } } + + override fun sendAndListenToDevice(command: HemoCubeCommands, listener: UsbServiceListener) { + mService.sendAndListenToHemoCube(command = HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND, listener) + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionFragment.kt index 954bb44..bbb4ea2 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionFragment.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.Intent import android.content.SharedPreferences import android.os.Bundle +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -20,6 +21,7 @@ import com.example.hpostesting.presentation.UsbServiceListener import com.example.hpostesting.presentation.dashboard.DashboardActivity import com.google.firebase.crashlytics.ktx.crashlytics import com.google.firebase.ktx.Firebase +import `in`.sminnovations.hpostesting.R import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding class DeviceProvisionFragment : Fragment() { @@ -56,13 +58,13 @@ class DeviceProvisionFragment : Fragment() { ) ) } - viewModel.deviceData.observe(viewLifecycleOwner) { - currentDeviceData = it - } } private fun observeViewModel() { + viewModel.deviceData.observe(viewLifecycleOwner) { + currentDeviceData = it + } viewModel.deviceProvisionResponse.observe(viewLifecycleOwner) { response -> when (response) { @@ -96,14 +98,16 @@ class DeviceProvisionFragment : Fragment() { Toast.makeText( activity, "Device registered successfully", Toast.LENGTH_LONG ).show() - - response.data.data?.credentials?.username?.let { DeviceData(deviceId = it) } - ?.let { viewModel.addDeviceId(it) } viewModel.addDeviceProvisionDataToDb( DeviceData( - deviceProvisionResponse = response.toString() + deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString(), + deviceProvisionResponse = response.data.data.toString() ) ) +// viewModel.addDeviceId(DeviceData(deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString())) + Log.e("idpass",response.toString()) + Log.e("idpass",response.data.data?.credentials?.username.toString()) + Log.e("idpass",deviceProvisionResponse) } else { Toast.makeText( activity, @@ -132,7 +136,13 @@ class DeviceProvisionFragment : Fragment() { else -> {} } } - + viewModel.fireBaseUpload.observe(viewLifecycleOwner) { result -> + if (result == "Success") { + Toast.makeText( + activity, "Device provision successfully uploaded to firebase", Toast.LENGTH_LONG + ).show() + } + } } diff --git a/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionViewModel.kt b/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionViewModel.kt index bc83159..f2cd209 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionViewModel.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/deviceprovision/DeviceProvisionViewModel.kt @@ -42,8 +42,8 @@ class DeviceProvisionViewModel @Inject constructor( fun addDeviceId(data: DeviceData){ viewModelScope.launch { try{ - val id = repository.getDeviceDataById(data.deviceId) - fireBaseUpload.postValue("Success") + repository.uploadDeviceId(data) + fireBaseUpload.postValue("Successfully device Id uploaded to firebase") } catch (e: Exception) { // Log.e("Testdb", "Exception during data upload: ${e.message}") fireBaseUpload.postValue("Error") @@ -56,7 +56,7 @@ class DeviceProvisionViewModel @Inject constructor( when (val response = repository.getDeviceResponse(data)) { is Response.Success -> { // Log.i("Testdb", "Data uploaded to Firestore successfully") - fireBaseUpload.postValue("Success") + fireBaseUpload.postValue("Successfully device response uploaded to firebase") } is Response.Error -> {