Machine Communication Flow
The protocol for communicating with the gashapon machine follows a specific command sequence. This section outlines the steps and commands involved in the interaction.
Machine Command Sequence
1. Device Login
The machine logs in to the server using the l command and receives device status information.
2. QR Code Scanning
The machine scans the QR code from the app and sends it to the machine backend for validation. The backend will call your API to validate the QR code.
3. Point Deduction
The backend verifies the user has sufficient points and deducts the appropriate amount.
4. Machine Activation
After point verification, a command is sent to the physical machine to dispense an item.
Important Commands
The following JSON commands are used to control the gashapon machine:
SE Command (Start Execution)
Sent from the machine backend to the gashapon machine to start the dispensing process.
"cmd": "se",
"mid": "MB001", // Mainboard ID
"pid": "P1", // Position ID
"cn": 1 // Number of coins to deduct
}
SER Command (Start Execution Response)
Sent from the gashapon machine to acknowledge receipt of the SE command.
"cmd": "ser",
"mid": "MB001",
"pid": "P1",
"result": "OK" // or "ERROR" with error code
}
ESR Command (Execution Result)
Sent from the gashapon machine after attempting to dispense an item, indicating success or failure.
"cmd": "esr",
"mid": "MB001",
"pid": "P1",
"result": "SUCCESS", // or "FAILURE" with error code
"error_code": "", // Only present if result is FAILURE
"timestamp": "2023-07-14T12:34:56Z"
}
Machine Communication Sequence
This diagram shows the machine communication sequence after QR code validation: