Commit 46c72662 authored by Nicolas Richard Walter Boeckh's avatar Nicolas Richard Walter Boeckh 💬

Added Time since last transmission on stats pane.

parent 40a51f18
......@@ -21,6 +21,8 @@ class NetworkHandler {
static final NetworkHandler _singleton = new NetworkHandler._internal();
DateTime _lastServerTransmission;
/// Method to send acquired data packets by using a POST requests.
void _sendDataToServer() async {
/// The default endpoint.
......@@ -61,6 +63,14 @@ class NetworkHandler {
DataHandler().pop();
}
print('RESPONSE ${response.statusCode}');
this._lastServerTransmission = DateTime.now();
}
}
Stream<DateTime> getLastServerConnection() async* {
while (true) {
yield _lastServerTransmission;
await Future.delayed(Duration(seconds: 2));
}
}
}
\ No newline at end of file
import 'package:flutter/material.dart';
import 'package:logair_application/enums/bluetooth_connection_status.dart';
import 'package:logair_application/handlers/bluetooth_le_handler.dart';
import 'package:logair_application/handlers/bluetooth_wake_handler.dart';
import 'package:logair_application/handlers/data_handler.dart';
import 'package:logair_application/handlers/network_handler.dart';
import 'package:logair_application/services/battery_service.dart';
import 'package:logair_application/ui/base_widget.dart';
......@@ -41,7 +43,7 @@ class StatsView extends StatelessWidget {
Text("Data", style: TextStyle(fontFamily: "Consolas", fontSize: 22)),
Spacer( flex: 1, ),
RaisedButton(
onPressed: () => BTLEHandler().switchState(),
onPressed: () => BTWakeHandler().switchState(),
child: Text('Toggle BTLE Service'),
),
Spacer( flex: 1, ),
......@@ -55,12 +57,28 @@ class StatsView extends StatelessWidget {
),
Spacer( flex: 1, ),
StreamBuilder<BluetoothConnectionStatus>(
initialData: null,
stream: BTLEHandler().getConnectionStatus(),
builder: (context, snapshot) {
BluetoothConnectionStatus data = snapshot.data;
return Text(data.toString());
},
),
Spacer( flex: 1, ),
Container(
height: 50,
alignment: Alignment.center,
width: sizingInfo.localWidgetSize.width,
color: Colors.grey[200],
child: StreamBuilder<DateTime>(
initialData: null,
stream: NetworkHandler().getLastServerConnection(),
builder: (context, snapshot) {
DateTime data = snapshot.data;
return Text('Last server connection was ${(data != null) ? data.toLocal() : null}');
},
)
),
],
)
),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment