CS30Pro-SDK Instructions V1.0.1
CS30Pro-SDK Instructions V1.0.1
CS30Pro SDK
Instruction
V1.0.1
Updated on
2021/03/18
Chapter 1 Overview .......................................................................................................................... 4
1.1. Introduction ....................................................................................................................... 4
1.2. Modify records ................................................................................................................... 4
1.3. Usage.................................................................................................................................. 5
1.3.1. Import the SDK for Android studio .......................................................................... 5
1.3.2. Runtime environment .............................................................................................. 6
Chapter 2 Contact Type IC Card ........................................................................................................ 6
2.1. IccCheck ............................................................................................................................. 6
2.2. IccOpen .............................................................................................................................. 6
2.3. IccCommand....................................................................................................................... 7
2.4. IccClose............................................................................................................................... 8
Chapter 3 Print .................................................................................................................................. 8
Caution: ..................................................................................................................................... 8
3.1. PrintInit .............................................................................................................................. 9
3.2. PrintStart .......................................................................................................................... 10
3.3. PrintCheckStatus .............................................................................................................. 10
3.4. PrintSetVoltage................................................................................................................. 11
3.5. PrintSetGray ..................................................................................................................... 11
3.6. PrintSetFont ..................................................................................................................... 11
3.7. PrintSetMode ................................................................................................................... 12
3.8. PrintStr ............................................................................................................................. 12
3.9. PrintBmp .......................................................................................................................... 12
3.10. PrintBarcode................................................................................................................... 13
3.11. PrintQrCode_Cut ............................................................................................................. 14
3.12. PrintCutQrCode_Str ......................................................................................................... 14
Chapter 4 Generic APIs ................................................................................................................... 15
4.1. SysUpdate......................................................................................................................... 15
4.2. SysGetRand ...................................................................................................................... 15
4.3. SysGetVersion................................................................................................................... 16
4.4. SysReadChipID .................................................................................................................. 16
4.5. SysWriteSN ....................................................................................................................... 16
4.6. SysReadSN ........................................................................................................................ 17
Chapter 5 Barcode Scan .................................................................................................................. 17
5.1. Start Scan ......................................................................................................................... 17
5.2. Stop Scan .......................................................................................................................... 18
5.3. Get scan results ................................................................................................................ 18
5.4. Scan settings..................................................................................................................... 19
Chapter 6 App White List ................................................................................................................ 20
6.1. AppInstallEnableAll .......................................................................................................... 21
6.2. AppInstallDisableAll.......................................................................................................... 21
6.3. AppInstallConfig ............................................................................................................... 21
6.4. AppInstallReadConfig ....................................................................................................... 22
Chapter 7 Android OS API ............................................................................................................... 22
7.1. installRomPackage............................................................................................................ 23
2
7.2. getOSVersion .................................................................................................................... 23
7.3. getDeviceId....................................................................................................................... 23
Chapter 8 Serial Port module .......................................................................................................... 24
8.1. fiscalOpen......................................................................................................................... 24
8.2. fiscalClose ......................................................................................................................... 24
8.3. fiscalWrite ........................................................................................................................ 25
8.4. fiscalRead ......................................................................................................................... 26
3
Chapter 1 Overview
1.1. Introduction
This document is the instruction of all API defined by Ciontek for developer to progra
m own Android application upon this android based smart POS. while the MCU
version need to be updated to the latest version to match the SDK version. Along
with this instruction document, usually one SDK file and a ZIP file of Demo code will b
e given.
The EMV kernal related API is introduced in another instruction file accordingly. Pleas
e contact your sales contact for updated version before your integration efforts.
4
1.3. Usage
Unzip the sdk “ciontek - cs30Pro - SDK - v *.zip” and merger the sdk files to your
android studio project.
NOTE: Keep “ICiontekPosService.aidl” in path “aidl/com/ciontek/ciontekposservice”,
And “PosApiHelper.java” in path “com/ctk/sdk”
Class PosApiHelper describe APIs for Ciontek CS30Pro, more detailed introduction
please see the APIs list in PosApiHelper.java
5
1.3.2. Runtime environment
For CS30Pro, Please make sure the android build number is a51_v0.08_20210324c or
after.
2.1. IccCheck
2.2. IccOpen
6
(-2403) Channel Error
(-2405) The card is pulled out or not
(-2404) Protocol error
(-2500) Voltage mode error of IC card reset
(-2503) Communication failure.
Function Initialize the IC card and return the response content of the card
description
Example byte ATR[] = new byte[41];
ret = posApiHelper.IccOpen(1, 1, ATR);
2.3. IccCommand
7
APDU_SEND ApduSend = new APDU_SEND(cmd, lc, dataIn, le);
APDU_RESP ApduResp = null;
byte[] resp = new byte[516];
2.4. IccClose
Chapter 3 Print
Caution:
1, Please don’t interrupt the printing process. Since the printer module
will maintain communication with the host CPU during this process, it is
2, for long sheet print such as 80k byte[], it will take around 5 seconds to
start.
3.1. PrintInit
Function public int PrintInit(int gray, int fontHeight, int fontWidth, int fontZoom)
prototype
Parameter Gray: the grad density. 1-high density, 2-medium,3-low
description Fontheight: font height. 16 or 24
Fontwidth: font width. 16 or 24
Fontzoom: bolt font, 0x00 or 0x33
Return 0: successfully
Other value: failure
For example:
-4001 : PRINT BUSY
-4002 : PRINT NOPAPER
-4003 : PRINT DATAERR
-4004 : PRINT FAULT
-4005 : PRINT TOOHEAT
-4006 : PRINT UNFINISHED
-4007 : PRINT NOFONTLIB
-4008 : PRINT BUFFOVERFLOW
-4009 : PRINT SETFONTERR
-4010 : PRINT GETFONTERR
Function Initialize printer function parameter and load font
description
Example void testApiSimple(){
int ret = posApiHelper.PrintInit(2, 24, 24, 0x33);
if(ret!=0){
return;
}
posApiHelper.PrintStr("Print Tile\n");
if(ret!=0){
return;
}
posApiHelper.PrintStr("- - - - - - - - - - - - - - - - - - - - - - - -\n");
posApiHelper.PrintStr(" Print Str2 \n");
posApiHelper.PrintBarcode("123456789", 360, 120, BarcodeFormat.CODE_128);
posApiHelper.PrintBarcode("123456789", 240, 240, BarcodeFormat.QR_CODE);
9
posApiHelper.PrintStr("CODE_128 : " + "123456789" + "\n\n");
posApiHelper.PrintStr("QR_CODE : " + "123456789" + "\n\n");
posApiHelper.PrintStr(" \n");
posApiHelper.PrintStart();
}
3.2. PrintStart
3.3. PrintCheckStatus
10
Example ret = posApiHelper.PrintCheckStatus();
3.4. PrintSetVoltage
3.5. PrintSetGray
Return 0 –successfully
Other -failure
Function Set print density
description
Example ret = posApiHelper.PrintSetGray (2);
3.6. PrintSetFont
11
Font set as bold and bigger, value 0x00 or 0x33
Return 0 –success
Other -failure
Function Set print font size
description
Example posApiHelper.PrintSetFont((byte)16, (byte)16, (byte)0x33);
posApiHelper.PrintSetFont((byte)24, (byte)24, (byte)0x00);
3.7. PrintSetMode
Return 0 –successfully
Other -failure
Function set print mode for receipt or label
description
Example ret = posApiHelper. PrintSetMode (1);
3.8. PrintStr
3.9. PrintBmp
12
description BMP photo data
Return 0 –successfully
Other -failure
Such as:
-4003 PRN_DATAERR
-4004 PRN_FAULT
-4008 PRN_BUFFOVERFLOW
Function Set BMP photo print content ( size requirement width <=384,height <=500)
description
Example Bitmap bmp =
BitmapFactory.decodeResource(PrintActivity.this.getResources(),
R.drawable.mbmp);
ret = posApiHelper.PrintBmp(bmp);
R.drawable.mbmp –photo path
3.10. PrintBarcode
Return 0 –successfully
Other -failure
Function Set barcode print content
description
posApiHelper.PrintBarcode("12345678", 360, 120, BarcodeFormat.EAN_8);
Example posApiHelper.PrintBarcode("12345678", 360, 120, BarcodeFormat.ITF);
posApiHelper.PrintBarcode("12345678", 360, 240,
BarcodeFormat.PDF_417);
posApiHelper.PrintBarcode("12345678",360,120,”CODE_128”);
posApiHelper.PrintBarcode("12345678",360,120,”CODE_39”);
posApiHelper.PrintBarcode("12345678",240,240,”QR_CODE”);
13
3.11. PrintQrCode_Cut
Parameter Input:
description Contents:Content of the dr code;
desiredWidth:Width;
desiredHeight:Heigh;
barcodeFormat:Coding format;
Output:no;
Return 0 –successfully
Other -failure
Function Print QR code
description
Example String content =
"com.chips.ewallet.scheme://{\"PayeeMemberUuid\":\"a3d7fe8e-873d-
499b-9f11-
000000000000\",\"PayerMemberUuid\":null,\"TotalAmount\":\"900\",\"Pa
yeeSiteUuid\":null,\"PayeeTransId\":\"100101-084850-
6444\",\"PayeeSiteReference\":\"\",\"PayeeDescription\":null,\"Confirmati
onUuid\":null,\"StpReference\":null}";
3.12. PrintCutQrCode_Str
Function public int PrintCutQrCode_Str (String qrContent, String printTxt ,int distance,
prototype int desiredWidth,int desiredHeight, String barcodeFormat);
Parameter Input:
description qrContent:Content of the dr code;
printTxt :Character next to the qr code;
Distance:Line spacing for input data of “printTxt ”;
desiredWidth:Width;
desiredHeight:Heigh;
barcodeFormat:Coding format;
Output:no;
14
Return 0 –successfully
Other -failure
Function print QR code, also print characters on the side.
description
Example String content =
"com.chips.ewallet.scheme://{\"PayeeMemberUuid\":\"a3d7fe8e-873d-
499b-9f11-
000000000000\",\"PayerMemberUuid\":null,\"TotalAmount\":\"900\",\"Pa
yeeSiteUuid\":null,\"PayeeTransId\":\"100101-084850-
6444\",\"PayeeSiteReference\":\"\",\"PayeeDescription\":null,\"Confirmati
onUuid\":null,\"StpReference\":null}";
4.1. SysUpdate
4.2. SysGetRand
15
Other failure
Function To get 8 byte random number
description
Example Byte[] random = new byte[8];
int ret = posApiHelper.SysGetRand (random);
4.3. SysGetVersion
4.4. SysReadChipID
4.5. SysWriteSN
16
Parameter SN:
description 16 byte serial no.
Return 0 successfully
Other failure
Function Write serial no.
description
Example byte SN[] = new byte[32];
4.6. SysReadSN
Description:
You can start scan through send a broadcast “ACTION_BAR_TRIGSCAN”, when scan is
triggered, the scanner will emit red light for 6 seconds by default, then stop scanning
if time out. The timeout index may be configured as below
For example:
Intent intent = new Intent ("ACTION_BAR_TRIGSCAN");
mContext.sendBroadcast(intent);
or (add timeout):
Intent intent = new Intent ("ACTION_BAR_TRIGSCAN");
intent.putExtra("timeout", 4);// Units per second, and Maximum 9
mContext.sendBroadcast(intent);
17
5.2. Stop Scan
Description:
You can start scan through Send a broadcast “ACTION_BAR_TRIGSTOP”.
For example:
intent = new Intent();
intent.setAction(ACTION_SCANNER_CANCEL);
mContext.sendBroadcast(intent);
Description :
There are two manners of scan result output, directly fill and API transfer.
In directly fill manner, the return value will be filled directly to “Editview”, and
you can read the content of Editview as well.
In API transfer manner, you can get the scan results by registering a broadcast
receiver “ACTION_BAR_SCAN”, This broadcast has 3 Parameters.
The parameter 1 “ EXTRA_SCAN_DATA” is the bar code value, of which the data
type is String or byte[].
The parameter 2 “EXTRA_SCAN_LENGTH” is the bar code data length, of which
the data type is int.
The parameter 3 “EXTRA_SCAN_ENCODE_MODE” is the coding type of result,
value may be 1,2,3 and means UTF-8,GBK, and raw value accordingly.
The parameter 4 “EXTRA_SCAN_BARTYPE” is the barcode type, of which the
data type is int
For example:
Register broadcase receiver:
mFilter= new IntentFilter("ACTION_BAR_SCAN");
mContext.registerReceiver(mReceiver, mFilter);
18
public static final int ENCODE_MODE_NONE = 3;
String scanResult=""
19
after scan
= 0 close scanning sound
EXTRA_SCAN_NOTY_SND INT
= 1 open scanning sound
= 0 close Scanning vibration
EXTRA_SCAN_NOTY_VIB INT
= 1 open Scanning vibration
= 0 close scanning indicator light
EXTRA_SCAN_NOTY_LED INT
= 1 open scanning indicator light
For example:
disable scanning
Intent intent = new Intent ("ACTION_BAR_SCANCFG");
intent.putExtra("EXTRA_SCAN_POWER", 0);
mContext.sendBroadcast(intent);
Enable scanning
Intent intent = new Intent ("ACTION_BAR_SCANCFG");
intent.putExtra("EXTRA_SCAN_POWER", 1);
mContext.sendBroadcast(intent);
For example:
Set scan to API output mode,and Automatically add “Enter” characters after scan
Or
The white list is used to restrict the APP that can be loaded. Only applications in
the white list can be loaded into the system to ensure the security of the system.
20
6.1. AppInstallEnableAll
6.2. AppInstallDisableAll
6.3. AppInstallConfig
21
false : fail
Function allow apps that specified to install
descriptio
n
Example
String packageNameList = "com.app.package.name1\r\n" +
"com.app.package.name2\r\n" +
"com.app.package.name3\r\n"
posApiHelper.AppInstallConfig (packageNameList);
6.4. AppInstallReadConfig
22
7.1. installRomPackage
7.2. getOSVersion
7.3. getDeviceId
23
Function Get the device serial number
description
Example String osVersion = posApiHelper.getDeviceId ();
The serial port at the bottom of the device use for the fiscal module.
8.1. fiscalOpen
Function public int fiscalOpen(int baudrate, int size, int stop, char parity, char cflow)
prototype
Parameter baudrate: the baudrate of serial port
descriptio size: data bits of serial port
n stop: stop bits of serial port
parity: parity bit of serial port
cflow: Control options serial port
Return 0: success
-1: fail
-2: uninitialized
-3: parameter error
-4: timeout
-5: init uart port error
-6: read error
-7: write error
Function Power on the fiscal module and open the serial port
descriptio
n
Example
posApiHelper.fiscalOpen(115200,8,1,'N','N');
8.2. fiscalClose
24
Parameter
description
Return 0: success
-1: fail
-2: uninitialized
-3: parameter error
-4: timeout
-5: init uart port error
-6: read error
-7: write error
Function power off the fiscal and close the uart port
description
Example
posApiHelper.fiscalClose();
8.3. fiscalWrite
ret = posApiHelper.fiscalWrite(cmd);
25
8.4. fiscalRead
26