dev_3.3_BLE
haroon amjad 2 years ago
parent e0a54798ba
commit 1bf0f7558d

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

@ -31,6 +31,7 @@ class _AndesFitSpirometerConnectScreenState extends State<AndesFitSpirometerConn
myTrackersVm.valuePEF = null; myTrackersVm.valuePEF = null;
myTrackersVm.valueFEV = null; myTrackersVm.valueFEV = null;
myTrackersVm.isAndesfitDeviceConnected = null; myTrackersVm.isAndesfitDeviceConnected = null;
myTrackersVm.timerForSpirometer.cancel();
myTrackersVm.disConnectAndesfitDevice(widget.deviceModel); myTrackersVm.disConnectAndesfitDevice(widget.deviceModel);
super.dispose(); super.dispose();
} }
@ -64,14 +65,14 @@ class _AndesFitSpirometerConnectScreenState extends State<AndesFitSpirometerConn
children: [ children: [
Text("PEF", style: TextStyle(fontSize: 20)), Text("PEF", style: TextStyle(fontSize: 20)),
Text(myTrackersViewModel.valuePEF.toString(), style: TextStyle(fontSize: 40, fontWeight: FontWeight.bold)), Text(myTrackersViewModel.valuePEF.toString(), style: TextStyle(fontSize: 40, fontWeight: FontWeight.bold)),
Text("", style: TextStyle(fontSize: 15)), Text("L/min", style: TextStyle(fontSize: 15)),
], ],
), ),
Column( Column(
children: [ children: [
Text("FEV", style: TextStyle(fontSize: 20)), Text("FEV", style: TextStyle(fontSize: 20)),
Text(myTrackersViewModel.valueFEV.toString(), style: TextStyle(fontSize: 40, fontWeight: FontWeight.bold)), Text(myTrackersViewModel.valueFEV.toString(), style: TextStyle(fontSize: 40, fontWeight: FontWeight.bold)),
Text("", style: TextStyle(fontSize: 15)), Text("L", style: TextStyle(fontSize: 15)),
], ],
), ),
], ],

