feat: implement sensor calibration flow
This commit is contained in:
@@ -59,4 +59,36 @@ class PhoenixSensorRepository implements SensorRepository {
|
||||
Stream<Map<String, dynamic>> sensorEvents() => realtime
|
||||
.channelMessages('sensors')
|
||||
.map((m) => {'event': m.event, ...m.payload});
|
||||
|
||||
@override
|
||||
Future<int> beginCalibration(int id) async {
|
||||
final json = await client.beginCalibration(id);
|
||||
return json['samples_needed'] as int;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> startStage(int id, double distance) =>
|
||||
client.startStage(id, distance);
|
||||
|
||||
@override
|
||||
Future<({double rssiRef, double pathLossExp})> finishCalibration(
|
||||
int id) async {
|
||||
final json = await client.finishCalibration(id);
|
||||
return (
|
||||
rssiRef: (json['rssi_ref'] as num).toDouble(),
|
||||
pathLossExp: (json['path_loss_exp'] as num).toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> cancelCalibration(int id) => client.cancelCalibration(id);
|
||||
|
||||
@override
|
||||
Stream<({String event, Map<String, dynamic> payload})> calibrationEvents(
|
||||
String sensorDeviceId) =>
|
||||
realtime.channelMessages('calibration:$sensorDeviceId');
|
||||
|
||||
@override
|
||||
void leaveCalibrationChannel(String sensorDeviceId) =>
|
||||
realtime.leaveChannel('calibration:$sensorDeviceId');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user