BP tracker Integration in Progress

dev_3.3_BLE
Faiz Hashmi 2 years ago
parent 6e6c4fef1a
commit 7d023cdb35

@ -9,6 +9,7 @@ import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.provider.Settings import android.provider.Settings
import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.core.app.ActivityCompat.startActivityForResult import androidx.core.app.ActivityCompat.startActivityForResult
import com.ejada.hmg.MainActivity import com.ejada.hmg.MainActivity
@ -19,6 +20,7 @@ import io.flutter.plugin.common.EventChannel
import android.util.SparseArray import android.util.SparseArray
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import com.cloud.diplomaticquarterapp.ble.utils.EcgData import com.cloud.diplomaticquarterapp.ble.utils.EcgData
import com.cloud.diplomaticquarterapp.ble.utils.RTBP2Data
import com.google.gson.Gson import com.google.gson.Gson
@ -29,6 +31,10 @@ import com.lepu.blepro.event.EventMsgConst
import com.lepu.blepro.event.EventMsgConst.Ble.* import com.lepu.blepro.event.EventMsgConst.Ble.*
import com.lepu.blepro.event.InterfaceEvent import com.lepu.blepro.event.InterfaceEvent
import com.lepu.blepro.ext.BleServiceHelper import com.lepu.blepro.ext.BleServiceHelper
import com.lepu.blepro.ext.bp2.Bp2File
import com.lepu.blepro.ext.bp2.BpFile
import com.lepu.blepro.ext.bp2.EcgFile
import com.lepu.blepro.ext.bp2.RtBpIng
import com.lepu.blepro.ext.er2.DeviceInfo import com.lepu.blepro.ext.er2.DeviceInfo
import com.lepu.blepro.ext.er2.Er2EcgFile import com.lepu.blepro.ext.er2.Er2EcgFile
import com.lepu.blepro.ext.er2.Er2File import com.lepu.blepro.ext.er2.Er2File
@ -51,8 +57,10 @@ class BleBridge(
private var eventSink: EventChannel.EventSink? = null private var eventSink: EventChannel.EventSink? = null
private var ecgFileNames = arrayListOf<String>() private var ecgFileNames = arrayListOf<String>()
private var bpFileNames = arrayListOf<String>()
var ecgList: ArrayList<EcgData> = arrayListOf() var ecgList: ArrayList<EcgData> = arrayListOf()
val gson = Gson() val gson = Gson()
companion object { companion object {
@ -61,6 +69,7 @@ class BleBridge(
private const val SCAN_DEVICE = "scan" private const val SCAN_DEVICE = "scan"
private const val SCAN_DEVICE_EKG = "scan_ekg" private const val SCAN_DEVICE_EKG = "scan_ekg"
private const val EKG_FILES_LIST = "ekg_files_list" private const val EKG_FILES_LIST = "ekg_files_list"
private const val BP2_FILES_LIST = "bp2_files_list"
private const val EKG_FILE_DETAIL = "ekg_file_detail" private const val EKG_FILE_DETAIL = "ekg_file_detail"
private const val DISCONNECT_DEVICE = "disconnect_device" private const val DISCONNECT_DEVICE = "disconnect_device"
} }
@ -137,7 +146,10 @@ class BleBridge(
private var rtTask = RtTask() private var rtTask = RtTask()
private var ecgRTHandler = Handler() private var ecgRTHandler = Handler()
private var ecgRTTask = ECGRtTask()
private var br2Handler = Handler()
private var bp2rtTask = Bp2RtTask()
inner class RtTask : Runnable { inner class RtTask : Runnable {
override fun run() { override fun run() {
@ -146,6 +158,13 @@ class BleBridge(
} }
} }
inner class Bp2RtTask : Runnable {
override fun run() {
br2Handler.postDelayed(bp2rtTask, 1000)
BleServiceHelper.BleServiceHelper.startRtTask(model)
}
}
inner class ECGRtTask : Runnable { inner class ECGRtTask : Runnable {
override fun run() { override fun run() {
ecgRTHandler.postDelayed(rtTask, 1000) ecgRTHandler.postDelayed(rtTask, 1000)
@ -153,6 +172,7 @@ class BleBridge(
} }
} }
@SuppressLint("NewApi") @SuppressLint("NewApi")
fun create() { fun create() {
channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL) channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
@ -167,6 +187,8 @@ class BleBridge(
// scanDeviceEKG(methodCall, result) // scanDeviceEKG(methodCall, result)
} else if (methodCall.method == EKG_FILES_LIST) { } else if (methodCall.method == EKG_FILES_LIST) {
getEKGFilesList() getEKGFilesList()
} else if (methodCall.method == BP2_FILES_LIST) {
getBP2FilesList()
} else if (methodCall.method == EKG_FILE_DETAIL) { } else if (methodCall.method == EKG_FILE_DETAIL) {
val fileName = methodCall.arguments; val fileName = methodCall.arguments;
getEKGFileDetail(fileName.toString()) getEKGFileDetail(fileName.toString())
@ -192,148 +214,229 @@ class BleBridge(
BleServiceHelper.BleServiceHelper.disconnect(false) BleServiceHelper.BleServiceHelper.disconnect(false)
} }
fun scanDevice(methodCall: MethodCall, result: MethodChannel.Result) { private fun scanDevice(methodCall: MethodCall, result: MethodChannel.Result) {
println("This is Test of Scanning") println("This is Test of Scanning")
LiveEventBus.get<Boolean>(EventMsgConst.Ble.EventServiceConnectedAndInterfaceInit) LiveEventBus.get<Boolean>(EventMsgConst.Ble.EventServiceConnectedAndInterfaceInit).observe(this.mainActivity) {
.observe(this.mainActivity) { // BleService init success
// BleService init success println("EventServiceConnectedAndInterfaceInit---------")
println("EventServiceConnectedAndInterfaceInit---------") BleServiceHelper.BleServiceHelper.startScan(models)
BleServiceHelper.BleServiceHelper.startScan(models) println("EventServiceConnectedAndInterfaceInit")
println("EventServiceConnectedAndInterfaceInit") }
} LiveEventBus.get<Bluetooth>(EventMsgConst.Discovery.EventDeviceFound).observe(this.mainActivity) {
LiveEventBus.get<Bluetooth>(EventMsgConst.Discovery.EventDeviceFound) var deviceName: String = ""
.observe(this.mainActivity) { for (b in BluetoothController.getDevices()) {
var deviceName: String = "" // println(b.name)
for (b in BluetoothController.getDevices()) { // if (b.name.contains("POD-1_SN8187", true) || b.name.contains(
// println(b.name) // "O2M 1670", true
if (b.name.contains("POD-1_SN8187", true) || b.name.contains( // ) || b.name.contains("DuoEK", true) || b.name.contains("BP2", true)
"O2M 1670", //
true
) || b.name.contains("DuoEK", true) if (b.name.contains("BP2", true)) {
) { println("connecting bp2")
model = b.model
deviceName = b.name model = b.model
BleServiceHelper.BleServiceHelper.setInterfaces(b.model) deviceName = b.name
BleServiceHelper.BleServiceHelper.stopScan() BleServiceHelper.BleServiceHelper.setInterfaces(b.model)
BleServiceHelper.BleServiceHelper.connect( BleServiceHelper.BleServiceHelper.stopScan()
this.mainActivity.applicationContext, BleServiceHelper.BleServiceHelper.connect(
b.model, this.mainActivity.applicationContext, b.model, b.device
b.device )
)
}
} }
}
println("EventDeviceFound") println("EventDeviceFound")
println(deviceName) println(deviceName)
if (deviceName == "POD-1_SN8187") { if (deviceName == "POD-1_SN8187") {
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.PC60Fw.EventPC60FwRtParam) LiveEventBus.get<InterfaceEvent>(InterfaceEvent.PC60Fw.EventPC60FwRtParam).observe(this.mainActivity) {
.observe(this.mainActivity) { val data = it.data as RtParam
val data = it.data as RtParam println("OXY DATA POD-1W: $data")
println("OXY DATA POD-1W: $data") eventSink?.success(data.toString())
eventSink?.success(data.toString())
}
} }
}
if (deviceName.contains("DuoEK", ignoreCase = true)) { if (deviceName.contains("DuoEK", ignoreCase = true)) {
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2Info) LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2Info).observe(this.mainActivity) {
.observe(this.mainActivity) { val data = it.data as DeviceInfo
val data = it.data as DeviceInfo println("DuoEK INFO DATA: $data")
println("DuoEK INFO DATA: $data") val returnData = mapOf("type" to "infoData", "data" to data.toString())
val returnData = mapOf("type" to "infoData", "data" to data.toString()) eventSink?.success(returnData)
eventSink?.success(returnData) }
} LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2FileList).observe(this.mainActivity) {
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2FileList) BleServiceHelper.BleServiceHelper.stopRtTask(model)
.observe(this.mainActivity) { ecgFileNames = it.data as ArrayList<String>
BleServiceHelper.BleServiceHelper.stopRtTask(model) readFile()
ecgFileNames = it.data as ArrayList<String>
readFile()
// val fileNames = it.data as ArrayList<String> // val fileNames = it.data as ArrayList<String>
// println("DuoEK FileNames List: ${fileNames}") // println("DuoEK FileNames List: ${fileNames}")
// val returnData = // val returnData =
// mapOf("type" to "fileList", "data" to fileNames) // mapOf("type" to "fileList", "data" to fileNames)
// eventSink?.success(returnData) // eventSink?.success(returnData)
} }
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2SetTime) LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2SetTime).observe(this.mainActivity) {
.observe(this.mainActivity) { println("EventEr2SetTime")
println("EventEr2SetTime") // Get Device Info
// Get Device Info BleServiceHelper.BleServiceHelper.er2GetInfo(model)
BleServiceHelper.BleServiceHelper.er2GetInfo(model)
// ecgRTTask.run() // ecgRTTask.run()
} }
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2ReadFileComplete) LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2ReadFileComplete).observe(this.mainActivity) {
.observe(this.mainActivity) { println("EventEr2ReadFileComplete")
println("EventEr2ReadFileComplete") val data = it.data as Er2File
val data = it.data as Er2File if (data.fileName.contains("R")) {
if (data.fileName.contains("R")) { val file = Er2EcgFile(data.content)
val file = Er2EcgFile(data.content) val ecgShorts = Er1Decompress.unCompressAlgECG(file.waveData)
val ecgShorts = Er1Decompress.unCompressAlgECG(file.waveData) val ecgData = EcgData()
val ecgData = EcgData() val startTime = DateUtil.getSecondTimestamp(data.fileName.replace("R", ""))
val startTime = DateUtil.getSecondTimestamp(data.fileName.replace("R", "")) ecgData.fileName = data.fileName
ecgData.fileName = data.fileName ecgData.duration = file.recordingTime
ecgData.duration = file.recordingTime ecgData.shortData = ecgShorts
ecgData.shortData = ecgShorts ecgData.startTime = startTime
ecgData.startTime = startTime ecgList.add(ecgData)
ecgList.add(ecgData) print(ecgList)
print(ecgList)
// val returnData = // val returnData =
// mapOf("type" to "fileDetail", "data" to gson.toJson(ecgList)) // mapOf("type" to "fileDetail", "data" to gson.toJson(ecgList))
// eventSink?.success(returnData) // eventSink?.success(returnData)
} }
ecgFileNames.removeAt(0) ecgFileNames.removeAt(0)
readFile() readFile()
} }
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2RtData) LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2RtData).observe(this.mainActivity) {
.observe(this.mainActivity) { val data = it.data as RtData
val data = it.data as RtData println("EventEr2RtData")
println("EventEr2RtData") val returnData = mapOf("type" to "realtimeDataECG", "data" to gson.toJson(data))
val returnData = println(returnData)
mapOf("type" to "realtimeDataECG", "data" to gson.toJson(data)) eventSink?.success(returnData)
println(returnData)
eventSink?.success(returnData)
// DataController.receive(data.wave.ecgFloats) // DataController.receive(data.wave.ecgFloats)
// hr.text = "${data.param.hr}" // hr.text = "${data.param.hr}"
// data_log.text = "${data.param}" // data_log.text = "${data.param}"
// sampling rate125HZ // sampling rate125HZ
// mV = n * 0.002467data.wave.ecgFloats = data.wave.ecgShorts * 0.002467 // mV = n * 0.002467data.wave.ecgFloats = data.wave.ecgShorts * 0.002467
// data.param.batteryState0no charge1charging2charging complete3low battery // data.param.batteryState0no charge1charging2charging complete3low battery
// data.param.battery0-100 // data.param.battery0-100
// data.param.recordTimeunits // data.param.recordTimeunits
// data.param.curStatus0idle1preparing2measuring3saving file4saving succeed // data.param.curStatus0idle1preparing2measuring3saving file4saving succeed
// 5less than 30s, file not saved66 retests7lead off // 5less than 30s, file not saved66 retests7lead off
}
} }
if (deviceName == "O2M 1670") { }
rtHandler.removeCallbacks(rtTask)
rtHandler.post(rtTask) if (deviceName == "O2M 1670") {
rtHandler.removeCallbacks(rtTask)
rtHandler.post(rtTask)
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.Oxy.EventOxyRtParamData) LiveEventBus.get<InterfaceEvent>(InterfaceEvent.Oxy.EventOxyRtParamData).observe(this.mainActivity) {
.observe(this.mainActivity) { val data = it.data as com.lepu.blepro.ext.oxy.RtParam
val data = it.data as com.lepu.blepro.ext.oxy.RtParam println("OXY DATA O2M: $data")
println("OXY DATA O2M: $data") eventSink?.success(data.toString())
eventSink?.success(data.toString())
// tv_oxy.text = data.spo2.toString() // tv_oxy.text = data.spo2.toString()
// tv_pr.text = data.pr.toString() // tv_pr.text = data.pr.toString()
// tv_pi.text = data.pi.toString() // tv_pi.text = data.pi.toString()
// data_log.text = "$data" // data_log.text = "$data"
// data.battery0-100 // data.battery0-100
// data.batteryState0no charge1charging2charging complete // data.batteryState0no charge1charging2charging complete
// data.state0lead off1lead onothererror // data.state0lead off1lead onothererror
} }
}
if (deviceName.contains("BP2", ignoreCase = true)) {
// br2Handler.removeCallbacks(bp2rtTask)
// br2Handler.post(bp2rtTask)
// println("startRtTask")
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.BP2.EventBp2SyncTime).observe(this.mainActivity) {
println("EventBp2SyncTime")
// Get Device Info
BleServiceHelper.BleServiceHelper.bp2GetInfo(model)
}
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.BP2.EventBp2Info).observe(this.mainActivity) {
val data = it.data as com.lepu.blepro.ext.bp2.DeviceInfo
println("BP2 INFO DATA: $data")
val returnData = mapOf("type" to "infoData", "data" to data.toString())
eventSink?.success(returnData)
BleServiceHelper.BleServiceHelper.startRtTask(model)
}
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.BP2.EventBp2FileList).observe(this.mainActivity) {
bpFileNames = it.data as ArrayList<String>
}
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.BP2.EventBp2ReadFileComplete).observe(this.mainActivity) {
val data = it.data as Bp2File
// data.type: 1(BP), 2(ECG)
println("LiveEventBus with BP2 : $data")
if (data.type == 1) {
val file = BpFile(data.content)
// file.measureTimeunits
println("BpFile : $file")
} else if (data.type == 2) {
val file = EcgFile(data.content)
val ecgData = EcgData()
val startTime = DateUtil.getSecondTimestamp(data.fileName)
ecgData.fileName = data.fileName
ecgData.duration = file.recordingTime
ecgData.shortData = Er1Decompress.unCompressAlgECG(file.waveData)
// ecgData.shortData = FilterUtil.getEcgFileFilterData(it.model, data.content)
ecgData.startTime = startTime
ecgList.add(ecgData)
// sampling rate125HZ
// mV = file.waveShortData * 0.003098
// file.measureTimeunits
// file.recordingTimeunits
// file.connectCable: Whether the cable is connected
// file.diagnosisEcgDiagnosis
// diagnosis.isRegularWhether Regular ECG Rhythm
// diagnosis.isPoorSignalWhether Unable to analyze
// diagnosis.isLeadOffWhether Always lead off
// diagnosis.isFastHrWhether Fast Heart Rate
// diagnosis.isSlowHrWhether Slow Heart Rate
// diagnosis.isIrregularWhether Irregular ECG Rhythm
// diagnosis.isPvcsWhether Possible ventricular premature beats
// diagnosis.isHeartPauseWhether Possible heart pause
// diagnosis.isFibrillationWhether Possible Atrial fibrillation
// diagnosis.isWideQrsWhether Wide QRS duration
// diagnosis.isProlongedQtcWhether QTc is prolonged
// diagnosis.isShortQtcWhether QTc is short
println("EcgFile : $file")
}
bpFileNames.removeAt(0)
readFileForBp2()
} }
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.BP2.EventBp2RtData).observe(this.mainActivity) {
val data = it.data as RTBP2Data
// data.status: RtStatus
// data.status.deviceStatus: 0(STATUS_SLEEP), 1(STATUS_MEMERY), 2(STATUS_CHARGE), 3(STATUS_READY),
// 4(STATUS_BP_MEASURING), 5(STATUS_BP_MEASURE_END),
// 6(STATUS_ECG_MEASURING), 7(STATUS_ECG_MEASURE_END), 20(STATUS_VEN)
// data.status.batteryStatus: 0(no charge), 1(charging), 2(charging complete), 3(low battery)
// data.status.percent: 0-100
// data.param: RtParam
// data.param.paramDataType: 0(Bp measuring), 1(Bp end), 2(Ecg measuring), 3(Ecg end)
println("EventBp2RtData FOR BP : $data")
val returnData = mapOf("type" to "RealTimeDataBP2", "data" to gson.toJson(data))
println(returnData)
eventSink?.success(returnData)
}
} }
}
val rawFolders = SparseArray<String>() val rawFolders = SparseArray<String>()
try { try {
BleServiceHelper.BleServiceHelper.initRawFolder(rawFolders) BleServiceHelper.BleServiceHelper.initRawFolder(rawFolders).initService(this.mainActivity.application)
.initService(this.mainActivity.application)
} catch (e: Exception) { } catch (e: Exception) {
println(e) println(e)
@ -342,19 +445,32 @@ class BleBridge(
private fun readFile() { private fun readFile() {
if (ecgFileNames.size == 0) { if (ecgFileNames.size == 0) {
val returnData = val returnData = mapOf("type" to "fileDetail", "data" to gson.toJson(ecgList))
mapOf("type" to "fileDetail", "data" to gson.toJson(ecgList))
eventSink?.success(returnData) eventSink?.success(returnData)
} else { } else {
BleServiceHelper.BleServiceHelper.er2ReadFile(model, ecgFileNames[0]) BleServiceHelper.BleServiceHelper.er2ReadFile(model, ecgFileNames[0])
} }
} }
private fun readFileForBp2() {
if (ecgFileNames.size == 0) {
val returnData = mapOf("type" to "fileDetail", "data" to gson.toJson(ecgList))
eventSink?.success(returnData)
} else {
BleServiceHelper.BleServiceHelper.bp2ReadFile(model, bpFileNames[0])
}
}
private fun getEKGFilesList() { private fun getEKGFilesList() {
//Get EKG File List //Get EKG File List
BleServiceHelper.BleServiceHelper.er2GetFileList(model) BleServiceHelper.BleServiceHelper.er2GetFileList(model)
} }
private fun getBP2FilesList() {
//Get EKG File List
BleServiceHelper.BleServiceHelper.bp2GetFileList(model)
}
private fun getEKGFileDetail(fileName: String) { private fun getEKGFileDetail(fileName: String) {
// readFile() // readFile()
// BleServiceHelper.BleServiceHelper.er2ReadFile(model, fileName) // BleServiceHelper.BleServiceHelper.er2ReadFile(model, fileName)

@ -0,0 +1,12 @@
package com.cloud.diplomaticquarterapp.ble.utils;
public class AlgorithmUtil {
public static native double[] filter(double var0, boolean var2);
public static native short[] shortFilter(short[] var0);
static {
System.loadLibrary("online-lib");
System.loadLibrary("offline-lib");
}
}

@ -0,0 +1,26 @@
//package com.cloud.diplomaticquarterapp.ble.utils;
//
////
//// Source code recreated from a .class file by IntelliJ IDEA
//// (powered by FernFlower decompiler)
////
//
//
//import doac.docd;
//import doag.doad;
//import doag.doae;
//
//public class DecompressUtil {
// private static doad er1Decompress;
// private static doae er3Decompress;
// private static docd waveFile;
// private static int leadType;
//
// public DecompressUtil() {
// }
//
// public static short[] er1Decompress(byte[] var0) {
// return doad. do (var0);
// }
//
//}

@ -0,0 +1,49 @@
//package com.cloud.diplomaticquarterapp.ble.utils;
//
////
//// Source code recreated from a .class file by IntelliJ IDEA
//// (powered by FernFlower decompiler)
////
//
//
//import doac.doba;
//import doac.dobn;
//import doac.docn;
//
//public class FilterUtil {
// public FilterUtil() {
// }
//
// public static short[] getEcgFileFilterData(int var0, byte[] var1) {
// if (var0 != 7 && var0 != 8) {
// if (var0 == 19) {
// return AlgorithmUtil.shortFilter((new doba(var1)).doan());
// }
//
// if (var0 == 52) {
// return AlgorithmUtil.shortFilter((new docn("", var1, "")).doah());
// }
//
// if (var0 != 77 && var0 != 127) {
// if (var0 == 32) {
// return AlgorithmUtil.shortFilter((new doba(var1)).doan());
// }
//
// if (var0 != 33 && var0 != 74 && var0 != 75) {
// switch (var0) {
// case 145:
// case 146:
// case 147:
// case 148:
// case 149:
// break;
// default:
// return new short[0];
// }
// }
// }
// }
//
// return AlgorithmUtil.shortFilter(DecompressUtil.er1Decompress((new dobn(var1)).doad()));
// }
//}

@ -0,0 +1,50 @@
package com.cloud.diplomaticquarterapp.ble.utils;
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
public class HexString {
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
private HexString() {
}
public static String bytesToHex(byte[] var0) {
char[] var1 = new char[var0.length * 2];
for(int var2 = 0; var2 < var0.length; ++var2) {
int var3 = var0[var2] & 255;
int var4 = var2 * 2;
char[] var5;
char[] var10001 = var5 = HEX_ARRAY;
int var10002 = var3;
var1[var4] = var5[var3 >>> 4];
var3 = var4 + 1;
var1[var3] = var10001[var10002 & 15];
}
return new String(var1);
}
public static byte[] hexToBytes(String var0) {
if (var0.length() % 2 == 1) {
throw new IllegalArgumentException("hexToBytes requires an even-length String parameter");
} else {
int var1;
byte[] var2 = new byte[(var1 = var0.length()) / 2];
for(int var3 = 0; var3 < var1; var3 += 2) {
int var4 = var3 / 2;
var2[var4] = (byte)((Character.digit(var0.charAt(var3), 16) << 4) + Character.digit(var0.charAt(var3 + 1), 16));
}
return var2;
}
}
public static String trimStr(String var0) {
return var0.trim();
}
}

@ -0,0 +1,34 @@
package com.cloud.diplomaticquarterapp.ble.utils;
import com.lepu.blepro.ext.bp2.RtParam;
import com.lepu.blepro.ext.bp2.RtStatus;
public class RTBP2Data {
private RtStatus status;
private RtParam param;
public RTBP2Data() {
}
public RtStatus getStatus() {
return this.status;
}
public void setStatus(RtStatus var1) {
this.status = var1;
}
public RtParam getParam() {
return this.param;
}
public void setParam(RtParam var1) {
this.param = var1;
}
public String toString() {
return "RtData{status=" + this.status + ", param=" + this.param + '}';
}
}

@ -19,6 +19,7 @@ import 'package:diplomaticquarterapp/pages/landing/home_page_2.dart';
import 'package:diplomaticquarterapp/pages/medical/medical_profile_page_new.dart'; import 'package:diplomaticquarterapp/pages/medical/medical_profile_page_new.dart';
import 'package:diplomaticquarterapp/pages/medical/my_trackers/ecg_ble.dart'; import 'package:diplomaticquarterapp/pages/medical/my_trackers/ecg_ble.dart';
import 'package:diplomaticquarterapp/pages/medical/my_trackers/spirometer.dart'; import 'package:diplomaticquarterapp/pages/medical/my_trackers/spirometer.dart';
import 'package:diplomaticquarterapp/pages/medical/my_trackers/viatom_devices/bp_tracker_ble.dart';
import 'package:diplomaticquarterapp/pages/medical/my_trackers/viatom_devices/ekg_tracker_ble.dart'; import 'package:diplomaticquarterapp/pages/medical/my_trackers/viatom_devices/ekg_tracker_ble.dart';
import 'package:diplomaticquarterapp/pages/medical/my_trackers/viatom_devices/oxymeter_ble.dart'; import 'package:diplomaticquarterapp/pages/medical/my_trackers/viatom_devices/oxymeter_ble.dart';
import 'package:diplomaticquarterapp/pages/medical/my_trackers/weight_scale_ble.dart'; import 'package:diplomaticquarterapp/pages/medical/my_trackers/weight_scale_ble.dart';
@ -572,7 +573,8 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
}, },
onLoginClick: () { onLoginClick: () {
// login(); // login();
Navigator.push(context, FadePage(page: EKG_BLE())); Navigator.push(context, FadePage(page: BpTrackerBLE()));
// Navigator.push(context, FadePage(page: EKG_BLE()));
}, },
onMedicalFileClick: () { onMedicalFileClick: () {
changeCurrentTab(1); changeCurrentTab(1);

@ -0,0 +1,181 @@
import 'dart:io';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/viatom_ble/ble_connect.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:permission_handler/permission_handler.dart';
class BpTrackerBLE extends StatefulWidget {
@override
State<BpTrackerBLE> createState() => _BpTrackerBLEState();
}
class _BpTrackerBLEState extends State<BpTrackerBLE> {
EventChannel eventChannel = EventChannel('BLE-Platform-Bridge-Event');
String receivedData = '';
final bpDataNotifier = ValueNotifier<String>("start");
// String deviceName = "CheckMeO2";
String deviceName = "BP2";
@override
void dispose() {
bpDataNotifier.dispose();
super.dispose();
BleChannel.disconnect();
}
@override
void initState() {
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return AppScaffold(
appBarTitle: "BP Tracker",
showNewAppBar: true,
isShowDecPage: false,
showNewAppBarTitle: true,
backgroundColor: Color(0xffF8F8F8),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: DefaultButton(
"Get Info",
() async {
checkBLEPermissions();
},
textColor: Colors.white,
),
),
mWidth(16.0),
Expanded(
child: DefaultButton(
"Get Files List",
() async {
await BleChannel.getBP2FilesList(["bloodpressure", "BP2"]);
},
textColor: Colors.white,
),
),
],
),
mHeight(20.0),
// _buildLiveLineChart()
ValueListenableBuilder(
valueListenable: bpDataNotifier,
builder: (context, value, _) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
value,
style: TextStyle(fontSize: 9.0),
),
mHeight(24.0),
getFilesListWidget(),
mHeight(20.0),
],
);
},
),
],
),
),
),
);
}
Widget getFilesListWidget() {
return SizedBox();
// return ListView.separated(
// shrinkWrap: true,
// physics: ScrollPhysics(),
// reverse: true,
// itemBuilder: (context, index) {
// return InkWell(
// onTap: () {
// showEKGFileDetails(ekgFileDetailResponseModelList[index]);
// },
// child: getECGFileCard(ekgFileDetailResponseModelList[index]));
// // child: Text(ekgFileDetailResponseModelList[index].fileName));
// },
// itemCount: ekgFileDetailResponseModelList.length,
// separatorBuilder: (context, index) => SizedBox(height: 14),
// );
}
void checkBLEPermissions() async {
[Permission.location, Permission.storage, Permission.bluetooth, Permission.bluetoothConnect, Permission.bluetoothScan].request().then((status) async {
// startBLEConnection();
eventChannel.receiveBroadcastStream().listen((event) {
print('Received event---: $event');
print(event['type']);
if (event['type'] == "infoData") {
bpDataNotifier.value = event['data'];
}
if (event['type'] == "fileList") {
// parseEKGFilesList(event['data']);
}
if (event['type'] == 'fileDetail') {
print("Received file data ---:");
print(event['data']);
// parseEKGFileDetailObject(event['data']);
}
if (event['type'] == "RealTimeDataBP2") {
bpDataNotifier.value = event['data'];
// parseEKGRealTimeDataObject(event['data']);
}
});
await BleChannel.getScanningResult(["bloodpressure", "BP2"]);
});
}
String getSPO2(String value) {
return "SpO2: " + value.split(",")[0].replaceAll("{spo2=", "");
}
String getPR(String value) {
return "Pulse Rate: " + value.split(",")[1].replaceAll("pr=", "");
}
String getPI(String value) {
return "Perfusion Index: " + value.split(",")[2].replaceAll("pi=", "") + "%";
}
String getSPO2iOS(String value) {
return "SpO2: " + value.split(",")[0];
}
String getPRiOS(String value) {
return "Pulse Rate: " + value.split(",")[1];
}
// List<String> setResult(String value) {
// List<String> values = value.split(",");
//
// print(values[0].replaceAll("{spo2=", ""));
// print(values[1].replaceAll("pr=", ""));
// print(values[2].replaceAll("pi=", ""));
//
// values.clear();
// values.add(values[0].replaceAll("{spo2=", ""));
// values.add(values[1].replaceAll("pr=", ""));
// values.add(values[2].replaceAll("pi=", ""));
//
// return values;
// }
}

@ -3,7 +3,6 @@ import 'package:flutter/services.dart';
class BleChannel { class BleChannel {
static const platform = MethodChannel('BLE-Platform-Bridge'); static const platform = MethodChannel('BLE-Platform-Bridge');
//BLE-Platform-Bridge //BLE-Platform-Bridge
static Future<String> getScanningResult(List<String> deviceType) async { static Future<String> getScanningResult(List<String> deviceType) async {
try { try {
@ -29,6 +28,18 @@ class BleChannel {
} }
} }
static Future<String> getBP2FilesList(List<String> deviceType) async {
try {
print("----------Flutter Init -------");
final String result = await platform.invokeMethod('bp2_files_list', deviceType);
print("----------Flutter Result -------");
print(result);
return result;
} catch (e) {
return "Error: $e";
}
}
static Future<String> getEKGFileDetails(String fileName) async { static Future<String> getEKGFileDetails(String fileName) async {
try { try {
print("----------Flutter Init -------"); print("----------Flutter Init -------");
@ -52,5 +63,4 @@ class BleChannel {
return "Error: $e"; return "Error: $e";
} }
} }
} }

Loading…
Cancel
Save