C API Samples: Difference between revisions

From wizarPOS
No edit summary
No edit summary
 
(29 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== JNI Samples ==
== C API Samples ==
=== Printer ===
In order to use the [http://{{SERVERNAME}}/jniinterfaceapi/ C API interface] of the device, we provide some examples that you can download:
Please find the printer JNI Interface from [http://{{SERVERNAME}}:9292/jniinterfaceapi/ API Spec].
{| class="wikitable"
|-
! Description & History !! Download
|-
|  Includes all the devices API demo of the POS, Add printHtml for D3. || [http://ftp.wizarpos.com/device/c/apidemo_c_20201021.zip API demo 1.5.3.1]
|-
| 20190505 || [ftp://sdkuser:wizsdkar@ftp.wizarpos.com/device/c/apidemo_c_20201021.zip API demo 1.5.3]
|-
| Includes all the devices API demo of the POS, Add Tuzheng new fingerpirnt implement. || [http://ftp.wizarpos.com/device/c/apidemo_c_1.5.0.2.zip API demo 1.5.0.2]
|-
| Includes all the devices API demo of the POS || [http://ftp.wizarpos.com/device/c/apidemo_c_1.5.0.zip API demo 1.5.0]
|-
| For printer api || [http://ftp.wizarpos.com/device/c/PrinterModelDemo.zip printer demo]
|-
| A simple demo to simulate payment, includes MSR swipe, PINPAD input, printing || [http://ftp.wizarpos.com/device/c/MSRPrinterPinpadDemo-1.4.0.zip Simple demo for MSR, Printer, PINPAD]
|}


The calling sequence is open>query_status>begin>write>end>close. Please notice that:
We will update the API demo version regularly. You can download the latest version from here.
* write method is used for printing content.
* print content should be between begin method and end method.
* query_status should be between open method and close method, but should not be between begin method and end method
 
The following code shows how to print some content:
  <syntaxhighlight lang="java">
  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();
</syntaxhighlight>
=== Contactless card reader ===

Latest revision as of 09:25, 30 July 2021

C API Samples

In order to use the C API interface of the device, we provide some examples that you can download:

Description & History Download
Includes all the devices API demo of the POS, Add printHtml for D3. API demo 1.5.3.1
20190505 API demo 1.5.3
Includes all the devices API demo of the POS, Add Tuzheng new fingerpirnt implement. API demo 1.5.0.2
Includes all the devices API demo of the POS API demo 1.5.0
For printer api printer demo
A simple demo to simulate payment, includes MSR swipe, PINPAD input, printing Simple demo for MSR, Printer, PINPAD

We will update the API demo version regularly. You can download the latest version from here.