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
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 2m41s
This commit is contained in:
24
lstMobile/src/components/LSTScanner.tsx
Normal file
24
lstMobile/src/components/LSTScanner.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import React from 'react'
|
||||
import { View, Text } from 'react-native'
|
||||
|
||||
export default function LSTScanner() {
|
||||
return (
|
||||
<View><View style={{ alignItems: "center", margin: 10 }}>
|
||||
<Text style={{ fontSize: 20, fontWeight: "600" }}>LST Scanner</Text>
|
||||
</View>
|
||||
<View
|
||||
style={{
|
||||
marginTop: 50,
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Text>Relocate</Text>
|
||||
<Text>0 / 4</Text>
|
||||
</View>
|
||||
|
||||
{/* <View>
|
||||
<Text>List of recent scanned pallets TBA</Text>
|
||||
</View> */}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
31
lstMobile/src/components/ProdScanner.tsx
Normal file
31
lstMobile/src/components/ProdScanner.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import React from 'react'
|
||||
import { View, Text } from 'react-native'
|
||||
import { ScannerTestScreen } from './ScannExample'
|
||||
import { useAppStore } from '../hooks/useAppStore';
|
||||
|
||||
export default function ProdScanner() {
|
||||
const scannerIdFromStore = useAppStore((s) => s.scannerId);
|
||||
return (
|
||||
<View>
|
||||
<View style={{ alignItems: "center", margin: 10 }}>
|
||||
<Text style={{ fontSize: 20, fontWeight: "600" }}>SScanner ID: {scannerIdFromStore}</Text>
|
||||
</View>
|
||||
<View
|
||||
style={{
|
||||
marginTop: 50,
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Text>Relocate</Text>
|
||||
<Text>0 / 4</Text>
|
||||
</View>
|
||||
|
||||
{/* <View>
|
||||
<Text>List of recent scanned pallets TBA</Text>
|
||||
</View> */}
|
||||
<ScannerTestScreen />
|
||||
</View>
|
||||
|
||||
|
||||
)
|
||||
}
|
||||
58
lstMobile/src/components/ScannExample.tsx
Normal file
58
lstMobile/src/components/ScannExample.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user