feat: Add RX/TX activity indicators and packet counters; update GPS coordinate conversion

This commit is contained in:
Janez T
2025-10-14 10:46:07 +02:00
parent 62bbb342ec
commit 373998bc7d
6 changed files with 316 additions and 33 deletions

View File

@@ -28,6 +28,19 @@ class ConnectionProvider with ChangeNotifier {
String? _error;
String? get error => _error;
// Activity indicators (for blinking)
bool _rxActivity = false;
bool _txActivity = false;
bool get rxActivity => _rxActivity;
bool get txActivity => _txActivity;
Timer? _rxActivityTimer;
Timer? _txActivityTimer;
// Packet counters
int get rxPacketCount => _bleService.rxPacketCount;
int get txPacketCount => _bleService.txPacketCount;
// Callbacks for other providers
Function(Contact)? onContactReceived;
Function(List<Contact>)? onContactsComplete;
@@ -90,6 +103,31 @@ class ConnectionProvider with ChangeNotifier {
_bleService.onTelemetryReceived = (publicKey, lppData) {
onTelemetryReceived?.call(publicKey, lppData);
};
// Activity indicators
_bleService.onRxActivity = () {
_rxActivity = true;
notifyListeners();
// Reset after 100ms
_rxActivityTimer?.cancel();
_rxActivityTimer = Timer(const Duration(milliseconds: 100), () {
_rxActivity = false;
notifyListeners();
});
};
_bleService.onTxActivity = () {
_txActivity = true;
notifyListeners();
// Reset after 100ms
_txActivityTimer?.cancel();
_txActivityTimer = Timer(const Duration(milliseconds: 100), () {
_txActivity = false;
notifyListeners();
});
};
}
/// Start scanning for MeshCore devices
@@ -269,6 +307,8 @@ class ConnectionProvider with ChangeNotifier {
@override
void dispose() {
_rxActivityTimer?.cancel();
_txActivityTimer?.cancel();
_bleService.dispose();
super.dispose();
}