mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
Open-source Flutter client for MeshCore LoRa mesh networking devices. Features: - BLE device scanning and connection - Nordic UART Service (NUS) integration - Material 3 design with system theme support - Provider-based state management - Placeholder screens for chat, contacts, and settings 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
107 lines
2.6 KiB
Dart
107 lines
2.6 KiB
Dart
enum LoRaBandwidth {
|
|
bw7_8(7800, '7.8 kHz'),
|
|
bw10_4(10400, '10.4 kHz'),
|
|
bw15_6(15600, '15.6 kHz'),
|
|
bw20_8(20800, '20.8 kHz'),
|
|
bw31_25(31250, '31.25 kHz'),
|
|
bw41_7(41700, '41.7 kHz'),
|
|
bw62_5(62500, '62.5 kHz'),
|
|
bw125(125000, '125 kHz'),
|
|
bw250(250000, '250 kHz'),
|
|
bw500(500000, '500 kHz');
|
|
|
|
final int hz;
|
|
final String label;
|
|
|
|
const LoRaBandwidth(this.hz, this.label);
|
|
}
|
|
|
|
enum LoRaSpreadingFactor {
|
|
sf5(5, 'SF5'),
|
|
sf6(6, 'SF6'),
|
|
sf7(7, 'SF7'),
|
|
sf8(8, 'SF8'),
|
|
sf9(9, 'SF9'),
|
|
sf10(10, 'SF10'),
|
|
sf11(11, 'SF11'),
|
|
sf12(12, 'SF12');
|
|
|
|
final int value;
|
|
final String label;
|
|
|
|
const LoRaSpreadingFactor(this.value, this.label);
|
|
}
|
|
|
|
enum LoRaCodingRate {
|
|
cr4_5(5, '4/5'),
|
|
cr4_6(6, '4/6'),
|
|
cr4_7(7, '4/7'),
|
|
cr4_8(8, '4/8');
|
|
|
|
final int value;
|
|
final String label;
|
|
|
|
const LoRaCodingRate(this.value, this.label);
|
|
}
|
|
|
|
class RadioSettings {
|
|
final double frequencyMHz;
|
|
final LoRaBandwidth bandwidth;
|
|
final LoRaSpreadingFactor spreadingFactor;
|
|
final LoRaCodingRate codingRate;
|
|
final int txPowerDbm;
|
|
|
|
RadioSettings({
|
|
required this.frequencyMHz,
|
|
required this.bandwidth,
|
|
required this.spreadingFactor,
|
|
required this.codingRate,
|
|
required this.txPowerDbm,
|
|
});
|
|
|
|
// Preset configurations
|
|
static RadioSettings get preset915MHz => RadioSettings(
|
|
frequencyMHz: 915.0,
|
|
bandwidth: LoRaBandwidth.bw125,
|
|
spreadingFactor: LoRaSpreadingFactor.sf7,
|
|
codingRate: LoRaCodingRate.cr4_5,
|
|
txPowerDbm: 20,
|
|
);
|
|
|
|
static RadioSettings get preset868MHz => RadioSettings(
|
|
frequencyMHz: 868.0,
|
|
bandwidth: LoRaBandwidth.bw125,
|
|
spreadingFactor: LoRaSpreadingFactor.sf7,
|
|
codingRate: LoRaCodingRate.cr4_5,
|
|
txPowerDbm: 14,
|
|
);
|
|
|
|
static RadioSettings get preset433MHz => RadioSettings(
|
|
frequencyMHz: 433.0,
|
|
bandwidth: LoRaBandwidth.bw125,
|
|
spreadingFactor: LoRaSpreadingFactor.sf7,
|
|
codingRate: LoRaCodingRate.cr4_5,
|
|
txPowerDbm: 20,
|
|
);
|
|
|
|
static RadioSettings get presetLongRange => RadioSettings(
|
|
frequencyMHz: 915.0,
|
|
bandwidth: LoRaBandwidth.bw125,
|
|
spreadingFactor: LoRaSpreadingFactor.sf12,
|
|
codingRate: LoRaCodingRate.cr4_8,
|
|
txPowerDbm: 20,
|
|
);
|
|
|
|
static RadioSettings get presetFastSpeed => RadioSettings(
|
|
frequencyMHz: 915.0,
|
|
bandwidth: LoRaBandwidth.bw500,
|
|
spreadingFactor: LoRaSpreadingFactor.sf7,
|
|
codingRate: LoRaCodingRate.cr4_5,
|
|
txPowerDbm: 20,
|
|
);
|
|
|
|
int get frequencyHz => (frequencyMHz * 1000).round();
|
|
int get bandwidthHz => bandwidth.hz;
|
|
int get sf => spreadingFactor.value;
|
|
int get cr => codingRate.value;
|
|
}
|