C SDK Integration
C SDK Only
The functions and information on this page are available only for the C SDK .
The C SDK includes working implementations for:
- Linux
- Windows
- STM32 microcontrollers
If your platform differs, use these implementations as a reference to adapt the SDK accordingly. See the sections below to learn how to integrate the C SDK.
Prerequisites
Before running the C SDK, you need to configure the following:
- Implement a method for reading and writing bytes from the platform's serial port connected to the VPOS. The SDK interacts with the hardware through a serial interface, and the following functions must be implemented:
drv_usart_rx_byte()
: Reads a single byte from the serial port.drv_usart_rx_chunk()
: Reads multiple bytes in one operation.drv_usart_get_rx_pending()
: Returns the number of pending bytes in the serial buffer.drv_usart_tx_data()
: Sends data bytes to the VPOS device.
- A periodic timer tick should be implemented to invoke the function
vmc_link_background()
with an interval of 5 ms to 10 ms. Additionally, the functioncpu_platform_get_time()
should return a continuously incrementing millisecond counter since the system startup.
Verify Communication
Before proceeding to vending operations, ensure that UART communication with VPOS is functional:
- Check for data transmission and reception.
- Validate that event callbacks are triggered correctly.
Integration Steps
To get started with the C SDK, follow the steps below.
you can refer to the provided mymain.c
file a sample code and import the necessary namespaces in your code.
-
Instantiate a VMC configuration object:
vmc_config_t config;
-
Fill in the appropriate fields. The following code block presents a standard configuration:
vmc_init() __strcpy(config.model, "marshall-c-sdk-demo"); __strcpy(config.serial, "01234567"); __strcpy(config.sw_ver, "vmc app version"); __strcpy(config.vmc_hw_ver, “01234567”); __strcpy(config. vmc_manuf_code, “manuf”); config.multi_vend_support = __false; config.multi_session_support = __false; config.price_not_final_support = __false; config.reader_always_on = __false; config.always_idle = __false; config.explicit_vend_success = __false; config.vend_denied_policy = vend_denied_policy_persist_e; config.mifare_approved_by_vmc_support = __false; config.mag_card_approved_by_vmc_support = __false; config.qr_approved_by_vmc_support = __false; config.dump_packets_level = debug_level_dump_none; config.debug = __true;
Mandatory Fields
The customer machine information are mandatory fields for the VMC configuration, these are the
model
,serial
,hw_ver
and themanuf_code
. Read more about these fields in VMC Configuration Object. -
Configure the SDK and register to link events.
vmc_link_register_callback((vmc_link_event_handler_cb_t)vmc_link_event_handler_cb); vmc_vend_register_callback((vmc_vend_event_handler_cb_t)vmc_vend_event_handler_cb);
-
Start the SDK and wait for the
onReady()
event:vmc_link_start()
Implementing Payment Flows
As explained in Payment Flows, the Marshall SDK supports various payment flows. The pages below explain how to implement each in your VMC using the C SDK.
Updated 2 months ago