feat: implement sensor calibration flow

This commit is contained in:
2026-05-21 16:19:43 +02:00
parent acbba735a0
commit cf3019f484
9 changed files with 1370 additions and 8 deletions
@@ -78,6 +78,12 @@ class RealtimeDataClient {
.map((msg) => (event: msg.event.value, payload: msg.payload ?? const {}));
}
/// Leaves [topic] and removes it from the channel cache.
void leaveChannel(String topic) {
final ch = _channels.remove(topic);
ch?.leave();
}
/// Pushes [event] on [topic] and waits for the server reply.
/// The channel must have been joined first via [channel].
Future<Map<String, dynamic>> push(
+13 -8
View File
@@ -38,17 +38,22 @@ class SensorClient extends LocaliserdClient {
})
as Map<String, dynamic>;
Future<Map<String, dynamic>> startCalibration(
int id,
double referenceDistance,
) async =>
await post('/api/sensors/$id/calibration/start', {
'reference_distance': referenceDistance,
Future<Map<String, dynamic>> beginCalibration(int id) async =>
await post('/api/sensors/$id/calibration/begin') as Map<String, dynamic>;
Future<Map<String, dynamic>> startStage(int id, double distance) async =>
await post('/api/sensors/$id/calibration/stage', {
'distance': distance,
})
as Map<String, dynamic>;
Future<Map<String, dynamic>> stopCalibration(int id) async =>
await post('/api/sensors/$id/calibration/stop') as Map<String, dynamic>;
Future<Map<String, dynamic>> finishCalibration(int id) async =>
await post(
'/api/sensors/$id/calibration/finish',
) as Map<String, dynamic>;
Future<void> cancelCalibration(int id) =>
delete('/api/sensors/$id/calibration');
Future<String> getVersion(int id) async {
final response =