diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/ble/BleBridge.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/ble/BleBridge.kt index b6be1fd6..aaceea38 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/ble/BleBridge.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/ble/BleBridge.kt @@ -48,6 +48,7 @@ class BleBridge( private const val EVENTCHANNEL = "BLE-Platform-Bridge-Event" private const val SCAN_DEVICE = "scan" private const val SCAN_DEVICE_EKG = "scan_ekg" + private const val EKG_FILES_LIST = "ekg_files_list" private const val DISCONNECT_DEVICE = "disconnect_device" } @@ -140,7 +141,9 @@ class BleBridge( } else if (methodCall.method == DISCONNECT_DEVICE) { disconnectDevice(methodCall, result) } else if (methodCall.method == SCAN_DEVICE_EKG) { - scanDeviceEKG(methodCall, result) +// scanDeviceEKG(methodCall, result) + } else if (methodCall.method == EKG_FILES_LIST) { + getEKGFilesList() } else { result.notImplemented() } @@ -212,12 +215,17 @@ class BleBridge( .observe(this.mainActivity) { val data = it.data as DeviceInfo println("DuoEK INFO DATA: $data") + val returnData = mapOf("type" to "infoData", "data" to data.toString()) + eventSink?.success(returnData) } LiveEventBus.get(InterfaceEvent.ER2.EventEr2FileList) .observe(this.mainActivity) { val fileNames = it.data as ArrayList println("DuoEK FileNames List: $fileNames") - eventSink?.success(fileNames.toString()) + val returnData = + mapOf("type" to "fileList", "data" to fileNames.toString()) +// eventSink?.success(fileNames.toString()) + eventSink?.success(returnData) } LiveEventBus.get(InterfaceEvent.ER2.EventEr2SetTime) @@ -227,7 +235,7 @@ class BleBridge( BleServiceHelper.BleServiceHelper.er2GetInfo(model) //Get EKG File List - BleServiceHelper.BleServiceHelper.er2GetFileList(model) +// BleServiceHelper.BleServiceHelper.er2GetFileList(model) } } @@ -262,65 +270,10 @@ class BleBridge( } } - fun scanDeviceEKG(methodCall: MethodCall, result: MethodChannel.Result) { - println("This is Test of Scanning EKG Device") - - LiveEventBus.get(EventMsgConst.Ble.EventServiceConnectedAndInterfaceInit) - .observe(this.mainActivity) { - // BleService init success - println("EventServiceConnectedAndInterfaceInit---------") - BleServiceHelper.BleServiceHelper.startScan(models) - println("EventServiceConnectedAndInterfaceInit") - } - - LiveEventBus.get(EventMsgConst.Discovery.EventDeviceFound) - .observe(this.mainActivity) { - var deviceName: String = "" - - for (b in BluetoothController.getDevices()) { - if (b.name.contains("DuoEK", true) - ) { - model = b.model - deviceName = b.name - BleServiceHelper.BleServiceHelper.setInterfaces(b.model) - BleServiceHelper.BleServiceHelper.stopScan() - BleServiceHelper.BleServiceHelper.connect( - this.mainActivity.applicationContext, - b.model, - b.device - ) - } - } - println("EventDeviceFound") - println(deviceName) - - if (deviceName.contains("DuoEK", ignoreCase = true)) { - LiveEventBus.get(InterfaceEvent.ER2.EventEr2Info) - .observe(this.mainActivity) { - val data = it.data as DeviceInfo - println("DuoEK INFO DATA: $data") - } - LiveEventBus.get(InterfaceEvent.ER2.EventEr2FileList) - .observe(this.mainActivity) { - val fileNames = it.data as ArrayList - println("DuoEK FileNames List: $fileNames") - eventSink?.success(fileNames.toString()) - } - - LiveEventBus.get(InterfaceEvent.ER2.EventEr2SetTime) - .observe(this.mainActivity) { - println("EventEr2SetTime") - // Get Device Info - BleServiceHelper.BleServiceHelper.er2GetInfo(model) - - //Get EKG File List - BleServiceHelper.BleServiceHelper.er2GetFileList(model) - } - } - - } - + fun getEKGFilesList() { + //Get EKG File List + BleServiceHelper.BleServiceHelper.er2GetFileList(model) } } \ No newline at end of file diff --git a/lib/config/config.dart b/lib/config/config.dart index 1b4c69b3..c5f6b164 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -20,8 +20,8 @@ var PACKAGES_ORDERS = '/api/orders'; var PACKAGES_ORDER_HISTORY = '/api/orders/items'; var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; // var BASE_URL = 'http://10.50.100.198:2018/'; -var BASE_URL = 'https://uat.hmgwebservices.com/'; -// var BASE_URL = 'https://hmgwebservices.com/'; +// var BASE_URL = 'https://uat.hmgwebservices.com/'; +var BASE_URL = 'https://hmgwebservices.com/'; // var BASE_URL = 'https://orash.cloudsolutions.com.sa/'; // var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/'; @@ -326,7 +326,7 @@ var UPDATE_COVID_QUESTIONNAIRE = 'Services/Doctors.svc/REST/COVID19_Questionnari var CHANNEL = 3; var GENERAL_ID = 'Cs2020@2016\$2958'; var IP_ADDRESS = '10.20.10.20'; -var VERSION_ID = 10.9; +var VERSION_ID = 11.4; var SETUP_ID = '91877'; var LANGUAGE = 2; // var PATIENT_OUT_SA = 0; diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index fb3c900a..43ac6df8 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -149,8 +149,8 @@ class BaseAppClient { // body['IdentificationNo'] = 1023854217; // body['MobileNo'] = "531940021"; - // body['PatientID'] = 4767370; //3844083 - // body['TokenID'] = "@dm!n"; + body['PatientID'] = 1231755; //3844083 + body['TokenID'] = "@dm!n"; // Patient ID: 3027574 // Mobile no.: 0502303285 diff --git a/lib/pages/medical/my_trackers/viatom_devices/ekg_tracker_ble.dart b/lib/pages/medical/my_trackers/viatom_devices/ekg_tracker_ble.dart index 6f05e108..ffa0f6bf 100644 --- a/lib/pages/medical/my_trackers/viatom_devices/ekg_tracker_ble.dart +++ b/lib/pages/medical/my_trackers/viatom_devices/ekg_tracker_ble.dart @@ -16,11 +16,14 @@ class _EKG_BLEState extends State { EventChannel eventChannel = EventChannel('BLE-Platform-Bridge-Event'); String receivedData = ''; + // final ekgValueNotifier = ValueNotifier>; final ekgValueNotifier = ValueNotifier("start"); + List ekgFilesList = []; + @override void dispose() { - ekgValueNotifier.dispose(); + // ekgValueNotifier.dispose(); super.dispose(); BleChannel.disconnect(); } @@ -29,12 +32,6 @@ class _EKG_BLEState extends State { void initState() { // TODO: implement initState super.initState(); - - eventChannel.receiveBroadcastStream().listen((event) { - print('Received event---: $event'); - ekgValueNotifier.value = event; - }); - } @override @@ -57,7 +54,17 @@ class _EKG_BLEState extends State { child: DefaultButton( "Get Info", () async { - await BleChannel.getScanningResultEKG(["oximeter", "ekg"]); + eventChannel.receiveBroadcastStream().listen((event) { + print('Received event---: $event'); + print(event['type']); + if (event['type'] == "infoData") { + ekgValueNotifier.value = event['data']; + } + if (event['type'] == "fileList") { + parseEKGFilesList(event['data'].toString().split(",")); + } + }); + await BleChannel.getScanningResult(["oximeter", "ekg"]); }, textColor: Colors.white, ), @@ -66,7 +73,9 @@ class _EKG_BLEState extends State { Expanded( child: DefaultButton( "Get Files List", - () {}, + () async { + await BleChannel.getEKGFilesList(["oximeter", "ekg"]); + }, textColor: Colors.white, ), ), @@ -106,10 +115,22 @@ class _EKG_BLEState extends State { // : Text(value); }, ), + mHeight(24.0), + getFilesListWidget() ], ), ), ), ); } + + void parseEKGFilesList(dynamic filesListArray) { + print("received files list: $filesListArray"); + ekgValueNotifier.value = filesListArray.toString(); + } + + Widget getFilesListWidget() { + return Container(); + } + } diff --git a/lib/viatom_ble/ble_connect.dart b/lib/viatom_ble/ble_connect.dart index 60f0902f..0ad00179 100644 --- a/lib/viatom_ble/ble_connect.dart +++ b/lib/viatom_ble/ble_connect.dart @@ -17,10 +17,22 @@ class BleChannel { } } - static Future getScanningResultEKG(List deviceType) async { + // static Future getScanningResultEKG(List deviceType) async { + // try { + // print("----------Flutter Init -------"); + // final String result = await platform.invokeMethod('scan_ekg', deviceType); + // print("----------Flutter Result -------"); + // print(result); + // return result; + // } catch (e) { + // return "Error: $e"; + // } + // } + + static Future getEKGFilesList(List deviceType) async { try { print("----------Flutter Init -------"); - final String result = await platform.invokeMethod('scan_ekg', deviceType); + final String result = await platform.invokeMethod('ekg_files_list', deviceType); print("----------Flutter Result -------"); print(result); return result;