API description: Difference between revisions

From wizarPOS
No edit summary
No edit summary
Line 1: Line 1:
==== Functions ====
== API Overview==
The calling sequence is open>query_status>begin>write>end>close.
  This document provides an introduction to the C APIs. C API is the lowest API, it provided by the POS driver, it packaged all the API implement in a so file, named "libUnionpayCloudPos.so".
===== open =====
  The third app should open this so file then call this API in its' C source code according as the corresponding head file.
   int printer_open()
=== Print ===
 
   Introduce the [[API]] of the printer device.The head file name is [[printer_interface.h]]
Open the printer device.This operation should be used before other operations.
=== Contactless reader ===
 
   Introduce the API of the contactless reader device.
'''Parameters'''
=== Cash Drawder ===
 
   Introduce the API about hwo to interaction with the external cash Drawder device.
'''Returns'''
=== Fingerprint ===
 
   Introduce the API of the fingerprinter device.
The result code, >= 0, success; <0 [[Error_code|error code]].
=== HSM ===
   Introduce the API of the HSM module.
===== begin =====
=== HDMI ===
   int printer_begin()
Introduce the API about how to interaction with the HDMIdevice.
Prepare to print, the app should print data after this funciton.
=== LED ===
 
Introduce the API of the LED device.
'''Parameters'''
=== MSR reader ===
 
   Introduce the API of the MSR reader device.
'''Returns'''
=== PINPAD ===
 
  Introduce the API of the PINPAD device.
The result code, >= 0, success; <0 [[Error_code|error code]].
=== Secondary display ===
 
Introduce the API about hwo to interaction with the external secondary display device.
===== end =====
=== Serial Port ===
   int printer_end()
Introduce the API of the serial port device.
End to print,the begin and end apis are pair operations.
=== Smart Card reader ===
 
   Introduce the API of the smart card reader device.
'''Parameters'''
=== Signature ===
 
   Introduce the API of the signature device.
'''Returns'''
 
The result code, >= 0, success; <0 [[Error_code|error code]].
 
===== close =====
   int printer_close()
Close the device.The open and close apis are pair operations. If you don’t want to use the device, you should call close to release the device.
 
'''Parameters'''
 
'''Returns'''
 
The result code, >= 0, success; <0 [[Error_code|error code]].
 
===== query_status =====
   int printer_query_status()
Query the status of the printer.This api should be used inner open and close, but not inner begin and end.
 
 
'''Parameters'''
 
'''Returns'''
 
The result code, == 1, has paper; == 0, success; <0 [[Error_code|error code]].
 
===== write =====
   int printer_write(unsigned char* pData, int nDataLength)
Write data to the device. The data can be String, Bitmap data or [[ESC command]].
 
 
'''Parameters'''
{|
|-
| ''pData'' || data or ESC command
|-
| ''nDataLength''|| Length of data
|}
'''Returns'''
 
The result code, >= 0, success; <0 [[Error_code|error code]].
===== read =====
===== query_voltage =====
==== Sample ====
   The following code shows how to print some content:
  int result = PrinterInterface.open();
  if (result <0){
    return;
  }
  Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(),
                R.drawable.printer_barcode_low);
  byte[] arryBeginText = null;
  byte[] arryEndText = null;
  try {
    arryBeginText = mContext.getResources().getString(R.string.print_QR_code).getBytes("GB2312");
    arryEndText = "This is a Bitmap of Barcode".getBytes("GB2312");
  } catch (UnsupportedEncodingException e) {
    e.printStackTrace();
  }
  int result = PrinterInterface.begin();
  if (result <0){
    return;
  }
  result = PrinterInterface.write(arryBeginText, arryBeginText.length);
  if (result <0){
    return;
  }
  // print line break
  writeLineBreak(2);     
  PrinterBitmapUtil.printBitmap(bitmap, 0, 0, true);
  // print line break
  writeLineBreak(2);
  // print text
  write(arryEndText);
  // print line break
  writeLineBreak(2);
  result = PrinterInterface.end();
   if (result <0){
    return;
  }
PrinterInterface.close();

Revision as of 07:34, 4 April 2018

API Overview

 This document provides an introduction to the C APIs. C API is the lowest API, it provided by the POS driver, it packaged all the API implement in a so file, named "libUnionpayCloudPos.so".
 The third app should open this so file then call this API in its' C source code according as the corresponding head file.

Print

 Introduce the API of the printer device.The head file name is printer_interface.h

Contactless reader

 Introduce the API of the contactless reader device.

Cash Drawder

 Introduce the API about hwo to interaction with the external cash Drawder device.

Fingerprint

 Introduce the API of the fingerprinter device.

HSM

 Introduce the API of the HSM module.

HDMI

Introduce the API about how to interaction with the HDMIdevice.

LED

Introduce the API of the LED device.

MSR reader

 Introduce the API of the MSR reader device.

PINPAD

 Introduce the API of the PINPAD device.

Secondary display

Introduce the API about hwo to interaction with the external secondary display device.

Serial Port

Introduce the API of the serial port device.

Smart Card reader

 Introduce the API of the smart card reader device.

Signature

 Introduce the API of the signature device.