# Access Point This service handles door card issuance and room ticket printing for hotels. It interacts with the card dispenser over serial, the Assa Abloy lock server, and prints receipts. ## Deployment We use Salt for deployment. To build and deploy a new version: 1. **Push your branch** with a meaningful commit message: ```bash git push origin ``` 2. **Tag and build**: ```bash ./tagbuild.sh ``` This script: - Builds the latest `hardlink.exe` binary - Tags the repository with the new version - Copies `hardlink_.exe` to `salt/hardlink/files` 3. **Commit the new binary** in Salt: ```bash cd salt git add hardlink/files/hardlink_.exe git commit -m "added hardlink" git push ``` 4. **Update pillar** (`pillar/hardlink/init.sls`) to point to the new version. 5. **Apply the state** on your hosts: ```bash salt '*' state.apply hardlink ``` ## Configuration Place `config.yml` alongside `hardlink.exe`: ```yaml port: 9091 lockservUrl: "http://192.168.4.109:4000" encoderAddr: "1" dispensPort: "COM9" dispensAddr: "15" printerName: "EPSON TM-T82II Receipt" logdir: "./logs" ``` Provide `TicketLayout.xml` for print layout: ```xml C:/Logo/logo.png Welcome to The Bike and Boot Your room number is This is the hotel details section Check Out Time C:/Logo/Roommaps ``` ## Build & Run ```bash # Install dependencies go mod tidy # Build the executable go build -o hardlink.exe # Run ./hardlink.exe ``` The HTTP server listens on `http://localhost:` (default `9091`). ## API Endpoints ### 1. Issue Door Card - **Endpoint**: `POST /issuedoorcard` - **Headers**: `Content-Type: application/json` - **Body**: ```json { "roomField": "101", "checkinTime": "2025-04-08 11:16:05 +0100", "checkoutTime": "2025-04-08 12:00:00 +0100", "followStr": "0" } ``` - **Responses**: - `200 OK` ```json { "Code": 200, "Message": "Card issued successfully" } ``` - `4XX` / `5XX` ```json { "Code": , "Message": "" } ``` ### 2. Print Room Ticket - **Endpoint**: `POST /printroomticket` - **Headers**: `Content-Type: application/xml` - **Body**: ```xml John Doe 16/05/2025 11:00 am 103 map.png Follow corridor... ``` - **Responses**: - `200 OK` ```json { "Code": 200, "Message": "Print job sent successfully" } ``` - `4XX` / `5XX` ```json { "Code": , "Message": "" } ``` ## Packages ### `main` - Entry point: reads config, sets up logging, initializes dispenser and lock server, loads print layout, and starts HTTP server. ### `dispenser` - Communicates with the card dispenser via serial port. - Commands: check status, move card, eject card. ### `lockserver` - Manages TCP connection to the Assa Abloy lock server. - Sends heartbeat and encoding commands. ### `printer` - Loads `TicketLayout.xml` into `LayoutOptions`. - Provides `printLogo`, `printMap`, `BuildRoomTicket`, `SendToPrinter`. - Converts images to ESC/POS raster commands with dithering and transparency support. ### `cmstypes` - Defines JSON and XML payload structures for door cards and room details. ## Logging Logs are written in JSON format to `/hardlink.log`. --- MIT © FutureSens Systems