mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 17:47:53 +00:00
push sos basic device implementation
This commit is contained in:
34
lib/pages/device_managment/sos/models/sos_status_model.dart
Normal file
34
lib/pages/device_managment/sos/models/sos_status_model.dart
Normal file
@ -0,0 +1,34 @@
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
|
||||
|
||||
class SosStatusModel {
|
||||
final int batteryLevel;
|
||||
final String sosStatus;
|
||||
final String deviceId;
|
||||
|
||||
SosStatusModel({
|
||||
required this.batteryLevel,
|
||||
required this.sosStatus,
|
||||
required this.deviceId,
|
||||
});
|
||||
|
||||
factory SosStatusModel.fromJson(String deviceId, List<Status> statuses) {
|
||||
late int batteryLevel;
|
||||
late String sosStatus;
|
||||
|
||||
for (var status in statuses) {
|
||||
switch (status.code) {
|
||||
case 'battery_percentage':
|
||||
batteryLevel = status.value;
|
||||
break;
|
||||
case 'sos':
|
||||
sosStatus = status.value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return SosStatusModel(
|
||||
deviceId: deviceId,
|
||||
batteryLevel: batteryLevel,
|
||||
sosStatus: sosStatus,
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user