mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-09 02:03:24 +10:00
Add polling interval configuration and improve contact handling
This commit is contained in:
@@ -193,6 +193,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
static const int _contactMsgBackoffFallbackMs = 5000;
|
static const int _contactMsgBackoffFallbackMs = 5000;
|
||||||
static const int _contactMsgBackoffMinMs = 500;
|
static const int _contactMsgBackoffMinMs = 500;
|
||||||
static const int _contactMsgBackoffMaxMs = 15000;
|
static const int _contactMsgBackoffMaxMs = 15000;
|
||||||
|
int _pollingInterval = 30;
|
||||||
bool _batteryRequested = false;
|
bool _batteryRequested = false;
|
||||||
bool _awaitingSelfInfo = false;
|
bool _awaitingSelfInfo = false;
|
||||||
bool _hasReceivedDeviceInfo = false;
|
bool _hasReceivedDeviceInfo = false;
|
||||||
@@ -2248,9 +2249,19 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
_batteryPollTimer = null;
|
_batteryPollTimer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPollingInterval(int i) {
|
||||||
|
_pollingInterval = i.clamp(1, 60);
|
||||||
|
if (isConnected) {
|
||||||
|
_radioStatsPollRefCount = 0;
|
||||||
|
_startRadioStatsPolling();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _startRadioStatsPolling() {
|
void _startRadioStatsPolling() {
|
||||||
_radioStatsPollTimer?.cancel();
|
_radioStatsPollTimer?.cancel();
|
||||||
_radioStatsPollTimer = Timer.periodic(const Duration(seconds: 1), (_) {
|
_radioStatsPollTimer = Timer.periodic(Duration(seconds: _pollingInterval), (
|
||||||
|
_,
|
||||||
|
) {
|
||||||
if (!isConnected) {
|
if (!isConnected) {
|
||||||
_stopRadioStatsPolling();
|
_stopRadioStatsPolling();
|
||||||
return;
|
return;
|
||||||
@@ -3753,8 +3764,9 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handleContact(Uint8List frame, {bool isContact = true}) {
|
void _handleContact(Uint8List frame, {bool isContact = true}) {
|
||||||
final contact = Contact.fromFrame(frame);
|
final contactTmp = Contact.fromFrame(frame);
|
||||||
if (contact != null) {
|
if (contactTmp != null) {
|
||||||
|
final contact = getFromDiscovered(contactTmp);
|
||||||
_handleDiscovery(contact, frame, noNotify: true, addActive: true);
|
_handleDiscovery(contact, frame, noNotify: true, addActive: true);
|
||||||
|
|
||||||
if (contact.type == advTypeRepeater) {
|
if (contact.type == advTypeRepeater) {
|
||||||
|
|||||||
Reference in New Issue
Block a user