feat(scanner): more work on the scanner and can now scan to prod no lst right now
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 2m41s

This commit is contained in:
2026-04-25 18:13:07 -05:00
parent 83a542d1b7
commit 77b4533dea
17 changed files with 615 additions and 43 deletions

View File

@@ -0,0 +1,58 @@
import { useEffect, useState } from "react";
import { Button, Text, View } from "react-native";
import { type ZebraScanResult, zebraScanner } from "../lib/ZebraScanner";
const STX = "\x02";
const ETX = "\x03";
export function ScannerTestScreen() {
const [lastResponse, setLastResponse] = useState("");
const handleScan = async (scan: ZebraScanResult) => {
console.log("Raw Zebra scan:", scan);
const scanned = scan.data;
// Hard-coded command example:
// <stx>98@{scanned}<etx>
const tcpMessage = `${STX}98@${scanned}${ETX}`;
console.log("TCP message to send:", tcpMessage);
console.log("TCP message visible:", `<stx>98@${scanned}<etx>`);
// Later this is where your TCP send goes.
// const response = await sendTcpMessage(tcpMessage);
const fakeResponse = `Would send TCP: <stx>98@${scanned}<etx>`;
console.log("TCP response:", fakeResponse);
setLastResponse(fakeResponse);
};
useEffect(() => {
zebraScanner.ensureProfile();
zebraScanner.startListening();
const sub = zebraScanner.addScanListener((scan) => {
console.log("SCAN:", scan);
handleScan(scan);
});
return () => {
sub.remove();
zebraScanner.stopListening();
};
}, []);
return (
<View style={{ padding: 20, gap: 12 }}>
<Button
title="Soft Trigger Scan"
onPress={() => zebraScanner.triggerScan()}
/>
<Text>Waiting for scan...</Text>
<Text>{lastResponse}</Text>
</View>
);
}