|
|
|
|
@ -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>(InterfaceEvent.ER2.EventEr2FileList)
|
|
|
|
|
.observe(this.mainActivity) {
|
|
|
|
|
val fileNames = it.data as ArrayList<String>
|
|
|
|
|
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>(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<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()) {
|
|
|
|
|
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>(InterfaceEvent.ER2.EventEr2Info)
|
|
|
|
|
.observe(this.mainActivity) {
|
|
|
|
|
val data = it.data as DeviceInfo
|
|
|
|
|
println("DuoEK INFO DATA: $data")
|
|
|
|
|
}
|
|
|
|
|
LiveEventBus.get<InterfaceEvent>(InterfaceEvent.ER2.EventEr2FileList)
|
|
|
|
|
.observe(this.mainActivity) {
|
|
|
|
|
val fileNames = it.data as ArrayList<String>
|
|
|
|
|
println("DuoEK FileNames List: $fileNames")
|
|
|
|
|
eventSink?.success(fileNames.toString())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LiveEventBus.get<InterfaceEvent>(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)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|