MDB Communication Protocal: Difference between revisions

From wizarPOS
No edit summary
(Replaced content with "{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/cloudpos-sdk/mdb-communication-protocal}}")
Tag: Replaced
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Introduction ==
{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/cloudpos-sdk/mdb-communication-protocal}}
This document outlines a serial communication protocol between the application running on Q3v and MDB Vending machines. The Q3v low-level hardware forwards MDB requests from the vending machine to the Android application as serial data. When the application processes all request serial data, the Q3v POS can be regarded as an MDB cashless slave device. Additionally, the application can request configuration commands, such as "get firmware version," making the protocol bi-directional. A mode byte indicates the direction of communication.
 
== Serial Protocol Packet Definition ==
=== Serial Port Parameters ===
* Baud rate 115200
* 8bit, 1 stop bit, and no parity
=== Packet Format===
{| class="wikitable"
|-
| Start code || Length || mode || Data || Checksum || End code
|}
* '''Start code''' size 1 byte, always be 0x09
* '''Length''' size: 1byte, the number bytes of mode, data, and checksum.
* '''Mode''' size: 1, 0x00 means a master request packet, 0x01 means a slave response packet, other value is prohibited.
* '''Data '''size: n bytes. The data could be raw MDB commands, such as SETUP, VEND(please refer the <Multi-Drop Bus Protocol V4.3>for detials).<br>
Or the MIB control commands, such as GET VERSION, SET PARAMETER.
* '''Checksum''' size: 1byte, using LRC algorithm, input data were "mode, data"
 
 
== Specifics ==
=== MDB Forwarding Mechanism ===
The Q3v forwards all MDB cashless device commands except the POLL command. The request and response procedure can be described in the following steps:
# VMC sends MDB request to Q3v.
# Q3v receives the data, removes the 9th MDB mode bit, fills it into the serial packet data part, and sends the serial packet to the application.
# The application listens to the serial port, receives step 2 data, unwraps it to MDB request data, handles it, wraps its MDB response into a serial packet, and sends it to Q3v.
# Q3v receives step 3 data, unwraps it to MDB response data, adds the MDB mode bit, and forwards it to the MDB master.
# MDB master handles the MDB slave response.
 
Taking the '''RESET''' for example
# ''VMC -> q3v: 0x110 0x10''
# ''q3v -> app: 0x09 0x04 0x00 0x10 0x10 0xE0 0x0D''
# ''app -> q3v: 0x09 0x04 0x01 0x00 0x00 0xFF 0x0D''
# ''q3v -> VMC: 0x00 0x100''
# ''VMC -> q3v: 0x00''
=== Application Notes===
* Focus on steps 2 and 3 listed above.
* The application is responsible for handling all cashless commands except the POLL command.
* When the cashless reader is ready for a transaction, it initiates a begin session command to notify the VMC.
* MDB raw data includes its checksum byte (distinct from the serial frame checksum).
 
 
== A Typical MDB Transaction Flow ==
[[File:Mdb flow chart.png|frame|center|MDB transacrion flow]]
 
== Protocol Command Definition ==
=== Common MDB Forwarding Command  ===
Common MDB Forwarding Command Description: This command forwards raw MDB commands (including MDB CHK), with the MDB mode bit removed.
{| class="wikitable"
|-
! Mode !! Data
|-
| Request 00H || VMC Request Command
(Reset,Setup,Reader,Expansion,Vend)
|}
'''Response packet'''<br>
{| class="wikitable"
|-
! Mode!! Data
|-
| Response 01H || Peripheral Response
|}
'''Example:''' <br>
q3v -> app 09 04 00 10 10 E0 0D <br>
 
q3v <- app 09 04 01 00 00 FF 0D.
===  Begin Session Command  ===
Begin Session Command Description: When the application is ready for a transaction, it issues a begin session command to inform the VMC master. This marks the beginning of a transaction. Balance amount is 2 bytes; if balance does not exist, fill with 0xFF. This command follows MDB spec definition but is initiated by the app.
{| class="wikitable"
|-
! Mode !! Data
|-
| Request 00H || Begin Session (03H) + Funds Available + MDB Checksum
|}
'''Response packet'''<br>
{| class="wikitable"
|-
! Mode!! Data
|-
| Response 01H || ACK 00H
|}
'''Example:''' <br>
q3v <- app 09 06 00 03 00 64 67 32 0d <br>
 
q3v -> app 09 03 01 00 ff 0d
=== Session Cancel Request(0x04)  ===
Session Cancel Request (0x04) Description: The application can end a payment session by issuing a session cancel request command. The POS acts as the master during this command.
{| class="wikitable"
|-
! Mode !! Data
|-
| Request 00H || Cancel Session Req(04H) + Funds Available + Checksum
|}
'''Response packet'''<br>
{| class="wikitable"
|-
! Mode!! Data
|-
| Response 01H || ACK 00H
|}
== Demo ==
[http://ftp.wizarpos.com/advanceSDK/MDBTest.zip Source code of terminal APP]
 
[http://ftp.wizarpos.com/advanceSDK/MDBTest_zlh_signed.apk APK]
 
[http://ftp.wizarpos.com/advanceSDK/vmc_master_tool-python-code.zip Source code of PC program]
 
[http://ftp.wizarpos.com/advanceSDK/MDBForCoffeeDemousage20220725.pdf MDBForCoffeeDemo usage]

Latest revision as of 05:30, 8 April 2024

Please visit new link of same subject:

https://smartpossdk.gitbook.io/cloudpossdk/cloudpos-sdk/mdb-communication-protocal

We're making a move! Our site's content is migrating to a new URL, to provide you with an enhanced browsing experience. Please update your bookmarks accordingly. Thank you for your continuous support!