|
|
|
|
@ -9,6 +9,7 @@ import android.os.Build
|
|
|
|
|
import android.os.Bundle
|
|
|
|
|
import android.os.Handler
|
|
|
|
|
import android.provider.Settings
|
|
|
|
|
import android.util.Log
|
|
|
|
|
import android.widget.Toast
|
|
|
|
|
import androidx.core.app.ActivityCompat.startActivityForResult
|
|
|
|
|
import com.ejada.hmg.MainActivity
|
|
|
|
|
@ -19,6 +20,7 @@ import io.flutter.plugin.common.EventChannel
|
|
|
|
|
import android.util.SparseArray
|
|
|
|
|
import androidx.annotation.RequiresApi
|
|
|
|
|
import com.cloud.diplomaticquarterapp.ble.utils.EcgData
|
|
|
|
|
import com.cloud.diplomaticquarterapp.ble.utils.RTBP2Data
|
|
|
|
|
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.InterfaceEvent
|
|
|
|
|
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.Er2EcgFile
|
|
|
|
|
import com.lepu.blepro.ext.er2.Er2File
|
|
|
|
|
@ -51,8 +57,10 @@ class BleBridge(
|
|
|
|
|
private var eventSink: EventChannel.EventSink? = null
|
|
|
|
|
|
|
|
|
|
private var ecgFileNames = arrayListOf<String>()
|
|
|
|
|
private var bpFileNames = arrayListOf<String>()
|
|
|
|
|
var ecgList: ArrayList<EcgData> = arrayListOf()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val gson = Gson()
|
|
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
|
@ -61,6 +69,7 @@ class BleBridge(
|
|
|
|
|
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 BP2_FILES_LIST = "bp2_files_list"
|
|
|
|
|
private const val EKG_FILE_DETAIL = "ekg_file_detail"
|
|
|
|
|
private const val DISCONNECT_DEVICE = "disconnect_device"
|
|
|
|
|
}
|
|
|
|
|
@ -137,7 +146,10 @@ class BleBridge(
|
|
|
|
|
private var rtTask = RtTask()
|
|
|
|
|
|
|
|
|
|
private var ecgRTHandler = Handler()
|
|
|
|
|
private var ecgRTTask = ECGRtTask()
|
|
|
|
|
|
|
|
|
|
private var br2Handler = Handler()
|
|
|
|
|
private var bp2rtTask = Bp2RtTask()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inner class RtTask : Runnable {
|
|
|
|
|
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 {
|
|
|
|
|
override fun run() {
|
|
|
|
|
ecgRTHandler.postDelayed(rtTask, 1000)
|
|
|
|
|
@ -153,6 +172,7 @@ class BleBridge(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("NewApi")
|
|
|
|
|
fun create() {
|
|
|
|
|
channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
|
|
|
|
|
@ -167,6 +187,8 @@ class BleBridge(
|
|
|
|
|
// scanDeviceEKG(methodCall, result)
|
|
|
|
|
} else if (methodCall.method == EKG_FILES_LIST) {
|
|
|
|
|
getEKGFilesList()
|
|
|
|
|
} else if (methodCall.method == BP2_FILES_LIST) {
|
|
|
|
|
getBP2FilesList()
|
|
|
|
|
} else if (methodCall.method == EKG_FILE_DETAIL) {
|
|
|
|
|
val fileName = methodCall.arguments;
|
|
|
|
|
getEKGFileDetail(fileName.toString())
|
|
|
|
|
@ -192,148 +214,229 @@ class BleBridge(
|
|
|
|
|
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")
|
|
|
|
|
LiveEventBus.get<Boolean>(EventMsgConst.Ble.EventServiceConnectedAndInterfaceInit)
|
|
|
|
|
.observe(this.mainActivity) {
|
|
|
|
|
// BleService init success
|
|
|
|
|
println("EventServiceConnectedAndInterfaceInit---------")
|
|
|
|
|
BleServiceHelper.BleServiceHelper.startScan(models)
|
|
|
|
|
println("EventServiceConnectedAndInterfaceInit")
|
|
|
|
|
}
|
|
|
|
|
LiveEventBus.get<Bluetooth>(EventMsgConst.Discovery.EventDeviceFound)
|
|
|
|
|
.observe(this.mainActivity) {
|
|
|
|
|
var deviceName: String = ""
|
|
|
|
|
for (b in BluetoothController.getDevices()) {
|
|
|
|
|
// println(b.name)
|
|
|
|
|
if (b.name.contains("POD-1_SN8187", true) || b.name.contains(
|
|
|
|
|
"O2M 1670",
|
|
|
|
|
true
|
|
|
|
|
) || 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
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
LiveEventBus.get<Boolean>(EventMsgConst.Ble.EventServiceConnectedAndInterfaceInit).observe(this.mainActivity) {
|
|
|
|
|
// BleService init success
|
|
|
|
|
println("EventServiceConnectedAndInterfaceInit---------")
|
|
|
|
|
BleServiceHelper.BleServiceHelper.startScan(models)
|
|
|
|
|
println("EventServiceConnectedAndInterfaceInit")
|
|
|
|
|
}
|
|
|
|
|
LiveEventBus.get<Bluetooth>(EventMsgConst.Discovery.EventDeviceFound).observe(this.mainActivity) {
|
|
|
|
|
var deviceName: String = ""
|
|
|
|
|
for (b in BluetoothController.getDevices()) {
|
|
|
|
|
// println(b.name)
|
|
|
|
|
// if (b.name.contains("POD-1_SN8187", true) || b.name.contains(
|
|
|
|
|
// "O2M 1670", true
|
|
|
|
|
// ) || b.name.contains("DuoEK", true) || b.name.contains("BP2", true)
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
if (b.name.contains("BP2", true)) {
|
|
|
|
|
println("connecting bp2")
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
println("EventDeviceFound")
|
|
|
|
|
println(deviceName)
|
|
|
|
|
|
|
|
|
|
if (deviceName == "POD-1_SN8187") {
|
|
|
|
|
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.PC60Fw.EventPC60FwRtParam)
|
|
|
|
|
.observe(this.mainActivity) {
|
|
|
|
|
val data = it.data as RtParam
|
|
|
|
|
println("OXY DATA POD-1W: $data")
|
|
|
|
|
eventSink?.success(data.toString())
|
|
|
|
|
}
|
|
|
|
|
if (deviceName == "POD-1_SN8187") {
|
|
|
|
|
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.PC60Fw.EventPC60FwRtParam).observe(this.mainActivity) {
|
|
|
|
|
val data = it.data as RtParam
|
|
|
|
|
println("OXY DATA POD-1W: $data")
|
|
|
|
|
eventSink?.success(data.toString())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (deviceName.contains("DuoEK", ignoreCase = true)) {
|
|
|
|
|
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2Info)
|
|
|
|
|
.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>(InterfaceEvent.ER2.EventEr2FileList)
|
|
|
|
|
.observe(this.mainActivity) {
|
|
|
|
|
BleServiceHelper.BleServiceHelper.stopRtTask(model)
|
|
|
|
|
ecgFileNames = it.data as ArrayList<String>
|
|
|
|
|
readFile()
|
|
|
|
|
if (deviceName.contains("DuoEK", ignoreCase = true)) {
|
|
|
|
|
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2Info).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>(InterfaceEvent.ER2.EventEr2FileList).observe(this.mainActivity) {
|
|
|
|
|
BleServiceHelper.BleServiceHelper.stopRtTask(model)
|
|
|
|
|
ecgFileNames = it.data as ArrayList<String>
|
|
|
|
|
readFile()
|
|
|
|
|
// val fileNames = it.data as ArrayList<String>
|
|
|
|
|
// println("DuoEK FileNames List: ${fileNames}")
|
|
|
|
|
// val returnData =
|
|
|
|
|
// mapOf("type" to "fileList", "data" to fileNames)
|
|
|
|
|
// eventSink?.success(returnData)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2SetTime)
|
|
|
|
|
.observe(this.mainActivity) {
|
|
|
|
|
println("EventEr2SetTime")
|
|
|
|
|
// Get Device Info
|
|
|
|
|
BleServiceHelper.BleServiceHelper.er2GetInfo(model)
|
|
|
|
|
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2SetTime).observe(this.mainActivity) {
|
|
|
|
|
println("EventEr2SetTime")
|
|
|
|
|
// Get Device Info
|
|
|
|
|
BleServiceHelper.BleServiceHelper.er2GetInfo(model)
|
|
|
|
|
// ecgRTTask.run()
|
|
|
|
|
}
|
|
|
|
|
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2ReadFileComplete)
|
|
|
|
|
.observe(this.mainActivity) {
|
|
|
|
|
println("EventEr2ReadFileComplete")
|
|
|
|
|
val data = it.data as Er2File
|
|
|
|
|
if (data.fileName.contains("R")) {
|
|
|
|
|
val file = Er2EcgFile(data.content)
|
|
|
|
|
val ecgShorts = Er1Decompress.unCompressAlgECG(file.waveData)
|
|
|
|
|
val ecgData = EcgData()
|
|
|
|
|
val startTime = DateUtil.getSecondTimestamp(data.fileName.replace("R", ""))
|
|
|
|
|
ecgData.fileName = data.fileName
|
|
|
|
|
ecgData.duration = file.recordingTime
|
|
|
|
|
ecgData.shortData = ecgShorts
|
|
|
|
|
ecgData.startTime = startTime
|
|
|
|
|
ecgList.add(ecgData)
|
|
|
|
|
print(ecgList)
|
|
|
|
|
}
|
|
|
|
|
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2ReadFileComplete).observe(this.mainActivity) {
|
|
|
|
|
println("EventEr2ReadFileComplete")
|
|
|
|
|
val data = it.data as Er2File
|
|
|
|
|
if (data.fileName.contains("R")) {
|
|
|
|
|
val file = Er2EcgFile(data.content)
|
|
|
|
|
val ecgShorts = Er1Decompress.unCompressAlgECG(file.waveData)
|
|
|
|
|
val ecgData = EcgData()
|
|
|
|
|
val startTime = DateUtil.getSecondTimestamp(data.fileName.replace("R", ""))
|
|
|
|
|
ecgData.fileName = data.fileName
|
|
|
|
|
ecgData.duration = file.recordingTime
|
|
|
|
|
ecgData.shortData = ecgShorts
|
|
|
|
|
ecgData.startTime = startTime
|
|
|
|
|
ecgList.add(ecgData)
|
|
|
|
|
print(ecgList)
|
|
|
|
|
// val returnData =
|
|
|
|
|
// mapOf("type" to "fileDetail", "data" to gson.toJson(ecgList))
|
|
|
|
|
// eventSink?.success(returnData)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
ecgFileNames.removeAt(0)
|
|
|
|
|
readFile()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2RtData)
|
|
|
|
|
.observe(this.mainActivity) {
|
|
|
|
|
val data = it.data as RtData
|
|
|
|
|
println("EventEr2RtData")
|
|
|
|
|
val returnData =
|
|
|
|
|
mapOf("type" to "realtimeDataECG", "data" to gson.toJson(data))
|
|
|
|
|
println(returnData)
|
|
|
|
|
eventSink?.success(returnData)
|
|
|
|
|
}
|
|
|
|
|
ecgFileNames.removeAt(0)
|
|
|
|
|
readFile()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2RtData).observe(this.mainActivity) {
|
|
|
|
|
val data = it.data as RtData
|
|
|
|
|
println("EventEr2RtData")
|
|
|
|
|
val returnData = mapOf("type" to "realtimeDataECG", "data" to gson.toJson(data))
|
|
|
|
|
println(returnData)
|
|
|
|
|
eventSink?.success(returnData)
|
|
|
|
|
// DataController.receive(data.wave.ecgFloats)
|
|
|
|
|
// hr.text = "${data.param.hr}"
|
|
|
|
|
// data_log.text = "${data.param}"
|
|
|
|
|
|
|
|
|
|
// sampling rate:125HZ
|
|
|
|
|
// mV = n * 0.002467(data.wave.ecgFloats = data.wave.ecgShorts * 0.002467)
|
|
|
|
|
// data.param.batteryState:0(no charge),1(charging),2(charging complete),3(low battery)
|
|
|
|
|
// data.param.battery:0-100
|
|
|
|
|
// data.param.recordTime:unit(s)
|
|
|
|
|
// data.param.curStatus:0(idle),1(preparing),2(measuring),3(saving file),4(saving succeed),
|
|
|
|
|
// 5(less than 30s, file not saved),6(6 retests),7(lead off)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// sampling rate:125HZ
|
|
|
|
|
// mV = n * 0.002467(data.wave.ecgFloats = data.wave.ecgShorts * 0.002467)
|
|
|
|
|
// data.param.batteryState:0(no charge),1(charging),2(charging complete),3(low battery)
|
|
|
|
|
// data.param.battery:0-100
|
|
|
|
|
// data.param.recordTime:unit(s)
|
|
|
|
|
// data.param.curStatus:0(idle),1(preparing),2(measuring),3(saving file),4(saving succeed),
|
|
|
|
|
// 5(less than 30s, file not saved),6(6 retests),7(lead 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)
|
|
|
|
|
.observe(this.mainActivity) {
|
|
|
|
|
val data = it.data as com.lepu.blepro.ext.oxy.RtParam
|
|
|
|
|
println("OXY DATA O2M: $data")
|
|
|
|
|
eventSink?.success(data.toString())
|
|
|
|
|
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.Oxy.EventOxyRtParamData).observe(this.mainActivity) {
|
|
|
|
|
val data = it.data as com.lepu.blepro.ext.oxy.RtParam
|
|
|
|
|
println("OXY DATA O2M: $data")
|
|
|
|
|
eventSink?.success(data.toString())
|
|
|
|
|
// tv_oxy.text = data.spo2.toString()
|
|
|
|
|
// tv_pr.text = data.pr.toString()
|
|
|
|
|
// tv_pi.text = data.pi.toString()
|
|
|
|
|
// data_log.text = "$data"
|
|
|
|
|
// data.battery:0-100
|
|
|
|
|
// data.batteryState:0(no charge),1(charging),2(charging complete)
|
|
|
|
|
// data.state:0(lead off),1(lead on),other(error)
|
|
|
|
|
}
|
|
|
|
|
// data.battery:0-100
|
|
|
|
|
// data.batteryState:0(no charge),1(charging),2(charging complete)
|
|
|
|
|
// data.state:0(lead off),1(lead on),other(error)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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.measureTime:unit(s)
|
|
|
|
|
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 rate:125HZ
|
|
|
|
|
// mV = file.waveShortData * 0.003098
|
|
|
|
|
// file.measureTime:unit(s)
|
|
|
|
|
// file.recordingTime:unit(s)
|
|
|
|
|
// file.connectCable: Whether the cable is connected
|
|
|
|
|
// file.diagnosis:EcgDiagnosis
|
|
|
|
|
// diagnosis.isRegular:Whether Regular ECG Rhythm
|
|
|
|
|
// diagnosis.isPoorSignal:Whether Unable to analyze
|
|
|
|
|
// diagnosis.isLeadOff:Whether Always lead off
|
|
|
|
|
// diagnosis.isFastHr:Whether Fast Heart Rate
|
|
|
|
|
// diagnosis.isSlowHr:Whether Slow Heart Rate
|
|
|
|
|
// diagnosis.isIrregular:Whether Irregular ECG Rhythm
|
|
|
|
|
// diagnosis.isPvcs:Whether Possible ventricular premature beats
|
|
|
|
|
// diagnosis.isHeartPause:Whether Possible heart pause
|
|
|
|
|
// diagnosis.isFibrillation:Whether Possible Atrial fibrillation
|
|
|
|
|
// diagnosis.isWideQrs:Whether Wide QRS duration
|
|
|
|
|
// diagnosis.isProlongedQtc:Whether QTc is prolonged
|
|
|
|
|
// diagnosis.isShortQtc:Whether 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>()
|
|
|
|
|
try {
|
|
|
|
|
BleServiceHelper.BleServiceHelper.initRawFolder(rawFolders)
|
|
|
|
|
.initService(this.mainActivity.application)
|
|
|
|
|
BleServiceHelper.BleServiceHelper.initRawFolder(rawFolders).initService(this.mainActivity.application)
|
|
|
|
|
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|
println(e)
|
|
|
|
|
@ -342,19 +445,32 @@ class BleBridge(
|
|
|
|
|
|
|
|
|
|
private fun readFile() {
|
|
|
|
|
if (ecgFileNames.size == 0) {
|
|
|
|
|
val returnData =
|
|
|
|
|
mapOf("type" to "fileDetail", "data" to gson.toJson(ecgList))
|
|
|
|
|
val returnData = mapOf("type" to "fileDetail", "data" to gson.toJson(ecgList))
|
|
|
|
|
eventSink?.success(returnData)
|
|
|
|
|
} else {
|
|
|
|
|
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() {
|
|
|
|
|
//Get EKG File List
|
|
|
|
|
BleServiceHelper.BleServiceHelper.er2GetFileList(model)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun getBP2FilesList() {
|
|
|
|
|
//Get EKG File List
|
|
|
|
|
BleServiceHelper.BleServiceHelper.bp2GetFileList(model)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun getEKGFileDetail(fileName: String) {
|
|
|
|
|
// readFile()
|
|
|
|
|
// BleServiceHelper.BleServiceHelper.er2ReadFile(model, fileName)
|
|
|
|
|
|