Scan official MeshCore channel QR codes
The QR scanner only read community codes, so the standard meshcore://channel/add?name=...&secret=... links used by the official app and sites like ipnt.uk were rejected as invalid community codes. The scanner now also accepts channel links. It skips channels already on the radio, asks before adding, and only uses a free slot after the channel sync has finished. Also fills in the 59 untranslated strings in all 17 locales. Fixes #604
This commit is contained in:
1 parent
b6c67b113c
commit
b1e968e7bf
42 files changed
+3816
-1850
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/utils/channel_qr.dart';
|
||||
|
||||
void main() {
|
||||
group('parseChannelQr', () {
|
||||
test('parses the official channel link', () {
|
||||
final result = parseChannelQr(
|
||||
'meshcore://channel/add?name=Public&secret=8b3387e9c5cdea6ac9e5edbaa115cd72',
|
||||
);
|
||||
|
||||
expect(result, isNotNull);
|
||||
expect(result!.name, 'Public');
|
||||
expect(result.psk.length, 16);
|
||||
expect(result.psk[0], 0x8b);
|
||||
expect(result.psk[15], 0x72);
|
||||
});
|
||||
|
||||
test('decodes URL-encoded names and uppercase hex', () {
|
||||
final result = parseChannelQr(
|
||||
'meshcore://channel/add?name=%23ipnet%20test&secret=${'AB' * 16}',
|
||||
);
|
||||
|
||||
expect(result, isNotNull);
|
||||
expect(result!.name, '#ipnet test');
|
||||
expect(result.psk.every((b) => b == 0xab), isTrue);
|
||||
});
|
||||
|
||||
test('ignores the optional region_scope parameter', () {
|
||||
final result = parseChannelQr(
|
||||
'meshcore://channel/add?name=Test&secret=${'00' * 16}®ion_scope=gb-est',
|
||||
);
|
||||
|
||||
expect(result, isNotNull);
|
||||
expect(result!.name, 'Test');
|
||||
});
|
||||
|
||||
test('rejects missing name, bad secret and other links', () {
|
||||
expect(
|
||||
parseChannelQr('meshcore://channel/add?secret=${'00' * 16}'),
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
parseChannelQr('meshcore://channel/add?name=X&secret=abcd'),
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
parseChannelQr('meshcore://channel/add?name=X&secret=${'zz' * 16}'),
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
parseChannelQr('meshcore://contact/add?name=X&public_key=${'00' * 32}'),
|
||||
isNull,
|
||||
);
|
||||
expect(parseChannelQr('https://ipnt.uk/channels'), isNull);
|
||||
expect(parseChannelQr('{"type":"meshcore_community"}'), isNull);
|
||||
expect(parseChannelQr(''), isNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user