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:
- Push your branch with a meaningful commit message:
git push origin <branch>
- Tag and build:
This script:./tagbuild.sh
- Builds the latest
hardlink.exe
binary - Tags the repository with the new version
- Copies
hardlink_<tag>.exe
tosalt/hardlink/files
- Builds the latest
- Commit the new binary in Salt:
cd salt git add hardlink/files/hardlink_<tag>.exe git commit -m "added hardlink" git push
- Update pillar (
pillar/hardlink/init.sls
) to point to the new version. - Apply the state on your hosts:
salt '*' state.apply hardlink
Configuration
Place config.yml
alongside hardlink.exe
:
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:
<LayoutOptions>
<LogoPath>C:/Logo/logo.png</LogoPath>
<TopMostText>Welcome to The Bike and Boot</TopMostText>
<BeforeRoomNumberText>Your room number is</BeforeRoomNumberText>
<BeforeDirectionsText></BeforeDirectionsText>
<HotelSpecificDetails>This is the hotel details section</HotelSpecificDetails>
<CheckOutTimeText>Check Out Time</CheckOutTimeText>
<RoomMapFolderPath>C:/Logo/Roommaps</RoomMapFolderPath>
</LayoutOptions>
Build & Run
# Install dependencies
go mod tidy
# Build the executable
go build -o hardlink.exe
# Run
./hardlink.exe
The HTTP server listens on http://localhost:<port>
(default 9091
).
API Endpoints
1. Issue Door Card
- Endpoint:
POST /issuedoorcard
- Headers:
Content-Type: application/json
- Body:
{ "roomField": "101", "checkinTime": "2025-04-08 11:16:05 +0100", "checkoutTime": "2025-04-08 12:00:00 +0100", "followStr": "0" }
- Responses:
200 OK
{ "Code": 200, "Message": "Card issued successfully" }
4XX
/5XX
{ "Code": <status>, "Message": "<error>" }
2. Print Room Ticket
- Endpoint:
POST /printroomticket
- Headers:
Content-Type: application/xml
- Body:
<roomdetails> <customername>John Doe</customername> <checkoutdatetime>16/05/2025 11:00 am</checkoutdatetime> <roomno>103</roomno> <roommap>map.png</roommap> <roomdirections>Follow corridor...</roomdirections> </roomdetails>
- Responses:
200 OK
{ "Code": 200, "Message": "Print job sent successfully" }
4XX
/5XX
{ "Code": <status>, "Message": "<error>" }
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
intoLayoutOptions
. - 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 <logdir>/hardlink.log
.
MIT © FutureSens Systems
Description
Languages
Go
100%