mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
Add polling interval configuration and improve contact handling
This commit is contained in:
parent
882abf3879
commit
6946b2050e
1 changed files with 15 additions and 3 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue