Add polling interval configuration and improve contact handling

This commit is contained in:
Winston Lowe 2026-03-26 16:44:39 -07:00
parent 882abf3879
commit 6946b2050e

View file

@ -193,6 +193,7 @@ class MeshCoreConnector extends ChangeNotifier {
static const int _contactMsgBackoffFallbackMs = 5000;
static const int _contactMsgBackoffMinMs = 500;
static const int _contactMsgBackoffMaxMs = 15000;
int _pollingInterval = 30;
bool _batteryRequested = false;
bool _awaitingSelfInfo = false;
bool _hasReceivedDeviceInfo = false;
@ -2248,9 +2249,19 @@ class MeshCoreConnector extends ChangeNotifier {
_batteryPollTimer = null;
}
void setPollingInterval(int i) {
_pollingInterval = i.clamp(1, 60);
if (isConnected) {
_radioStatsPollRefCount = 0;
_startRadioStatsPolling();
}
}
void _startRadioStatsPolling() {
_radioStatsPollTimer?.cancel();
_radioStatsPollTimer = Timer.periodic(const Duration(seconds: 1), (_) {
_radioStatsPollTimer = Timer.periodic(Duration(seconds: _pollingInterval), (
_,
) {
if (!isConnected) {
_stopRadioStatsPolling();
return;
@ -3753,8 +3764,9 @@ class MeshCoreConnector extends ChangeNotifier {
}
void _handleContact(Uint8List frame, {bool isContact = true}) {
final contact = Contact.fromFrame(frame);
if (contact != null) {
final contactTmp = Contact.fromFrame(frame);
if (contactTmp != null) {
final contact = getFromDiscovered(contactTmp);
_handleDiscovery(contact, frame, noNotify: true, addActive: true);
if (contact.type == advTypeRepeater) {