0% found this document useful (0 votes)
317 views30 pages

CS30Pro-SDK Instruction V1.0.2

This document provides instructions for using the Ciontek CS30Pro SDK APIs. It describes APIs for printing, reading contactless cards, barcode scanning, app whitelist/blacklist management, Android OS functions, and serial port communication. The SDK requires a minimum Android version of a51_v0.13_20210625g and MCU version of V1.2.0. Version 1.0.2 of the document added new printing APIs and was last updated on June 23, 2021.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
317 views30 pages

CS30Pro-SDK Instruction V1.0.2

This document provides instructions for using the Ciontek CS30Pro SDK APIs. It describes APIs for printing, reading contactless cards, barcode scanning, app whitelist/blacklist management, Android OS functions, and serial port communication. The SDK requires a minimum Android version of a51_v0.13_20210625g and MCU version of V1.2.0. Version 1.0.2 of the document added new printing APIs and was last updated on June 23, 2021.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Ciontek

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.

Support : CS30Pro Android10.0

1.2. Modify records

version author date remarks


V1.0.1 Tao 2021-03-11
V1.0.2 Tao 2021-6-23 1. Add Print API:
PrintSetUnderline
PrintSetReverse
PrintSetBold
PrintLogo
2.Discarded the old APP White List APIs that in
V1.0.1, And replace it use the new APIs :
enableAppInstallWhiteList
disableAppInstallWhiteList
addAppToInstallWhiteList
delAppFromInstallWhiteList
getAppInstallWhiteList
3.Add APP black list
enableAppUninstallBlackList
disableAppUninstallBlackList
addAppToUninstallBlackList
delAppFromUninstallBlackList
getAppUninstallBlackList

4
1.3. Usage

1.3.1. Import the SDK for Android studio

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

By get a PosApiHelper instance to call APIs, for example:

PosApiHelper posApiHelper = PosApiHelper.getInstance();


posApiHelper.SysGetVersion(version);

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

Chapter 2 Contact Type IC Card

2.1. IccCheck

Function public int IccCheck(byte slot)


prototype
Parameter slot cassette No.:
description 0x00-IC Card Channel;
0x01-PSAM1 Card Channel;
0x02-PSAM2 Card Channel;
Return int
0 :The card was detected and inserted
Other:failure
Function Check if there is a card in the specified cassette
description
Example ret = posApiHelper.IccCheck(1);

2.2. IccOpen

Function public int IccOpen(byte slot, byte vccMode, byte[] atr)


prototype
Parameter Slotcassette No.:
description 0x00-IC Card Channel;
0x01-PSAM1 Card Channel;
0x02-PSAM2 Card Channel;
VCC_Mode Read Card Voltage:
1---5V;
2---3V;
3---1.8V;
ATR :

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

Function public int IccCommand(byte slot, byte[] apduSend, byte[] apduResp)


prototype
Parameter Slotcassette No.:
description 0x00-IC Card Channel;
0x01-PSAM1 Card Channel;
0x02-PSAM2 Card Channel;
ApduSend:
sent to the card’s apdu
ApduResp:
Receive the card's apdu of returned
Return int
0 Execute successfully
(-2503) Communication timeout
(-2405) The cards are put out in the transaction
(-2401) Parity error
(-2403) Select Channel error
(-2400) Sending data too long(LC)
(-2404) The Protocol error(is Not T = 0 or T = 1)
(-2406) No reset card
Function Read and Write IC Card
description If both LC and LE exist, you should set "LC = X; LE = 0x01"
Example byte cmd[] = new byte[4];
cmd[0] = 0x00; //0-3 cmd
cmd[1] = (byte) 0x84;
cmd[2] = 0x00;
cmd[3] = 0x00;
short lc = 0x00;

7
short le = 0x04;

String sendmsg = "";


byte [] dataIn = sendmsg.getBytes();

APDU_SEND ApduSend = new APDU_SEND(cmd, lc, dataIn, le);


APDU_RESP ApduResp = null;
byte[] resp = new byte[516];

ret = posApiHelper.IccCommand(slot, ApduSend.getBytes(), resp);

2.4. IccClose

Function public int IccClose(byte slot)


prototype
Parameter Slotcassette No.:
description 0x00-IC and Channel
0x01-PSAM1 and Channel
0x02-PSAM2 and Channel
Return int
0 : successfully
Other :failure
Function Close IC Card
description
Example ret = posApiHelper.IccClose(1);

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

recommended to block the Return, Power, Home buttons and other

events that can suddenly interrupt printing, such as a mask pop-up.

For example: to block the Power button: disableFunctionLaunch(true);

