46 lines
1.8 KiB
Dart
46 lines
1.8 KiB
Dart
import '../../domain/models/sensor.dart';
|
|
|
|
abstract class SensorRepository {
|
|
Future<Sensor> createSensor(String sensorId, {String? name});
|
|
Future<List<Sensor>> getSensors();
|
|
Future<List<Sensor>> getUnplacedSensors();
|
|
Future<Sensor> getSensor(int id);
|
|
Future<Sensor> updateSensor(int id, {String? name});
|
|
Future<void> deleteSensor(int id);
|
|
Future<Sensor> placeSensor(int id,
|
|
{required int roomId, required double x, required double y});
|
|
Future<Sensor> unplaceSensor(int id);
|
|
|
|
Future<String?> getVersion(int id);
|
|
|
|
/// Stream of raw SensorsChannel messages. Each map contains an `event` key
|
|
/// (`sensor_announced` or `sensor_enrollment_timeout`) plus the payload.
|
|
Stream<Map<String, dynamic>> sensorEvents();
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Calibration
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/// Enters calibration mode on the sensor. Returns the number of samples the
|
|
/// server will collect per stage.
|
|
Future<int> beginCalibration(int id);
|
|
|
|
/// Starts a collection stage at [distance] metres.
|
|
Future<void> startStage(int id, double distance);
|
|
|
|
/// Runs least-squares regression over all completed stages and persists the
|
|
/// result. Returns the fitted (rssiRef, pathLossExp) pair.
|
|
Future<({double rssiRef, double pathLossExp})> finishCalibration(int id);
|
|
|
|
/// Aborts calibration and discards all accumulated stage data.
|
|
Future<void> cancelCalibration(int id);
|
|
|
|
/// Real-time events from the server's CalibrationChannel.
|
|
/// Topic: `calibration:{sensorDeviceId}` (the string BLE device ID).
|
|
Stream<({String event, Map<String, dynamic> payload})> calibrationEvents(
|
|
String sensorDeviceId);
|
|
|
|
/// Leaves the calibration Phoenix channel for [sensorDeviceId].
|
|
void leaveCalibrationChannel(String sensorDeviceId);
|
|
}
|