diff --git a/lib/models/device.dart b/lib/models/device.dart index 3f596e0..9d3a598 100644 --- a/lib/models/device.dart +++ b/lib/models/device.dart @@ -27,6 +27,8 @@ class Device extends Equatable { final DateTime lastUpdated; final String location; final BluetoothDevice bluetoothDevice; + final String activeFirmwareVersion; + final String standbyFirmwareVersion; const Device({ this.condition, @@ -38,7 +40,9 @@ class Device extends Equatable { this.created, this.lastUpdated, this.location, - this.bluetoothDevice + this.bluetoothDevice, + this.activeFirmwareVersion, + this.standbyFirmwareVersion }); @override @@ -53,6 +57,8 @@ class Device extends Equatable { lastUpdated, location, bluetoothDevice, + activeFirmwareVersion, + standbyFirmwareVersion ]; static Device fromJson(dynamic json) { diff --git a/lib/repositories/device_api_client.dart b/lib/repositories/device_api_client.dart index efbfc75..7c25b29 100644 --- a/lib/repositories/device_api_client.dart +++ b/lib/repositories/device_api_client.dart @@ -94,10 +94,7 @@ class DeviceApiClient { body.addAll(response2.sublist(8)); // Remove the 8-byte header final decodedBody = decodeCBOR(body); print('Decoded Response: $decodedBody\n'); - final images = decodedBody[0]['images']; - final image = images[0]; - final version = image['version']; - print('${ version }\n'); + final images = decodedBody[0]['images'] as List; // Return the device state final device = Device( @@ -109,7 +106,9 @@ class DeviceApiClient { locationId: 0, lastUpdated: DateTime.now(), location: '${ bluetoothDevice.name } ${ bluetoothDevice.id.toString() }', - bluetoothDevice: bluetoothDevice + bluetoothDevice: bluetoothDevice, + activeFirmwareVersion: (images.length >= 1) ? images[0]['version'] : '', + standbyFirmwareVersion: (images.length >= 2) ? images[1]['version'] : '', ); return device; } diff --git a/lib/widgets/device_firmware.dart b/lib/widgets/device_firmware.dart new file mode 100644 index 0000000..ab62e52 --- /dev/null +++ b/lib/widgets/device_firmware.dart @@ -0,0 +1,38 @@ +// Widget to display firmware versions in a device +import 'package:flutter/material.dart'; +import '../blocs/blocs.dart'; + +class DeviceFirmware extends StatelessWidget { + final String activeFirmwareVersion; + final String standbyFirmwareVersion; + + DeviceFirmware({ + Key key, + this.activeFirmwareVersion, + this.standbyFirmwareVersion + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + Text( + 'Active Firmware: $activeFirmwareVersion', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w100, + color: Colors.white, + ), + ), + Text( + 'Standby Firmware: $standbyFirmwareVersion', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w100, + color: Colors.white, + ), + ) + ], + ); + } +} diff --git a/lib/widgets/device_summary.dart b/lib/widgets/device_summary.dart index 0353f5b..e5b8b89 100644 --- a/lib/widgets/device_summary.dart +++ b/lib/widgets/device_summary.dart @@ -30,11 +30,9 @@ class DeviceSummary extends StatelessWidget { padding: EdgeInsets.all(20.0), child: BlocBuilder( builder: (context, state) { - return Temperature( - temperature: device.temp, - high: device.maxTemp, - low: device.minTemp, - units: state.temperatureUnits, + return DeviceFirmware( + activeFirmwareVersion: device.activeFirmwareVersion, + standbyFirmwareVersion: device.standbyFirmwareVersion, ); }, ), diff --git a/lib/widgets/widgets.dart b/lib/widgets/widgets.dart index 78b85e7..dc66741 100644 --- a/lib/widgets/widgets.dart +++ b/lib/widgets/widgets.dart @@ -1,6 +1,7 @@ export './city_selection.dart'; export './combined_weather_temperature.dart'; export './device.dart'; +export './device_firmware.dart'; export './device_summary.dart'; export './find_device.dart'; export './gradient_container.dart';