Munsi Bridge - Windows setup
=====================================

The bridge lets Odoo / Munsi POS in this PC's browser use local receipt printers,
label printers (Zebra ZPL, TSC TSPL) and serial scales. It runs as the Windows
service "Munsi Bridge", starts automatically with the PC (before anyone
signs in) and restarts itself if it stops unexpectedly. It listens only on this
PC: http://127.0.0.1:8765.

Install
-------
1. Extract this ZIP to a folder (right-click > Extract All).
2. Double-click "Install Munsi Hardware Bridge.cmd" and approve the administrator prompt.
   If Windows SmartScreen warns about the download, inspect the scripts first,
   then choose More info > Run anyway.
3. Confirm the Odoo address (filled in from the site you downloaded from) and,
   optionally, pick an existing bridge config.json to keep its devices and token.
4. Setup needs Python 3.10+ (offers to install Python 3.13 with winget if missing)
   and internet access for the Python packages pyserial and cryptography.
5. At the end the pairing token is shown and copied to the clipboard.
   In Odoo open Lottery > Hardware Bridge (or Settings > Point of Sale >
   Munsi Hardware Bridge > Pair this PC), paste the token, click Save Pairing.

If an older bridge is running from the tray or a terminal (start-tray / start-local),
setup offers to stop it so the service can use port 8765. Do not start the old
launchers again afterwards.

Where things are
----------------
Program:  C:\Program Files\Munsi\Bridge  (bridge, Python environment, service host)
Settings: C:\ProgramData\Munsi\Bridge    (config.json, jobs.sqlite3, bridge.log, service.log)
          Readable only by SYSTEM and Administrators because it contains the pairing token.

Start menu > Munsi Bridge:
  Munsi Bridge Tray                - show the service controller in the notification area
  Bridge Status and Pairing Token - service state, health, token (Copy), restart
  Edit Bridge Settings            - devices and allowed Odoo addresses (config.json), then restart
  Restart Bridge / Open Bridge Log
  Uninstall Munsi Bridge (also in Settings > Apps)

The tray controller starts at Windows sign-in (quiet installs show it at the
next sign-in). Right-click its icon for Start, Stop, Restart, Edit configuration,
Status and pairing token, and Open log. Double-click to show status and token.
Windows may place it under the hidden-icons arrow next to the clock.
Administrative actions ask for approval. Exit tray closes only the icon; it
does not stop the bridge service. The icon reports service state, not hardware
readiness; use Status and pairing token for the authenticated health check.
This controller manages the installed service; it never starts a second Python
bridge. Do not use the older development start-tray launcher with the service.

Configure devices in config.json under "devices" (see config.example.json in the
program folder), or use Detect Hardware on the Odoo Hardware Bridge page to find them.

Reinstalling or upgrading keeps the settings and pairing token. Uninstall keeps
them too unless you choose to delete them.

Unattended install (administrator PowerShell):
  .\Install-MunsiHardwareBridge.ps1 -Quiet -OdooUrl https://munsi.app [-ImportConfig C:\path\config.json]
