add logo, do more aggressive batching
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 3.7 KiB |
|
@ -45,6 +45,7 @@ class MyHomePage extends StatefulWidget {
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
final _barcodeScanner = BarcodeScanner(formats: [BarcodeFormat.qrCode]);
|
final _barcodeScanner = BarcodeScanner(formats: [BarcodeFormat.qrCode]);
|
||||||
|
// late final AnalysisController _scannerController;
|
||||||
final _rxTextController = BehaviorSubject<String>();
|
final _rxTextController = BehaviorSubject<String>();
|
||||||
late final Stream<String> _rxTextStream = _rxTextController.stream;
|
late final Stream<String> _rxTextStream = _rxTextController.stream;
|
||||||
|
|
||||||
|
@ -53,6 +54,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
final HashSet<RaptorPacket> _rxData = HashSet();
|
final HashSet<RaptorPacket> _rxData = HashSet();
|
||||||
String _rxText = '';
|
String _rxText = '';
|
||||||
int _rxCount = 1;
|
int _rxCount = 1;
|
||||||
|
int _bSize = 0;
|
||||||
|
|
||||||
final _formatter = NumberFormat('###,###,###');
|
final _formatter = NumberFormat('###,###,###');
|
||||||
|
|
||||||
|
@ -66,18 +68,19 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: CameraAwesomeBuilder.previewOnly(
|
body: CameraAwesomeBuilder.previewOnly(
|
||||||
|
zoom: 1.5,
|
||||||
onImageForAnalysis: (img) => _processImageBarcode(img),
|
onImageForAnalysis: (img) => _processImageBarcode(img),
|
||||||
imageAnalysisConfig: AnalysisConfig(
|
imageAnalysisConfig: AnalysisConfig(
|
||||||
androidOptions: const AndroidAnalysisOptions.nv21(
|
androidOptions: const AndroidAnalysisOptions.nv21(
|
||||||
width: 600,
|
width: 600,
|
||||||
),
|
),
|
||||||
maxFramesPerSecond: 20,
|
maxFramesPerSecond: 20,
|
||||||
autoStart: false,
|
autoStart: true,
|
||||||
),
|
),
|
||||||
builder: (cameraModeState, previewSize, previewRect) {
|
builder: (cameraModeState, previewSize, previewRect) {
|
||||||
|
//_scannerController = cameraModeState.analysisController!;
|
||||||
return _RxTextDisplayWidget(
|
return _RxTextDisplayWidget(
|
||||||
rxTextStream: _rxTextStream,
|
rxTextStream: _rxTextStream,
|
||||||
analysisController: cameraModeState.analysisController!,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -124,30 +127,42 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
|
|
||||||
case CuttleState.receiving:
|
case CuttleState.receiving:
|
||||||
{
|
{
|
||||||
var txconf = await api.getTxConfig(bytes: dbytes);
|
if (_bSize > 0 && dbytes.length < _bSize) {
|
||||||
if (txconf != null) {
|
|
||||||
await api.dropTxConfig(txc: txconf);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final packet = RaptorPacket(field0: dbytes);
|
if (_bSize == 0) {
|
||||||
_rxData.add(packet);
|
var txconf = await api.getTxConfig(bytes: dbytes);
|
||||||
_rxCount += 1;
|
if (txconf != null) {
|
||||||
if (_rxCount % 40 == 0) {
|
await api.dropTxConfig(txc: txconf);
|
||||||
_rxCount = 1;
|
|
||||||
final content = await api.decodePackets(
|
|
||||||
packets: _rxData.toList(), txconf: _txConfig!);
|
|
||||||
if (content != null) {
|
|
||||||
_rxData.clear();
|
|
||||||
_barcodeScanner.close();
|
|
||||||
_cuttleState = CuttleState.received;
|
|
||||||
_rxTextController.add("DONE RECEIVING $_rxText");
|
|
||||||
final f =
|
|
||||||
await _saveReceivedFile(_txConfig!.filename, content);
|
|
||||||
_rxTextController.add("Saved content to $f");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_bSize = dbytes.length;
|
||||||
|
final packet = RaptorPacket(field0: dbytes);
|
||||||
|
_rxData.add(packet);
|
||||||
|
_rxCount += 1;
|
||||||
final bytesTotal = _rxData.length * dbytes.length;
|
final bytesTotal = _rxData.length * dbytes.length;
|
||||||
|
if (_rxCount % 40 == 0) {
|
||||||
|
_rxCount = 1;
|
||||||
|
|
||||||
|
// if we've not received at least as many bytes as txconf.len,
|
||||||
|
// we cannot have enough bytes to reconstruct, so only try to
|
||||||
|
// decode if we've gotten at least that many
|
||||||
|
if (bytesTotal > _txConfig!.len) {
|
||||||
|
final content = await api.decodePackets(
|
||||||
|
packets: _rxData.toList(), txconf: _txConfig!);
|
||||||
|
if (content != null) {
|
||||||
|
_rxData.clear();
|
||||||
|
_barcodeScanner.close();
|
||||||
|
_cuttleState = CuttleState.received;
|
||||||
|
_rxTextController.add("DONE RECEIVING $_rxText");
|
||||||
|
final f =
|
||||||
|
await _saveReceivedFile(_txConfig!.filename, content);
|
||||||
|
_rxTextController.add("Saved content to $f");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
final pct = (100.0 * bytesTotal / _txConfig!.len).floor();
|
final pct = (100.0 * bytesTotal / _txConfig!.len).floor();
|
||||||
_rxTextController.add(
|
_rxTextController.add(
|
||||||
"$_rxText -- $pct% received (${_formatter.format(bytesTotal)} bytes)");
|
"$_rxText -- $pct% received (${_formatter.format(bytesTotal)} bytes)");
|
||||||
|
@ -176,13 +191,10 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
class _RxTextDisplayWidget extends StatefulWidget {
|
class _RxTextDisplayWidget extends StatefulWidget {
|
||||||
final Stream<String> rxTextStream;
|
final Stream<String> rxTextStream;
|
||||||
|
|
||||||
final AnalysisController analysisController;
|
|
||||||
|
|
||||||
const _RxTextDisplayWidget({
|
const _RxTextDisplayWidget({
|
||||||
// ignore: unused_element
|
// ignore: unused_element
|
||||||
super.key,
|
super.key,
|
||||||
required this.rxTextStream,
|
required this.rxTextStream,
|
||||||
required this.analysisController,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -199,24 +211,6 @@ class _RxTextDisplayWidgetState extends State<_RxTextDisplayWidget> {
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||||
Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: CheckboxListTile(
|
|
||||||
value: widget.analysisController.enabled,
|
|
||||||
onChanged: (newValue) async {
|
|
||||||
if (widget.analysisController.enabled == true) {
|
|
||||||
await widget.analysisController.stop();
|
|
||||||
} else {
|
|
||||||
await widget.analysisController.start();
|
|
||||||
}
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
title: const Text(
|
|
||||||
"Enable barcode scan",
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
Container(
|
||||||
height: 120,
|
height: 120,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
|