Integrating EKG device

dev_3.3_BLE
haroon amjad 2 years ago
parent 2500441832
commit e52e75aefd

@ -1,5 +1,6 @@
package com.ejada.hmg.utils
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.content.Intent.getIntent
@ -26,6 +27,7 @@ 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.er2.DeviceInfo
import com.lepu.blepro.ext.pc60fw.RtParam
import com.lepu.blepro.objs.Bluetooth
import com.lepu.blepro.objs.BluetoothController
@ -45,6 +47,7 @@ class BleBridge(
private const val CHANNEL = "BLE-Platform-Bridge"
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 DISCONNECT_DEVICE = "disconnect_device"
}
@ -126,6 +129,7 @@ class BleBridge(
}
}
@SuppressLint("NewApi")
fun create() {
channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
Echannel = EventChannel(flutterEngine.dartExecutor.binaryMessenger, EVENTCHANNEL)
@ -135,6 +139,8 @@ class BleBridge(
scanDevice(methodCall, result)
} else if (methodCall.method == DISCONNECT_DEVICE) {
disconnectDevice(methodCall, result)
} else if (methodCall.method == SCAN_DEVICE_EKG) {
scanDeviceEKG(methodCall, result)
} else {
result.notImplemented()
}
@ -175,7 +181,7 @@ class BleBridge(
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
@ -201,6 +207,30 @@ class BleBridge(
}
}
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)
}
}
if (deviceName == "O2M 1670") {
rtHandler.removeCallbacks(rtTask)
rtHandler.post(rtTask)
@ -232,4 +262,65 @@ 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)
}
}
}
}
}

@ -570,8 +570,8 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
changeCurrentTab(1);
},
onLoginClick: () {
// login();
Navigator.push(context, FadePage(page: Oxymeter_BLE()));
login();
// Navigator.push(context, FadePage(page: Oxymeter_BLE()));
},
onMedicalFileClick: () {
changeCurrentTab(1);

@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/pages/medical/my_trackers/blood_suger/blood
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/temperature.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/weight_scale_ble.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -168,6 +169,19 @@ class MyTrackers extends StatelessWidget {
height: 45.0,
),
),
InkWell(
onTap: () {
Navigator.push(context, FadePage(page: EKG_BLE()));
},
child: MedicalProfileItem(
title: "EKG BLE",
imagePath: 'assets/tracker/weight.png',
subTitle: null,
isPngImage: true,
width: 45.0,
height: 45.0,
),
),
],
),
),

@ -0,0 +1,115 @@
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';
class EKG_BLE extends StatefulWidget {
const EKG_BLE();
@override
State<EKG_BLE> createState() => _EKG_BLEState();
}
class _EKG_BLEState extends State<EKG_BLE> {
EventChannel eventChannel = EventChannel('BLE-Platform-Bridge-Event');
String receivedData = '';
final ekgValueNotifier = ValueNotifier<String>("start");
@override
void dispose() {
ekgValueNotifier.dispose();
super.dispose();
BleChannel.disconnect();
}
@override
void initState() {
// TODO: implement initState
super.initState();
eventChannel.receiveBroadcastStream().listen((event) {
print('Received event---: $event');
ekgValueNotifier.value = event;
});
}
@override
Widget build(BuildContext context) {
return AppScaffold(
appBarTitle: "EKG 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 {
await BleChannel.getScanningResultEKG(["oximeter", "ekg"]);
},
textColor: Colors.white,
),
),
mWidth(16.0),
Expanded(
child: DefaultButton(
"Get Files List",
() {},
textColor: Colors.white,
),
),
],
),
mHeight(50.0),
ValueListenableBuilder(
valueListenable: ekgValueNotifier,
builder: (context, value, _) {
return Text(value);
// ? Platform.isAndroid
// ? Column(
// children: [
// Text(
// getSPO2(
// value.toString().replaceAll("RtParam", ""),
// ),
// ),
// Text(
// getPR(
// value.toString().replaceAll("RtParam", ""),
// ),
// ),
// // Text(
// // getPI(
// // value.toString().replaceAll("RtParam", ""),
// // ),
// // ),
// ],
// )
// : Column(
// children: [
// Text(getSPO2iOS(value.toString())),
// Text(getPRiOS(value.toString())),
// ],
// )
// : Text(value);
},
),
],
),
),
),
);
}
}

@ -17,6 +17,18 @@ class BleChannel {
}
}
static Future<String> getScanningResultEKG(List<String> 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<String> disconnect() async {
try {
print("----------Flutter Init -------");

Loading…
Cancel
Save