8
To activate the Power button: disableFunctionLaunch(false)

For more examples please refer to the PrintActivity.Java in SDK Demo

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

Function public int PrintStart()


prototype
Parameter none
description
Return 0:success;
-1001/1001:send fail;
-1002/1002:receive timeout;
-1:Short of paper;
-2:The temperature is too high;
-3: The voltage is too low;
8/9:Instruction reply disorder;
-1023:status error;
-1021:Short of paper;
-1000/-1016/-1001/-1002/-1003/-1004/-1019/-1017/-1018/-1020:print
timeout;
-1007/-1008/-1009/-1010/-1011/-1012:Print times exceeds limit;
-1022:heat error;
-1015/-1014;Short of paper;
Function Start print
description
Example ret = posApiHelper.PrintStart();

3.3. PrintCheckStatus

Function public int PrintCheckStatus()


prototype
Parameter None
description
Return 0 –success ; -1 –need paper

10
-2 –high temperature ; -3 –Low battery voltage
Function Check printer status
description
Example ret = posApiHelper.PrintCheckStatus();

3.4. PrintSetVoltage

Function public int PrintSetVoltage(int voltage)


prototype
Parameter voltage:
description current battery voltage*10
Return 0 –successfully
Other -failure
Function Set voltage
description
Example //Set current voltage as 7.5V
ret = posApiHelper.PrintSetVoltage(75);

3.5. PrintSetGray

Function public int PrintSetGray(int nLevel)


prototype
Parameter nLevel:
description density level, value 1~5
1:Lowest 3:medium 5:Highest

Return 0 –successfully
Other -failure
Function Set print density
description
Example ret = posApiHelper.PrintSetGray (2);

3.6. PrintSetFont

Function public int PrintSetFont(byte fontHeight, byte fontWidth, byte zoom)


prototype
Parameter asciiFontHeight:
description

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

Function public int PrintSetMode (int mode)


prototype
Parameter mode:
description 0 -> print a receipt (default)
1 -> print a label

Return 0 –successfully
Other -failure
Function set print mode for receipt or label
description
Example ret = posApiHelper. PrintSetMode (1);

3.8. PrintStr

Function public int PrintStr(String str)


prototype
Parameter str:
description print content
Return 0 –successfully
-4002 –need paper
-4003 –data error
Function Set print content
description
Example posApiHelper.PrintStr("POS SALES SLIP\n");

12
3.9. PrintBmp

Function public int PrintBmp(Bitmap bitmap)


prototype
Parameter bitmap:
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

Function public int PrintBarcode(String contents, int desiredWidth, int desiredHeight,


prototype String barcodeFormat);
Parameter contents:
description barcode content
desiredWidth:
barcode width
desiredHeight:
barcode height
barcodeFormat:
barcode standard
CODE_128 , CODE_39, EAN_8, QR_CODE
PDF_417 , ITF

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

Function public int PrintQrCode_Cut (String contents, int desiredWidth, int


prototype desiredHeight, String barcodeFormat);

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}";

posApiHelper.PrintStr("QR_CODE display " );


posApiHelper.PrintQrCode_Cut(content, 360, 360,
BarcodeFormat.QR_CODE);
posApiHelper.PrintStr("PrintCutQrCode_Str display " );
posApiHelper.PrintCutQrCode_Str(content,"PK TXT adsad adasd sda",5, 300,
300,”QR_CODE”);

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}";

posApiHelper.PrintStr("QR_CODE display " );


posApiHelper.PrintQrCode_Cut(content, 360, 360, “QR_CODE”);
posApiHelper.PrintStr("PrintCutQrCode_Str display " );
posApiHelper.PrintCutQrCode_Str(content,"PK TXT adsad adasd sda",5, 300,
300, BarcodeFormat.QR_CODE);

3.13. PrintSetUnderline

Function public int PrintSetUnderline(int x);


prototype
Parameter x:The value is in HEX format,
description The upper four digits are the number of underlined lines, greater than 2 is 2
lines, and less than 2 is 1 line
The lower four bits are the width

Return 0 –successfully
Other -failure
Function Set the lines and width of underline
description
Example posApiHelper. PrintSetUnderline (0x1F);

15
3.14. PrintSetReverse

Function public int PrintSetReverse (int x);


prototype
Parameter x:
description * 0(default) -> normal
* 1 -> reverse

Return 0 –successfully
Other -failure
Function Set the font display reverse mode
description
Example posApiHelper. PrintSetReverse (1);

3.15. PrintSetBold

Function public int PrintSetBold (int x);


prototype
Parameter mode:
description * 0(default) -> normal
* 1 -> Bold

Return 0 –successfully
Other -failure
Function Set the font display Bold mode
description
Example posApiHelper. PrintSetBold (1);

3.16. PrintLogo

Function public int PrintLogo (byte[] logo);


prototype
Parameter byte[] logo: the byte[] for a picture
description

Return 0 -successfully
Other -failure

16
Function print a picture by a byte[]
description
Example posApiHelper. PrintLogo (logo);

Chapter 4 Generic APIs

4.1. SysUpdate

Function public int SysUpdate()


prototype
Parameter None
description
Return 0 successfully
Other failure
Function Payment module firmware upgrade
description
Example int ret = posApiHelper.SysUpdate ();

4.2. SysGetRand

Function Public int SysGetRand(byte[] rnd)


prototype
Parameter byte[] rnd:
description The random number returned by the MCU
Return 0 successfully
Other failure
Function To get 8 byte random number
description
Example Byte[] random = new byte[8];
int ret = posApiHelper.SysGetRand (random);

4.3. SysGetVersion

Function public int SysGetVersion (byte[] buf)


prototype

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

Function public int SysReadChipID (byte[] buf, int len)


prototype
Parameter buf:
description IC card ID no.
len:
length
Return 0 successfully
Other failure
Function Get IC card ID no.
description
Example
byte chipIdBuf[] = new byte[16];
int ret = posApiHelper.SysReadChipID(chipIdBuf, 16);

4.5. SysWriteSN

Function public int SysWriteSN (byte[] SN)


prototype
Parameter SN:
description 16 byte serial no.
Return 0 successfully
Other failure
Function Write serial no.
description
Example byte SN[] = new byte[32];

int ret = posApiHelper.SysWriteSN(SN);

18
4.6. SysReadSN

Function public int SysReadSN (byte[] SN)


prototype
Parameter SN:
description 16 byte serial no.
Return 0 successfully
Other failure
Function Write serial no.
description
Example byte SN[] = new byte[32];
ret= posApiHelper.SysReadSN(SN);

Chapter 5 Barcode Scan

5.1. Start Scan

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);

5.2. Stop Scan

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);

5.3. Get scan results

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);

unregister broadcase receiver:


mContext.unregisterReceiver(mReceiver);

obtain scan results:

public static final int ENCODE_MODE_UTF8 = 1;


public static final int ENCODE_MODE_GBK = 2;
public static final int ENCODE_MODE_NONE = 3;

String scanResult=""

mReceiver= new BroadcastReceiver() {


public void onReceive(Context context, Intent intent) {
int length = intent.getIntExtra("EXTRA_SCAN_LENGTH",0);
int encodeType= intent.getIntExtra("EXTRA_SCAN_ENCODE_MODE",1);
if (encodeType == ENCODE_MODE_NONE ){

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");
}
}
};

5.4. Scan settings

All config may be set in “Setting-Scanner” manually or by sending broadcast


“ACTION_BAR_SCANCFG”,

The parameters are defined as follows:

parameter data type Remarks


= 0 disable scanning
= 1 enable scanning
Explanation: when the scan head is enabled,
EXTRA_SCAN_POWER INT
system will initialize the scan head.It will take
some time, and the relevant scan request is
ignored
= 0 as a normal trigger mode
EXTRA_TRIG_MODE INT
= 1 as continuous trigger mode
Filling = 1 : The scan results are filled
directly into the editview
EXTRA_SCAN_MODE INT
Api = 2 :The scan results are output by
a broadcast
=0
EXTRA_SCAN_AUTOENT INT = 1 Automatically add “Enter” characters
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");

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

//SCAN_MODE : Fill mode


Intent intent = new Intent ("ACTION_BAR_SCANCFG");
intent.putExtra("EXTRA_SCAN_MODE", 1);
intent.putExtra("EXTRA_SCAN_AUTOENT", 1);
mContext.sendBroadcast(intent);

Or

//SCAN_MODE : Api mode


Intent intent = new Intent ("ACTION_BAR_SCANCFG");
intent.putExtra-("EXTRA_SCAN_MODE", 2);
intent.putExtra("EXTRA_SCAN_AUTOENT", 1);
mContext.sendBroadcast(intent);

Chapter 6 App White List& Black List

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

Function public boolean enableAppInstallWhiteList()


prototype
Parameter
descriptio
n
Return true : success
false : fail
Function enable the function of App White list
descriptio
n
Example
posApiHelper. enableAppInstallWhiteList ();

6.2. disableAppInstallWhiteList

Function public boolean disableAppInstallWhiteList ()


prototype
Parameter
descriptio
n
Return true : success
false : fail
Function disable the function of App White list
descriptio
n
Example
posApiHelper. disableAppInstallWhiteList ();

6.3. addAppToInstallWhiteList

Function public boolean addAppToInstallWhiteList (String pkgName)


prototype
Parameter pkgName:
descriptio the APP package name
n

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

Function public boolean delAppFromInstallWhiteList (String pkgName)


prototype
Parameter
descriptio
n
Return true : success
false : fail
Function delete an apk from white list
descriptio
n
Example
String packageNameList = "com.app.package.name"
posApiHelper. delAppFromInstallWhiteList (packageNameList);

6.5. getAppInstallWhiteList

Function public List<String>getAppInstallWhiteList ()


prototype
Parameter
descriptio
n
Return The app white list

Function get the APP white list


descriptio
n
Example posApiHelper. getAppUninstallBlackList ();

24
APIs for App black list:

6.6. enableAppUninstallBlackList

Function Public boolean enableAppUninstallBlackList ()


prototype
Parameter
descriptio
n
Return true : success
false : fail

Function enable the function of App black list


descriptio
n
Example posApiHelper. enableAppUninstallBlackList ();

6.7. disableAppUninstallBlackList

Function Public boolean disableAppUninstallBlackList ()


prototype
Parameter
descriptio
n
Return true : success
false : fail

Function disable the function of App black list


descriptio
n
Example posApiHelper. disableAppUninstallBlackList ();

25
6.8. addAppToUninstallBlackList

Function Public boolean addAppToUninstallBlackList (String pkgName)


prototype
Parameter
descriptio
n
Return true : success
false : fail

Function add an apk to black list


descriptio
n
Example posApiHelper. addAppToUninstallBlackList (pkgName);

6.9. delAppFromUninstallBlackList

Function Public boolean delAppFromUninstallBlackList(String pkgName)


prototype
Parameter
descriptio
n
Return true : success
false : fail

Function delete an apk from black list


descriptio
n
Example posApiHelper. delAppFromUninstallBlackList (pkgName);

6.10. getAppUninstallBlackList

Function Public List<String>getAppUninstallBlackList ()


prototype
Parameter
descriptio
n

26
Return
Function get the APP black list
descriptio
n
Example posApiHelper. getAppUninstallBlackList ();

Chapter 7 Android OS API

This API is available for Ciontek CS30Pro.

7.1. installRomPackage

Function public int installRomPackage(String romFilePath)


prototype
Parameter context :Context
descriptio romFilePath : rom file path
n
Return 0 : success
!0 : fail
Function API for Android firmware update, useful for client want to deploy its own OTA
descriptio system.
n
Example String path = "/storage/emulated/0/update.zip";
File mOsFile=new File(path);
if(!mOsFile.exists()){
//TODO
return;
}

boolean flag = posApiHelper.installRomPackage(path);

7.2. getOSVersion

Function public String getOSVersion()


prototype
Parameter
description

27
Return String: the OS version
Function Get OS version
description
Example String osVersion = posApiHelper.getOSVersion();

7.3. getDeviceId

Function public String getDeviceId ()


prototype
Parameter
description
Return String: the device serial number
Function Get the device serial number
description
Example String osVersion = posApiHelper.getDeviceId ();

Chapter 8 Serial Port module

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 public int fiscalClose ()


prototype
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

Function public int fiscalWrite(byte[] data)


prototype
Parameter data
description
Return 0: success
-1: fail
-2: uninitialized
-3: parameter error
-4: timeout
-5: init uart port error

29
-6: read error
-7: write error

Function Write data to fiscal by the serial port


description
Example byte[] cmd = new byte[6];
cmd[0] = (byte)0x04;
cmd[1] = (byte)0x01;
cmd[2] = (byte)0x00;
cmd[3] = (byte)0x30;
cmd[4] = (byte)0xff;
cmd[5] = (byte)0xcd;

ret = posApiHelper.fiscalWrite(cmd);

8.4. fiscalRead

Function int fiscalRead(byte[] buffer, int bufLen, int timeout)


prototype
Parameter Buffer: the buffer for data form serial port
description bufLen: the length of the buffer
timeout: timeout for read, unit: ms

Return >0 : the counts read form serial port


<0: read fail
-1: fail
-2: uninitialized
-3: parameter error
-4: timeout
-5: init uart port error
-6: read error
-7: write error

Function read data from fiscal by the serial port


description
Example byte[] buffer = new byte[36];
readCount = posApiHelper.fiscalRead(buffer,36,500);

30

You might also like