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