ANT-1776 Command Tool
=====================
Document control
----------------
  Title:         ANT-1776 Command Tool - README
  Version:       1.2
  Release date:  14 Oct 2026
  Based on:      ICD 1.0.8.b

Revision history
----------------
  Ver  Date         Change
  1.0  5 Oct 2026   Initial release: Reboot, Get Version, Get/Set Time, Get
                    Temperature, Get Config Number, Factory Default over UDP 3100.
  1.1  5 Oct 2026   Fixed PowerShell parse error (non-ASCII dashes; file now
                    ASCII with BOM).
  1.2  14 Oct 2026  Fixed Reboot/Factory Default confirmation crash (MessageBox
                    default button); Get Temperature decoded as ASCII text; Get
                    Version shows raw bytes and 32-bit little-endian value.

For Antrica Technical Director Les Litwin.

UDP control utility for the ANT-1776 (protocol confirmed on real hardware;
commands from ICD 1.0.8.b). Window title: "ANT-1776 Command Tool v1.2 (14 Oct 2026)".

Files
-----
  ant1776_tool.py          Python Tkinter GUI (stdlib only)
  ant1776_tool.ps1         PowerShell + WinForms GUI (ZERO installs on Windows)
  Run ANT-1776 Tool.bat    Double-click launcher for the PowerShell version
  test_checksum.py         Asserts reboot packet = A5 0F EA 04 0D 0E 0A 0D
  README.txt               This file

How to run on Windows (recommended - no install)
------------------------------------------------
1. Copy this whole folder to the Windows PC.
2. Double-click:  Run ANT-1776 Tool.bat


Uses built-in Windows PowerShell, System.Net.Sockets.UdpClient, and
System.Windows.Forms. No Python, no .NET SDK, no admin rights required
for a normal interactive session.

How to run with Python (if installed)
-------------------------------------
1. Install Python 3 from https://www.python.org/downloads/
   - tick "tcl/tk and IDLE" (needed for the GUI).
2. Open a command prompt in this folder and run:

     python ant1776_tool.py

   Or double-click ant1776_tool.py if .py is associated with Python.

Optional checksum check:

     python ant1776_tool.py --self-check
     python test_checksum.py

Windows .exe
------------
A standalone .exe was NOT built on the Linux build host (no Wine / Windows
Python / PyInstaller cross-build path available in reasonable time).
Use the .bat / .ps1 no-install path above, or the Python script if Python
is present. An .exe can be provided later if built on a Windows machine
with PyInstaller, e.g.:

     pyinstaller --onefile --windowed --name ANT1776_Command_Tool ant1776_tool.py

Usage notes
-----------
- Enter the device IP (default field shows 192.168.0.70), port 3100, timeout 3s.
- Pick a command from the dropdown.
- For "Set Time & Date", parameter fields appear (defaults from local clock).
  Year is entered as full year (e.g. 2026) and sent as last-2-digits-from-2000.
- "Send" transmits the UDP packet and logs hex + decoded ACK/NAK/reply.
- "Build hex only" shows the packet without sending.
- Reboot and Factory Default ask for confirmation first.
- Factory Default and Reboot use magic bytes 0D 0E 0A 0D.
- Confirmed reboot packet: A5 0F EA 04 0D 0E 0A 0D
- Get Temperature: the unit replies with ASCII text plus a terminator
  (e.g. 33 31 00 = "31"), so the tool shows 31 deg C. This differs from the ICD.
- Get Version: the tool shows the raw bytes and the 32-bit little-endian
  value (e.g. 6C C9 01 00 = 117100, likely firmware 1.1.7.1.00 - to be
  confirmed against the web interface).
- The startup log line shows the tool version and release date.

Protocol (summary)
------------------
- UDP port 3100, binary little-endian
- Header 4 bytes: Sync 0xA5, Message ID, Checksum, Data Length
- Checksum = (sum of ALL bytes EXCEPT the checksum byte) & 0xFF
- Set commands reply ACK/NAK: A5 FF <chk> 03 BB|CC <msg_id> <err_byte>
  (ACK=0xBB, NAK=0xCC; do not hardcode checksum/error)

Commands included
-----------------
  15  Reboot System
  11  Get Version
  10  Get Time & Date   (Year field in reply = Year - 1900)
   9  Set Time & Date   (Year byte = last 2 digits from 2000)
 110  Get Temperature
  14  Get Configuration Number
  12  Set Factory Default
