diff --git a/pos_briefing.py b/pos_briefing.py index 40cc8ac..91e484f 100644 --- a/pos_briefing.py +++ b/pos_briefing.py @@ -504,9 +504,14 @@ def discover_printer(): def print_receipt(raw_bytes): try: - with socket.create_connection((PRINTER_IP, PRINTER_PORT), timeout=10) as sock: + ip = discover_printer() + except Exception as e: + print(f"[!] Printer discovery failed: {e}") + return False + try: + with socket.create_connection((ip, PRINTER_PORT), timeout=10) as sock: sock.sendall(raw_bytes) - print(f"✓ Receipt sent to {PRINTER_IP}:{PRINTER_PORT}") + print(f"✓ Receipt sent to {ip}:{PRINTER_PORT}") return True except Exception as e: print(f"[!] Print failed: {e}")