Skip to content
Snippets Groups Projects
Commit cd759f84 authored by Marvin Weiler's avatar Marvin Weiler
Browse files

resolved merge conflicts

parents b7462e47 2540c69b
No related branches found
No related tags found
1 merge request!7Draft: Resolve "User should be able to specify a min and max value which raw sensor distances should be recorded"
Pipeline #277049 passed
......@@ -399,7 +399,7 @@ class ForegroundTaskHandler extends TaskHandler {
..sensorTwoDistances = s2Data
..sensorOneDistances = s1Data
..confirmedIdx = confirmedIdx
..timestamp = now
..timestamp = now.toUtc()
..batteryVoltage = 4.0 // TODO: get the battery voltage via ble
..latitude = location.latitude
..longitude = location.longitude
......
......@@ -4,6 +4,7 @@ import 'package:app/manager/settings_manager.dart';
import 'package:http/http.dart' as http;
import 'package:http_parser/http_parser.dart';
import 'package:isar/isar.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';
......@@ -82,20 +83,21 @@ class UploadManager {
}
String _genMetadataHeader(Trip trip, int maxMeasurements,
int handlebarDistance, int maxFlightTimeinMicroSec) {
int handlebarDistance, int maxFlightTimeinMicroSec, String appVersion) {
// https://github.com/openbikesensor/OpenBikeSensorFirmware/blob/main/docs/software/firmware/csv_format.md#metadata
final fields = [
"OBSFirmwareVersion=${trip.obsFirmwareRevision}",
"OBSDataFormat=2",
"DataPerMeasurement=3",
"MaximumMeasurementsPerLine=$maxMeasurements",
"OffsetLeft=${handlebarDistance / 2}",
"OffsetRight=${handlebarDistance / 2}",
"OffsetLeft=$handlebarDistance",
"OffsetRight=$handlebarDistance",
"NumberOfDefinedPrivacyAreas=0", // can be 0 as we do not record in privacy areas
"PrivacyLevelApplied=AbsolutePrivacy",
"MaximumValidFlightTimeMicroseconds=$maxFlightTimeinMicroSec",
"DistanceSensorsUsed=HC-SR04/JSN-SR04T", // TODO read from db
"DeviceId=obs-app"
"DeviceId=obs-app-$appVersion",
"TimeZone=UTC"
];
return fields.join("&");
}
......@@ -193,11 +195,16 @@ class UploadManager {
return fields.join(";");
}
String _genCSVFile(
Trip trip, int handlebarDistance, int maxFlightTimeinMicroSec) {
String _genCSVFile(Trip trip, int handlebarDistance, String appVersion,
int maxFlightTimeinMicroSec) {
final maxMeasurements = _maxDistanceForTrip(trip);
final metadata = _genMetadataHeader(
trip, maxMeasurements, handlebarDistance, maxFlightTimeinMicroSec);
trip,
maxMeasurements,
handlebarDistance,
maxFlightTimeinMicroSec,
appVersion,
);
final header = _genCSVHeader(trip, maxMeasurements);
final List<String> rows = [];
......@@ -226,7 +233,9 @@ class UploadManager {
throw Exception("No portal key set");
}
String csvContent = _genCSVFile(trip, handlebarDistance,
final appVersion = (await PackageInfo.fromPlatform()).version;
String csvContent = _genCSVFile(trip, handlebarDistance, appVersion,
maxMeasurements * MICRO_SEC_TO_CM_DIVIDER.toInt());
String filename = "${trip.trackID}_${trip.createdAt.toString()}.csv";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment