CS30Pro-SDK Instruction V1.0.2
CS30Pro-SDK Instruction V1.0.2
CS30Pro SDK
Instruction
V1.0.2
Updated on
2021/06/23
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 .......................................................................................................................... 13
3.10. PrintBarcode................................................................................................................... 13
3.11. PrintQrCode_Cut ............................................................................................................. 14
3.12. PrintCutQrCode_Str ......................................................................................................... 14
3.13. PrintSetUnderline........................................................................................................... 15
3.14. PrintSetReverse .............................................................................................................. 16
3.15. PrintSetBold ................................................................................................................... 16
3.16. PrintLogo ........................................................................................................................ 16
Chapter 4 Generic APIs ................................................................................................................... 17
4.1. SysUpdate......................................................................................................................... 17
4.2. SysGetRand ...................................................................................................................... 17
4.3. SysGetVersion................................................................................................................... 17
4.4. SysReadChipID .................................................................................................................. 18
4.5. SysWriteSN ....................................................................................................................... 18
4.6. SysReadSN ........................................................................................................................ 19
Chapter 5 Barcode Scan .................................................................................................................. 19
5.1. Start Scan ......................................................................................................................... 19
5.2. Stop Scan .......................................................................................................................... 19
5.3. Get scan results ................................................................................................................ 20
5.4. Scan settings..................................................................................................................... 21
Chapter 6 App White List& Black List .............................................................................................. 22
APIs for App White list: ........................................................................................................... 23
6.1. enableAppInstallWhiteList ............................................................................................... 23
2
6.2. disableAppInstallWhiteList ............................................................................................... 23
6.3. addAppToInstallWhiteList ................................................................................................ 23
6.4. delAppFromInstallWhiteList ............................................................................................. 24
6.5. getAppInstallWhiteList ..................................................................................................... 24
APIs for App black list: ............................................................................................................. 25
6.6. enableAppUninstallBlackList ............................................................................................ 25
6.7. disableAppUninstallBlackList............................................................................................ 25
6.8. addAppToUninstallBlackList ............................................................................................. 26
6.9. delAppFromUninstallBlackList.......................................................................................... 26
6.10. getAppUninstallBlackList ................................................................................................ 26
Chapter 7 Android OS API ............................................................................................................... 27
7.1. installRomPackage............................................................................................................ 27
7.2. getOSVersion .................................................................................................................... 27
7.3. getDeviceId....................................................................................................................... 28
Chapter 8 Serial Port module .......................................................................................................... 28
8.1. fiscalOpen......................................................................................................................... 28
8.2. fiscalClose ......................................................................................................................... 29
8.3. fiscalWrite ........................................................................................................................ 29
8.4. fiscalRead ......................................................................................................................... 30
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 Android firmware no earlier than a51_v0.13_20210625g and MCU
version no earlier than V1.2.0 .
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.13_20210625g or
after
Special instructions:
Because of the SDK APIs may be a time consuming call, So you need create a new
thread to invoke them
2.1. IccCheck
2.2. IccOpen
6
Card reset response. (at least 32+1bytes of space). The contents are
length (1 byte) + reset response content
Return int
0 Initialization success.
(-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
short le = 0x04;
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
8
To activate the Power button: disableFunctionLaunch(false)
source code.
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;
}
9
posApiHelper.PrintStr("- - - - - - - - - - - - - - - - - - - - - - - -\n");
posApiHelper.PrintStr(" Print Str2 \n");
posApiHelper.PrintBarcode("123456789", 360, 120, BarcodeFormat.CODE_128);
posApiHelper.PrintBarcode("123456789", 240, 240, BarcodeFormat.QR_CODE);
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
-2 –high temperature ; -3 –Low battery voltage
Function Check printer status
description
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 dot matrix height, value 16 or 24
extendFontHeight:
font dot matrix width, value 16 or 24
Zoom:
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
12
3.9. PrintBmp
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);
13
posApiHelper.PrintBarcode("12345678",360,120,”CODE_128”);
posApiHelper.PrintBarcode("12345678",360,120,”CODE_39”);
posApiHelper.PrintBarcode("12345678",240,240,”QR_CODE”);
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);
14
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;
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}";
3.13. PrintSetUnderline
Return 0 –successfully
Other -failure
Function Set the lines and width of underline
description
Example posApiHelper. PrintSetUnderline (0x1F);
15
3.14. PrintSetReverse
Return 0 –successfully
Other -failure
Function Set the font display reverse mode
description
Example posApiHelper. PrintSetReverse (1);
3.15. PrintSetBold
Return 0 –successfully
Other -failure
Function Set the font display Bold mode
description
Example posApiHelper. PrintSetBold (1);
3.16. PrintLogo
Return 0 -successfully
Other -failure
16
Function print a picture by a byte[]
description
Example posApiHelper. PrintLogo (logo);
4.1. SysUpdate
4.2. SysGetRand
4.3. SysGetVersion
17
Parameter buf: firmware no.
description
Return 0 successfully
Other failure
Function Read firmware version
description
Example byte buf[] = new byte[9];
ret= posApiHelper.SysGetVersion(buf);
4.4. SysReadChipID
4.5. SysWriteSN
18
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);
Description:
You can start scan through Send a broadcast “ACTION_BAR_TRIGSTOP”.
For example:
19
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);
String scanResult=""
20
byte[] data = intent.getByteArrayExtra("EXTRA_SCAN_DATA");
scanResult= new String (data ,0,length ,Encode);//Encode is the
coding type returned.
}else {
scanResult=intent.getStringExtra("EXTRA_SCAN_DATA");
}
}
};
21
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. On
the contrary the black list is used to restrict the APP that can not be loaded.
22
APIs for App White list:
6.1. enableAppInstallWhiteList
6.2. disableAppInstallWhiteList
6.3. addAppToInstallWhiteList
23
Return true : success
false : fail
Function add an apk to white list
descriptio
n
Example
String packageNameList = "com.app.package.name"
posApiHelper. addAppToInstallWhiteList (packageNameList);
6.4. delAppFromInstallWhiteList
6.5. getAppInstallWhiteList
24
APIs for App black list:
6.6. enableAppUninstallBlackList
6.7. disableAppUninstallBlackList
25
6.8. addAppToUninstallBlackList
6.9. delAppFromUninstallBlackList
6.10. getAppUninstallBlackList
26
Return
Function get the APP black list
descriptio
n
Example posApiHelper. getAppUninstallBlackList ();
7.1. installRomPackage
7.2. getOSVersion
27
Return String: the OS version
Function Get OS version
description
Example String osVersion = posApiHelper.getOSVersion();
7.3. 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
28
-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
Function power off the fiscal and close the uart port
description
Example
posApiHelper.fiscalClose();
8.3. fiscalWrite
29
-6: read error
-7: write error
ret = posApiHelper.fiscalWrite(cmd);
8.4. fiscalRead
30