Prolin API Programming Guide (V2.5.3) - 20220330
Prolin API Programming Guide (V2.5.3) - 20220330
Guide
V 2.5.3
Copyright © 2000-2022 PAX Computer Technology (Shenzhen) Co., Ltd. All rights
reserved. Any part of this documentation is strictly prohibited to be reproduced or
distributed in any form or for any purpose without the prior written permission of PAX
Computer Technology (Shenzhen) Co., Ltd. Despite the effort to enhance the accuracy
of this documentation, there are possible errors or omissions left herein. The content
of this documentation is subject to change without further notice. The examples and
sample programs demonstrated in this manual are for illustrations only and may fail to
meet practical needs. Please test and verify their applicability before putting into
commercial use.
I
History of Revisions
Date Version Note Author
1. Exported the original version of
2012-08-15 V1.0.0 Prolin Team
Prolin from WIKI.
2012-11-06 V1.0.1 1. Internal review and modification. Prolin Team
1. Added Return Code List in
system function;
2. Added a new interface:
2012-12-26 V1.0.2 OsVerifySignExternal(); Prolin Team
3. Added WiFi module;
4. Added Appendix registry table.
2013-02-20 V1.0.3 Added instruction of OsOpenFont (). Prolin Team
1. Modified the instruction of
OsModemOpen();
2. Added two return values in
Modem: -3219 and -3220;
3. Added notes of DetectDialTone;
2013-03-06 V1.0.4 Added a new interface: Prolin Team
OsModemSwitchPower();
4. Modified parameter description
of OsPrnOpen() to “support bmp
format only”;
5. Modified sci_get_fd ().
1. Modified the description of
Chapter 4.10 “S series do not
support this function as S model
has no landline”;
2. Modified open() node in Chapter
14.4.1;
3. Updated time setting code “pow-
hwclock –w” to “pow-hwclock –
2013-04-17 V1.0.5 Prolin Team
w –u”;
4. Updated instruction of OsWlInit():
When return value is
ERR_WL_NOSIM, some
functions can be used without an
SIM card;
5. Updated the instruction of
OsCheckBattery ().
2013-05-17 V1.0.6 1. Modified the description of Timer; Prolin Team
II
2. Supplemented the description of
Time Delay;
3. Added description of Registry
Table;
4. Modified the parameter
description of
ValueinOsRegGetValue ();
5. Modified the parameter
description of ShaOut in OsSHA
();
6. Updated description of GUI;
7. Added “1200, V22” and“2400,
FC” to the parts of synchronous
variable of ConnectRate[20]
inMODEM.
1. Modified the Registry;
III
1. Added parameter description of
KeyVarType about 0x02 in
OsPedDesDukpt();
2. Modified the value ranges of
several parameters in chapter
PED;
3. Modified the parameter
description of ucATQ0 in
OsPiccAntiSel();
4. Deleted OsPiccGetParam() and
2013-11-20 V2.0.0 Prolin Team
OsPiccSetParam();
5. Updated the instruction of
OsRegGetValue();
6. Added description of
OsPortOpen();
7. Added description of
OsSysSleep();
8. Updated Return Code List in
Network Configuration chapter;
9. Added instruction of OsNetDns().
1. Modified Appendix 4;
2. Modified the instruction of
OsWlSelSim();
3. Added a new return value
forOsMsrOpen();
4. Added new interfaces
OsWlLoginEx(), OsMount() and
OsUmount();
5. Added chapter 26 Barcode;
6. Added description of AES
2014-02-25 V2.0.1 functional interface; Prolin Team
7. Modified the parameter
description of Name in
OsInstallFile();
8. Added an error code
“ERR_APP_MODE” for
OsInstallFile();
9. Added a new interface
OsCheckPowerSupply();
10. Deleted invalid codes in chapter
7 LCD for upgraded Prolin-2.4.
1. Updated OsSysSleep();
2014-03-04 V2.0.2 Prolin Team
2. Updated the WiFi module.
Modified the description of WiFi
2014-03-24 V2.0.3 Prolin Team
module.
1. Updated WiFi module;
2014-04-16 V2.0.4 3. Added a new interface Prolin Team
OsSysSleepEx();
IV
4. Removed MountFlag’s support to
MS-MOVE in OsMount();
5. Added new interfaces
OsReboot() and OsPowerOff().
1. Modified the instruction of
OsPrnSetIndent();
2. Modified functionality description
of OsModemCheck();
3. Modified parameter description
of TimeoutMS in OsPortRecv();
4. Modified value range of Volume
in OsPlayWave();
2014-06-03 V2.0.5 Prolin Team
5. Modified parameter description
of OsMifareOperate();
6. Added the corresponding
relationship between device
node and serial port.
7. Updated the instruction of
OsWlSwitchSleep() and
OsWifiSwitchPower().
1. Updated the instruction of
OsLog();
2. Updated the return value of
OsPedSetInterval();
3. Added a new interface
OsPedCancelPinEntry();
2014-07-10 V2.0.6 4. Added new return values of Prolin Team
OsVerifySign() and
OsVerifySignExternal();
5. Updated the instruction of
OsCheckBattery();
6. Updated Appendix 3 and
Appendix 4.
1. Updated the return value
PPP_LOGOUTING in
OsWlLogin() and add
corresponding instruction;
2014-10-09 V2.0.7 Prolin Team
2. Modified int OsWifiClose(void) to
void OsWifiClose(void);
3. Modified device nodes of LCD,
keypad and touch screen.
1. Modified the instruction of
OsRunApp();
2014-11-26 V2.0.8 Prolin Team
2. Added U disk file format limitation
in OsMount();
V
3. Added the instruction of
parameter Channel about S920
model in OsPortOpen();
4. Modified the instruction of
OsNetPing();
5. Modified the instruction of
OsNetDns();
6. Added the instruction of
OsNetSetConfig();
7. Added the instruction of
OsNetStartDhcp();
8. Modified the functionality of
OsNetSetRoute()and added a new
return value;
9. Modified functionality, return
value and instruction of
OsNetGetRoute();
10. Modified the instruction of
OsPppoeLogin();
11. Modified the instruction of
OsWILogin();
12. Modified the instruction of
OsWILoginEx();
13. Added sampling frequency
limitation of WAVE file in
OsPlayWave();
VI
1. Added a new return value
ERR_APP_NOT_EXIST in
OsRunApp();
2. Modified the instruction of
OsPedSetInterval();
3. Updated the parameter
description of DataIn in
OsPedUpdatePinBlock();
4. Modified the instruction of
OsPedDesDukpt();
5. Modified parameter description of
DataInLen in
OsPedRsaRecover();
6. Modified Appendix 1;
VII
1. Revised the V2.1.1 version of this
documentation;
2. Added a return value and
function instruction in condition
that the battery power of D200 or
S920 gets too low (<3.65V);
3. Added the instruction of
OsPedWriteRsaKey();
4. Supplemented the instruction of
OsSysSleep();
5. Added and modified some codes
of user configuration structure:
PCD_USER_ST;
6. Modified parameter description
2015-07-09 V2.1.2 Prolin Team
of PUKType in OsVerifySign();
7. Added some codes in TCP
programming;
8. Modified the instruction of
OsInstallFile();
9. Added the instructionof PX7
andPX5 in OsPortOpen();
10. Supplemented the instruction of
Prolin-2.4 and Prolin-phoenix-2.5
in OsPedWriteKey();
11. Added some descriptions of PX5
and PX7 in chapter POSIX
Interface;
12. Added PXX model in Appendix 4.
1. Added a return value
ERR_PUK_NOT_EXIST in the
chapter of System Function;
2. Added the instruction of
OsMount();
3. Added the instruction of
OsUmount();
4. Addedthe macro of SM (Secure
Module) key in the chapter of
2015-11-24 V2.1.3 PED; Prolin Team
5. Added the SM part in
OsPedWriteKey() function;
6. Added nine functions in the
chapter of PED, including
OsPedGenSM2Pair(),
OsPedWriteSM2Key(),
OsPedSM2Sign(),
OsPedSM2Verify(),
OsPedSM2Recover(),
OsPedSM(), OsPedSM(),
VIII
OsPedGetMacSM(), and
OsPedGetPinBlockSM4();
7. Added two new return values
ERR_MSR_END_ZEROERR
and
ERR_MSR_PED_DECRYPTER
R in the chapter of MSR;
8. Added new return values in
Return Code List and added
PPP_DIRECT link in Physical
Channel List in the chapter of
Network Configuration;
9. Added a return value
ERR_MODE_NOT_SUPPORT
in the chapter of WiFi;
10. Added return value and
instruction in OsSysSleep ();
11. Added return value and
instruction in OsSysSleepEx().
1. Updated the instruction of
OsMount();
2. Updated the instruction of
OsUmount();
3. Added a return value and
instruction in
OsFirmwareUpgrade();
4. Added introduction of three-level
key system and PED key
mechanism in PED chapter;
5. Added OsGetOptInfo() and its
corresponding data structure in
chapter System Function;
6. Added instruction of low battery
2016-06-13 V2.1.4 in RF, Wifi, Printer and GPRS Prolin Team
chapters;
7. Added a member unsigned char
anti_interference_flag in user
configuration structure struct
pcd_user_t in RF chapter;
8. Modified some errors of Ipv6
related interfaces;
9. Added some related return
values and data structure of Ipv6
in chapter Network
Configuration;
10. Added some system
configuration parameters in
Appendix 3 Registry.
IX
1. Updated the instruction of
OsSysSleep();
2. Modified the value range of
ConnectTimeout from 0~300 to
0~60 in the table of Variable
definitions of
ST_MODEM_SETUP in chapter
MODEM;
3. Updated the parameter
KeepAlive in OsWlLogin() and
OsWlLoginEx();
4. Updated the instruction of
OsModemConnect();
5. Updated the instruction of
OsSysSleepTime();
6. Added a new system
configuration parameter
2016-07-04 V2.1.5 persist.sys.lcdsaverbrightness Prolin Team
and deleted
persist.sys.eth0.enable in the
Appendix 3 Registry;
7. Added three encrypted file
system interfaces
OsCryptFormat() ,
OsCryptMount() and
OsCryptUmount() and related
return code list in chapter System
Function;
8. Added chapter 23 GPS;
9. Added a new return value
POWER_WPC and an related
note in OsCheckPowerSupply();
10. Modified the second point in the
note area under the
OsPmGetEvent().
1. Added an interface
OsPedSetPinIconLayout() in
PED chapter;
2. Added an interface
OsPrnClrBuf() in Printer chapter;
3. Added a note about Bssid
2016-07-21 V2.1.6 member of ST_WifiApSet structure Prolin Team
in the instruction of OsWifiConnect();
4. Added two new system
configuration parameters
persist.sys.wifi.roam.dhcp
and persist.sys.tm.imei in
Appendix 3 Registry;
X
5. Updated the instruction of
OsGpsClose();
6. Updated the instruction of
OsWlSwitchPower();
7. In 6.5.6
OsPedGetPinBlock(),6.6.1
OsPedGetPinDukpt(),6.4.4
OsPedVerifyPlainPin(),6.4.5
OsPedVerifyCipher() and 6.9.9
OsPedGetPinBlockSM4()
interfaces, added a note about
how calling they migh cause an
exception to the applications that
are running XUI and how to solve
this problem.
1. In Appendix 4 Validity of models
and contents, added Q80 and
D220 models to the validity table;
2. In MODEM chapter, added two
new return values, the error
codes are -3180 and -3184;
3. Added new system configuration
parameters
persist.sys.timezone.tz,
persist.sys.delayshutdown and
persist.sys.continue.print in
Appendix 3 Registry;
4. Added DnsAddrInfo structure
2016-10-17 V2.1.7 and OsNetDnsEx() function in Prolin Team
chapter 20 Network
Configuration;
5. Added a new interface
OsWifiWpsConnect() in WiFi
chapter;
6. In Power Management chapter,
added poweroff event, forbidding
poweroff and allowing poweroff
functions;
7. In Printer chapter, updated the
instruction of interface
OsPrnStart() and added a new
interface OsPrnSetParam().
1. Added new system configuration
parameters
persist.sys.autouload.enable,
2017-03-10 V2.1.8 Prolin Team
persist.sys.autostartup.enable,
persist.sys.hostname,
persist.sys.wnet.version and
XI
persist.sys.confirmshutdown in
Appendix 3 Registry;
2. In Network Configuration
chapter, added two new return
values ERR_ROUTE_EXIST and
ERR_ROUTE_NONEXIST, a
structure Ipv4RouteTable and
three Ipv4 interfaces
OsNetSetRouteTable(),
OsNetDelRouteTable() and
OsNetGetRouteTable();
3. In Keyboard chapter, added a
new key value KEYCAMERA in
the key definition table;
4. In Barcode chapter, added data
definition and
OsScanSetParam() interface of
camera’s scan barcode function;
5. In Power Management chapter,
added return code list and
POWER_TYPE structure;
6. Added description of ports used
by USB scanner;
7. Added instructions for
OsPortOpen() and
OsPortSend();
8. Added chapter 24 Base;
9. Added instruction and return
value for OsScanSetParam();
10. Modified instruction of
OsBaseOpen() and
OsBaseClose();
11. Delete the repeated return value
-3606 in barcode module;
12. Added
persist.sys.keypad.duty_cycle
and items related to barcode
module in registry table;
13. Deleted ro.fac.scanner in registry
table.
1. Added a return value of
OsGpsOpen();
2. Added instruction of
OsNetSetDns();
2017-07-13 V2.1.9 3. Added note of OsSysSleep(); Prolin Team
4. Added ro.fac.coulomb_counter
key in registry table;
5. Modified the function of
OsGetSysVer();
XII
6. Added a note of OsSysSleep();
7. Modified the instruction of
OsPortRecv();
8. Added persist.sys.enable.debug
and rt.sys.mainapp.restart in
registry table, and updated the
relevant function instructions;
9. Modified the description of lights
in OsScanSetParam();
10. Updated the parameter
description of KeyVarType in
OsPedDesDukpt();
11. Added note of OsGetAppInfo();
12. Added the length limit of key in
OsRegSetValue() function;
13. Added return code list,
OsRecordOpen(),
OsRecordStart(),
OsRecordStop(),
OsRecordCheck(),
OsRecordClose() and
OsStopPlayWave() functions in
chapter 27 Audio.
14. Add new functions
OsPiccApplePoll() and
OsPiccOffCarrier().
1. Add a Enumeration structure
WAKEUP_SOURCE;
2. Add a new function
OsWakeupSource();
2017-09-07 V2.2.0 Prolin Team
3. Add a new function
OsPedSetPinBg().
4. Add a new function
OsPedCustomKeypad().
1. Modified the description of
OsRecordStart();
2. Updated the instruction of
OsPedCustomKeypad();
3. Added
persist.sys.ped.keypad.mask in
registry table;
2017-11-15 V2.2.1 4. Added persist.sys.sound.enable Prolin Team
in registry table;
5. Modified the description of
persist.sys.delayshutdown in
registry table;
6. Modified the instructions of
OsSysSleep() and
OsSysSleepEx();
XIII
7. Updated the instruction of
OsPmGetEvent();
8. Added ro.fac.security_level and
ro.fac.security_mode in registry
table;
9. Added camera photography
function.
1. Added
persist.sys.mainapp.restart in
registry table;
2. Added
persist.sys.ped.keypad.type in
registry table;
3. Added a new function
OsGetAppExitCode();
4. Added
persist.sys.batterylow.offcnt,
2018-01-08 V2.2.2 Prolin Team
persist.sys.reboot.cnt and
persist.sys.powerkey.offcnt in
registry table;
5. Added a new function
OsPedSetOfflinePin();
6. Modified instruction and
parameter Dns of
OsNetSetDns();
7. Modified the value of parameter
InputLen in PED SM2 Algorithm.
1. Added macro
PORT_USBHOST1, and
modified the instruction of
OsPortOpen();
2. Modified the instruction of
OsNetSetDns() in section 20.4.1;
3. Added persist.sys.dns.static in
registry table;
4. Added
2018-04-02 V2.2.3 Prolin Team
persist.sys.xcb.installapp.lock in
registry table;
5. Modified the description of DataIn
in section 6.5.6
OsPedGetPinBlock;
6. Updated section 24.3 API
7. Updated the instructions of
OsInstallFile() and
OsFirmwareUpgrade().
1. Updated the instructions of
OsPedSetPinIconLayout(), the
2018-05-23 V2.2.4 Prolin Team
description of parameters DataIn
and Mode in
XIV
OsPedUpdatePinBlock() and the
description of parameters
InitVector, DataInLen and Mode
in OsPedAes();
2. Modified the description of
persist.sys.ped.keypad.type and
added
persist.sys.ped.pin.icon.alignin in
registry table;
3. Added interface
OsScanDecodeBuf().
4. Added the permission instruction
of OsInstallFile() and
OsUninstallFile();
5. Deleted section 14.4 POSIX;
6. Added return code -3606.
1. Updated the content of chapter
“IC Card Reader” and “RF
Reader”;
2. Updated the description of
“POSIX Interface”.
3. Updated the description of
parameters DataInLen and Mode
in OsPedDes();
4. Added section “6.10 DES FIRE”;
2018-08-16 V2.2.5 Prolin Team
5. Added interface
OsPiccInitIso15693();
6. Added a new return code -2959
to RF module;
7. Added interfaces
OsPedEndPinEntry() and
OsPedPinKeyNotify(), and
updated section “6.5.10
OsPedGetKcv”.
1. Added NET_LINK_BT for
Bluetooth link;
2. Modified the instruction of the
registry key
“persist.sys.ped.keypad.type”;
3. Added two interfaces
OsPlayAudio() and
2018-11-15 V2.2.6 Prolin Team
OsStopPlayAudio();
4. Added macros
RESOLUTION_WIDTH_1024_H
EIGHT_480 and
CAMERA_PIXEL_FORMAT_SB
GGR8 in chapter “Barcode and
Camera”;
XV
5. Updated the instruction in section
OsCameraCapture();
6. Updated the parameter and
instruction in
OsPedGetPinBlock();
7. Updated the parameter and
instruction in
OsPedWriteAesKey();
8. Updated the function description
of OsPedAes();
9. Added a new return value
ERR_MSR_NO_TRACK_ERR in
“MSR” module;
10. Added a new interface
OsMsrReadJIS();
11. Added NET_LINK_USB link in
“Network Configuration” module;
12. Added event type
PM_MSG_POWER_ABNORMA
L and interface
OsCheckPowerStatus() in
“Power Management” module.
1. Updated the description of
parameter Level in
“OsSysSleepEx”;
2. Added key word
ro.security_version in “Appendix
3 Registry”;
3. Modified the description of
2018-11-29 V2.2.7 DUKPT mechanism; Prolin Team
4. Updated the structure
WAKEUP_SOURCE;
5. Updated the function instruction
and description of parameter
level in OsSysSleepEx();
6. Updated the applicable platform
of OsWakeupSource().
1. Updated the limited models for
OsSysSleep() and
OsSysSleepEx();
2019-02-01 V2.2.8 2. Added interface OsWlInitEx(); Prolin Team
3. Modified the description of return
code -3510 in chapter
“GPRS/CDMA”.
1. Added keyword
persist.sys.usbd.mode in the
2019-03-13 V2.2.9 registry; Prolin Team
2. Added new interface OsLed(),
and list the interface parameter
XVI
settings related to the model in
the instruction;
3. Updated parameter KeyFlag in
OsPedSetFunctionKey(), and the
instruction of
OsPedGetPinBlock(), and the
keyword
persist.sys.ped.keypad.type in
the registry.
Added
PM_MSG_BATTERY_DAMAGE and
2019-04-22 V2.3.0 Prolin Team
upgraded section
“OsCheckPowerStatus()”.
1. Added a new interface
OsTerminalConsumeInfo();
2. Added description of
usbd.mode=4 in keyword
persist.sys.usbd.mode
3. Added
PCD_ERR_RXLEN_EXCEED_F
2019-05-15 V2.3.1 LAG in the return code list of RF Prolin Team
reader;
4. Updated section “User
Configuration Structure”;
5. Added macro ERR_EAP_ID in
the WiFi return code list.
6. Added a new interface
OsPedRkiInjectKey().
1. Added a new interface
OsSetKeyTone();
2. Modified the instruction of
OsRegSetValue().
2019-06-20 V2.3.2 Prolin Team
3. Modified the parameter
description in OsPedGetKcv();
4. Added a new interface
OsNetNat().
1. Modified the instruction of
OsCheckPowerStatus();
2. Added ERR_USB_MODE;
3. Added instruction in Zhang Mengying
2019-07-23 V2.3.3 OsOnBase();
4. Updated the return code and Zheng Zhihai
instruction of OsBaseOpen();
5. Added interface
OsCheckPortStatus().
1. Added instruction for Chen Xiaoyong
2019-09-12 V2.3.4 OsPedCancelPinEntry() and
OsPedEndPinEntry(); Zheng Zhihai
XVII
2. Updated the parameter
description of
OsPedGetPinBlock();
3. Added keywords
“persist.sys.ped.reboot.cycle”
and
“persist.sys.ped.pinwait.retain” in
the Registry table;
4. Updated the instruction and
parameter description of
OsCheckPortStatus().
1. Added a new interface
OsGetBaseInfo();
2. Updated the description of
parameter DutyCycle;
3. Updated interface
OsCameraCapture(); Zheng Zhihai
4. Added a new interface Huang Ruzhen
2019-11-20 V2.3.5
OsCameraDetectMotion(); Li Xin
5. Modified the definition of wakeup Zhang Mengying
source;
6. Added description for interface
OsCheckBMSMode(), keyword
rt.app.key.tone and
rt.app.key.backlight.
1. Added section “Digital IO”;
2. Updated section “Macro
Definition of Camera” and
“OsScanSetParam”;
3. Updated chapter “Power
Management” and the Zheng Zhihai
description of Fang Wei
2019-12-03 V2.3.6
“persist.sys.confirmshutdown” in Zhang Mengying
registry; Zheng Zhihai
4. Added section “OsPortCheckRx”;
5. Updated the return value in
section “OsCheckPortStatus”
and “OsGetBaseInfo”;
6. Added section “OsBaseCmd”.
1. Updated the instruction of section
“OsPortRecv”; Xu Bin
2019-12-31 V2.3.7
2. Added the instruction of Zhang Mengying
“OsPortCheckRx”.
1. Added the return code
description for installing fwp in
the OsInstallFile();
2020-04-01 V2.3.8 Zhang Mengying
2. Updated the description of the
registry key
“persist.sys.usbd.mode”.
XVIII
1. Update the user configuration
structure in the chapter “RF
Reader”.
2. Modified the description of the Zhang Mengying
2020-05-13 V2.3.9 keyword ro.fac.videocard;
3. Added descriptions of keywords Huang Ruzhen
persist.sys.tm.cpu,
persist.sys.tm.flash and
persist.sys.tm.ram.
Updated “OsTerminalConsumeInfo”
and “OsPiccApplePoll” and Zhang Mengying
2020-06-30 V2.4.0
“persist.sys.usbd.mode” in the Huang Ruzhen
Registry.
1. Optimized the structure of the
PED chapter;
2020-11-19 V2.4.1 Yang Yongquan
2. Added APIs AES MKSK and AES
DUKPT.
1. Added caution in chapter LCD;
2020-12-09 V2.4.2 Zhang Mengying
2. Updated chapter Touch Screen.
Updated the return code list in
2021-01-21 V2.4.3 Fang Wei
chapter Barcode and Camera.
1. Added structure member
PCD_USER_ST;
2. Added instruction of Hu Liancong
OsPiccSetUserConfig();
2021-04-27 V2.4.4 Zhang Mengying
3. Modified the return value of
OsBaseConnect(); Wu Haisheng
4. Added a new interface
OsIccTransfer().
Added a new interface
2021-08-06 V2.4.5 Liao Wenxiong
OsPrnRawData().
Added the description of the keyword
2021-08-30 V2.4.6 Zhang Mengying
"persist.sys.tm.pwd".
Modified the interface
2021-11-29 V2.4.7 Li Ling
OsGetBaseInfo and OsOnBase.
Modified the instruction of
2021-11-30 V2.4.8 He Wenliang
OsWlGetSignal.
Modified the instruction of
2021-12-27 V2.4.9 Yang Yongquan
OsPedWriteRsaKey.
Added new interfaces
OsPedCalcAesGcm,
OsPedGenerateEccKeyPair,
2022-02-28 V2.5.0 OsPedWriteEccKey, Huang Ruzhen
OsPedReadEccPublicKey,
OsPedEccSign, OsPedEccVerify and
OsPedEccPointMul.
Modified the instruction of the
2022-03-02 V2.5.1 parameter Mac [Output] of Yang Yongquan
OsPedGetMacAes.
XIX
1. Modified the instruction of
OsOnBase.
2022-03-18 V2.5.2 Li Ling
2. Added a registry key
persist.sys.switch.tm.app.
Modified the ScrKeyType in the
2022-03-24 V2.5.3 Yang Yongquan
interface OsPedWriteAesKey.
XX
Table of Contents
1 Introduction ........................................................................................................... 1
3 Thread .................................................................................................................. 7
XXI
4.4.2 OsTimerCheck ............................................................................... 11
4.5.1 OsSleep.......................................................................................... 12
4.9.1 OsGetAppInfo................................................................................. 14
XXII
4.14 Install and Uninstall Files.......................................................................... 18
4.14.1 OsInstallFile.................................................................................... 18
4.21.3 OsCryptUmount.............................................................................. 30
XXIII
4.22 LED .......................................................................................................... 31
4.23.1 OsTerminalConsumeInfo................................................................ 32
5.5.1 OsAES............................................................................................ 37
6 PED .................................................................................................................... 41
XXIV
6.2 Data Definition .......................................................................................... 44
6.3.2 RSA Key Structure for Verifying the Ciphertext IC Card PIN .......... 46
6.4.1 OsPedOpen.................................................................................... 46
6.5.9 OsPedSetAsteriskLayout................................................................ 58
XXV
6.5.10 OsPedSetPinIconLayout ................................................................ 59
6.6.7 OsPedGetKcv................................................................................. 74
6.7.4 OsPedDesDukpt............................................................................. 81
XXVI
6.8.3 OsPedRsaRecover ......................................................................... 85
XXVII
6.12.1 OsPedRkiInjectKey ...................................................................... 103
XXVIII
8.1 OsKbBacklight ........................................................................................ 128
XXIX
11.4.9 OsPrnPrintf ................................................................................... 138
XXX
14.1 Return Code List .................................................................................... 151
XXXI
16.1 Return Code List .................................................................................... 166
XXXII
17 Communication Port ..................................................................................... 179
XXXIII
18.4 OsModemClose ..................................................................................... 204
XXXIV
20.3.2 OsNetPing .................................................................................... 226
XXXV
20.5.2 OsNetSetIPv6Addr ....................................................................... 239
XXXVI
21.3 Wireless Module Information Settings .................................................... 257
XXXVII
24.1 Introduction ............................................................................................ 272
XXXVIII
27.7 OsPlayWave .......................................................................................... 288
XXXIX
28.3.10 OsScanDecodeBuf ..................................................................... 300
XL
Appendix 4 Validity of Models and Contents .......................................................... 328
XLI
Table List
Table 17.2 Return code list of USB port functions ........................................... 179
XLII
Table 21.1 GPRS/CDMA return code list ........................................................ 244
XLIII
Prolin API Programming Guide
1 Introduction
1.1 Purpose
This documentation introduces the framework of Prolin applications and the key points
of GUI and other important frameworks. It provides programming guide for API
interfaces compatible with controlling hardware based on Prolin OS and offers
corresponding instructions conducive to a successful design for developers.
Prolin provides a series of interfaces based on Linux system calls and POSIX
interfaces. And a set of OSAL interfaces, beginning with the prefix “Os”, are
encapsulated for the compatibility demand of some background services and
applications. In addition, demo programming codes of POSIX interfaces and system
libraries are illustrated in this documentation to guide developers to access device or
system function.
In this documentation, all the interfaces beginning with “Os” are defined in osal.h of
SDK, unless otherwise specified.
Prolin SDK provides necessary tools and resources for local Prolin applications.
Different from the background system applications, Prolin SDK can run independently
as executive programs on Prolin OS-based devices. Local applications enjoy a great
deal of privileges. They can access all Prolin OS features, save data in local file system
and even communicate with other installed programs through a special URL.
1.3 Prerequisites
Process, thread and Linux system functions and their roles in application
development;
Conventions used in this document and their corresponding meanings are listed
below:
Giving notes.
Table 2.1 lists the types and value ranges of return codes involved in this document:
Value(Decimalis
Type Description
m)
General Return
-1000~-1999 General error code of API.
Value
System Function -2200~-2299
Power Management -2300~-2399
Encryption and
-2400~-2499
Decryption
Font Library -2500~-2599
LED display -2600~-2699
MSR -2700~-2799
IC Card Reader -2800~-2899
Contactless IC Card
-2900~-2999
Reader
Communication
-3000~-3099
Port
MODEM -3100~-3299
IP Network
-3300~-3399
Configuration
PED -3800~-3899
Table 2.2 lists the macro definitions, values and corresponding descriptions of the
general return values in this documentation.
2.3 Parameter
There are two types of API parameters: input parameter and output parameter. They
are distinguished with identifiers in this documentation.
All the input and output string parameters end with"\x00" and valid string length must
be clarified in parameter description.
3 Thread
Prolin supports pthread of POSIX. The header file of pthread is located at the
installation directory of ProlinBuilder: toolchains\arm-linux\arm-softfloat-linux-
gnu\include\pthread.
4 System Function
LOG_T:
typedef enum{
LOG_DEBUG, /* Display debugging message*/
LOG_INFO, /* Display prompt message*/
LOG_WARN, /* Display warning message*/
LOG_ERROR, /* Display error message*/
} LOG_T;
ST_TIME(time structure):
ST_TIME:
typedef struct{
int Year; /*Year 1970– 2037*/
int Month; /*Month 1 –12*/
int Day; /*Day 1 –31*/
int Hour; /*Hour 0 – 23*/
int Minute; /*Minute 0 –59*/
int Second; /*Second 0 –59*/
int DayOfWeek;/* Monday–Sunday (valid only in read time)*/
} ST_TIME;
ST_TIMER(timer structure):
ST_TIMER:
typedef struct{
unsigned long Start;
unsigned long Stop;
unsigned long TimeLeft;
} ST_TIMER;
ST_APP_INFO:
typedef struct{
char Id[64];
char Name[64];
char Bin[64];
char Artwork[64];
char Desc[64];
char Vender[32];
char Version[32] ;
} ST_APP_INFO;
ST_OPT_INFO:
typedef struct {
char Name[64];
char Version[32];
} ST_OPT_INFO;
4.3.1 OsSetTime
Only the main application has permission to set time; otherwise, it will fail
Instruction and return ERR_NEED_ADMIN.
4.3.2 OsGetTime
Instruction
4.4 Timer
4.4.1 OsTimerSet
4.4.2 OsTimerCheck
4.5 Delay
4.5.1 OsSleep
Return None
Instruction
4.6 Thread
Prolin thread is implemented by standard linux POSIX interface. Please refer to the
following code:
Example:
#include <pthread.h>
static pthread_t ntid;
static void *thread_fn(void *arg)
{
printf("This is child thread\n");
return ((void *)0);
}
int main()
{
printf("This is main thread\n");
if(pthread_create(&ntid,NULL,thread_fn,NULL) != 0)
printf("can't create thread\n");
sleep(5);
return 0;
}
4.7 Log
4.7.1 OsLogSetTag
Return None.
1. Call this function to set LOG tag; the default tag is NULL.
2. It is recommended to set tag to be an application name.
Instruction 3. The valid Tag length ranges from 0 to 32 bytes; only the first 32 bytes
will be used if Tag length exceeds 32 bytes.
4. OsLog() will not save LOG information for a NULL tag or an empty
string.
4.7.2 OsLog
4.8.1 OsGetTickCount
Instruction
4.9.1 OsGetAppInfo
4.9.2 OsGetOptInfo
4.10 Buzzer
4.10.1 OsBeep
Return None.
4.11.1 OsSetKeyTone
Instruction
4.12.1 OsRunApp
4.12.2 OsGetAppExitCode
Parameters None
Users can call this function after OsRunApp() to get the exit code
Instruction
of sub-application.
4.13.1 OsRegSetValue
4.13.2 OsRegGetValue
4.14.1 OsInstallFile
4.14.2 OsUninstallFile
4.15.1 OsFirmwareGetVersion
4.15.2 OsFirmwareUpgrade
4.16.1 OsVerifySign
4.16.2 OsVerifySignExternal
4.17.1 OsGetSysVer
Prolin can test whether the handset is on the base or not, which is not applicable to
models that do not have any base.
4.18.1 OsOnBase
Prolin can monitor program state. Once the program crashes, it will save the crash
report in the directory“/data/tombstones” after calling OsSaveCrashReport(). .
4.19.1 OsSaveCrashReport
4.20.1 OsMount
4.20.2 OsUmount
4.21.1 OsCryptFormat
4.21.2 OsCryptMount
4.21.3 OsCryptUmount
4.22 LED
4.22.1 OsLed
SP200 Id = 3: green
Id = 4: red
B920 Id = 1: red or green
IM20 Id = 1: red, green, blue, yellow,
Q20 cyan, magenta or white
Id = 1: green
Q28
Id = 2: red or green
Id = 1: red
Id = 2: green
Id = 3: blue
Q30
Id = 4: yellow
Id = 5: red or green
Id = 6: red or green
4.23.1 OsTerminalConsumeInfo
4.24 Digital IO
4.24.1 OsDigitalIOGetStat
4.24.2 OsDigitalIOSetStat
5.2.1 OsGetRandom
Prolin supports SHA algorithms, including SHA-1, SHA-2(SHA-256, SHA-512) and the
truncation form of SHA-2 (SHA-224, SHA-384).
5.3.1 OsSHA
SHA_TYPE_38 48
SHA_TYPE_512 64
Return None.
Instruction
5.4.1 OsDES
5.5.1 OsAES
int KeyLen,
int Mode);
Function Encrypt or decrypt data with AES algorithm
Input[Input] 16-byte input data.
Output[Outpu
16-byte output data.
t]
AesKey[Input
Parameters ] Key.
5.6.1 OsRSA
5.6.2 OsRSAKeyGen
ERR_INVALID_PARA
Invalid Parameters.
M
ERR_GEN_RANDOM Fail to generate random data.
ERR_GEN_FAIL Fail to generate RSA Key pair.
Instruction
6 PED
Prolin provides a series of PED interfaces, including built-in PED, MK/SK, DUKPT,
RSA and other related interfaces.
The architecture of PED is desiged to contain three levels of key. From top to bottom,
its order is:
Each PED terminal only has one TLK. Its index number is 1.
Terminal master key or acquirer master key, each PED terminal can have 100
TMKs. The index number is from 1 to 100.
Transaction working key, which is used to perform PIN, MAC and other operations.
Each PED terminal can have 100 TMKs. The index number is from 1 to 100.
Each key has its corresponding index number, length, purpose and tags which are
set through API before writing in the key so as to authorize the permission and
avoid abuse of the key.
Mechanism of DUKPT:
DUKPT (Derived Unique Key Per Transaction) is the one-time pad system in which
different key (PIN、MAC) is used for each transaction. KSN (Key Serial Number)
concept which is the key factor to realize one-time pad is introduced in this system.
Each key corresponding to KSN can generate different keys according to the usage
and variant constants listed below.
Each PED terminal can have 100 DUKPT groups. Selection of group index is needed
when writing in TIK; select the corresponding index number when using DUKPT.
ST_RSA_KEY
typedef struct{
int ModulusLen; /*Modulus length(bits) */
unsigned char Modulus[512]; /*Modulus.When modulus length is less
than 512 bytes, add 0x00 on the left. */
int ExponentLen; /* Exponent length (bits) */
unsigned char Exponent [512]; /*Exponent.When exponent is less than
512 bytes, add 0x00 on the left.*/
unsigned char KeyInfo[128]; /* RSA key information */
}ST_RSA_KEY;
6.3.2 RSA Key Structure for Verifying the Ciphertext IC Card PIN
ST_RSA_PINKEY
typedef struct{
int ModulusLen; /*Modulus length of PIN public key(unit: bits) */
unsigned char Modulus[256]; /*Modulus of PIN public key*/
unsigned char Exponent [4]; /* Exponent of PIN public key*/
int IccRandomLen; /*Length of random data from IC card*/
unsigned char IccRandom[8]; /*Random data from IC card*/
}ST_RSA_PINKEY;
6.4.1 OsPedOpen
6.4.2 OsPedGetVer
RET_OK Succeeded.
Return ERR_DEV_NOT_OPEN PED device is not open.
ERR_INVALID_PARAM Invalid parameter.
Instruction
6.4.3 OsPedEraseKeys
6.4.4 OsPedClose
6.4.5 OsPedInjectKeyBlock
When SrcKeyType =
PED_TLK,
SrcKeyIdx = 1;
When SrcKeyType =
PED_TMK,
SrcKeyIdx = [1~100];
When ucSrcKeyType
= PED_AES_TLK,
Header ucSrcKeyIdx = 1;
When ucSrcKeyType
= PED_AES_TMK,
ucSrcKeyIdx =
[1~100];
DstKeyIdx:
When DstKeyType =
PED_TMK,
DstKeyIdx = [1~100];
When DstKeyType =
PED_TPK or
PED_TAK or
PED_TDK,
DstKeyIdx = [1~100];
When
DstKeyType=PED_A
ES_TMK,
DstKeyIdx=[1~100];
1 byte When
DstKeyType=PED_
AES_TPK/PED_AE
S_TAK/PED_AES_
TDK,
DstKeyIdx=[1~100];
When
DstKeyType=PED_
TIK,
DstKeyIdx=[1~100];
When
DstKeyType=PED_
AES_TIK,
DstKeyIdx=[1~40].
Key Block ‘B’ TDEA
Version ID(1
byte) ‘D’ AES
special final
optional block
that is filled
with an
appropriate
number of
padding
characters.)
Encryption Cipher text (2 bytes len +
body key + padding)
TDES is 16 bytes, AES
MAC
is 32 bytes
0 Succeeded
Return
others Failed
The relationship between the types of destination keys that each
source key supports for injection is as follows:
1. When SrcKeyType = TLK, key TLK, TMK or TIK can be
injected;
2. When SrcKeyType = TMK, key TMK, TPK, TAK or TDK can
be injected;
3. When SrcKeyType = AES_TLK, key AES_TLK, AES_TMK
or AES_TIK can be injected;
Instruction
4. When SrcKeyType = AES_TMK, key AES_TMK, AES_TPK,
AES_TAK or AES_TDK can be injected.
The length of the source key and destination key must meet the
following conditions:
1. You cannot use a key with a length of 8 bytes as the source
key;
2. The length of the destination key should be less than or
equal to the length of the source key.
6.5.1 OsPedSetInterval
6.5.2 OsPedVerifyPlainPin
6.5.3 OsPedVerifyCipherPin
Encryption algorithm:
Get ciphertext PIN by using the public key to calculate the data
which are listed in following table with RSA algorithm.
6.5.4 OsPedSetFunctionKey
6.5.5 OsPedCancelPinEntry
Parameters None.
6.5.6 OsPedSetOfflinePin
ERR_DEV_NOT_OP
PED device is not open
EN
Return ERR_INVALID_PAR
Invalid parameter
AM
Others Refer to the PED Return Code List
Instruction
6.5.7 OsPedEndPinEntry
Instruction This function does not require PED service, so there is no need
to call OsPedOpen() before using it.
6.5.8 OsPedPinKeyNotify
6.5.9 OsPedSetAsteriskLayout
int OsPedSetAsteriskLayout(int x,
int y,
Prototype int fontSize,
int fontColor,
uchar align);
Function Set the layout attributes of asterisk while inputting PIN.
x X-coordinate
y Y-coordinate
Font size of asterisk:
fontSize = 16: the character size is 16 dots;
fontSize = 24: the character size is 24 dots;
fontSize = 32: the character size is 32 dots;
fontSize
Parameters fontSize = 48: the character size is 48 dots.
Note:The asterisk is displayed with PED internal
font, which has no relation with the installed
system font library.
Font color of asterisk.
fontColor Macro definition RGB (_r, _g, _b) is used; the 16-
bit color value will be generated according to the
input three primary colors.
Alignment:
PED_ASTERISK_ALIGN_LEFT:
Display asterisk from left to right; the left
starting position is fixed.
PED_ASTERISK_ALIGN_CENTER:
align Display asterisk from the middle to both right
side and left side symmetrically; the middle
position is fixed.
PED_ASTERISK_ALIGN_RIGHT:
Display asterisk from right to left; the right
starting position is fixed.
RET_OK Succeeded.
ERR_DEV_NOT_OP
PED device is not open.
EN
Return
ERR_INVALID_PAR
Invalid parameter.
AM
Others Refer to the PED Return Code List.
1. This function is only used to display asterisk, while PIN input
interface is displayed by application.
2. This function should be called to set the layout of asterisk
Instruction
before calling OsPedVerifyPlainPin(),
OsPedVerifyCipherPin() OsPedGetPinBlock() or
OsPedGetPinDukpt ().
6.5.10 OsPedSetPinIconLayout
int OsPedSetPinIconLayout(int X,
int Y,
int Interval,
uchar IconNum,
Prototype
char *PinIcon,
int PinIconLen,
char *PinIconBG,
int PinIconBGLen);
Function Set the layout attributes of foreground and background icons.
The initial x coordinate of foreground
X [Input]
and background icons.
Parameters The initial y coordinate of foreground
Y [Input]
and background icons.
Interval [Input] The interval of two adjacent icons.
6.5.11 OsPedSetPinBg
6.5.12 OsPedCustomKeypad
6.6 MK/SK
6.6.1 OsPedWriteKey
When ucSrcKeyType =
PED_SM4_TMK,
ucSrcKeyIdx = [1~100];
When ucSrcKeyType =
PED_SM4_TPK/PED_SM4_T
AK/PED_SM4_TDK,
ucSrcKeyIdx = [1~100];
DstKeyIdx:
When DstKeyType =
PED_TLK,
DstKeyIdx = 1;
When DstKeyType =
1 byte PED_TMK,
DstKeyIdx = [1~100];
When DstKeyType =
PED_TPK or PED_TAK or
PED_TDK or
PED_TDFK,DstKeyIdx =
[1~100].
DstKeyType:
PED_TLK
PED_TMK
PED_TPK/PED_TAK/PED_T
1 byte DK
PED_SM4_TMK
PED_SM4_TPK/PED_SM4_T
AK/PED_SM4_TDK
PED_TDFK
DstKeyLen: 8/16/24
When DstKeyType is
PED_SM4_TMK/PED_SM4_
1 byte
TPK/PED_SM4_TAK/PED_S
M4_TDK,
DstKeyLen=16.
DstKeyValue.
8/16/24
bytes Destination key plaintext /
ciphertext.
KcvMode:
1 byte
0x00: No verification.
ERR_PED_KEY_TYPE_E
RR Key type error.
Return ERR_PED_NO_MORE_B
UF System memory is not enough.
ERR_PED_KCV_MODE_
ERR PED KCV verification mode error.
ERR_PED_KCV_CHECK_
FAIL PED KCV verification failed.
6.6.2 OsPedWriteKeyVar
Key types:
PED_TMK
KeyType PED_TPK
PED_TAK
PED_TDK
Source key index.The valid range is from 1
Parameters SrcKeyIdx to 100.
Destination key index. The valid range is
DstKeyIdx
from 1 to 100.
A 24-byte string involoved in calculation.
KeyVar[Input] The string is used to xor with the source key.
The string length should be the same as the
key’s, and it is extensible.
RET_OK Succeeded.
ERR_DEV_NOT_OPEN PED device is not open.
Return
ERR_INVALID_PARAM Invalid parameter
Others Refer to PED Return Code List .
Instruction
6.6.3 OsPedGetPinBlock
6.6.4 OsPedUpdatePinBlock
6.6.5 OsPedGetMac
6.6.6 OsPedDes
6.6.7 OsPedGetKcv
PED_SM4_TMK/PED_SM4_TPK/PED_SM4_T
AK/PED_SM4_TDK).
Length of data that needs to be calculated.
The valid data length ranges from 0 to 128bytes
KcvDataLen and must be a multiple of 8. When KeyType is
TIK, KcvDataLen can be set to 0; When the KCV
check mode is 0x04, the data length must be
divisible by 16.
KcvData[Inpu A pointer to the data that needs to be calculated.
t] NULL pointer is valid when KeyType is TIK.
KCV.
Kcv[Output] The valid length of Kcv is 8 bytes when KeyType
is TIK, and 3 bytes for rest KeyType.
RET_OK Succeeded.
ERR_DEV_NOT_OP
PED device is not open.
EN
Return
ERR_INVALID_PAR
Invalid parameter.
AM
Others Refer to the PED Return Code List .
Instruction
6.6.8 OsPedDeriveKey
6.7 DUKPT
6.7.1 OsPedWriteTIK
10
Initialize KSN.
bytes
RET_OK Succeeded.
ERR_DEV_NOT_OPE
PED device is not open.
N
Return
ERR_INVALID_PARA
Invalid parameter
M
Others Refer to PED Return Code List .
When calling this function to write the ciphertext or plaintext of
a key to a specific index position of the specific key type area,
please pay attention to the following notes:
1. When SrcKeyIdx=0, DstKeyValue is regarded as the
plaintext of key. The system will directly write the
DstKeyValue to DstKeyIdx in DstKeyType area without
judging SrcKeyType and SrcKeyIdx.
2. Only when PED_TLK does not exist, plaintext is allowed to
be written and key is allowed to be downloaded.
Instruction 3. When PED_TLK exists, plaintext is not allowed to be written
and key is not allowed to be downloaded.
4. If SrcKeyIdx is valid, DstKeyValue is regarded as the
ciphertext of the key. The system will decrypt DstKeyValue
with SrcKeyIdx key in SrcKeyType area and write the key to
DstKeyIdx in DstKeyType. (DstKeyType >= SrcKeyType)
5. KVC is used to verify plaintext. If plaintext is typed-in directly,
and the KcvMode of KeyIn is not 0, the system will perform
KCV verification on plaintext according to the specified
KcvMode.
6.7.2 OsPedGetPinDukpt
6.7.3 OsPedGetMacDukpt
1. 0x20/0x21/0x22/0x40/0x41/0x42: KSN
does not increase1 automatically.
2. 0x40/0x41/0x42: MAC calculation method
is the same as 0x20/0x21/0x22’s.
3. 0x40/0x41/0x42: Choose to respond to
MAC key.
0x20/0x21/0x22: KSN choose to request
or respond to MAC key
4. Other values are reserved for extended
MAC algorithm.
RET_OK Succeeded.
ERR_DEV_NOT_OPEN PED device is not open.
Return
ERR_INVALID_PARAM Invalid parameter.
Others Refer to PED Return Code List .
If KSN does not increase 1, both the response MAC key and the
Instruction
request MAC key can calculate MAC for unlimited times.
6.7.4 OsPedDesDukpt
RET_OK Succeeded
ERR_DEV_NOT_OPEN PED device is not open.
Return
ERR_INVALID_PARAM Invalid parameter.
Others Refer to PED Return Code List .
If KSN does not increase 1 automatically, a DUKPT group can
perform DES operations for 256 times at most when
Instruction
KeyVarType is 0x00/0x01; a DUKPT group can only do one DES
operation when KeyVarType is 0x02.
6.7.5 OsPedGetKsnDukpt
6.7.6 OsPedIncreaseKsnDukpt
6.8 RSA
6.8.1 OsPedReadRsaKey
6.8.2 OsPedWriteRsaKey
1. The supported RSA key length is not more than 512 bytes.
6.8.3 OsPedRsaRecover
Instruction
6.8.4 OsPedReadCipherRsaKey
6.8.5 OsPedWriteCipherRsaKey
6.9 AES
6.9.1 OsPedWriteAesKey
6.9.2 OsPedAes
intOsPedAes(intKeyIdx,
unsigned char *InitVector,
const unsigned char *DataIn,
Prototype
intDataInLen,
unsigned char *DataOut,
int Mode);
Use TAESK or PED_AES_TDK to do AES encryption or
Function
decryption for DataIn whose length is specified by DataInLen.
TAESK index.
KeyIdx[Input]
The value range is from 1 to100.
Initialization vector.
When Mode=0x02/0x03/0x04/0x05,
initialization vector is needed in
encryption/decryption. If InitVector is
NULL, the initialization vector is set to
16-byte 0x00 by default.
InitVector[Input/Out When Mode=0x00/0x01, the initialization
put] vector is not needed and can be set to
NULL.
Parameters
When Mode=0x06/0x07, the initialization
vector represents a 16-byte temporary
counter which is required for calculation,
and the counter will be updated after
calculated successfully.
A pointer to the data that needs to be
DataIn[Input]
calculated.
Length of data that needs to be
calculated.
DataInLen[Input]
The valid length is not more than 1024
bytes and must be a multiple of 16.
6.9.3 OsPedGetMacAes
6.9.4 OsPedCalcAesGcm
6.10 SM Algorithm
6.10.1 OsPedGenSM2Pair
uchar *PubKey,
int KeyLenBit);
Function Generate SM2 key pair.
PvtKey[Output] A pointer to SM2 private key.
The valid length is 32 bytes.
Parameters PubKey[Output] A pointer to SM2 public key.
The valid length is 64 bytes.
KeyLenBit[Input] Private key bit, 256 bits.
RET_OK Succeeded.
ERR_DEV_NOT_OPEN Device is not open.
Return
ERR_INVALID_PARAM Invalid parameter.
ERR_SYS_BAD System error
Instruction 256 bits of SM2 private key and 512 bits of public key are valid.
6.10.2 OsPedWriteSM2Key
6.10.3 OsPedSM2Sign
6.10.4 OsPedSM2Verify
6.10.5 OsPedSM2Recover
6.10.6 OsPedSM3
6.10.7 OsPedSM4
6.10.8 OsPedGetMacSM
6.10.9 OsPedGetPinBlockSM4
uchar *PinBlockOut,
int Mode,
ulong TimeoutMs);
Within specified TimeoutMs, scan the input PIN on the keyboard
Function
and output PIN block which is encrypted by SM4 algorithm.
KeyIdx[Input] PED_SM4_TPK key index, the value
range is from 1 to 100.
ExpPinLenIn[Input] A pointer to valid password length string,
which is an enumeration set from 0 to 12.
Application lists all the valid passwords
and separates them with “,”. For example,
if 4 and 6 digits of passwords are allowed,
then the string should be set to “4, 6”.
DataIn[Input] When Mode=0x00, DataIn points to the
16-bit primary account number generated
Parameters
after shifting the card number.
PinBlockOut[Outpu Encrypted PIN block
t] The valid length is 16 bytes.
Mode[Input] Format of PIN block.
0x00 ISO9564 format 0
TimeoutMs[Input] Timeout of inputting PIN.[unit: ms]
The maximum timeout is 300,000ms; the
default timout is 30,000 ms; 0 means using
the default timeout.
RET_OK Succeeded.
ERR_DEV_NOT_OPEN Device is not open.
ERR_INVALID_PARAM Invalid parameter.
ERR_SYS_BAD System error.
ERR_PED_KEY_IDX_ERR Key index error.
ERR_PED_KEY_TYPE_ERR Key type error.
Return ERR_PED_NO_KEY Key doesn’t exist.
ERR_PED_TAMPERED PED is tampered.
ERR_PED_KEY_LEN_ERR Key length error.
ERR_PED_NO_PIN_INPUT No input.
ERR_PED_PIN_INPUT_CANC
Cancel input.
EL
ERR_PED_WAIT_INTERVAL Interval is too short.
6.11.1 OsPedDFAuthDiver
Instruction
6.11.2 OsPedDFAuthMerge
6.12 RKI
6.12.1 OsPedRkiInjectKey
The DUKPT algorithm defines the process of generating one or more unique keys for
each transaction, without the need for the SCD of the transaction initiator to retain any
information that can determine any keys previously used by the SCD, nor does it
include any keys that have been or will be used.
This key management standard is used in conjunction with the AES to manage
symmetric keys, which can be used to protect messages and other sensitive
information in the financial service environment. The security and reliability of any AES-
based process directly depends on the protection of the key.
The derivation function is used to derive intermediate derived keys from TIK (terminal
initial key), and these intermediate derived keys are used to generate the working key
of the transaction. The strength of the working key must be the same or weaker than
these intermediate derived keys. The corresponding relationship is as follows:
6.13.3 OsPedWriteAesTIK
6.13.4 OsPedGetPinAesDukpt
uchar Mode,
ulong TimeoutMs,
uchar *Ksn,
uchar *PinBlock);
Within the specified time limit, input the PIN on the keypad, and
Function output the PIN block calculated using the PIN key of AES
DUKPT.
AES DUKPT group index, which ranges
GroupIdx [Input]
from 1 to 40.
When Mode=0x20, DataIn points to the 16-
digit main account number generated after
the card number is shifted
When Mode=0x21, it is meaningless
When Mode=0x22, DataIn points to the 16-
DataIn [Input]
digit main account number generated after
the card number is shifted
When Mode=0x23, DataIn is the transaction
serial number ISN, which is 6-bytes ASCII.
When Mode=0x24, DataIn is main account
A string of valid password length that can be
entered, which is an enumerated set of
0~12;
The application enumerates all the allowed
password lengths, and separates each
ExpPinLen [Input] length with a ",". If 4 or 6-digit passwords
Parameters
and press confirm without a password are
allowed, the string should be set to "0," 4,6";
If the length of the enumeration is 0, it
means that you can directly press the enter
key to return without entering any number
When KeyType = 2TDEA_or_3TDEA_, use
TDES algorith to calculate pin block;
KeyType [Input] When KeyType =_AES128,
AES192_or_AES256_, use AES algorith to
calculate pin block, and at the meantime,
Mode can only be 0x24;
Choose the format of PIN block:
When Mode = 0x20, PIN block format is
ISO9564 Format 0, KSN will not
Mode [Input] automatically add 1;
When Mode = 0x21, PIN block format is
ISO9564 Format 1, KSN will not
automatically add 1;
RET_OK Succeeded
ERR_DEV_NOT_OPEN Device is not open
Return
ERR_INVALID_PARAM Invalid parameter
Others Refer to PED Return Code List
Calling OsPedGetPinAesDukpt() will operate on the
framebuffer, which may cause resource conflicts. If you find an
interface abnormality in an application that uses XUI, you can
Instruction call XuiSuspend() before calling OsPedGetPinAesDukpt() to
suspend the operation of XUI, and call XuiResume() later to
restore.
6.13.5 OsPedGetMacAesDukpt
6.13.6 OsPedCalcAesDukpt
RET_OK Succeeded
ERR_DEV_NOT_OPEN Device is not open
Return
ERR_INVALID_PARAM Invalid parameter
Others Refer to PED Return Code List
Instruction
6.13.7 OsPedGetKsnAesDukpt
6.13.8 OsPedIncreaseKsnAesDukpt
6.14 ECC
6.14.1 OsPedGenerateEccKeyPair
RET_OK Succeeded.
ERR_DEV_NOT_OPEN PED device is not open.
Return ERR_INVALID_PARAM Invalid parameter.
ERR_SYS_BAD System error.
Others Refer to PED Return Code List.
Instruction
6.14.2 OsPedWriteEccKey
RET_OK Succeeded.
ERR_DEV_NOT_OPEN PED device is not open.
Return ERR_INVALID_PARAM Invalid parameter.
ERR_SYS_BAD System error.
Others Refer to PED Return Code List.
Instruction
6.14.3 OsPedReadEccPublicKey
RET_OK Succeeded.
ERR_DEV_NOT_OPEN PED device is not open.
Return ERR_INVALID_PARAM Invalid parameter.
ERR_SYS_BAD System error.
Others Refer to PED Return Code List.
Instruction
6.14.4 OsPedEccSign
uchar EccPrivateKeyIndex,
uint DataLen,
const uchar *Data,
uint *SignLen,
uchar *Sign,
uchar Mode);
Function ECC sign.
RET_OK Succeeded.
ERR_DEV_NOT_OPEN PED device is not open.
Return ERR_INVALID_PARAM Invalid parameter.
ERR_SYS_BAD System error.
Others Refer to PED Return Code List.
This interface directly signs the input data and does not
calculate the hash value. If you need to sign the hash value of
Instruction the data, the caller needs to calculate the hash value first and
then pass in the hash value.
6.14.5 OsPedEccVerify
RET_OK Succeeded.
ERR_DEV_NOT_OPEN PED device is not open.
ERR_INVALID_PARAM Invalid parameter.
Return
ERR_SYS_BAD System error.
ERR_VERIFY_SIGN_FAIL Verification failed.
Others Refer to PED Return Code List.
The interface directly verifies the input data, and does not
Instruction calculate the hash value of the input data.
6.14.6 OsPedEccPointMul
uchar *EccSharedKey,
uchar Mode);
Function Generate ECC shared key.
RET_OK Succeeded.
ERR_DEV_NOT_OPEN PED device is not open.
Return ERR_INVALID_PARAM Invalid parameter.
ERR_SYS_BAD System error.
Others Refer to PED Return Code List.
Instruction
7 LCD
Prolin supports Minigui, QT and other GUI support system to manage the display on
LCD. Prolin provides interfaces that can directly access physical device of LCD for
applications to configure light, set contrast and retrieve screen size of LCD.
5. Write framebuffer.
int open_screen(void)
{
char vtname[128];
int fd, nr;
unsigned y, addr;
struct fb_fix_screeninfo fix;
sb = (screen_buffer*)malloc(sizeof (screen_buffer));
if ((sb->dev_fd = open(FB_DEV_PATH, O_RDWR)) == -1) {
perror("open");
return -1;
}
if (ret) {
sb->width = FB_WIDTH;
sb->height = FB_HEIGHT;
sb->bytes_per_pixel = FB_BYTES_PER_PIXEL;
fprintf(stderr,"in %s line %d",__FUNCTION__,__LINE__);
} else {
sb->width = fb_vinfo.xres;
sb->height = fb_vinfo.yres;
sb->bytes_per_pixel = fb_vinfo.bits_per_pixel / 8;
}
if(sb->bytes_per_pixel == 3)
sb->bytes_per_pixel = 4;
}
memset(sb->buffer, 0, fbmemlen);
return 0;
}
7.1 OsScrContrast
7.2 OsScrBrightness
7.3 OsScrGetSize
8 Keyboard
The input subsystem can directly be used to test keyboard drivers or transplant other
GUI systems. The device node of keyboard is "/dev/keypad".
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/input.h>
static int keypad_fd = -1;
struct input_event ev0[64];
//for handling/key/event
static int handle_event0() {
int button = 0, realx = 0, realy = 0, i, rd;
rd = read(keypad_fd, ev0, sizeof(struct input_event) * 64);
if ( rd < sizeof(struct input_event) ) return 0;
for (i = 0; i < rd / sizeof(struct input_event); i++) {
printf("", ev0[i].type, ev0[i].code, ev0[i].value);
if (ev0[i].type == 3 && ev0[i].code == 0)
realx = ev0[i].value;
else if (ev0[i].type == 3 && ev0[i].code == 1)
realy = ev0[i].value;
else if (ev0[i].type == 1) {
if (ev0[i].code == 158) {
//if key esc then exit
return 0;
}
}
else if (ev0[i].type == 0 && ev0[i].code == 0 && ev0[i].value == 0) {
realx = 0, realy = 0;
}
printf("event(%d): type: %d; code: %3d; value: %3d; realx: %3d;
realy: %3d\n", i,
ev0[i].type, ev0[i].code, ev0[i].value, realx, realy);
}
return 1;
}
int main(void) {
int done = 1;
printf("sizeof(struct input_event) = %d\n", sizeof(struct input_event));
keypad_fd = open("/dev/keypad", O_RDWR);
if ( keypad_fd < 0 )
return -1;
while ( done ) {
printf("begin handel_event0...\n");
done = handle_event0();
printf("end handel_event0...\n");
}
if ( keypad_fd > 0 ) {
close(keypad_fd);
keypad_fd = -1;
}
return 0;
}
8.1 OsKbBacklight
9 Touch Screen
Application developers can directly use the input subsystem to test touchscreen drivers
or transplant other GUI systems.
About input subsystem calling, please refer to Chapter 8 Keyboard. The node of touch
screen is “/dev/tp”.
Always keeping the RF module enabled may affect the operating experience of the
touch screen, such as the touch screen does not respond, reports random points, or
abnormal signatures. It is recommended that the RF module is turned off when
operating the actual functions of the touch screen.
10 Signature Pad
For more details, please refer to the “Prolin XUI Programming Guide”.
11 Printer
Prolin supports both physical printing and virtual printing, and provides developers with
uniform printing interfaces.
Virtual printer generates BMP images and saves the printing result in local disk space.
This part includes three functions: opening, resetting and closing printer.
11.2.1 OsPrnOpen
11.2.2 OsPrnReset
Return None.
Instruction
11.2.3 OsPrnClose
11.3.1 OsPrnSetSize
11.3.2 OsPrnSetDirection
11.3.3 OsPrnSetGray
11.4.1 OsPrnSetSpace
11.4.2 OsPrnSetReversal
11.4.3 OsPrnSetIndent
11.4.4 OsPrnCheck
Return ERR_PRN_PAPERO
Out of paper.
UT
ERR_PRN_OVERHE
Printer is overheated.
AT
Instruction
11.4.5 OsPrnGetDotLine
11.4.6 OsPrnSetFont
11.4.7 OsPrnSelectFontSize
11.4.8 OsPrnFeed
Return None.
Instruction 1. This function applies to both physical and virtual printer.
11.4.9 OsPrnPrintf
11.4.10 OsPrnRawData
11.4.11 OsPrnPutImage
11.4.12 OsPrnStart
Return ERR_PRN_WRONG_
Data package format error.
PACKAGE
ERR_PRN_OVERHEA
Printer is overheated.
T
ERR_PRN_OUTOFME
Data size is too large.
MORY
1. OsPrnStart() will begin printing task and will not return until
the task is completed.
2. After completing printing task, OsPrnStart() will return the
Instruction printer status in return value. Therefore, it is not necessary to
check printer status.
3. After the printing task is finished, slip will be reprinted if this
function is called again.
11.4.13 OsPrnClrBuf
Parameters None
Return None
Instruction
11.4.14 OsPrnSetParam
11.5 POSIX
Prolin physical printer driver provides application developers with POSIX interface.
11.5.1 Open
11.5.2 Read
buf[0] Description
0x00 Normal
Sample code:
unsigned char buf[10];
int ret = read(handle, buf, 2);
if (ret > 0) {
//buf[0]
}
11.5.3 Write
The first two bytes of buffer are gray setting and reserved bit.Suppose that the buffer
is char buf[50], bit0~bit2 in the buf[0] represent the printing gray control values.
bit3~bit7 are reserved.
111 Reserved
From buf[2] on, every line is composed of 48 characters (384 dots), if less than 48
characters, the driver will be padded with 0x00.
Sample code:
unsigned char buf[50];
buf[0] = 0x01;
memset(buf + 2, 0xff, 48);
1. For 384 dots thermal printer, when printing horizontally, the driver can deal with
5000 dot lines each time at most; otherwise, the printer will not work.
2. When printing vertically, the driver can deal with 384 lines each time at most, and
each line can print 5000 dots at most; otherwise, the printer will not work.
11.5.4 Close
close (handle);
12Font Library
Prolin uses Freetype as the system font library. Therefore, the system supports a
series of vector font and bitmap font.
FT_FONT
typedef struct {
char FileName[64]; /* Font file name */
char FontName[64]; /* Font name */
}FT_FONT;
FT_DOT
typedef struct {
unsigned char Left; /*Left base-line shift*/
unsigned char Top; /* Top base-line shift*/
unsigned char Width; /* Font width */
unsigned char Height; /* Font height */
unsigned char Dot[3072]; /*Valid font data */
}FT_DOT;
12.2.1 OsEnumFont
12.2.2 OsOpenFont
12.2.3 OsCloseFont
12.2.4 OsGetFontDot
13 Code
Prolin uses UTF-8 as the default code and provides interfaces to converse code.
13.1.1 OsCodeConvert
14 MSR
Prolin provides interfaces to read data from MSR. Additionally, the customized MSR
decoding logic can be implemented by application which can access the driver of card
reader and directly get the bit-stream of magnetic stripe through POSIX interface.
MSR data structure: Record information and status of each magnetic track.
ST_MSR_DATA:
typedef struct {
unsigned char TrackData[256]; /* Decoded bit stream*/
int DataLen; /* Track data length*/
int Status; /*Track data status, 0 means succeeded, other value means
failed*/
}ST_MSR_DATA;
14.3.1 OsMsrOpen
14.3.2 OsMsrClose
14.3.3 OsMsrReset
14.3.4 OsMsrSwiped
14.3.5 OsMsrRead
14.3.6 OsMsrReadJIS
ERR_MSR_NOT_SWIP
No card is swiped.
ED
ERR_INVALID_PARAM Invalid parameter.
ERR_DEV_NOT_OPEN Device is not open.
1. If any track’s data is not needed, set the corresponding pointer
to NULL, then the data will not be outputted.
2. All track data must be read out within 30 seconds after swiping
card successfully; otherwise, all track data will be cleared
automatically and output data are all 0x00.
Instruction
3. Track 4 is used to store the JCB (JIS II) data, and track 1-3 is
used to store the data in other formats.
4. If the magnetic head of one side has not detected any tracks,
ERR_MSR_NO_TRACK_ERR will be returned to the Status of
the corresponding Track.
15 IC Card Reader
In this chapter, all protocol interfaces for IC card are based on ISO7816/EMV.
ST_ APDU_REQ
typedef struct
{
Unsigned char Cmd[4]; /*CLA, INS, P1, P2*/
int LC; /* The valid length of DataIn sent to IC card */
unsigned char DataIn[512];/* The data sent to ICC */
int LE; /* The expected length of returned data*/
}ST_ APDU_REQ;
ST_APDU_REQ structure:
ST_ APDU_RSP:
typedef struct
{
Int LenOut; /* Data length returned from ICC*/
unsigned char DataOut[512]; /*Data pointer returned from ICC */
unsigned char SWA; /*status word 1 of ICC */
unsigned char SWB; /* status word 2 of ICC */
}ST_ APDU_RSP;
15.3.1 OslccOpen
Instruction
15.3.2 OsIccDetect
This interface will power off the SAM card. Please ensure this
interface is called before resetting SAM card.
15.3.3 OsIccInit
0 – Unsupported;
1 – Supported.
(Bit 3~4)Rate used in power-
onreset:
00 – Standard rate 9600;
10 – Four times rate 38400.
The rate mentioned here is a
reference value in typical frequency
(3.57MHz).
The communication rate between IC
card and card reader is closely related
to working clock frequency provided by
a specific machine.
(Bit 5) Supported standards:
0 – EMV;
1 - ISO7816.
If EMV mode is specified, the power
on rate will be marked as invalid and it
will use the standard rate by default.
(Bit 6 ~31)Reserved
“Option” is set to 0 by default (that is,
5V, non-PPS, standard rate, and
conforming to EMVx).
Atr [Output] 1. Answer To Reset (ATR). The card
will return response data of 34
bytes at most.
2. Contents: Length of ATR (1 byte)
and ATR.
RET_OK Succeeded.
Return Others Please refer to IC Card Return Code
List.
1. ATR output buffer should be allocated at least 34 bytes.
2. Whether PPS communication parameters negotiation protocol is
supported or not depends on the specific card.
Instruction 3. Some terminals can only work with one SAM card at a time. If several
cards need to be operated at the same time, initialize cards one by
one: (OsIccInit ( )) - > operation (OsIccExchange()) - > close
(OsIccClose( )).
15.3.4 OsIccExchange
15.3.5 OsIccTransfer
RET_OK Succeeded.
Return Others Please refer to IC Card Return Code
List.
The following is an example of how the terminal sends the
standard APDU commands and extended APDU commands
supported by the card to the IC card:
unsigned char ucpSrc[4096] = {0};
Instruction unsigned int iTxNum = 0;
unsigned char ucpDes[4096] = {0};
unsigned int ipRxNum = 0;
unsigned int Lc = 0;/*the length of send data*/
15.3.6 OsIccClose
16 RF Reader
For more information about the request data structure and response data structure,
please refer to Chapter IC Card Reader 15.2.1 and 15.2.2.
PCD_USER_ST
typedef struct pcd_user_t{
unsigned char wait_retry_limit_w; /* S(WTX) responds to write
permission of sending times*/
unsigned int wait_retry_limit_val; /*S(WTX)responds to the maximum
repetition times.*/
os_picc_transfer_rxlen_set_v
al is invalid */
unsigned int os_picc_transfer_rxlen_set_val ; /*Set the maximum
allowable data length in the
half-duplex block
(OsPiccTransfer) transfer*/
unsigned char os_picc_transfer_direct_transmit_set_w; /* 1 means the
data is transmitted in the way
of data stream, that is, the
half-duplex block
transmission protocol is not
applicable;0 represents data
transfer using the half duplex
block transfer protocol */
unsigned char configure_technology_type_w; /* Set whether the
configure_technology_type_v
al parameter can be written:
1—allowed, other values--not
allowed */
unsigned char configure_technology_type_val; /* Configure the modulation
technology type of the data
sent by OsPiccTransfer()*/
unsigned char reserved[34]; /* Reserved byte, for future use.
sizeof(PCD_USER_ST)= 76*/
} PCD_USER_ST;
16.3.1 OsPiccOpen
16.3.2 OsPiccClose
16.3.3 OsPiccResetCarrier
16.3.4 OsPiccPoll
16.3.5 OsPiccAntiSel
16.3.6 OsPiccActive
0 Succeeded.
Return Others Fail to activate card. (Details refer to
Return Code List.)
Instruction
16.3.7 OsPiccTransfer
16.3.8 OsPiccRemove
16.3.9 OsMifareAuthority
16.3.10 OsMifareOperate
16.3.11 OsPiccInitFelica
16.3.12 OsPiccIsoCommand
16.3.13 OsPiccSetUserConfig
int OsPiccSetUserConfig(PCD_USER_ST
Prototype
*pcd_user_config) ;
Function Set user configuration.
pcd_user_config A pointer to user configuration structure
Parameters
[Input] PCD_USER_ST.
0 Succeeded.
Return
Others Failed. (Refer to Return Code List.)
The parameter configure_technology_type_val of
pcd_user_config is used to configure the modulation mode of
the data sent by OsPiccTransfer. After calling OsPiccOpen(),
call OsPiccSetUserConfig() to set this parameter, and the
configure_technology_type_val parameter is defined as follows:
0x03 means Type A short frame modulation mode;
0x04 means Type A standard frame modulation mode,
without CRC check byte at the end of the frame;
0x05 means Type B modulation mode;
0x06 represents Type A standard frame modulation mode,
with 2 bytes of CRC check byte at the end of the frame.
Instruction
Demo code:
PCD_USER_ST pcd_user;
OsPiccOpen();
memset(&pcd_user,0x00,sizeof(PCD_USER_ST));
pcd_user.configure_technology_type_w = 1;
pcd_user.configure_technology_type_val = 0x03;
pcd_user.protocol_layer_fwt_set_w = 1;
pcd_user.protocol_layer_fwt_set_val = 9;
ret = OsPiccSetUserConfig(&pcd_user);/* Set the timeout time
(FWT)according to actual needs*/
16.3.14 OsPiccGetUserConfig
int OsPiccGetUserConfig(PCD_USER_ST
Prototype
*pcd_user_config);
Function Get user configuration.
pcd_user_config A pointer to user configuration structure
Parameters
[Output] PCD_USER_ST.
0 Succeeded.
Return
Others Failed. (Refer to the Return Code List.)
Instruction
16.3.15 OsPiccApplePoll
"\x01\x00\x00\x01" represents
Terminal in VAS App AND Payment
Mode.
"\x01\x00\x00\x02", represents
Terminal in VAS App Mode Only.
"\x01\x00\x00\x03", represents
Terminal in Payment Mode Only.
When the first byte is 0x02, enter a
variable-length byte, the lower nibble of
the second byte X represents the length
of Terminal Data:
"\x02\x8X\x00\x00"+X-byte Terminal
Data.
0 Succeeded.
Return
Others Failed. (Refer to the Return Code List.)
1. Mifare card is a special kind of A card.
Instruction
2. The returned card type of M card is type A.
16.3.16 OsPiccOffCarrier
16.3.17 OsPiccInitIso15693
As model S900 and S920 are equipped with both touch screen and RF reader,
application developers should pay special attention to the following notes:
2. After finishing the transaction, OsPiccRemove() must be called to remove the card.
17 Communication Port
17.2.1 OsPortOpen
2. Data bit: 7 or 8.
3. Parity check method: “o” - odd parity; “e”
- even parity; “n” - no parity.
4. Stop bit: 1 or 2.
For example, “9600, 8, n, 1\0”.
1. attr =“9600, 8, n, 1”, it represents that the
baud rate is 9600bps; 8 data bits; no
parity; 1 stop bit.
RET_OK Succeeded.
ERR_DEV_BUSY Device is busy.
Return ERR_DEV_NOT_EXIS
Port does not exist.
T
ERR_INVALID_PARA
Invalid parameter.
M
1. When program starts, OsPortOpen() must be called
successfully to open communication port; otherwise, the
related functions will fail to work.
2. Soft flow control and hard flow control will be closed.
3. Only PX7 and PX5 support 921,600 baud rate, while other
models don’t .
4. For device which conforms to HID Category Specification
Instruction and connects to terminal with USB device, PORT_USBHID
port can be used to read data. For example, it supports the
common USB barcode scanner device.
5. For terminal with only one USB HOST port, channel
PORT_USBHOST should be used to open the USB HOST
port; For terminal with two USB HOST ports, channel
PORT_USBHOST and PORT_USBHOST1 should be used
to open their corresponding USB HOST port, respectively.
17.2.2 OsPortClose
17.2.3 OsPortSend
17.2.4 OsPortRecv
17.2.5 OsPortReset
17.2.6 OsPortCheckTx
Instruction
17.2.7 OsPortCheckRx
Prolin serial ports are allowed to be accessed by POSIX interfaces. Only PX7 and
PX5 series models suppport soft flow control and hard flow control.
For Prolin-2.4 and Prolin-phoenix-2.5 platforms, since there is no soft link for serial port,
the corresponding relation between device nodes and serial ports can refer to the
following table. For Prolin-cygnus-2.6 and later platforms, the device nodes
corresponding to each serial port need to be determined by the soft links of
/dev/ttycom1 and /dev/ttycom2, and the specific terminals will not be updated in the list.
Corresponding
Device node Serial port Applicable models
module
/dev/ttyAMA0 Modem Modem S800
/dev/ttyAMA1 Wireless Wireless S800/S900
S800/S900/S300/D2
/dev/ttyAMA2 PORT_COM1 COM1
00
/dev/ttyAMA3 PORT_PINPAD Pinpad S800
/dev/ttyAMA3 PORT_COM2 COM2 PX5/PX7
S800/S900/S300/D2
/dev/ttyhost PORT_USBHOST USB
00/S920//PX5/PX7
S800/S900/S300/D2
/dev/ttydev PORT_USBDEV USB
00/S920//PX5/PX7
17.3.1 Open
Open communication port and the device names are ttyAMA0, ttyAMA1, ttyAMA2,
ttyAMA3.
Sample code:
int fd;
fd = open(“/dev/ttyAMA1”, O_RDWR);
if(-1 == fd){
perror(“Open uart error”);
}
17.3.2 Read
Sample code:
charbuff [1024];
int Len = 1024;
int readByte = read (fd, buff, Len);
17.3.3 Write
Sample code:
charbuffer [1024];
int Length = 1024;
int nByte;
nByte = write (fd, buffer, Length);
17.3.4 Close
close(fd);
Sample code:
int remain;
int count;
/* Inquiry the number of bytes remained in send buffer */
ioctl(fd, TIOCOUTQ, &remain);
/* Inquiry the number of bytes remained in receive buffer */
ioctl(fd, TIOCINQ, &count);
Sample code:
Sample code:
/* Set baud rate, data bits, parity bits and stop bits of uart*/
int SetTermios (int fd, int nSpeed, int nBits, char cEvent, int nStop)
{
struct termios newtio, oldtio;
newtio.c_cflag |= CSTOPB;
/* Set waiting time and the minimum number of characters*/
newtio.c_cc[VTIME] = 0;
newtio.c_cc[VMIN] = 0;
/* Clear send buffer*/
tcflush (fd, TCIFLUSH);
/* Set new configuration message */
if ((tcsetattr (fd, TCSANOW, &newtio)) != 0)
{
printf("Set serial error\n");
return -1;
}
return 0;
}
18 MODEM
Prolin system implements Modem communication through built-in serial ports to send
AT commands to Modem. Besides, there are a series of encapsulated interfaces for
developers to realize Modem communication.
Calling synchronous
communication sending
-3132
data packets retry more
than specified times.
Calling synchronous
-3133 communication sending
data packets timeout.
Calling synchronous
communication
receiving
-3134
acknowledgement
packets retry more than
specified times.
Calling synchronous
-3135 communication sending
state packet 2 errors.
Calling synchronous
-3136 communication sending
state packet 3 errors.
Calling synchronous
-3137 communication sending
state packet 4 errors.
Calling synchronous
communication
-3138 receiving data packets
retry more than specified
times.
Calling synchronous
-3139 communication sending
state packet 5 errors.
Calling synchronous
-3140 communication sending
state packet 6 errors.
Bypass telephone and
parallel telephone are
both idle (used only
when switching from
automatically sending
-3144 number to manually
answering).
In automatically sending
number mode, the
phone is not picked up
timely.
Called synchronization
-3145 handshake fails to send
handshake packet.
Called synchronization
handshake fails to
-3146
receive handshake
packet.
Called synchronization
-3147 handshake more than
specified times.
Called synchronous
-3148 communication sending
state packet 1 error.
Called synchronous
communication
-3149
receiving process 1
error.
Called synchronous
-3150 communication chip is
on-hook.
Called synchronous
communication
-3151
receiving process 2
errors.
Called synchronous
communication
-3152
receiving retry more than
specified times.
Called synchronous
-3153 communication sending
state packet 2 errors.
Called synchronous
-3154 communication sending
data packet error
Called synchronous
communication
-3155
receiving process 3
errors.
Called synchronous
communication
-3156 receiving packet retry
more than specified
times.
Called synchronous
-3157 communication sending
state packet 3 errors.
Called connection
-3160 receiving ring
information error.
Called connection fails
-3161
to detect line voltage.
Called connection
-3162 detecting line voltage
data format error.
Called connection
-3163 voltage is less than
threshold value.
Called connection
-3164
timeout.
Called asynchronous
-3165
line rate format error.
Called asynchronous
-3166
line rate is illegal.
Called connection
-3167
information format error.
Called connection fails
-3170
to set command string 1.
Called connection fails
-3171
to set command string 2.
Called connection fails
-3172 to set extended
command string.
Calling connection fails
-3175
to set command string 1.
Calling connection fails
-3176
to set command string 2.
Calling connection fails
-3177
to set command string 3.
Calling connection fails
-3178
to set command string 4.
Calling connection fails
-3179
to set command string 5.
If no or error
implementation of
OsModemConnect(),
-3218
then implement
OsPppomLogin()
orOsPppomCheck().
Modem or ModemPPP is
-3219 being used, Modem
cannot be powered off.
Modem is not powered
-3220
on.
ST_MODEM_SETUP:
typedef struct {
int CallMode;
int CommMode;
int CodeType;
int CodeDuration;
int CodeSpacing;
int DetectLineVoltage;
int DetectDialTone;
int DialToneTimeout;
int CommaPauseTime;
char ConnectRate[20];
char ConnectFormat[20];
int ConnectTimeout;
int DialTimes;
int IdleTimeout;
int Pppom;
int Reserved[9];
}ST_MODEM_SETUP;
MODEM_PRE_DIA
Pre-dial.
L
CallMode MODEM_DIAL Dial.
MODEM_WAIT_CA
Called/Answer the call.
LL
MODEM_COMM_S
Synchronization.
YNC
CommMode
MODEM_COMM_A
Asynchronization.
SYNC
MODEM_CODE_D DTMF(Dual Tone Multiple
TMF Frequency) dialing.
Pulse dialing 1(Pulse rate 10/s;
MODEM_CODE_P
break-make ratio1.6:1; signal
ULSE1
CodeType interval>=500ms).
Pulse dialing 2(Pulse rate 10/s;
MODEM_CODE_P
break-make ratio2:1; signal
ULSE2
interval >=600ms).
Other values Reserved.
“9600”/*9600 bps */
“12000”/*12000 bps*/
“14400”/*14400 bps */
“19200”/*19200 bps */
“24000”/*24000 bps */
“26400”/*26400 bps */
“28800”/*28800 bps */
“31200”/*31200 bps */
“33600”/*33600 bps */
“48000”/*48000 bps */
“56000”/*56000 bps */
For null string "\ 0",the system will select “1200” by
default in synchronous communication and select the
maximum rate that the chip supports by default in
asynchronous communication.
S800 supports baud rate.
Asynchronization:
“1200”/*1200 bps */
“1200,V22”/*1200 bps normal connect */
“1200,V23C”/*1200 bps for V.23C(FSK) */
“1200,B202”/*1200 bps for Bell 202(FSK) */
“2400,FC”/*2400 bps fast connect */
“2400”/*2400 bps*/
“4800”/*4800 bps */
“7200”/*7200 bps */
“9600”/*9600 bps */
“12000”/*12000 bps */
“14400”/*14400 bps */
“19200”/*19200 bps */
“24000”/*24000 bps */
“26400”/*26400 bps */
“28800”/*28800 bps */
“31200”/*31200 bps */
“33600”/*33600 bps */
“48000”/*48000 bps */
“56000”/*56000 bps */
Synchronization:
“1200”/*1200 bps */
“1200,V22”/*1200 bps normal connect */
“2400,FC”/*2400 bps fast connect */
“2400”/*2400 bps*/
“9600”/*9600 bps*/
ConnectFormat[ Format of connection and communication(Expressed as a
20 string):
“8, n, 1”
“8, e, 1”
“8, o, 1”
“7, e, 1”
“7, o, 1”
For null string "\ 0", the system will select “8, n, 1” by
default.
For synchronous communication, the system will select “8,
n, 1”automatically.
Connection timeout. [unit: second]
ConnectTimeout
The valid timeout ranges from 0 to 60s.
The total number of dial-up cycle.
The valid range is 1 to 255. 0 will be converted to 1
DialTimes
automatically.
Dialing all the dialer numbers is one dial-up cycle.
If there is no data exchange in application-layer within
specified time, MODEM will hang up.[Unit: 10s]
IdleTimeout
0 means no timeout. The maximum timeout is 900s. This
value is invalid to ModemPPP.
TRUE Modem PPP communication
Pppom
FALSE Common Modem communication
Reserved[9] Reserved.
18.3 OsModemOpen
18.4 OsModemClose
18.5 OsModemSwitchPower
Parameter
int OnOff OnOff=1, power on,
s
OnOff=0, power off.
RET_OK Succeeded.
18.6 OsModemConnect
18.7 OsModemCheck
18.8 OsModemExCmd
18.9 OsModemHangup
If dialing the number again right after hanging up, the Modem will
wait and start redialing after 3 seconds so as to allow PABX to
finish hanging up action and transmitting dialing tone again.
18.10 OsModemSend
18.11 OsModemRecv
18.12 OsPppomLogin
when baud rate is not more than 33600 will enjoy a low re-
training rate and high success rate.
5. For 96169 background (Guidway A8010), if re-training
occurrs and the duration time is more than 20 seconds after
sending number, then the background communication will no
longer conform to ppp protocol and fail to establish link.
6. After successfully setup the link, it can communicate through
the IP network communication function.
7. If users want to hang up by pressing the cancel button in the
dialing process, operate as follows:
Start a thread and take a key. If it is the cancel key, perform
OsPppomLogin ("a", "a", 1, -1). The first 3 parameters should
be filled in accordance with the requirements, and the fourth
parameter must be set to -1, then ModemPPP will hang-up
and automatically logout.
18.13 OsPppomCheck
18.14 OsPppomLogout
19 Network Communication
Prolin uses unified network protocol stack to manage different physical links. Prolin
provides a standard socket programming for network communication.
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(void)
{
struct sockaddr_in stSockAddr;
int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if(-1 == SocketFD)
{
perror("cannot create socket");
exit(EXIT_FAILURE);
}
memset(&stSockAddr, 0, sizeof(stSockAddr));
stSockAddr.sin_family = AF_INET;
stSockAddr.sin_port = htons(1100);
stSockAddr.sin_addr.s_addr = INADDR_ANY;
if(-1 == bind(SocketFD,(struct sockaddr *)&stSockAddr,
sizeof(stSockAddr)))
{
perror("error bind failed");
close(SocketFD);
exit(EXIT_FAILURE);
}
if(-1 == listen(SocketFD, 10))
{
perror("error listen failed");
close(SocketFD);
exit(EXIT_FAILURE);
}
for(;;)
{
int ConnectFD = accept(SocketFD, NULL, NULL);
if(0 > ConnectFD)
{
perror("error accept failed");
close(SocketFD);
exit(EXIT_FAILURE);
}
/* perform read-write operations ... read(ConnectFD,buff,size)*/
if (-1 == shutdown(ConnectFD, SHUT_RDWR))
{
perror("cannot shutdown socket");
close(ConnectFD);
exit(EXIT_FAILURE);
}
close(ConnectFD);
}
return EXIT_SUCCESS;
}
/* Client code in C language*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(void)
{
struct sockaddr_in stSockAddr;
int Res;
int KeepAlive = 1;
int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (-1 == SocketFD)
{
perror("cannot create socket");
exit(EXIT_FAILURE);
}
Res = setsockopt(SocketFD, SOL_SOCKET, SO_KEEPALIVE, (void
*)&KeepAlive, sizeof(KeepAlive));
if (-1 == Res)
{
perror("cannot set keepalive");
exit(EXIT_FAILURE);
}
memset(&stSockAddr, 0, sizeof(stSockAddr));
stSockAddr.sin_family = AF_INET;
stSockAddr.sin_port = htons(1100);
Res = inet_pton(AF_INET, "192.168.1.3", &stSockAddr.sin_addr);
if (0 > Res)
{
perror("error: first parameter is not a valid address family");
close(SocketFD);
exit(EXIT_FAILURE);
}
else if (0 == Res)
{
perror("char string (second parameter does not contain valid
ipaddress)");
close(SocketFD);
exit(EXIT_FAILURE);
}
if (-1 == connect(SocketFD, (struct sockaddr *)&stSockAddr,
sizeof(stSockAddr)))
{
perror("connect failed");
close(SocketFD);
exit(EXIT_FAILURE);
}
/* perform read write operations ... */
shutdown(SocketFD, SHUT_RDWR);
close(SocketFD);
return EXIT_SUCCESS;
}
int main(void)
{
int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
struct sockaddr_in sa;
char buffer[1024];
ssize_t recsize;
socklen_t fromlen;
memset(&sa, 0, sizeof sa);
sa.sin_family = AF_INET;
sa.sin_addr.s_addr = INADDR_ANY;
sa.sin_port = htons(7654);
fromlen = sizeof(sa);
if (-1 == bind(sock,(struct sockaddr *)&sa, sizeof(sa)))
{
perror("error bind failed");
close(sock);
exit(EXIT_FAILURE);
}
for (;;)
{
printf ("recv test....\n");
recsize = recvfrom(sock, (void *)buffer, sizeof(buffer), 0, (struct sockaddr
*)&sa, &fromlen);
if (recsize < 0) {
fprintf(stderr, "%s\n", strerror(errno));
exit(EXIT_FAILURE);
}
printf("recsize: %z\n ", recsize);
sleep(1);
printf("datagram: %.*s\n", (int)recsize, buffer);
}
}
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <unistd.h>
#include <arpa/inet.h>
20 Network Configuration
Prolin provides network configuration interfaces, including ARP setting, Ping service,
DNS configuration, network card configuration, DHCP service, routing setting and
PPPoE service etc.
has no corresponding
device.)
TCP / UDP session is
ERR_NET_SESS_BROKEN -3308
disconnected.
ERR_NET_PASSWD -3309 Wrong password.
Application logout
ERR_NET_LOGOUT -3310
actively.
ERR_NET_INIT -3311 Initialization failed.
DHCP Server is not
ERR_NET_DHCP_DISCOVER -3312
found.
DHCP cannot get the IP
ERR_NET_DHCP_OFFER -3313
address.
ERR_NET_DHCP_START -3314 DHCP is not started.
DNS cannot analyze the
ERR_NET_DNS -3315
corresponding domain.
The port specified by the
ERR_NET_SERV_USING -3316
server is in use.
Domain name server is
ERR_NET_NODNServer -3317
not configured.
Link is disconnected by
ERR_NET_LINKDOWN -3318
the server.
Cannot connect to the
ERR_NET_CONN -3319
specified server.
ERR_NET_TIMEOUT -3320 Connection timeout.
ERR_NET_PPP -3321 PPP connection error.
PPPoE server is not
ERR_NET_SERV -3322
found.
Request resource is not
ERR_NET_AGAIN -3323
found, please try again.
Cannot connect to
ERR_NET_AUTH -3324
RADIUS server.
Windows server is not
ERR_PPP_SERV_NOTREADY -3325 ready when connected
to ppp_direc.
ERR_NET_ICMPV6_UNREACH -3327 Target is unreachable.
ERR_NET_ICMPV6_PKT_TOOBI SIZE is greater than the
-3328
G minimum MTU.
TTL exceeds the
ERR_NET_ICMPV6_TIME_EXCE maximum value (default
-3329
ED
value:64).
Protocol parameter
ERR_NET_ICMPV6_PARAMPRO error; cannot process
-3330
B middle route or target
node.
Unrecognizable
ERR_NET_DHCPV6_DNS -3331 keywords or illegal IP
address in Resolv.conf.
Macro Description
NET_LINK_ETH Ethernet.
Wireless network, including GPRS, CDMA,
NET_LINK_WL
TDSCDMA
NET_LINK_WIFI WiFi
NET_LINK_PPPOE ADSL link
NET_LINK_MODEM Modem PPP link
NET_LINK_PPPDIRECT ppp_direct link
NET_LINK_BT Bluetooth link
NET_LINK_USB USB link
IPv6Info is used to get an existed IPV6 address, and link address, site address and
global address are different.
Struct IPv6Info
Struct IPv6Info{
char LinkAddr[64]; /*Link address of IPv6,at most 1 link address*/
int NumSiteAddr; /*Number of site address of IPv6*/
char SiteAddr[4][64]; /*Site address of IPv6,at most 4 site
addresses*/
int NumGlobalAddr; /*Number of global address of IPv6*/
IPv6RouteTable
struct IPv6RouteTable{
Char RouteNum; /* The number of items in the routing table
*/
Struct {
char DestAddr[64]; /*Prefix of destination address*/
char DestAddrPrefixLen; /*Not supported*/
char NextHop[64]; /*Next hop address*/
}RouteTable[16];
}
DnsAddrInfo
struct DnsAddrInfo{
int NumIPv4Addr; /*numbers of IPv4 addr*/
char IPv4Addr[4][16]; /*IPv4 addr*/
int NumIPv6Addr; /*numbers of IPv6 addr*/
char IPv6Addr[4][64]; /*IPv6 addr*/
};
Structure: IPv4RouteTable
IPv4RouteTable
struct IPv4RouteTable{
int RouteNum;/* number of Route*/
struct{
20.3.1 OsNetAddArp
IP address.
Parameters The format is “XXX.XXX.XXX.XXX”. The value
Addr[Input] range of XXX is from 0 to 255. e.g.:
“192.168.0.1”.
It can’t be NULL.
The MAC address corresponding to the IP
MAC[Input] address;
The size of MAC is 6 bytes. It can’t be NULL.
RET_OK Succeeded.
ERR_INVALID_PARAM Invalid parameter.
Return
The network link cannot be used
ERR_NET_IF
(not established or disconnected).
Instruction
1. Static ARP table is used to resist the attack from ARP Cheat.
2. Static ARP table is obtained dynamically, so application
doesn’t need to configure it.
20.3.2 OsNetPing
20.3.3 OsNetPingEx
20.3.4 OsNetDns
20.3.5 OsNetDnsEx
20.3.6 OsNetSetConfig
20.3.7 OsNetGetConfig
20.3.8 OsNetStartDhcp
RET_OK Succeeded.
Return
ERR_NET_IF Ethernet or WiFi module is not configured.
1. This interface is just used to start the DHCP and will not wait
for the address allocation process.
2. OsNetCheckDhcp() can be called to check the status of
Instruction
address allocation.
3. After obtaining the address successfully, this link will be set
as the default route.
20.3.9 OsNetCheckDhcp
NET_LINK_ETH: Ethernet;
NET_LINK_WIFI:WiFi;
NET_LINK_BT: Bluetooth;
NET_LINK_USB: USB
20.3.10 OsNetStopDhcp
Return None.
1. If the DHCP is stopped, OsNetSetConfig() shall be called to
re-configure the network;
Instruction 2. After a successful DHCP, the system will update the
configuration information at regular interval; if the update
fails, the network will be unavailable.
20.3.11 OsPppoeLogin
20.3.12 OsPppoeCheck
20.3.13 OsPppoeLogout
20.3.14 OsNetSetRoute
20.3.15 OsNetGetRoute
20.3.16 OsNetSetRouteTable
20.3.17 OsNetDelRouteTable
20.3.18 OsNetGetRouteTable
20.3.19 OsNetNat
The following interfaces apply to both IPv4 and IPv6 network environment.
20.4.1 OsNetSetDns
20.5.1 OsNetPing6
20.5.2 OsNetSetIPv6Addr
20.5.3 OsNetGetIPv6Addr
RET_OK Succeeded.
Return ERR_NET_IF The link is not established or is
disconnected.
For example:
Instruction struct IPv6Info AddrInfo;
ret = OsNetGetIPv6Addr(NET_LINK_ETH,&AddrInfo);
20.5.4 OsNetGetRouteAdvertise6
Case IP6_DHCP6_STATEFULL_ADDR_CONFIG :
ret=OsNetStartDhcp6(NET_LINK_ETH,IP6_DHCP6_ST
ATEFULL_ADDR_CONFIG);
if(ret != RET_OK)
{……};
break;
Case IP6_DHCP6_STATELESS_ADDR_CONFIG:
ret=OsNetStartDhcp6(NET_LINK_ETH,IP6_DHCP6_ST
ATELESS_ADDR_CONFIG);
if(ret != RET_OK)
{……};
break;
}
}
……
20.5.5 OsNetStartDhcp6
20.5.6 OsNetCheckDhcp6
20.5.7 OsNetStopDhcp6
20.5.8 OsNetSetRouteTable6
20.5.9 OsNetGetRouteTable6
21 GPRS/CDMA
Prolin supports GPRS and CDMA network and provides a series of related APIs for
developers.
21.2.1 OsWlLock
21.2.2 OsWlUnLock
21.2.3 OsWlInit
21.2.4 OsWlInitEx
intOsWlInitEx(constchar*SimPin,
intTimeOutMs,
Prototype char*CmeString,
int Size);
21.2.5 OsWlSwitchPower
21.2.6 OsWlSwitchSleep
no SIM card,
deactivated PIN,
21.2.7 OsWlGetSignal
21.2.8 OsWlCheck
21.2.9 OsWlLogin
21.2.10 OsWlLoginEx
21.2.11 OsWlLogout
21.3.1 OsWlSelSim
RET_OK Succeeded.
ERR_DEV_NOT_EXIST Module does not exist.
Return ERR_DEV_NOT_OPEN Fail to call OsWlLock().
ERR_WL_ERR_BUSY Module is busy.
Other non-zero value Refer to Return Code List.
1. OsWlLock() must be called successfully before calling this
function.
2. OsWlInit() shall be called again to initialize module after
successfully calling OsWlSelSim(). In this process, the
Instruction module will be powered off and then powered on, this
function will block for about 15 seconds.
3. If the selected card slot has a bad card or has no card, the
function will still return; when logging in, whether it is a bad
card or no card can be detected.
22 WiFi
Prolin WiFi supports two modes: Station and IBSS work mode.
Station mode: the communication between the terminal and Access Point (AP), such
as wireless router.
Authentication Modes:
WIFI_AUTH_MODE
enum WIFI_AUTH_MODE{
AUTH_NONE_OPEN=1,
AUTH_NONE_WEP,
AUTH_NONE_WEP_SHARED, /* The mode will be scanned as
AUTH_NONE_WEP */
AUTH_IEEE8021X,
AUTH_WPA_PSK,
AUTH_WPA_EAP,
AUTH_WPA_WPA2_PSK,
AUTH_WPA_WPA2_EAP,
AUTH_WPA2_PSK,
AUTH_WPA2_EAP
};
WEP_SEC_KEY
typedef struct _WepSecKey{
char Key[4][40]; /* WEP key data */
int KeyLen; /* Length of WEP key data */
int Idx; /* WEP key index [0,3] */
} WEP_SEC_KEY;
WPA_PSK_KEY
typedef struct _WpaPskKey{
char Key[64]; /* PSK-Key data */
int KeyLen; /* PSK-Key data length */
} WPA_PSK_KEY;
WPA_EAP_KEY
typedef struct _WpaEapKey{
int EapType; /* EAP type */
char Pwd[132]; /* Password */
char Id[132]; /* Identity */
char CaCert[132]; /* Path and filename of CA certificate */
char CliCert[132];/* Path and filename of client certificate */
char PriKey[132]; /*Private key file from file path to client */
char PriKeyPwd[132]; /* Private key file of password */
} WPA_EAP_KEY;
ST_WifiApInfo
typedef struct _WifiApInfo
{
char Essid[33]; /* AP name */
char Bssid[20]; /* MAC address */
int Channel; /* Information channel */
int Mode; /* Connection mode, 0:Station; 1:IBSS */
int Rssi; /* Signal value, the value range is [-99,0] */
int AuthMode; /* Authentication mode*/
int SecMode; /* Encryption mode, NONE,WEP,TKIP,CCMP */
}ST_WifiApInfo;
Connect to AP settings:
ST_WifiApSet
typedef struct _WifiApSet
{
char Essid[33]; /* AP name, valid length is not more than 32 bytes,
ending with ‘\0’*/
char Bssid[20]; /* MAC address, ending with ‘\0’; Bssid can be‘\0’ if there
is no AP with the same ESSID*/
int Channel; /* Information channel, which is valid only in IBSS
mode; 0: default setting */
int Mode; /* Connection mode, 0:Station; 1:IBSS */
int AuthMode; /* Authentication mode */
int SecMode; /*Encryption mode, NONE,WEP,TKIP,CCMP*/
union KEY_UNION{ /* Key setting */
WEP_SEC_KEY WepKey; /* WEP mode */
WPA_PSK_KEY PskKey; /*wpa,wpa2-psk mode*/
WPA_EAP_KEY EapKey; /* wpa,wpa2-eap mode*/
} KeyUnion;
}ST_WifiApSet;
WPS Mode
enum WPS_MODE
{
WPS_MODE_PBC = 1; /* Use keypad to connect, it is also called
PBC connection */
22.4 OsWifiOpen
Function Connect with WiFi server and obtain usage rights of WiFi
module.
Parameters None
RET_OK Succeeded.
ERR_DEV_NOT_EXIS Abnormal loading of module driver or
T module error.
ERR_DEV_BUSY WiFi is busy.
Return
ERR_BATTERY_VOLT
AGE Battery voltage is too low.
_TOO_LOW
ERR_BATTERY_ABS
Battery does not exist.
ENT
1. D200 and S920 POS models must be powered by battery
before accessing Wifi; otherwise,
ERR_BATTERY_ABSENT will be returned.
Instruction
2. When the battery voltage is 0, the module fails to work
normally and returns
ERR_BATTERY_VOLTAGE_TOO_LOW.
22.5 OsWifiClose
Prototype voidOsWifiClose(void);
Function Release the usage right of WiFi module.
Parameters None
Return None
22.6 OsWifiSwitchPower
22.7 OsWifiScan
return -1;
for(i=0; i<num; i++)
printf("[%d] AP name: %s\n", i,Aps[i].Essid);
22.8 OsWifiConnect
22.9 OsWifiDisconnect
Parameters None.
RET_OK Succeeded.
Return ERR_DEV_NOT_OP
Fail to access WiFi device.
EN
Instruction
22.10 OsWifiCheck
22.11 OsWifiCmd
RET_OK Succeeded.
ERR_INVALID_PAR
Invalid parameter.
AM
Return ERR_WIFI_POWER
WiFi module is powered off.
_OFF
ERR_DEV_NOT_O
Fail to access WiFi device.
PEN
1. Argv can be all the commands and parameters supported
by WPA_Supplicant, such as ‘SCAN’ command.
2. If there is only one command in Argv, set Argc to 1.
Instruction
3. This function is called only when other WiFi APIs cannot
meet requirements.
4. Result is the original return value of WPA_Supplicant.
22.12 OsWifiWpsConnect
23 GPS
GPS_LOCATION
typedef struct {
double latitude; /*Latitude, unit: degree.*/
double longitude; /*Longitude, unit: degree.*/
double altitude; /*Altitude, unit: meter.*/
} GPS_LOCATION;
23.3 OsGpsOpen
23.4 OsGpsRead
23.5 OsGpsClose
Parameters None
Return None
1. GPS module can only be closed by the same application which was
used to open it firstly. If GPS module is not open, this function does
not do anything.
Instruction
2. As long as RET_OK is returned after calling OsGpsOpen(),
OsGpsClose() must be called to close GPS module when program
exits.
24 Base
24.1 Introduction
Newly added base APIs are used for operating base-set, including detecting whether
the handset is on base and opening/detecting/closing the communication mode of
handset-base.
When the communication mode is enabled on the handset-base, functions will be
extended on base; (B920 extends the Ethernet function, and Px Dock extends printer
and scanner functions). When the communication mode is closed on the handset-base,
extended functions are invalid on base.
Mode instructions
24.3 API
24.3.1 OsOnBase
Parameters None
RET_OK Handset is on the base.
ERR_BASE_ABSEN Base is absent.
T
Return ERR_SYS_NOT_SU System does not support this function.
PPORT
ERR_TIME_OUT Timeout
ERR_SYS_BAD System error
This function only applies to handsets connected to the base via USB or
Instruction serial ports.
24.3.2 OsBaseOpen
Parameters None
RET_OK Succeeded
ERR_SYS_NOT_SUPPOR System does not support this function.
T
ERR_SYS_BAD System error.
ERR_TIME_OUT Timeout
Return ERR_NOT_CONNECT Bluetooth has not connected.
ERR_DEV_BUSY Device is busy.
ERR_BASE_ABSENT Base is absent.
ERR_USB_MODE USB mode error
Others Return values of the Bluetooth module
1. After opening the handset mode, API of serial port, modem and
Ethernet will be switched to the port which is corresponding to the
operation base side;
Instruction 2. When the connection mode between the handset and the base is
USB, please ensure the USB works in single channel mode,
otherwise the interface will return ERR_USB_MODE.
24.3.3 OsBaseCheck
24.3.4 OsBaseClose
Parameters None
RET_OK Succeeded
Return ERR_SYS_NOT_SUPP System does not support this function.
ORT
Instruction
24.3.5 OsBaseScan
Instruction
Sample code
24.3.6 OsBaseConnect
Sample code
typedef struct _HandsetLinkSet {
int type; //Reserved for future use
union {
struct {
char mac[32]; //Bluetooth MAC address
} bt;
unsigned char reserved[1024];
} u;
} ST_HandsetLinkSet;
24.3.7 OsBaseDisconnect
Parameters None
RET_OK Succeeded.
ERR_SYS_NOT_SUPP System does not support this function.
ORT
Return ERR_SYS_BAD System error
ERR_TIME_OUT Timeout
ERR_DEV_BUSY Device is busy.
Instruction Only the process which has opened the base can close the base.
24.3.8 OsCheckPortStatus
24.3.9 OsGetBaseInfo
24.3.10 OsBaseCmd
25 File System
26 System Information
The SIGMAG is valid only when the magnetic stripe reader is open.
Example
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <pthread.h>
#include <osal.h>
#include <cutils/log.h>
#define printf(...) LOGI(__VA_ARGS__)
static sigset_t mask;
void * handler_sigwait(void * arg)
{
int ret, signo;
while(1){
ret = sigwait(&mask, &signo);
if(ret != 0){
printf("sigwait err, ret=%d\n", ret);
break;
}
switch(signo){
case SIGMAG:
printf("Capture msr signal\n");
break;
case SIGICC:
printf("Capture icc signal\n");
break;
default:
printf("Capture other signal %d\n", signo);
break;
}
}
}
int main()
{
int ret;
sigset_t oldmask;
pthread_t tid;
ret = OsMsrOpen();
if (ret < 0)
exit(-1);
ret = OsIccOpen(ICC_USER_SLOT);
if (ret < 0){
OsMsrClose();
return -1;
}
sigemptyset(&mask);
sigaddset(&mask, SIGMAG);
sigaddset(&mask, SIGICC);
ret = pthread_sigmask(SIG_SETMASK, &mask, &oldmask);
if(ret != 0){
printf("pthread_sigmask error, ret=%d\n", ret);
exit(-1);
}
OsMsrClose();
OsIccClose(ICC_USER_SLOT);
27 Audio
Prolin audio device is a speaker. In general, the volume settings are unified and can
be set in TM interface.
27.2 OsRecordOpen
ERR_DEV_NOT_EXI
Device does not exist.
ST
Return
ERR_DEV_BUSY Device is occupied by other application
programs.
1. OsRecordOpen() should be called before calling
OsRecordStart() or OsRecordStop().
Instruction
2. After all the operations have been completed, OsRecordClose()
should be called to release the voice recording device.
27.3 OsRecordStart
Example
if (OsRecordOpen())
return -1;
OsRecordStart("/data/app/MAINAPP/test.wav", NULL, 1, NULL, 44100, 20);
while (1)
{
if (!XuiHasKey())
continue;
key = XuiGetKey();
if (key == XUI_KEY1)
OsRecordStop();
else if (key == XUI_KEY2)
ret = OsRecordCheck();
else if (key == XUI_KEYCANCEL)
break;
}
OsRecordClose();
27.4 OsRecordStop
27.5 OsRecordCheck
27.6 OsRecordClose
Function Release the access to the recording device and disconnect the
device from the Prolin recording service.
Parameters None
Return None
Instruction
27.7 OsPlayWave
Example
int fd, ret = 0;
char *buff;
int len;
struct stat state;
stat(FILENAME, &state);
len = state.st_size;
buff = (char *) malloc(len * sizeof(char));
fd = open(FILENAME, O_RDONLY);
if(fd<0)
printf("Open File Fail\n");
ret = read(fd, buff, len);
ret = OsPlayWave(buff, len, 3, 0);
if(ret != RET_OK)
printf("PlayWave Fail\n");
close(fd);
free(buff);
27.8 OsStopPlayWave
ERR_SYS_NOT_SU
System does not support this feature.
PPORT
1. When a thread calls OsPlayWave() to play an audio,
OsStopPlayWave() can be called by another thread to stop
Instruction
playing the audio.
2. If no audio is playing, ERR_DEV_NOT_OPEN will be returned.
27.9 OsPlayAudio
The sample code of playing MP3 audio is shown as below, the FILENAME is the audio
file name.
Sample code
int fd = 0, ret = 0;
char *buf;
struct stat state;
fd = open(FILENAME, O_RDONLY);
if (fstat(fd, &stat) == -1 || stat.st_size == 0) {
printf(“audio file error\n”);
return -1;
}
buf = mmap(0, stat.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (buf == MAP_FAILED)
return -1;
ret = OsPlayAudio(buf, stat.st_size, 1);
printf("PlayAudio result = %d\n", ret);
munmap(buf, stat.st_size);
close(fd);
27.10 OsStopPlayAudio
One-dimensional code is composed of vertical black and white bars of different widths,
and generally there are letters or digits at the bottom of these bars. The code is
commonly used to identify the basic information of products, such as name, price, etc.
Two-dimensional code is in a dot matrix form usually with square structure. Chequered
with black and white bars of different widths, the code is dotted with polygonous images
within its code area. In addition to the identification function, two-dimensional code can
contain much more detailed contents.
CameraAttribute
typedef struct SCameraAttribute
{
int SupportResolution; /*Read only, describes all the resolutions which
the device supports in bits.*/
int CurrentResolution; /*Read and write, it is the current resolution.*/
int SupportPixelFormat; /*Read only, it is the format of output pixel data,
and it only supports yuyv and rgb565 formats.*/
int CurrentPixelFormat; /* Read and write, it is the format of current
output data, and it only support yuyv format*/
char Reserved[128]; /*Reserved for future use.*/
}CameraAttribute;
28.3.1 OsScanSetParam
28.3.2 OsScanOpen
28.3.3 OsScanRead
28.3.4 OsScanClose
Return None.
Instruction
28.3.5 OsCameraOpen
28.3.6 OsCameraClose
Return None.
Instruction
28.3.7 OsCameraGetParam
28.3.8 OsCameraSetParam
28.3.9 OsCameraCapture
28.3.10 OsScanDecodeBuf
28.3.11 OsCameraDetectMotion
29 Power Management
PM_MSG_T:
typedef enum {
PM_MSG_NO_EVENT, /* No event.*/
PM_MSG_ENTER_SLEEP, /* Device enters sleep mode.*/
PM_MSG_EXIT_SLEEP, /* Device exits sleep mode.*/
PM_MSG_ENTER_SCREENSAVER, /* Device enters screensaver mode.*/
PM_MSG_EXIT_SCREENSAVER, /* Device exits screensaver mode.*/
PM_MSG_ENTER_ POWEROFF, /* Device starts to power off*/
PM_MSG_POWER_ABNORMAL, /* Device power is abnomal*/
PM_MSG_BATTERY_DAMAGE, /* Battery is out of service */
} PM_MSG_T;
PM_REQ_T:
typedef enum {
PM_FORBID_SLEEP, /* Forbid device from sleeping. */
PM_ALLOW_SLEEP, /* Allow device to sleep.*/
PM_FORBID_SCREENSAVER, /*Forbid device from entering screensaver mode. */
PM_ALLOW_SCREENSAVER, /* Allow device to enter screensaver mode.*/
PM_FORBID_ POWEROFF, /*Forbid device from powering off. */
PM_ALLOW_ POWEROFF, /*Allow device to power off.*/
} PM_REQ_T;
POWER_TYPE:
typedef enum {
POWER_ADAPTER = 1, /*Supplied by adapter.*/
POWER_USB, /*Supplied by USB external device.*/
POWER_BATTERY, /*Supplied by battery.*/
POWER_WPC /*Supplied by wireless base.*/
} POWER_TYPE;
WAKEUP_SOURCE:
typedef enum {
WAKEUP_SRC_NONE = 0, /* No wakeup has been done, it has
no wakeup source. */
WAKEUP_SRC_KP, /* Key pressing wakeup */
WAKEUP_SRC_RTC, /* Timer wakeup */
WAKEUP_SRC_BT, /* Bluetooth wakeup */
WAKEUP_SRC_CHC, /* Power wakeup */
WAKEUP_SRC_WIFI, /* WIFI wakeup */
WAKEUP_SRC_MSR, /* MSR wakeup */
WAKEUP_SRC_SMARTCARD0 = 8, /* IC card wakeup */
WAKEUP_SRC_UART = 12, /* serial port wakeup*/
WAKEUP_SRC_ETHER, /* Ethernet wakeup */
WAKEUP_SRC_GENERAL1 = 1000, /* general wakeup 1 */
WAKEUP_SRC_GENERAL2, /* general wakeup 2 */
WAKEUP_SRC_GENERAL3, /* general wakeup 3 */
WAKEUP_SRC_GENERAL4, /* general wakeup 4 */
WAKEUP_SRC_GENERAL5, /* general wakeup 5 */
} WAKEUP_SOURCE;
29.3 OsCheckBattery
29.4 OsCheckPowerSupply
Parameters None.
29.5 OsSysSleep
Parameters None.
RET_OK Succeeded.
29.6 OsSysSleepEx
29.7 OsSysSleepTime
29.8 OsReboot
Parameters None.
29.9 OsPowerOff
29.10 OsPmGetEvent
29.11 OsPmRequest
29.12 OsWakeupSource
29.13 OsCheckPowerStatus
Q92 Bit0-Bit5
QR68, QR65 Bit0
29.14 OsCheckBMSMode
int OsCheckBMSMode(int*CurrentMode,
int *Capacity,
Prototype
int *FullCharge,
int *Recharge);
Function Get information about battery management system.
RET_OK Succeeded
ERR_INVALID_PARA Invalid parameter.
Return M
ERR_SYS_NOT_SU System does not support.
PPORT
Instruction
PM_MSG_T msg;
while(1) {
msg = OsPmGetEvent(100000);
if (msg > 0) {
switch (msg) {
case PM_MSG_ENTER_SLEEP:
break;
case PM_MSG_EXIT_SLEEP:
break;
/*add other case*/
default:
break;
}
}
}
This PIN block is constructed by modulo-2 addition of two 64-bit fields: the plain text
PIN field and the account number field. The formats of these fields are described in
1.1.1 and 1.1.2 respectively.
Bit
1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 64
where
N = PIN length: 4-bit binary number with permissible values of 0100(4) to 1100(12);
P/F = PIN/Fill digit: designation of these fields is determined by the PIN length field;
Bit
1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 64
Wherein,
0 = Pad digit: a 4-bit field with the only permissible value of 0000(zero);
A1…A12 = Account number: content is the 12 rightmost digits of the primary account
number (PAN) excluding the check digit. A12 is the digit immediately preceding the
PAN’s check digit. If the PAN excluding the check digit is less than 12 digits, the
digits are right justified and padded to the left with zeros. Permissible values are
0000 (zero) to 1001 (9).
This PIN block is constructed by concatenation of two fields: the plain text PIN field
and the transaction field.
The format 1 PIN block should be used in situations where the PAN is not available.
Bit
1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 64
Wherein,
N = PIN length: 4-bit binary number with permissible values 0100(4) to 1100 (12);
P = PIN digit: 4-bit field with permissible values 0000 (zero) to 1001 (9);
T = Transaction digit: 4-bit binary number with permissible values of 0000 (zero) to
1111 (15).
The transaction field is a binary number formed by [56-(N*4)] bits. This binary shall
be unique (except by chance) for every occurrence of the PIN block and can, for
example, be derived from a transaction sequence number, time stamp, random
number or similar.
The transaction field should not be transmitted and is not required in order to
translate the PIN block to another format since the PIN length is known.
The format 2 PIN block has been specified for local use with IC cards. The format 2
PIN block shall only be used in an offline environment and shall not be used for
online PIN verification.
The format 3 PIN block is the same as format 0 PIN block except for the fill digits.
This PIN block is constructed by modulo-2 addition of two 64-bit fields: the plain text
PIN field and the account number field. The formats of these fields are described in
1.4.2 and 1.4.3 respectively.
Bit
1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 64
Wherein,
N = PIN number: 4-bit binary number with permissible values of 0100 (4) to 1100
(12);
P = PIN digit: 4-bit field with permissible values of 0000 (zero) to 1001 (9);
P/F = PIN/Fill digit: designation of these fields is determined by the PIN length field;
F = Fill digit: 4-bit field, with values from 1010(10) to 1111(15), where the
Fill-digit values are randomly or sequentially selected from this set of six possible
values, such that it is highly unlikely that the identical configuration of fill digits will be
used more than once with the same account number field by the same PIN device.
Bit
1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 64
For more details related to PIN Block format please refer to ISO 9564-1:2002(E).
Convert the above data into BCD code and use TPK to encrypt the BCD code with
DES/TDES algorithm.
Appendix 3 Registry
The table below is a registry of functions which mainly begin with “ro.fac.” and
“persist.sys.”. The "ro.fac." are read-only and"persist.sys." can be both read and
written.
System configuration
Description
name
ro.fac.bootver Boot version information.
ro.fac.hwver Hardware version number. Main board- interface board.
ro.fac.mach Product model name.
Boardid information, including the product model,
ro.fac.boardid
hardware version number, etc.
ro.fac.conf.ver Version information of configuration files.
ro.fac.pn PN number.
ro.fac.sn SN number.
ro.fac.prolin_debug_le Prolin_debug_level information, this value is 0 and 1 for
vel release system and debug system, respectively.
Whether there is a network cable port.(0: does not exist;
ro.fac.eth
1: exist)
Whether there is a main device interface.(0: does not
ro.fac.usb.host
exist; 1: exist)
Whether there is an USB device interface.(0: does not
ro.fac.usb.device
exist; 1: exist)
Whether there is an USB OTG interface.(0: does not
ro.fac.usb.otg
exist; 1: exist)
Whether there is a LED digital tube.(0: does not exist; 1:
ro.fac.leddt
exist)
Key types.(0: have no key; 1: physical button; 2: touch-
ro.fac.keybroad
screen button)
Whether there is a Buzzer module.(0: does not exist; 1:
ro.fac.buzzer
exist)
ro.fac.simsocket The number of SIM card slot.
ro.fac.battery Whether there is a battery.(0: does not exist; 1: exist)
ro.fac.coulomb_count Whether there is a coulombmeter. (None means it does
er not exist by default.)
Name of WiFi module.(None means it does not exist by
ro.fac.wifi
default.)
Allowing for the configuration differences for different models, some OSAL interfaces
may be invalid for certain kinds of model. For the validity of different models and
Thread √ √ √ √ √ √ √ √
System √ √ √ √ √ √ √ √
Function
Encryptio √ √ √ √ √ √ √ √
n and
Decryptio
PED √ √ √ √ √ √ √ √
clockwi direction
se e e
Keyboard √ √ √ √ √ √ √ NA
Touch √ NA √ √ NA √ √ √
Screen
Signature √ NA √ √ NA √ √ √
Pad
Printer NA √ √ √ NA NA √ NA
Font √ √ √ √ √ √ √ √
Library
Code √ √ √ √ √ √ √ √
MSR √ √ √ √ √ √ √ √
IC Card √ √ √ √ √ √ √ √
Reader
RF √ √ √ √ √ √ √ √
Reader
Port 1 1 1 DEV
PORT_ PORT_ PORT_U PORT_U
Communi
cation
Configura
tion
MA
(optional)
(optional)
File √ √ √ √ √ √ √ √
System
System √ √ √ √ √ √ √ √
Informati
on
Audio √ √ √ √ N/A √ √ √
Managem
ent
(optional)