Abstract: This paper describes the embedded system design of a mobile phone vending machine based on mobile value-added services. The hardware design presents the vending machine design scheme and briefly introduces the components used. The software design provides a flowchart of the vending machine and a functional overview of the server. Keywords: Mobile phone USSD | Mobile vending machine | GSM/GPRS Introduction The core characteristics of mobile value-added services are mobility, immediacy, and personalization. Mobile value-added services are a new service model that has rapidly developed based on the continuous development and integration of communication technology, computer technology, and Internet technology, driven by the rapid growth of people's information-based application needs, and under the premise of the increasing level of social informatization. Due to the inherent mobility, lack of time and space restrictions, exclusivity, security, and fashion of mobile communication, coupled with the rich and diverse application services based on these characteristics, such as SMS, games, payment, location, and office applications, China's mobile value-added services have rapidly developed from nothing to a thriving industry in just a few years. This system uses an ATmega128 microcontroller as its core for vending machines. It communicates with the server via a BENQ 13SM/GPRS M22 module to implement a mobile value-added service system using mobile payment. In the actual design process, the operation of the vending machine hardware platform at low temperatures was considered. 1. Vending Machine Network Structure Figure 1 outlines the network structure of the mobile vending machine system during actual operation. 2. Hardware Design The vending machine is the terminal interface directly faced by the user. Its main functions are: ① Goods storage and dispensing. The vending machine stores the goods for sale. Taking a beverage machine as an example, it can store up to 300 beverages. The vending machine is equipped with a constant temperature control system and a sealed storage space, effectively ensuring the storage period of goods under various complex climatic conditions. ② Wireless data exchange. The vending machine has wireless communication capabilities, allowing it to interface with existing 3SM/CDMA networks, accepting various wireless communication connections initiated by the network side, and also actively initiating connections to GSM/CDMA networks. Through wireless data exchange, it enables remote wireless control of the vending machine and allows real-time acquisition of the machine's current system status and sales volume, thus ensuring controllability of the entire transaction process. Supported wireless communication methods include SMS, USSD, GPRS, and CDMA 1X. 2.1 Microcontroller Section: The Atmel ATmega128 microcontroller integrates a large-capacity memory and a wealth of powerful hardware interfaces: timers/counters, real-time clock, PWM channel, A/D converter, I2C serial interface, programmable serial USART interface, SPI serial interface, programmable watchdog timer with on-chip crystal oscillator, and on-chip analog comparators. It is highly characterized by its power saving performance, stability, anti-interference performance, and flexibility. The microcontroller system uses a 5V power supply, with an external 24V power supply converted to 5V via an LM2576s chip switching power supply as the system's main power supply. 2.2 LCD Section Jinpeng Technology Co., Ltd.'s OCMJ Chinese module series LCD displays contain GB 2312 16×16 dot matrix Simplified Chinese characters (National Standard Level 1) and ASCII 8×8 (half-height) and 8×16 (full-height) dot matrix English character libraries, eliminating the need for external storage expansion. Users can input zone codes or ASCII codes to display text. This series of modules has commands to move the current display screen up/down/left/right and clear the screen. All initialization settings of the OCMJ Chinese module are automatically completed upon power-on, achieving "plug and play." A dedicated reset line is also provided for forced reset. The 10 user interface command codes are neatly arranged and easy to remember. The hardware interface uses the REQ/BUSY handshake protocol, which is simple and reliable. The OCMJ5X10 module's backlight positive pin requires a large current to ensure LCD brightness, so a 9012 transistor is added for amplification. The selection of the transistor's base resistor must consider the transistor's characteristics at low temperatures to ensure proper LCD driving. 2.3 The GSM/GPRS module uses the BENQ M22 module, as shown in Figure 2. This module uses the standard AT command set, and its normal operating voltage is 3.3–4.3 V. The 5 V VCC is stepped down to approximately 4.3 V by an IN5401 for module use, as shown in Figure 3. Because the GSM/GPRS module has instantaneous pulsating current, a 2200 μF electrolytic capacitor was added during the circuit design to meet the module's instantaneous high current requirements. 2.4 Motor Drive Section and Motor 5×10 Control Array The process of the vending machine dispensing drinks is actually the motor pushing the drinks down. Since motors are inductive, there will be reverse current when they stop, so a PC847 opto-isolator is needed to isolate the control and drive signals, and then an L293D is used to drive the motor. The motor drive requires 24 V. The control signal becomes 24 V after passing through the L293D. A power signal of around V is required to drive the motor. The motor has three wires: power, ground, and feedback signal (a low-level signal is emitted for each rotation of the motor). To control 50 motors, 15 I/O ports of the microcontroller are used, 5 of which are row lines active low and 10 are column lines active high, forming a 5×10 array. When a motor at the intersection of row low and column high moves, it pushes out the goods. In mechanical manufacturing, the motor rotates one revolution to push out a bottle of beverage, generating a feedback signal that stops the motor. Another scenario is that the infrared detector detects goods falling, causing the motor to stop. 2.5 ISP Download Interface: JTAG emulators are expensive; using ISP download with serial port debugging saves costs. The PDI, PDO, SCK, and RESET pins of the ATmegal 28, along with VCC and GND, constitute the ISP interface. The download cable and related software provided by Guangzhou Shuanglong Electronics are used to configure the fuses. From Table 1, it can be seen that if CKSEL3.1 is 111, then an external crystal oscillator of 8... MHz, can be downloaded using an ISP download cable. Use the ATmega28's serial port LJSART1 to communicate with the PC, and display debugging information using a terminal emulator. 3. Vending Machine Software The built-in main control module manages the internal processes of the vending machine, including: dispensing process, transaction data reporting, LCD user interface display, and fault reporting. 3.1 USSD Wireless Communication Mode USSD (Unstructured Supplementary Service Data) is defined as a mechanism for transmitting information and instructions between the mobile station and network applications via the Home Location Register (HLR). It provides a text-based interface for mobile communication users to manage user services. USSD uses the Stand-alone Dedicated Control Channel (SDCCH) during a call (data transmission rate approximately 600 bps; in non-call states, USSD uses the Fast Associated Control Channel (FACCH), with a data transmission rate of approximately 1 kbps, higher than SMS. USSD maintains a communication connection throughout the session, providing a transparent channel without store-and-forward. Similar to GPRS, USSD maintains a session during interaction, eliminating the need to re-establish the channel for each data transmission. Therefore, the USSD system responds instantly to user call requests, significantly accelerating response time. The majority of response latency is shifted to the application server, resulting in a faster response time than SMS. USSD is suitable for smaller data transmission volumes. In interactive sessions, USSD offers intuitive menu operations for user convenience. In a single information service session, users only need to dial the service number and then follow the menu prompts for further operations, enabling the creation of a WAP portal to provide value-added telecommunications services. The USSD interface protocol is similar to that of SMS, using either SMPP or CMPP. SMPP is an internationally used protocol, while CMPP is a protocol developed by China Mobile based on SMPP for my country's specific circumstances. Both have largely the same architecture and application scope, but their data packet formats and content differ somewhat. CMPP has now been upgraded to version 3.0. This system uses CMPP. Messages are divided into a message header and a message body, with a fixed header length. The main information includes the total message length, command type, and message serial number. The command type indicates whether the message is a connection or a transmission from the USSD center to the Service Provider (SP). Messages from the Provider or from the SP to the USSD center, etc. Message serial numbers are sequentially incremented with a step size of 1, used cyclically, and a pair of request and response message serial numbers must be the same. There is a status message indicating whether the request message response was successful. The length and data of the message body are determined by the message type and content, but the length of its custom information does not exceed 160 bytes. Custom information refers to the content of short messages entered or received by mobile phones or the custom communication protocol part in industrial communication. Compared with SMPP, CMPP adds a lot of information, especially billing and number information. 3.2 Vending Machine Program Design The program of the vending machine control board is written in C language, and the development environment is ICCAVR provided by Atmel. The control board program flowchart is shown in Figure 4. 3.3 Vending Machine Transaction Flowchart The transaction flow of the vending machine is shown in Figure 5. Since PHS cannot use real-time data transmission methods such as USSD and GPRS, IVR (Interactive Voice Response) is adopted. ① The user sends a shopping request through IVR/SMS, and the IVR/SMS platform forwards the user request to the application server. ② The application server parses the user's instructions, and after finding out the product type, price, and other information in the database based on the vending machine number and channel number entered by the user, it performs user authentication and deduction/points deduction operations to the BOSS system. ③ The BOSS system notifies the application server that the deduction/points deduction is successful. ④ The application server sends a control command to the vending machine via GPRS, requesting the vending machine to dispense the product specified by the user. ⑤ The vending machine dispenses the product, and the user successfully obtains the product. ⑥ The vending machine notifies the application server of the successful transaction via GPRS. ⑦ The application server sends an SMS to the user, informing the user of the transaction details. 4 Server Introduction The application server mainly implements the background management of the entire business. (1) Transaction process management The orderly management of the entire process from the user issuing a shopping request to the product being dispensed and the implementation of various transaction failure recovery processes. (2) Logistics management The server manages the sales and inventory of all vending machine products managed by the server, and can realize real-time automatic allocation and notification of logistics personnel. ① Statistical Analysis. Business operations are statistically analyzed daily, weekly, and monthly (or as specified), including sales, malfunctions, deductions/points, reconciliation, and logistics staff workload. This detailed analysis is provided for management reference. ② Billing and Reconciliation. Integration with the mobile BOSS system enables both phone bill payment and points payment. Automatic daily reconciliation is performed, automatically comparing each transaction and sending SMS alerts when discrepancies exceed expectations. Conclusion This system has been put into production and has achieved good results in practical use. Mobile value-added services from mobile vending machines represent a new business model and market channel with a large customer base. Due to the mobility, convenience, and security of mobile e-commerce, it will inevitably attract numerous merchants and customers to utilize it for business and consumption activities. This will lead to the formation of a mobile value chain, successfully binding users and integrating it into all sectors of society, making mobile indispensable to all industries, ultimately creating a "win-win" situation. Banks extend their influence through mobile e-commerce platforms, creating pocket-sized financial assistants.