@ -14,6 +14,7 @@ import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profil
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class BleDevicesScreen extends StatefulWidget { class BleDevicesScreen extends StatefulWidget {
@ -26,6 +27,7 @@ class _BleDevicesScreenState extends State<BleDevicesScreen> {
@override @override
void dispose() { void dispose() {
FlutterBluePlus.stopScan();
myTrackersVm.resetList(); myTrackersVm.resetList();
super.dispose(); super.dispose();
} }
@ -44,6 +46,7 @@ class _BleDevicesScreenState extends State<BleDevicesScreen> {
} }
void onDeviceTapped(BleDeviceModel device) { void onDeviceTapped(BleDeviceModel device) {
FlutterBluePlus.stopScan();
switch (device.deviceType) { switch (device.deviceType) {
case TrackerTypeEnum.OxymeterTracker: case TrackerTypeEnum.OxymeterTracker:
if (myTrackersVm.isDeviceFromAndesFit(device.name)) { if (myTrackersVm.isDeviceFromAndesFit(device.name)) {

@ -288,7 +288,9 @@ class MyTrackersViewModel extends ChangeNotifier {
} }
Future checkBLEPermissions() async { Future checkBLEPermissions() async {
return [Permission.location, Permission.storage, Permission.bluetooth, Permission.bluetoothConnect, Permission.bluetoothScan].request(); return [Permission.location, Permission.storage, Permission.bluetooth, Permission.bluetoothConnect, Permission.bluetoothScan].request().then((value) {
print(value);
});
} }
Future<void> startSearchingForTracker() async { Future<void> startSearchingForTracker() async {
@ -409,10 +411,11 @@ class MyTrackersViewModel extends ChangeNotifier {
}); });
filterOutTheSearchedDevicesFlutter(bleDevices); filterOutTheSearchedDevicesFlutter(bleDevices);
}); });
FlutterBluePlus.startScan( FlutterBluePlus.startScan(timeout: const Duration(seconds: 10), androidUsesFineLocation: false,
timeout: const Duration(seconds: 10), // withServices: [Guid(BLEUtils.TEMPERATURE_SERVICE)]
androidUsesFineLocation: false, ).catchError((err) {
); debugPrint(err.toString());
});
} }
} }
@ -448,7 +451,7 @@ class MyTrackersViewModel extends ChangeNotifier {
(Timer timer) async { (Timer timer) async {
log("I will stop scan after: $secondsToWaitForNativeScan"); log("I will stop scan after: $secondsToWaitForNativeScan");
if (secondsToWaitForNativeScan == 0) { if (secondsToWaitForNativeScan <= 0) {
secondsToWaitForNativeScan--; secondsToWaitForNativeScan--;
timer.cancel(); timer.cancel();
timerToWaitForNativeScan.cancel(); timerToWaitForNativeScan.cancel();
@ -761,7 +764,7 @@ class MyTrackersViewModel extends ChangeNotifier {
characteristic.onValueReceived.listen((event) { characteristic.onValueReceived.listen((event) {
print("onValueReceived Stream"); print("onValueReceived Stream");
print(event); print(event);
updateCurrentTempInCelsius(convertIntListToHex(event)); updateCurrentTempInCelsius(convertIntListToHexTemp(event));
String currentTempInFahrenheit = ((num.parse(currentTempInCelsius) * 1.8) + 32).toStringAsFixed(1); String currentTempInFahrenheit = ((num.parse(currentTempInCelsius) * 1.8) + 32).toStringAsFixed(1);
String tempCurrentTempInCelsius = currentTempInCelsius + "\u2103" + " / " + currentTempInFahrenheit + "\u2109"; String tempCurrentTempInCelsius = currentTempInCelsius + "\u2103" + " / " + currentTempInFahrenheit + "\u2109";
updateCurrentTempInCelsius(tempCurrentTempInCelsius); updateCurrentTempInCelsius(tempCurrentTempInCelsius);
@ -777,19 +780,33 @@ class MyTrackersViewModel extends ChangeNotifier {
await device.connect(timeout: Duration(seconds: 35)); await device.connect(timeout: Duration(seconds: 35));
} }
String convertIntListToHex(List<int> byteArray) { String convertIntListToHexTemp(List<int> byteArray) {
String b = (byteArray.map((x) { String b = (byteArray.map((x) {
return x.toRadixString(16); return x.toRadixString(16);
})).join(";"); })).join(";");
List<String> hexString = b.split(";"); List<String> hexString = b.split(";");
print("HexString: $hexString"); print("HexString: $hexString");
String returnString = hexString[2] + hexString[3]; String returnString = hexString[3] + hexString[2] + hexString[1];
print("Temp Hex String: $returnString"); print("Temp Hex String: $returnString");
final number = int.parse(returnString, radix: 16); final number = int.parse(returnString, radix: 16);
print("Temp Number: ${number * 0.1}"); print("Temp Number: ${number * 0.01}");
return (number * 0.1).toStringAsFixed(1); return (number * 0.01).toStringAsFixed(1);
} }
// String convertIntListToHex(List<int> byteArray) {
// String b = (byteArray.map((x) {
// return x.toRadixString(16);
// })).join(";");
// List<String> hexString = b.split(";");
// print("HexString: $hexString");
// String returnString = hexString[2] + hexString[3];
// print("Temp Hex String: $returnString");
// final number = int.parse(returnString, radix: 16);
// print("Temp Number: ${number * 0.1}");
//
// return (number * 0.1).toStringAsFixed(1);
// }
StreamSubscription bloodSugarValuesStream; StreamSubscription bloodSugarValuesStream;

@ -32,7 +32,7 @@ class _TemperatureHomePageState extends State<TemperatureHomePage> {
return AppScaffold( return AppScaffold(
appBarTitle: TranslationBase.of(context).temperature, appBarTitle: TranslationBase.of(context).temperature,
showNewAppBar: true, showNewAppBar: true,
isShowDecPage: true, isShowDecPage: false,
showNewAppBarTitle: true, showNewAppBarTitle: true,
backgroundColor: Color(0xffF8F8F8), backgroundColor: Color(0xffF8F8F8),
body: SingleChildScrollView( body: SingleChildScrollView(

Loading…
Cancel
Save