mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-27 20:57:31 +10:00
Merge pull request #45 from mtlynch/flutter-analyze
Fix issues flagged by flutter analyze
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
name: Flutter Analyze
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Flutter
|
||||||
|
uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
channel: stable
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: flutter pub get
|
||||||
|
|
||||||
|
- name: Analyze
|
||||||
|
run: flutter analyze --fatal-infos --fatal-warnings
|
||||||
@@ -1766,7 +1766,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
_batteryMillivolts = readUint16LE(frame, 1);
|
_batteryMillivolts = readUint16LE(frame, 1);
|
||||||
final volts = (_batteryMillivolts! / 1000.0).toStringAsFixed(2);
|
final volts = (_batteryMillivolts! / 1000.0).toStringAsFixed(2);
|
||||||
_appDebugLogService?.info(
|
_appDebugLogService?.info(
|
||||||
'Pulled battery: $volts V (${_batteryMillivolts} mV)',
|
'Pulled battery: $volts V ($_batteryMillivolts mV)',
|
||||||
tag: 'Battery',
|
tag: 'Battery',
|
||||||
);
|
);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -2272,7 +2272,6 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
// [6-9] = estimated_timeout_ms (uint32)
|
// [6-9] = estimated_timeout_ms (uint32)
|
||||||
|
|
||||||
if (frame.length >= 10) {
|
if (frame.length >= 10) {
|
||||||
final isFlood = frame[1] != 0;
|
|
||||||
final ackHash = Uint8List.fromList(frame.sublist(2, 6));
|
final ackHash = Uint8List.fromList(frame.sublist(2, 6));
|
||||||
final timeoutMs = readUint32LE(frame, 6);
|
final timeoutMs = readUint32LE(frame, 6);
|
||||||
|
|
||||||
@@ -2618,7 +2617,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
final keyLen = psk.length < 16 ? psk.length : 16;
|
final keyLen = psk.length < 16 ? psk.length : 16;
|
||||||
key16.setRange(0, keyLen, psk);
|
key16.setRange(0, keyLen, psk);
|
||||||
|
|
||||||
final cipher = ECBBlockCipher(AESFastEngine());
|
final cipher = ECBBlockCipher(AESEngine());
|
||||||
cipher.init(false, KeyParameter(key16));
|
cipher.init(false, KeyParameter(key16));
|
||||||
final out = Uint8List(cipherText.length);
|
final out = Uint8List(cipherText.length);
|
||||||
for (var i = 0; i < cipherText.length; i += 16) {
|
for (var i = 0; i < cipherText.length; i += 16) {
|
||||||
@@ -2992,7 +2991,6 @@ const int _phVerMask = 0x03;
|
|||||||
|
|
||||||
const int _routeTransportFlood = 0x00;
|
const int _routeTransportFlood = 0x00;
|
||||||
const int _routeFlood = 0x01;
|
const int _routeFlood = 0x01;
|
||||||
const int _routeDirect = 0x02;
|
|
||||||
const int _routeTransportDirect = 0x03;
|
const int _routeTransportDirect = 0x03;
|
||||||
|
|
||||||
const int _payloadTypeGroupText = 0x05;
|
const int _payloadTypeGroupText = 0x05;
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ void main() async {
|
|||||||
final storage = StorageService();
|
final storage = StorageService();
|
||||||
final connector = MeshCoreConnector();
|
final connector = MeshCoreConnector();
|
||||||
final pathHistoryService = PathHistoryService(storage);
|
final pathHistoryService = PathHistoryService(storage);
|
||||||
final retryService = MessageRetryService(storage);
|
final retryService = MessageRetryService();
|
||||||
final appSettingsService = AppSettingsService();
|
final appSettingsService = AppSettingsService();
|
||||||
final bleDebugLogService = BleDebugLogService();
|
final bleDebugLogService = BleDebugLogService();
|
||||||
final appDebugLogService = AppDebugLogService();
|
final appDebugLogService = AppDebugLogService();
|
||||||
|
|||||||
@@ -388,8 +388,9 @@ class _MapScreenState extends State<MapScreen> {
|
|||||||
if (!contact.hasLocation) continue;
|
if (!contact.hasLocation) continue;
|
||||||
|
|
||||||
// Apply node type filters
|
// Apply node type filters
|
||||||
if (contact.type == advTypeRepeater && !settings.mapShowRepeaters)
|
if (contact.type == advTypeRepeater && !settings.mapShowRepeaters) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (contact.type == advTypeChat && !settings.mapShowChatNodes) continue;
|
if (contact.type == advTypeChat && !settings.mapShowChatNodes) continue;
|
||||||
if (contact.type != advTypeChat &&
|
if (contact.type != advTypeChat &&
|
||||||
contact.type != advTypeRepeater &&
|
contact.type != advTypeRepeater &&
|
||||||
|
|||||||
@@ -895,7 +895,7 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
DropdownButtonFormField<int>(
|
DropdownButtonFormField<int>(
|
||||||
value: _bandwidth,
|
initialValue: _bandwidth,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: l10n.repeater_bandwidth,
|
labelText: l10n.repeater_bandwidth,
|
||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
@@ -917,7 +917,7 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
DropdownButtonFormField<int>(
|
DropdownButtonFormField<int>(
|
||||||
value: _spreadingFactor,
|
initialValue: _spreadingFactor,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: l10n.repeater_spreadingFactor,
|
labelText: l10n.repeater_spreadingFactor,
|
||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
@@ -939,7 +939,7 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
DropdownButtonFormField<int>(
|
DropdownButtonFormField<int>(
|
||||||
value: _codingRate,
|
initialValue: _codingRate,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: l10n.repeater_codingRate,
|
labelText: l10n.repeater_codingRate,
|
||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:math';
|
|
||||||
import 'dart:typed_data';
|
|
||||||
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';
|
||||||
@@ -34,7 +31,6 @@ class _TelemetryScreenState extends State<TelemetryScreen> {
|
|||||||
static const int _statusResponseBytes =
|
static const int _statusResponseBytes =
|
||||||
_statusPayloadOffset + _statusStatsSize;
|
_statusPayloadOffset + _statusStatsSize;
|
||||||
Uint8List _tagData = Uint8List(4);
|
Uint8List _tagData = Uint8List(4);
|
||||||
int _timeEstment = 0;
|
|
||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
bool _isLoaded = false;
|
bool _isLoaded = false;
|
||||||
@@ -64,18 +60,19 @@ class _TelemetryScreenState extends State<TelemetryScreen> {
|
|||||||
|
|
||||||
if (frame[0] == respCodeSent) {
|
if (frame[0] == respCodeSent) {
|
||||||
_tagData = frame.sublist(2, 6);
|
_tagData = frame.sublist(2, 6);
|
||||||
_timeEstment = frame.buffer.asByteData().getUint32(6, Endian.little);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)) {
|
||||||
_handleStatusResponse(context, frame.sublist(6));
|
if (!mounted) return;
|
||||||
|
_handleStatusResponse(frame.sublist(6));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleStatusResponse(BuildContext context, Uint8List frame) {
|
void _handleStatusResponse(Uint8List frame) {
|
||||||
|
if (!mounted) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
_parsedTelemetry = CayenneLpp.parseByChannel(frame);
|
_parsedTelemetry = CayenneLpp.parseByChannel(frame);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -86,14 +86,26 @@ class BleDebugLogService extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _describeFrame(int code, Uint8List frame, bool outgoing, String? note) {
|
String _describeFrame(int code, Uint8List frame, bool outgoing, String? note) {
|
||||||
final label = _codeLabel(code);
|
final label = _codeLabel(code, outgoing: outgoing);
|
||||||
final prefix = outgoing ? 'TX' : 'RX';
|
final prefix = outgoing ? 'TX' : 'RX';
|
||||||
final extra = _frameDetail(code, frame);
|
final extra = _frameDetail(code, frame);
|
||||||
final noteText = note != null ? ' • $note' : '';
|
final noteText = note != null ? ' • $note' : '';
|
||||||
return '$prefix $label$extra$noteText';
|
return '$prefix $label$extra$noteText';
|
||||||
}
|
}
|
||||||
|
|
||||||
String _codeLabel(int code) {
|
String _codeLabel(int code, {required bool outgoing}) {
|
||||||
|
if (outgoing) {
|
||||||
|
return _commandLabel(code) ?? 'CODE_$code';
|
||||||
|
}
|
||||||
|
|
||||||
|
final pushLabel = _pushLabel(code);
|
||||||
|
if (pushLabel != null) return pushLabel;
|
||||||
|
final responseLabel = _responseLabel(code);
|
||||||
|
if (responseLabel != null) return responseLabel;
|
||||||
|
return 'CODE_$code';
|
||||||
|
}
|
||||||
|
|
||||||
|
String? _commandLabel(int code) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case cmdAppStart:
|
case cmdAppStart:
|
||||||
return 'CMD_APP_START';
|
return 'CMD_APP_START';
|
||||||
@@ -135,6 +147,13 @@ class BleDebugLogService extends ChangeNotifier {
|
|||||||
return 'CMD_SET_CHANNEL';
|
return 'CMD_SET_CHANNEL';
|
||||||
case cmdGetRadioSettings:
|
case cmdGetRadioSettings:
|
||||||
return 'CMD_GET_RADIO_SETTINGS';
|
return 'CMD_GET_RADIO_SETTINGS';
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String? _responseLabel(int code) {
|
||||||
|
switch (code) {
|
||||||
case respCodeOk:
|
case respCodeOk:
|
||||||
return 'RESP_CODE_OK';
|
return 'RESP_CODE_OK';
|
||||||
case respCodeErr:
|
case respCodeErr:
|
||||||
@@ -167,6 +186,13 @@ class BleDebugLogService extends ChangeNotifier {
|
|||||||
return 'RESP_CODE_CHANNEL_INFO';
|
return 'RESP_CODE_CHANNEL_INFO';
|
||||||
case respCodeRadioSettings:
|
case respCodeRadioSettings:
|
||||||
return 'RESP_CODE_RADIO_SETTINGS';
|
return 'RESP_CODE_RADIO_SETTINGS';
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String? _pushLabel(int code) {
|
||||||
|
switch (code) {
|
||||||
case pushCodeAdvert:
|
case pushCodeAdvert:
|
||||||
return 'PUSH_CODE_ADVERT';
|
return 'PUSH_CODE_ADVERT';
|
||||||
case pushCodePathUpdated:
|
case pushCodePathUpdated:
|
||||||
@@ -184,7 +210,7 @@ class BleDebugLogService extends ChangeNotifier {
|
|||||||
case pushCodeNewAdvert:
|
case pushCodeNewAdvert:
|
||||||
return 'PUSH_CODE_NEW_ADVERT';
|
return 'PUSH_CODE_NEW_ADVERT';
|
||||||
default:
|
default:
|
||||||
return 'CODE_$code';
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import 'package:crypto/crypto.dart';
|
|||||||
import '../models/contact.dart';
|
import '../models/contact.dart';
|
||||||
import '../models/message.dart';
|
import '../models/message.dart';
|
||||||
import '../models/path_selection.dart';
|
import '../models/path_selection.dart';
|
||||||
import 'storage_service.dart';
|
|
||||||
import 'app_settings_service.dart';
|
import 'app_settings_service.dart';
|
||||||
import 'app_debug_log_service.dart';
|
import 'app_debug_log_service.dart';
|
||||||
|
|
||||||
@@ -36,7 +35,6 @@ class MessageRetryService extends ChangeNotifier {
|
|||||||
static const int maxRetries = 5;
|
static const int maxRetries = 5;
|
||||||
static const int maxAckHistorySize = 100;
|
static const int maxAckHistorySize = 100;
|
||||||
|
|
||||||
final StorageService _storage;
|
|
||||||
final Map<String, Timer> _timeoutTimers = {};
|
final Map<String, Timer> _timeoutTimers = {};
|
||||||
final Map<String, Message> _pendingMessages = {};
|
final Map<String, Message> _pendingMessages = {};
|
||||||
final Map<String, Contact> _pendingContacts = {};
|
final Map<String, Contact> _pendingContacts = {};
|
||||||
@@ -59,7 +57,7 @@ class MessageRetryService extends ChangeNotifier {
|
|||||||
AppDebugLogService? _debugLogService;
|
AppDebugLogService? _debugLogService;
|
||||||
Function(String, PathSelection, bool, int?)? _recordPathResultCallback;
|
Function(String, PathSelection, bool, int?)? _recordPathResultCallback;
|
||||||
|
|
||||||
MessageRetryService(this._storage);
|
MessageRetryService();
|
||||||
|
|
||||||
void initialize({
|
void initialize({
|
||||||
required Function(Contact, String, int, int) sendMessageCallback,
|
required Function(Contact, String, int, int) sendMessageCallback,
|
||||||
|
|||||||
Reference in New Issue
Block a user