|
|
|
@ -1,5 +1,4 @@
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:math';
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
@ -70,7 +69,7 @@ class _NeighboursScreenState extends State<NeighboursScreen> {
|
|
|
|
// Check if it's a binary response
|
|
|
|
// Check if it's a binary response
|
|
|
|
if (frame[0] == pushCodeBinaryResponse &&
|
|
|
|
if (frame[0] == pushCodeBinaryResponse &&
|
|
|
|
listEquals(frame.sublist(2, 6), _tagData)) {
|
|
|
|
listEquals(frame.sublist(2, 6), _tagData)) {
|
|
|
|
_handleNeighboursResponse(context, connector, frame.sublist(6));
|
|
|
|
_handleNeighboursResponse(connector, frame.sublist(6));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -116,18 +115,14 @@ class _NeighboursScreenState extends State<NeighboursScreen> {
|
|
|
|
return neighbours.values.toList();
|
|
|
|
return neighbours.values.toList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void _handleNeighboursResponse(
|
|
|
|
void _handleNeighboursResponse(MeshCoreConnector connector, Uint8List frame) {
|
|
|
|
BuildContext context,
|
|
|
|
|
|
|
|
MeshCoreConnector connector,
|
|
|
|
|
|
|
|
Uint8List frame,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
final buffer = BufferReader(frame);
|
|
|
|
final buffer = BufferReader(frame);
|
|
|
|
final neighbourCount = buffer.readUInt16LE();
|
|
|
|
final neighbourCount = buffer.readUInt16LE();
|
|
|
|
final parsedNeighbours = parseNeighboursData(buffer, buffer.readUInt16LE());
|
|
|
|
final parsedNeighbours = parseNeighboursData(buffer, buffer.readUInt16LE());
|
|
|
|
connector.contacts.where((c) => c.type == advTypeRepeater).forEach((
|
|
|
|
connector.contacts.where((c) => c.type == advTypeRepeater).forEach((
|
|
|
|
repeater,
|
|
|
|
repeater,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
parsedNeighbours.forEach((neighbourData) {
|
|
|
|
for (var neighbourData in parsedNeighbours) {
|
|
|
|
final publicKey = neighbourData['publicKey'];
|
|
|
|
final publicKey = neighbourData['publicKey'];
|
|
|
|
if (listEquals(
|
|
|
|
if (listEquals(
|
|
|
|
repeater.publicKey.sublist(0, _reqNeighboursKeyLen),
|
|
|
|
repeater.publicKey.sublist(0, _reqNeighboursKeyLen),
|
|
|
|
@ -135,7 +130,7 @@ class _NeighboursScreenState extends State<NeighboursScreen> {
|
|
|
|
)) {
|
|
|
|
)) {
|
|
|
|
neighbourData['contact'] = repeater;
|
|
|
|
neighbourData['contact'] = repeater;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
@ -376,7 +371,9 @@ class _NeighboursScreenState extends State<NeighboursScreen> {
|
|
|
|
_hasData &&
|
|
|
|
_hasData &&
|
|
|
|
!(_parsedNeighbours == null ||
|
|
|
|
!(_parsedNeighbours == null ||
|
|
|
|
_parsedNeighbours!.isEmpty))
|
|
|
|
_parsedNeighbours!.isEmpty))
|
|
|
|
_buildNeighboursInfoCard(l10n.repeater_neighbours),
|
|
|
|
_buildNeighboursInfoCard(
|
|
|
|
|
|
|
|
"${l10n.repeater_neighbours} - $_neighbourCount",
|
|
|
|
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -413,8 +410,12 @@ class _NeighboursScreenState extends State<NeighboursScreen> {
|
|
|
|
_buildInfoRow(
|
|
|
|
_buildInfoRow(
|
|
|
|
entry.value['contact'] != null
|
|
|
|
entry.value['contact'] != null
|
|
|
|
? entry.value['contact'].name
|
|
|
|
? entry.value['contact'].name
|
|
|
|
: 'Unknown (${pubKeyToHex(entry.value['publicKey'])})',
|
|
|
|
: context.l10n.neighbors_unknownContact(
|
|
|
|
'Heard: ${fmtDuration(entry.value['lastHeard'] + 0.0)} ago',
|
|
|
|
"<${pubKeyToHex(entry.value['publicKey'])}>",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
context.l10n.neighbors_heardAgo(
|
|
|
|
|
|
|
|
fmtDuration(entry.value['lastHeard'] + 0.0),
|
|
|
|
|
|
|
|
),
|
|
|
|
entry.value['snr'],
|
|
|
|
entry.value['snr'],
|
|
|
|
connector.currentSf!,
|
|
|
|
connector.currentSf!,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|