mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
- Added BleCommandQueue to manage command serialization and responses in BleCommandSender. - Updated writeData, writeDataAndWaitForAck, and writeDataAndWaitForResponse methods to utilize the command queue. - Enhanced BleResponseHandler to complete commands based on responses received from the BLE device. - Introduced new commands for channel management, including getChannel and setChannel. - Created LocationTrailLayer and TrailControls widgets for displaying and managing location trails on the map. - Added PermissionRequestDialog to handle location permission requests on app startup. - Updated LocationTrackingService to allow GPS tracking without a BLE connection.
52 lines
1.3 KiB
Dart
52 lines
1.3 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import '../models/channel.dart';
|
|
|
|
/// Manages channel information from the MeshCore device
|
|
class ChannelsProvider with ChangeNotifier {
|
|
final Map<int, Channel> _channels = {};
|
|
|
|
/// Get all channels
|
|
List<Channel> get channels => _channels.values.toList()..sort((a, b) => a.index.compareTo(b.index));
|
|
|
|
/// Get a specific channel by index
|
|
Channel? getChannel(int index) => _channels[index];
|
|
|
|
/// Get the display name for a channel
|
|
String getChannelDisplayName(int index) {
|
|
final channel = _channels[index];
|
|
if (channel != null) {
|
|
return channel.displayName;
|
|
}
|
|
// Fallback if channel hasn't been synced yet
|
|
return index == 0 ? 'Public' : 'Channel $index';
|
|
}
|
|
|
|
/// Add or update a channel
|
|
void addOrUpdateChannel(int index, String name, {int? flags}) {
|
|
_channels[index] = Channel(
|
|
index: index,
|
|
name: name,
|
|
flags: flags,
|
|
);
|
|
notifyListeners();
|
|
}
|
|
|
|
/// Clear all channels
|
|
void clear() {
|
|
_channels.clear();
|
|
notifyListeners();
|
|
}
|
|
|
|
/// Check if channels have been loaded
|
|
bool get hasChannels => _channels.isNotEmpty;
|
|
|
|
/// Get the number of channels
|
|
int get channelCount => _channels.length;
|
|
|
|
@override
|
|
void dispose() {
|
|
_channels.clear();
|
|
super.dispose();
|
|
}
|
|
}
|