Professional Documents
Culture Documents
APPLICATION DEVELOPMENT
MANUAL
V 0.1.2
Author: Harrison
Approved:
Date: 2013-12-03
Date:
1. Revision History
Date
Revision Level
Description
Modified by
2013-3-13
0.0.1
Create
Ryan Huang
2013-4-20
0.0.2
Harrison Lee
2013-4-26
0.0.3
Kent Song
2013-4-28
0.0.4
Revision
Henry Li
2013-6-7
0.0.5
Alex Chen
2013-07-17
0.0.6
Ryan Huang
2013-09-26
0.0.7
Kent Song
2013-10-21
0.0.8
Henry Li
2013-12-03
0.0.9
Henry Li
2014-01-02
0.1.0
Henry Li
2014-02-28
0.1.1
Henry Li
2014-07-31
0.1.2
Henry Li
2. General Introduction
NEW8210 is a mobile POS terminal, base on Linux OS by New Pos Technology
Limited, its development platform is Linux OS, please download the latest SDK,
firmware, DownloadTool and related documents from the server:
ftp://customer:loadsoftware@121.15.134.230/NEW8210/SDK
3. Function Introduction
4. Development Platform
If you want develop the application on Linux platform, you need to install a 32-bit
Linux system based on x86 platform (our SDK have not been certificated on 64-bit
Linux). You can also develop application on a virtual Linux by running virtual machine on
Windows system, at that time, you can develop application on Windows platform. Due to
we dont offer SDK on Windows platform, so you cant develop application on Windows
system directly.
To develop application, we recommend to use Eclipse, it is a multi-platform
development tool based on Java, Eclipse integrates functions of edit, compile, debug,
and etc,. Eclipse has friendly interface, and easy operating. If you know how to write
Makefile well, you also can develop application directly without any development tool.
Target: arm-unknown-linux-gnu
--target=arm-unknown-linux-gnu
--prefix=/opt/compiler/glibc-oabi-toolchain-arm-
--with-sysroot=/opt/compiler/glibc-oabi-toolchain-arm-generic/arm-unknown-linux-gnu//sys-root
languages=c,c++,java,objc,obj-c++
--disable-multilib
--with-float=soft
--enable-
--with-pkgversion='<lihua_338@163.com>'
--with-mpc=/opt/compiler/glibc-oabi-toolchain-arm-generic
prefix=/opt/compiler/glibc-oabi-toolchain-arm-generic/arm-unknown-linux-gnu//sys-root
--disable-nls
--with-local--enable-
Because this toolchain uses a high grade version of GCC toolchain, it needs
dynamic library mpfr-2.4.2, if your Linux system havent the dynamic library, or havent
the enough high grade version of dynamic library, it will report error libmpfr.so when using
this toolchain. Please download mpfr-2.4.2.tar.bz2, compile and install it again, step
below:
Unzip file:
tar jxf mpfr-2.4.2.tar.bz2
Configure and compile:
cd mpfr-2.4.2
./configure prefix=/usr
make
Install: need root privilege
su
make install
exit
The figure below shows the "Environment Variables" dialog box that opens next. It lists
two kinds of variable- those that apply only to the current user and those that apply to the
whole system. You can simply scroll down the lists to see what is on your system or you
can edit the lists. To create a new variable, use the "New" button. There are also buttons
for editing and for deleting variables.
The box for adding a new user variable is shown below. Generally, this is likely to be a
directory that you use frequently but can be any string of less than 8192 bytes. The
maximum total size for all environment variables, including variable names and the
"equals" sign, is 32767 characters.
The next figure shows a box for editing a variable; in this case it is the PATH variable. Be
sure to remember to separate directory names with a semicolon.
--target=arm-unknown-linux-gnu
--prefix=/cygdrive/C/glibc-oabi-toolchain-arm-generic
--with-
sysroot=/cygdrive/C/glibc-oabi-toolchain-arm-generic/arm-unknown-linux-gnu//sys-root --enable-languages=c,c++,objc,obj-c+
+
--disable-multilib
--enable-libgomp
--with-float=soft
--enable-libssp
--with-pkgversion=lihua_338@163.com
--enable-__cxa_atexit
--enable-libmudflap
--with-gmp=/home/Administrator/crosstool/bin/build/arm-unknown-linux-gnu/build/static
--with-mpfr=/home/Administrator/crosstool/bin/build/arm-unknown-linux-gnu/build/static
--enable-threads=posix
--enable-target-optspace --with-local-prefix=/cygdrive/C/glibc-oabi-toolchain-arm-generic/arm-unknown-linux-gnu//sys-root
--disable-nls --enable-symvers=gnu --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.3.4 (lihua_338@163.com)
2.
3.
Download Eclipse
The server is: http://www.eclipse.org/downloads/ please download Windows file
package have the version of Eclipse IDE for C/C++ Developers.
Unzip Eclipse
Run Eclipse
4.5.1.
Choose menu File->New->C Project, or choose toolbar New->C Project, or right click
on Project Explorer windowss blank, choose New->C Project:
4.5.2.
Configure application project name at Project Name, choose Hello World ANSI C
Project at Project type, if you chooses Empty Project , it will not generate default
program. We recommend automatic generate program which is contain main
function by Eclipse.Then click Next to go into next configuration.
4.5.3.
4.5.4.
In default condition, project create by Eclipse use gcc to compile the programs, and
the target is a application run on x86 platform; But our target system is ARM, of course it
can not run on x86 platform, so you need to configure the compile toolchain, cross
compile program which is running on ARM platform.
In Project Explore windows, right click the configured project, choose Properties
4.5.4.1.
Choose GCC C Compiler from Tool Settings tag, modify Command on right side to
cross compile toolchain which we provide:
If you use Linux system, it should be:
/opt/compiler/glibc-oabi-toolchain-arm-generic/bin/arm-unknown-linux-gnu-gcc
If you use Windows system, it should be:
/cygdrive/c/glibc-oabi-toolchain-arm-generic/bin/arm-unknown-linux-gnu-gcc
Assume the Linux toolchain was installed in: /opt/compiler/glibc-oabi-toolchain-armgeneric
Assume the Windows toolchain was installed in: C:\glibc-oabi-toolchain-arm-generic
4.5.4.2.
Choose GCC C Linker of Tool Settings tags, modify Command on right side to cross
compile toolchain we provided:
If you use Linux system, it should be:
/opt/compiler/glibc-oabi-toolchain-arm-generic/bin/arm-unknown-linux-gnu-gcc
If you use Windows system, it should be:
/cygdrive/c/glibc-oabi-toolchain-arm-generic/bin/arm-unknown-linux-gnu-gcc
General Option:
Here is a general linking option. Choose No shared libraries(static) if you need static link program;choose nothing if you need
dynamic link program. Usually, we choose dynamic link program.
Libraries Option:
Here is used to configure linking assigned dynamic library and
configure path of search dynamic library, just like option lxxxxx
Lxxxxx.For example, if you want to link library directfb.so, just
need to add directfb in Libraries(-l), and add path of dynamic
library in Library search path(-L).
Miscellaneous Option: For NEW8210, we modify Linker flags to:
-marm -mapcs -mno-sched-prolog -mabi=apcs-gnu -mlittleendian -mno-thumb-interwork -msoft-float -Wl,-Map,"${PWD}/$
{ProjName}.map"
Shared Library Settings: Options here is available when compiling dynamic library, keep
default option when compiling application program.
4.5.4.3.
Choose GCC Assembler of Tool Settings tag, modidy cross compile toolchain we
provide in right sides Command to :
If you use Linux system, it should be:
/opt/compiler/glibc-oabi-toolchain-arm-generic/bin/arm-unknown-linux-gnu-gcc
If you use Windows system, it should be:
/cygdrive/c/glibc-oabi-toolchain-arm-generic/bin/arm-unknown-linux-gnu-gcc
Here is used to configure compile options which is used when compiling assembly
file, usually application doesnt use assembly language, so it is not need to configure.
4.5.5.
4.5.5.1.
In default condition, project create by Eclipse use gcc to compile the programs, and
the target is a application run on x86 platform; But our target system is ARM, of course it
can not run on x86 platform, so you need to configure the compile toolchain, cross
compile program which is running on ARM platform.
We setting the global environment configure in here, to avoid setting every project. Click the
menu Window-->select Preferences as follow figure:
Click the button Add... to add an environment variable GCCPATH as follow figure:
4.5.5.2.
Miscellaneous Option: Here is used to define compile options for ourselves. For
NEW8210, we recommend set Other flags as:
-Wundef
-Wstrict-prototypes
-Werror-implicit-functiondeclaration -Wdeclaration-after-statement -fsigned-char -marm
-mapcs -mno-sched-prolog -mabi=apcs-gnu -mlittle-endian
-mno-thumb-interwork -msoft-float -c
General Option:
Here is a general linking option. Choose No shared libraries(static) if you need static link program;choose nothing if you need
dynamic link program. Usually, we choose dynamic link program.
Libraries Option:
Here is used to configure linking assigned dynamic library and
configure path of search dynamic library, just like option lxxxxx
Lxxxxx.For example, if you want to link library directfb.so, just
need to add directfb in Libraries(-l), and add path of dynamic
library in Library search path(-L).
Miscellaneous Option: For NEW8210, we modify Linker flags to:
-marm -mapcs -mno-sched-prolog -mabi=apcs-gnu -mlittleendian -mno-thumb-interwork -msoft-float -Wl,-Map,"${PWD}/$
{ProjName}.map"
Shared Library Settings: Options here is available when compiling dynamic library, keep
default option when compiling application program.
Here is used to configure compile options which is used when compiling assembly
file, usually application doesnt use assembly language, so it is not need to configure.
2. translateDISK-LABEL:\into/cygdrive/ DISK-LABEL/
for example
E:\NEW8210\sdk\include should translate into
/cygdrive/e/NEW8210/sdk/include
C:\glibc-oabi-toolchain-arm-generic\bin\arm-unknown-linux-gnu-gcc
should
translate into
/cygdrive/c/glibc-oabi-toolchain-arm-generic/bin/arm-unknown-linux-gnu-gcc
4.5.7.
Compile
Use command Build Project to compile an application, there are some methods to
execute this command:
Choose menu Project->Build Project
Choose project of Project Explorer, right click it, select Build Project command.
Default compile is Debug version, if you want to compile a Release version, you can
choose Build button on toolbar, then select Release.
If you want to compile again, choose Build Clean command, then choose Build
Project command, output information of compile is located at Console window of IDE
environment:
4.5.8.
Run program
NEW8210 have an application launcher, users application can run by this launcher,
it need developer to write a launch configuration, and add it to current users Desktop
folder (always locate at /home/admin/Desktop).
Below is application launcher configure file form:
Filename is xxxxx.desktop
Content of file is some record entries.
Every line of file is a record entry.
There is 2 typies of record entry, one is section description, another is item
description.
Section description begins of [, and ends of ], between [ and ] is key word
of section description.
Item description is a type of key word = descripe the content.
4.6.1.
Debug by Eclipse
We had introduced how to create a Eclipse C Project above, now, we will modify C
Project source code, add a bug , then finding the bug by Eclipse.
Modify source code to the content below:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static int bug_in_here(void)
{
int *p;
p = NULL;
*p = 0x12345678;
return *p;
}
int main(int argc, char *argv[])
{
Choose Select other bottom, then choose GDB(DFS) Remote System Process
Launcher, click OK to confirm:
Configure Debugger, choose Debugger tag, configure GDB debugger to arm-unknownlinux-gnu-gdb of toolchain:
/opt/compiler/glibc-oabi-toolchain-arm-generic/bin/arm-unknown-linux-gnu-gdb
Configure GDB command file to null, just like picture below:
Switch to Connection tab page of Debugger, choose TCP of Type option, configure
NEW8210s IP address to Host name of IP address, configure Port number to
2331(when run gdbserver command on NEW8210 above, wo choose gdbservers
listening port of 2331, make sure that gdbservers listening port is the same as here),
then click Debug button to debug, like picture below:
Now enter into the debug window, click Step Over (F6) to skip this sentence, click Step
into (F5) to enter into function implementation of this sentence, also can configure
breakpoint to debug, we will not introduce these debug methods here.Picture below is the
location when we executing the error language, it will notice error when clicking Step
Over, the problem of program is here:
4.6.2.
Insight debugger is also a easy used gdb graphical front-end debugging, it also uses
gdb to debug, it has intuitive interface, and easy to use. This tool is a open source tool,
you can download it at http://sourceware.org/insight/downloads.php. If you want to debug
NEW8210 application program, we need to cross compile it. Here we dont introduce how
to compile this tool, but how to make use of this tool.
Firstly run arm-linux-insight, its interface is below:
Then execute menu File->Open, open DemoApp program we have compiled, then
execute File->Target Settings, configure it like picture below:
4.6.3.
Except of using GDB to debug application program, we also can find out the location
of exception from error message which is printed by kernel. This method needs
developer knows well about assembly language, it is fit to experienced developers.
Picture below is the error message printed by kernel when executing the exception
program:
DemoApp
is at 0x8440
is at 0x8484
[ 117.620000] pc : [<00008440>]
lr : [<00008484>]
psr: 60000010
Mode USER_32
[ 117.620000] ffc0: 000084ac 00000000 00008310 00000000 00000000 00000000 40024000 be96fb30
[ 117.620000] ffe0: be96fb34 be96fb20 00008484 00008440 60000010 ffffffff
These debug message can get by executing dmesg program. Form these error
message, we found that exception happened on USER_32 mode, it is application
program exception, if the mode is not USER_32, then it isnt an application program
exception; you can also find that error program is DemoApp, the reason of exception
happen is unhandled page fault(11) at 0x00000000, PC point to 0x8440 when exception
happening, return address LR point to 0x8484, all the registers value when exception
happening have been printed(R0R10SPIPFPSPSRLRPC) , with these
information, we can find the location of error program by disassemble application
information.
To disasembled the program DemoApp, use command below:
/opt/compiler/glibc-oabi-toolchain-arm-generic/bin/arm-unknown-linux-gnu-objdump
DemoApp > DemoApp.asm
-D
8440:
8444:
8448:
844c:
8450:
8454:
e5823000
e51b3010
e5933000
e1a00003
e99da800
12345678
set R3 to 0
8430: e3a03000
mov r3, #0
8434: e50b3010
str r3, [fp, #-16] store R3 in the unit of fp-16 pointing to
8438: e51b2010
ldr r2, [fp, #-16] set R2 to unit content of fp-16 pointing to
843c: e59f3010
ldr r3, [pc, #16] ; set R3 to unit content of pc+16 pointing to
8440: e5823000
str r3, [r2] set unit of R2 pointing to to content of R3
It is clear that the value of R2 is 0 before execute str r3,[r2]; value of r3 is content of
address 8454, it is 0x12345678. After executing str r3,[r2], it is the same as *(uint32_t *)
0 = 0x12345678.
If developers dont know assemble language well, we can change assemble code to
C code. Just needing to add S,--source option when disassembling: Intermix source
code with disassemblycommand which is to disassembled is below:
/opt/compiler/glibc-oabi-toolchain-arm-generic/bin/arm-unknown-linux-gnu-objdump
DemoApp > DemoApp.asm
Now look at disassembler code, it is clear:
00008420 <bug_in_here>:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static int bug_in_here(void)
{
8420: e1a0c00d
mov ip, sp
8424: e92dd800
push
{fp, ip, lr, pc}
8428: e24cb004
sub fp, ip, #4 ; 0x4
842c: e24dd004
sub sp, sp, #4
; 0x4
int *p;
p = NULL;
8430: e3a03000
8434: e50b3010
-DS
*p = 0x12345678;
8438: e51b2010
ldr r2, [fp, #-16]
843c: e59f3010
ldr r3, [pc, #16] ; 8454 <bug_in_here+0x34>
8440: e5823000
str r3, [r2]
return *p;
8444: e51b3010
8448: e5933000
844c: e1a00003
8450: e99da800
8454: 12345678
mov r0, r3
ldmib
sp, {fp, sp, pc}
.word
0x12345678
4.6.4.
We have introduced 2 debugging methods, they are all debugging by GDB, but there
will have conditions that can not use GDB to debug:
If object program have been optimized, then source code will not correspond to
debugging location when debugging; if object program do not contains debugging
message, then gdb cant know the location of source code, and of course can not
correspond to source code to debugging; if error code is in dynamic library, gdb can not
debug in dynamic library, because of dynamic library is dynamic linking, location of
linking is not fixed; if source code have some files that have the same filename, and they
are located in different folder, it may search the wrong source file when debugging.
5. API manual
NEW8210 device name
Device
Notes
Printer
/dev/printer?
?=0,1,2, ,15
Magnetic stripe
/dev/magcard?
?=0,1,2, ,15
Modem/GPRS/CDMA
/dev/ttyS1
Barscanner/External PED
/dev/ttyS2
UART
/dev/ttyS3
AD
/dev/adc
NFC Card
/dev/nfc
IC Card
/dev/usercard
/dev/samcard?
User card
?=1,2,3 SAM card
5.1. System
API functions of this module was defined in the posapi.h; libpos.so must be used
when linking.
5.1.1.
sys_reboot
Prototype
void sys_reboot(void)
Function
Restart system
Parameter
None
Return
None
Support
NEW8210
Notes
System will turn off all the program, reset and restart
5.1.2.
sys_poweroff
Prototype
void sys_poweroff(void)
Function
Power off
Parameter
None
Return
None
Support
NEW8210
Notes
System will turn off all the program, power off the system
5.1.3.
sys_kbd_set
Prototype
Function
Parameter
pset
input
parameter
beep_enable
beep_freq
beep_time
Buzzer duration
0~100ms)
time
(unit:
ms,
Return
Support
backlight
feed_enable
Set OK.
-EINVAL
others
NEW8210
Notes
5.1.4.
sys_kbd_get
Prototype
Function
Parameter
Return
pset
beep_enable
beep_freq
beep_time
backlight
feed_enable
output
parameter
Set OK.
Be
Applicable
in
-EINVAL
others
NEW8210
Notes
5.1.5.
sys_set_time
Prototype
Function
Parameter
tm
tm_sec
tm_min
minutescope059
tm_hour
hourscope023
tm_mday
tm_mon
monthscope011month begin
from 0
tm_year
Return
Setting success
-EINVAL
others
Support
NEW8210
Notes
Call this function to set systems local time(not UTC time), transition
from local time to UTC time is depended on settings of system time
zone.
Due to the limitation of RTC chip, when set in the time before
5.1.6.
sys_get_status_bar_height
Prototype
Function:
Parameter:
Return:
int sys_get_status_bar_height(void);
Get height of the status bar
Support:
NEW8210
Notes:
5.1.7.
sys_delay_to_suspend
Prototype:
int sys_delay_to_suspend(void);
Function:
Parameter:
None
Return:
Support:
NEW8210
Success
Notes:
5.1.8.
sys_suspend_now
Prototype:
int sys_suspend_now(void)
Function:
Parameter:
None
Return:
Support:
NEW8210
Success
Notes:
5.1.9.
sys_get_sn
Prototype
Function
Parameter
sn output
nbytes
Return
Support
NEW8210
Notes
5.1.10. beep
Prototype
Function
Parameter
frequency
keepms
Return
None
Support
NEW8210
Notes
5.1.11.
sys_backlight_set_time
Prototype
Function
Parameter
keepunitsecond
>0
=0
no backlight
<0
Backlight always on
Return
Set OK
Others
Support
NEW8210
Notes
Once it is set up, the backlight will run according to the set value. But
after system reset, the set value of backlight will recover to its default
one..
5.1.12.
sys_backlight_get_time
Prototype
Function
Parameter
Set OK
Return
-EINVAL
others
Be
application
in
NEW8210
Notes
Once it is set up, the backlight will run according to the set value. But
after system reset, the set value of backlight will recover to its default
one..
5.1.13. sys_get_machine_config
Prototype
Function
Parameter
config output
nr
>= 0
The number
information
-EINVAL
others
Return
of
real
output
module
Support
NEW8210
Notes
Module information
Terminal
Terminal nameNEW8210
Printer
Printer type
Modem
maximum
rate
synchronous/asynchronous
communication
PCI
None
USB host
USB
interfaceUSB2.0
USB device
None
Ethernet
None
WIFI
None
GPRS
None
CDMA
None
NFC
None
of
standard
5.1.14. led_get_brightness
Prototype
Function:
Parameter:
Return:
Be
applicable
in:
Notes
led name
brightness
(output parameter)
Set OK
-EINVAL
others
NEW8210
Corresponding
LED_ARROW_DOWN
LED_ARROW_UP
LED_BATTERY_SHELL
LED_BATTERY_1
LED_BATTERY_2
LED_BATTERY_3
LED_BATTERY_4
LED_BACKLIGHT
LCD backlight
LED_CARD
LED_LCD_CONTRAST
LCD contrast
LED_LOCK
LED_POWER_SUPPLY
LED_MODEM_OFFHOOK
LED_MODEM_ONHOOK
LED_MODEM_BASE
LED_SIGNAL_STATION
LED_SIGNAL_1
LED_SIGNAL_2
LED_SIGNAL_3
LED_SIGNAL_4
LED_ONLINE
LED_TX
LED_RX
5.1.15. led_set_brightness
Prototype
Function
Parameter
led_name
led name
brightness
Set OK
-EINVAL
Others
Return
Support
NEW8210
Notes
5.1.16.
sys_get_hardware_config
Prototype
Function
Parameter
module input
type (output)
numbers
Successful.
others
Return
Support
NEW8210
Notes
5.1.17.
comment
HARDWARE_MACHINE
HARDWARE_BATTERY
Battery
HARDWARE_LCD
LCD
HARDWARE_TOUCHSCREEN
Touch Screen
HARDWARE_KEYBOARD
KeyBoard
HARDWARE_MSR
HARDWARE_PRINTER
Printer
HARDWARE_NFC
NFC
HARDWARE_TF
TransFlash
HARDWARE_IC
IC Card Reader
HARDWARE_SAM
SAM Slot
HARDWARE_2SIM
SIM Slot
HARDWARE_UART
UART
HARDWARE_BARSCANNER
Barcode Scanner
HARDWARE_WIRELESS
Wireless
HARDWARE_MODEM
MODEM
HARDWARE_LAN
LAN
HARDWARE_WIFI
WIFI
HARDWARE_BLUETOOTH
BlueTouch
HARDWARE_USBH
USB Host
HARDWARE_USBD
USB Device
HARDWARE_USBO
USB OTG
HARDWARE_GPS
GPS
HARDWARE_FINGERPRINT
FingerPrinter
sys_software_update
Prototype
Function
Parameter
filenameinput
Successful.
others
Return
Be
application
in
NEW8210
Notes
Calling this function can update the file that is downloaded by TMS
remotely.
The parameter of filename is that downloaded by TMS and stored
temporarily int the POS machine.
The filename includes the firmware and the file packed by
New8210DownloadTool.
If it is a firmware, after calling this function, you must restart the
machine in order to complete the update.
If it is a packed file, call this function and then update is complete
immediately.
5.1.18. sys_battery_info
Prototype
Function
Parameter
battery_info
(Output)
status
0-Battery-powered
1-Charging
2-Full charge
3-External-powered
Return
Be
application
in
Notes:
cur_values
Current voltage
max_values
Maximum voltage
min_values
Minimum voltage
percent
Successful
others
NEW8210
PC-101
key
Code
Symbol
KEY_0
0x0B
DIKS_0
0x30
KEY_1
0x02
DIKS_1
0x31
KEY_2
0x03
DIKS_2
0x32
KEY_3
0x04
DIKS_3
0x33
KEY_4
0x05
DIKS_4
0x34
KEY_5
0x06
DIKS_5
0x35
KEY_6
0x07
DIKS_6
0x36
KEY_7
0x08
DIKS_7
0x37
KEY_8
0x09
DIKS_8
0x38
KEY_9
0x0A
DIKS_9
0x39
CANCEL
Esc
KEY_ESC
0x01
DIKS_ESCAPE
0x1B
ENTER
Enter
KEY_ENTER
0x1C
DIKS_ENTER
0x0D
KEY_UP
0x67
DIKS_CURSOR _UP
0xF002
KEY_DOWN
0x6C
DIKS_CURSOR _DOWN
0xF003
CLEAR
Backspace
KEY_BACKSPACE
0x0E
DIKS_BACKSPACE
0x08
FEED
PrScrn
KEY_SYSRQ
0x63
DIKS_PRINT
0xF009
MENU
Left Alt
KEY_LEFTALT
0x38
DIKS_ALT
0xF204
FUNC
Left Ctrl
KEY_LEFTCTRL
0x1D
DIKS_CONTROL
0xF202
ALPHA
Left Shift
KEY_LEFTSHIFT
0x2A
DIKS_SHIFT
0xF201
ATM-1
F1
KEY_F1
0x3B
DIKS_F1
0xF101
ATM-2
F2
KEY_F2
0x3C
DIKS_F2
0xF102
ATM-3
F3
KEY_F3
0x3D
DIKS_F3
0xF103
ATM-4
F4
KEY_F4
0x3E
DIKS_F4
0xF104
The Power key is not listed here, because NEW8210 application program cant control
and get this key, while pressing power key for more than 1.5 s, system will be turned off
automatically.
In addition, on default condition it will start printers function of paper skip when pressing
feed key, application program can get the key value of the key.
5.3. Display
NEW8210 display based on the DirectFB library, the web site is http://www.directfb.org.
API documents link is http://www.directfb.org/docs/DirectFB_Refer _1_4/index.html.
The applications based on DirectFB have its own Window, DrectFB manage the
entire display windows, and so that each program is displayed on the LCD does not
interfere with other programs. Besides manage the display windows, DirectFB also
manages the input devices, the event buffer, fonts, graphics, audio/video, providing
users with a unified, friendly programming interface.
NEW8210 can support these fonts:
TTF/TTC
OTB(X11 bitmap font)
BDF(Bitmap Distribution Format)
JPEG
PNG
GIF
BMP
The formats of otb and bdf are point-array font library, the otb format is binary array
library, and the bdf format is text array library, these two formats can be converted to
each other, the file of bdf format is larger than that of otb format. No matter ttf library, or
otb, bdf font library, it is the same interface for external call, the programmer no need to
care for the different. Note: the ttf format is zoomable, but the otb and bdf formats unable
to do so, the size of them are fixed, if a not exist size is selected, it will not work.
5.3.1. DirectFB
5.3.1.1.
Layers
It represents a separate image buffer. Most embedded devices have more than one
layer. Hardware using the appropriate alpha value for blending, then display.
5.3.1.2.
Surface
A reserved area of memory used to store pixel data. The operation drawing and
blitting are ultimately act on the surfaces, the memory of surface can be obtained from
video memory, also can be obtained from system memory, which is determined by the
given limit.
5.3.1.3.
Primary Surface
It represents a particular layer of special surface of the frame buffer. If the primary
surface is single buffer, any operation on this main surface will be seen on screen.
1 IDirectFB
N Screens
1 Screen
N Layers
1 Layer
1 Primary Surface
1 Layer
N Windows
1 Window
1 Window Surface
1 Surface
N Subsurface
Usually one screen has a display layer, but DFB support each of them have multiple
instances.
5.3.1.4.
Each screen has one or more layers, typically, a screen only has one layer, but some
system support overlays, due to hardware support one layer display above on other
layers, there can be exist many layers.
5.3.1.5.
Screen can not create window directly, but you can request a primary layer`s ID, and
request IDirectFB interface for your layer interface, then by this interface, you can create
a window.
5.3.1.6.
Every window associating with a surface, the content drawn to the surface will not
display on the screen immediately, because the window manager will assembles all
surfaces to a main surface based on the region to be freshened and the sequence of
stack.
5.3.1.7.
Every layer associating with a surface, too. This surface is a direct manifestation to
the layer memory. In exclusive mode, you can only access to this surface, otherwise, you
can only create a window, then draw the surface by window manager.
exit_entry:
return ret;
}
First you should initialize the DirectFB, by calling the API DicectFBInit(), process the
input parameter, then by calling the API DirectFBCreate() to create a dfb object. Note:
this object should be released by calling API Release() to release the resource occupied
by it.
Above we described the relation about screen, layer, window and surface, they are
seemed complex, you can remember the rule for short: when custom displays, it`s only to
surface,and the drawing operations are also valid only for surface, no matter this surface
is created on layer directly, or got from a created window, or created from another
surface.
There are many methods to get surface, we recommend using the following
procedure:
DirectFBInit
DirectFBCreate(&dfb)
dfb->GetDisplayLayer(&layer)
layer->CreateWindow (&window)
window->GetSurface(&surface)
libz.so
libfusion.so
libdirect.so
libdirectfb.so
When linking, please use command line: -lz -lfusion -ldirect -ldirectfb, and use -L to
index the path of these library.
5.4. Ped
PED supports Master/SessionfixedDUKPT key solutions keys supports for every
key type
Key name
Number of keys
Master Key
1024
PIN Key
1024
MAC Key
1024
Fixed-PIN Key
1024
Fixed-MAC Key
1024
DUKPT Key
16
Supports online PIN and offline plaintext pin and offline encipher pin.
API functions of this module was defined in the ped.h; libped.so must be used when
linking.
5.4.1.
ped_get_random
Prototype
uint32_t ped_get_random(void)
Function
Parameter
None
Return
Support
NEW8210
Notes
5.4.2.
ped_get_random_nr
Prototype
Function
Parameter:
Return
data output
Success
-1
Support:
NEW8210
Notes
5.4.3.
ped_set_pin_input_region
Prototype:
Function:
Parameter:
width
Width
height
Height
success
-1
Return
Support
NEW8210
Notes
5.4.4.
ped_format
Prototype
int ped_format(void)
Function
Rebuild PED (Or PED format), it will clear all PED key and unlock the
PED (If the PED is in lock status).
Only the root user can rebuild PED when PED was attacked.
Parameter
None
Return
Support
Success
-1
Error. The error code please gets from the global variable
errno.
NEW8210
Notes
5.4.5.
ped_clear_user_keys
Prototype
int ped_clear_user_keys(void)
Function
Parameter
None
Return
Support
Success
-1
NEW8210
Notes
5.4.6.
ped_delete_key
Prototype
Function
Parameter
KeyType
KeyIndex
Key index.
1.If the key type is KEY_TYPE_MASTK /
KEY_TYPE_PINK
/
KEY_TYPE_MACK
/
KEY_TYPE_FIXPINK / KEY_TYPE_FIXMACK, the
key index value from 0 to 1023;
2.If the key type is KEY_TYPE_DUKPTKEY, the key
index value from 0 to 15;
Return
Support
Success
-1
Error. The error code please get from the global variable
errno.
NEW8210
Notes
5.4.7.
ped_get_sensitive_timer
Prototype
Function
Parameter
SensitiveType[i]
TYPE_PIN_INTERVAL
0x01
Return
>=0
Support
NEW8210
Notes
5.4.8.
ped_set_pin_input_timeout
Prototype
Function
Parameter
timeout
Return
Support
>120
30~120
<30
Success
-1
Error. The error code please get from the global variable
errno.
NEW8210
Notes
5.4.9.
ped_get_dukpt_ksn
Prototype
Function
Calculate PIN Block and MAC one time after one time KSN get
Parameter
KeyIndex
Ksn(Output)
Return
Success
-1
Error. The error code please gets from the global variable
errno.
Support
NEW8210
Notes
5.4.10. ped_write_pin_key
Prototype
Function
Write a PIN key into the PED, which encrypted by MasterKeyID, and
without verify code.
Parameter
MasterKeyID
PinKeyID
PinKeyLen
PinKey
Success
-1
Return
Support
NEW8210
Notes
5.4.11. ped_write_pin_key_ex
Prototype
Function
Parameter
Mode
Return
TDEA_DECRYPT
Encrypted KeyData
KEY_VERIFY_NONE
No check value
KEY_VERIFY_KVC
KVC
KEY_VERIFY_CMAC
CMAC
MasterKeyID
DestKeyID
KeyLen
KeyData length
PIN Key data length
+Checkdata lengthKVCCMAC is 4 bytes
KeyData
Success
-1
Support
NEW8210
Notes
5.4.12. ped_write_mac_key
Prototype
Function
Parameter
MasterKeyID
MacKeyID
MacKeyLen
MacKey
Return
Support
Success
-1
Error. The error code please gets from the global variable
errno.
NEW8210
Notes
5.4.13. ped_write_mac_key_ex
Prototype
Function
Parameter
Mode
TDEA_DECRYPT
KeyData is encrypted
KEY_VERIFY_NONE
No Check Code
KEY_VERIFY_KVC
KVC
KEY_VERIFY_CMAC
CMAC
MasterKeyID
DestKeyID
Return
KeyLen
KeyData
Success
-1
Error. The error code please gets from the global variable
errno.
Support
NEW8210
Notes
5.4.14. ped_write_master_key
Prototype
Function
Parameter
Mode
Return
TDEA_DECRYPT
KeyData is encrypted
KEY_VERIFY_NONE
No check code
KEY_VERIFY_KVC
KVC
KEY_VERIFY_CMAC
CMAC
MasterKeyID
DestKeyID
KeyLen
KeyData
Success
-1
Error. The error code please gets from the global variable
errno.
Support
NEW8210
Notes
5.4.15. ped_inject_pin_key
Prototype
Function
Parameter
PinKeyID
PinKeyLen
PinKey
Return
Support
Success
-1
Error. The error code please get from the global variable errno.
NEW8210
Notes
5.4.16. ped_inject_mac_key
Prototype
Function
Parameter
MacKeyID
MacKeyLen
MacKey
Return
Support
Success
-1
Error. The error code please get from the global variable errno.
NEW8210
Notes
5.4.17. ped_create_dukpt_key
Prototype
Function
Parameter
KeyIndex
InitKey
KeyLen
Key length16
Ksn
10 bytes KSN
Return
Support
Success
-1
Error. The error code please get from the global variable errno.
NEW8210
Notes
5.4.18. ped_get_pin
Prototype
Function
Parameter
KeyIndex
ExpectPinLen
CardNo
bytes is ISN.
Return
Mode
PIN_BLOCK_FORMAT_0
/PIN_BLOCK_FORMAT_EPS
PinBlock
Success
-1
Error. The error code please get from the global variable
errno.
Support
NEW8210
Notes
The default timeout is 120 seconds. If you want to set the timeout
value, please call the API ped_set_pin_input_timeout() to set.
Note: PIN input is sensitive service, if the time between two PIN input
is too fast, the operation will be refused. So you can call
ped_get_sensitive_timer() to get current state, if the return value
large than 0(etc n), it means only after n seconds, you can inpuit PIN
again.
Explain :
(1) ANSI X3.92 standard(Format EPS) as follow:
Data string format:1234 + ISN [6bytes] + PIN[6bytes];
If PIN not enough 6 bytes, then fill 0 with ahead.
Convert the string to BCD code, and use TPK as the key to TDEA.
(2) ANSI X9.8 standard(Format 0) as follow:
String 1 is 0000 with suffix of card number last 12 charters.
Convert string 1 to BCD bytes.
String 2 is PIN length [ASCII, 2bytes] + PIN [ASCII];
If string 2 not enough 16 bytes, add charter F to the tail, and convert string 2 to BCD
bytes.
Use string 1 BCD XOR string 2 BCD then get 8 bytes number K, use TPK as TDEA key
to encrypt K, and then get the PIN_BLOCK.
5.4.19. ped_get_pin_fix
Prototype
Function
Let cardholder input PIN and Compute the PIN block, different from
ped_get_pin, this API use fixed key hierarchy.
Parameter
KeyIndex
ExpectPinLen
Return
CardNo
Mode
PIN_BLOCK_FORMAT_0
PIN_BLOCK_FORMAT_EPS
PinBlock
Success
-1
Error. The error code please gets from the global variable
errno.
Support
NEW8210
Notes
Refer to ped_get_pin
5.4.20. ped_get_pin_dukpt
Prototype
Function
Parameter
KeyIndex
ExpectPinLen
CardNo
Mode
PIN_BLOCK_FORMAT_0
/PIN_BLOCK_FORMAT_EPS
PinBlock[o]
Return
Success
-1
Error. The error code please get from the global variable
errno.
Support
NEW8210
Notes
Refer to ped_get_pin
5.4.21. ped_icc_offline_plain_pin
Prototype
Function
PED prompts cardholder to input PIN. Once PED kernel gets plaintext PIN,
PED kernel transfer it to plaint PIN BLOCK and sends corresponding
command to ICC card in corresponding slot indicated by CardSlot for
offline plaintext authentication.
Parameter
iccfd
ExpectPinLen
icc
rsplen
rspdata length.
rspdata
Return
Success
-1
Error. The error code please get from the global variable
errno.
Support
NEW8210
Notes
As for the length of PIN entry control, please refer to the description in
online PIN entry.
The format of Plaintext offline PIN block showed following:
C
P/
F
P/
F
P/
F
P/
F
P/
F
P/
F
P/
F
P/
F
Name
Value
Control field
PIN length
c)
P
PIN
P/F
Padding bit
Note: PIN input is sensitive service, if the time between two PIN input
is too fast, the operation will be refused. So you can call
ped_get_sensitive_timer() to get current state, if the return value
large than 0(etc n), it means only after n seconds, you can inpuit PIN
again.
typedef struct {
uint32_t modlen; // The module length of PIN encryption public
key,
uint8_t
mod[256]; // The module data of PIN encryption public
key,
uint32_t explen; // The exponet length of PIN encryption public
key,
uint8_t
exp[4];
// The exponet data of PIN encryption public
key,
uint8_t
iccrandom[8]; // The random data from ICC
} RsaPinKey_t;
The structure of IccOfflinePinApdu_t:
typedef struct {
uint8_t cla;
uint8_t ins;
uint8_t p1;
uint8_t p2;
uint8_t leflg;
uint8_t le;
RsaPinKey_t rsakey;
} IccOfflinePinApdu_t;
5.4.22. ped_icc_offline_cipher_pin
Prototype
Function
PED prompts cardholder to input PIN. Once PED kernel gets plaintext PIN,
PED kernel encrypted it to cipher PIN BLOCK using RsaPinKey according
Return
iccfd [input]
ExpectPinLen
icc[input]
Rsplen[output]
rspdata length.
Rspdata[output]
Success
-1
Error. The error code please get from the global variable
errno.
Support
NEW8210
Notes
length
Description
Unit
Header
0x7F
PIN BLOCK
PINBLOCK
Padding data
NIC
17
Note: PIN input is sensitive service, if the time between two PIN input
is too fast, the operation will be refused. So you can call
ped_get_sensitive_timer() to get current state, if the return value
large than 0(etc n), it means only after n seconds, you can inpuit PIN
again.
IccOfflinePinApdu_t : please refer to ped_icc_offline_plain_pin
5.4.23. ped_get_mac
Prototype
Function
Parameter
KeyIndex
DataIn
DataLen
8/16/24/32/40/48...
Mode
MAC_MODE_1
MAC_MODE_2
MAC_MODE_EMV
MAC_MODE_CUP
MacOut
Return
Support
Mode,
uint32_t
Success
-1
Error. The error code please get from the global variable
errno.
NEW8210
Notes
Explain :
Algorithm 1:
When Len = 8, only use data to do one DES/3DES encrypt.
When Len > 8, we use the standard algorithm to encrypt MAC data. The algorithm as follow:
D1(8bytes)
D2(8bytes)
D3(8bytes)
Dn(8bytes)
K1
R1
K2
R1
K3
R3
Kn
Rn
We use first 8 bytes data (D1) as K1, and use the MAC key TDEA encrypt K1 get result R1.
R1 XOR with the second 8 bytes data (D2) then get the result K2. Use the MAC key TDEA
encrypt K2 get result R2 and so on, the last Rn is the MAC result.
Algorithm 2:
When Len = 8, only use data to do one DES/3DES encrypt.
When Len > 8, we use the standard algorithm to encrypt MAC data. The algorithm as follow:
D1(8bytes)
D2(8bytes)
D3(8bytes)
Dn(8bytes)
K2
K2
K2
Kn
MAC
EMV2000 Algorithm:
EMV2000 Algorithm is very like as Algorithm 1. If MAC key length is 8 bytes, that
EMV2000 Algorithm is same as Algorithm 1; If MAC key length is 16 bytes or 24 bytes, there are
some different, from the step 1 to the step n-1 are use 8bytes MAC key to encrypt data, and the
step n use 16 bytes or 24 bytes MAC key to encrypt data.
China UnionPay algorithm:
D1(8bytes)
D2(8bytes)
D3(8bytes)
Dn(8bytes)
K2
K2
K2
Kn
First 8 char
Last 8 char
R1
R2
Convert R2 to 16 ASCII
char
The first 8 char is the result MAC
5.4.24.
ped_get_mac_fix
Prototype
Function
Parameter
KeyIndex
DataIn
DataLen
8/16/24/32/40/48...
Mode
MAC_MODE_1
MAC_MODE_2
MAC_MODE_EMV
MAC_MODE_CUP
MacOut
Return
Support
Success
-1
Error. The error code please get from the global variable
errno.
NEW8210
Notes
5.4.25.
ped_get_mac_dukpt
Prototype
Function
Parameter
KeyIndex
DataIn
DataLen
Mode
MAC_MODE_1
MAC_MODE_2
MAC_MODE_EMV
MAC_MODE_CUP
MacBlock
Return
Support
Success
-1
Error. The error code please get from the global variable
errno.
NEW8210
Notes
5.4.26. ped_inject_key_by_root
Prototype
Function
Parameter
CUID
CID + UID
KeyType
Key Type
KeyIndex
Key Index
KeyLen
Key length
PlaintextKey
Return
0 Success
1
Error. The error code please get from the global variable
errno.
Support
NEW8210
Notes
Used to inject key, this function can be called by the root user only.
5.4.27. ped_get_config
Prototype
Function
Parameter
Config[output]
Success
-1
Return
Support
NEW8210
Notes
5.5.1.
enum EPP_ERROR_CODE
{
EPP_SUCCESS = 0,
EPP_RECV_PACKET_ERROR=2001,
EPP_PORT_OPEN_ERROR,
EPP_SEND_PACKET_ERROR, // 3
EPP_PACKET_LEN_ERROR,
EPP_RECV_TIMEOUT, // 5
EPP_PACKET_LEN_TOO_LONG,
EPP_CRC_CHECK_ERROR, // 7
EPP_OPEN_FILE_ERROR,
EPP_SEEK_FILE_ERROR, // 9
EPP_WRITE_FILE_ERROR,
EPP_READ_FILE_ERROR, // 11
EPP_CONFIGURE_INVALID,
EPP_CONFIGURE_MAC_ERROR, // 13
EPP_NO_PIN,
EPP_SEND_CMD_ERROR, // 15
EPP_RECV_CMD_ERROR,
EPP_RECV_RET_ERROR, // 17
EPP_RECV_LEN_ERROR,
EPP_MAC_CHECK_ERROR, // 19
EPP_AUTHEN_FAILED,
EPP_INPUT_PARAM_ERROR, // 21
EPP_USER_PRESS_CANCEL,
EPP_INPUT_CMD_ERROR, // 23
EPP_INPUT_KEY_INDEX_ERROR,
EPP_INPUT_MAC_LEN_ERROR, // 25
EPP_INPUT_MODE_ERROR,
EPP_KEY_TYPE_ERROR, // 27
EPP_KEY_INDEX_ERROR,
EPP_MASTER_KEY_INDEX_ERROR, // 29
EPP_BMP_ERROR,
EPP_PIN_CFG_LANGE_TYPE_ERROR, // 31
EPP_PIN_CFG_SYMBOL_TYPE_ERROR,
EPP_INPUT_DATA_LEN_ERROR, // 33
EPP_SET_PORT_ERROR,
EPP_CFG_ERROR, // 35
EPP_CLOSE_FAILED,
};
enum N20_RETURN_CODE{
RET_ERROR_BASE = 2300,
RET_PASSWORD_ERROR, // 1
RET_BOOT_LEN_ERROR,
RET_BOOT_HASH_ERROR, // 3
RET_BOOT_MAC_ERROR,
RET_NOT_UBSK, // 5
RET_CHECK_UBSK_FAILED,
RET_CHECK_KSK_FAILED, // 7
RET_NOT_LCK,
RET_NOT_AUTH, // 9
RET_NOT_LOGON,
RET_RECV_FAILED, // 11
RET_AUTH_CHECK_FAILED,
RET_MAC_CHECK_FAILED, // 13
RET_CRC_CHECK_ERROR,
RET_KVC_CHECK_ERROR, // 15
RET_NOT_APP_FREE_SPACE,
RET_APP_NOT_EXIST, // 17
RET_KEY_TYPE_ERROR,
RET_KEY_TYPE_NOT_SUPPORT, // 19
RET_MAC_LEN_ERROR,
RET_MAIN_KEY_INDEX_ERROR, // 21
RET_MAIN_KEY_NOT_EXIST,
RET_KEY_INDEX_ERROR, // 23
RET_KEY_LEN_ERROR,
RET_KEY_BE_USE, // 25
RET_MAIN_KEY_BE_USE, // 26
RET_MAC_ALG_MODE_ERROR,
RET_KEY_GET_ERROR,
RET_KEY_OVER_FLOW, // 29
RET_KEY_SAME_ERROR,
RET_KEY_NOT_EXIST, // 31
RET_KEY_MAC_CHECK_FAILED,
RET_KEY_KSN_LEN_ERROR, // 33
RET_KEY_BDK_LEN_ERROR,
RET_USER_PRESS_CANCEL_EXIT, // 35
RET_USER_INPUT_TIME_OUT,
RET_KSN_LEN_RERROR, // 37
RET_APP_NUM_OVER_FLOW,
RET_RW_LENGTH_ERROR, // 39
RET_PIN_KEY_TIME_LOCK,
RET_MAC_KEY_TIME_LOCK, // 41
RET_SET_PIN_TIME_OUT_ERROR,
RET_WRITE_EEPROM_FAILED, // 43
RET_RECV_LEN_ERROR,
RET_PARAM_ERROR // 45
};
typedef struct {
BYTE AppName[32];
BYTE Lck[16];
BYTE Mtek[24];
BYTE Akdak[16];
BYTE Akuak[16];
BYTE Mdtek[24];
BYTE Mutek[24];
} EppAuthKey_t; // 152 bytes
5.5.2.
module structure
typedef struct {
BYTE KeyType; /* key type
0x01master key
0x02MAC key
0x03PIN key
0x10Fixed MAC key
0x11Fixed PIN key */
BYTE Mode;/*
Bit0~3 TDEA_DECRYPT 0x00 use decryption method to get expressly
target key
TDEA_NONE
0x02
write into expressly target key directly(is
invalid to MAC key and PIN key)
Bit4~7 PARITY_NONE 0x00 no check on the (decrypted) Key express
PARITY_ODD
0x10 odd parity on the (decrypted) key express
PARITY_EVEN
0x20
even parity on the (decrypted) key
express*/
BYTE KeyLen; // length of key, valid values is 8/16/24
BYTE KeyIndex; // Key Index[1,100]
BYTE MasterKeyIndex; /*master key index[1,100], this parameter is valid just when
key type is MAC key or PIN key*/
BYTE KeyData[24]; // content of key
} EppAppKey_t;
typedef struct _EPP_CONFIGURE_
5.5.3.
EPP_CFG;
epp_open
Prototype
Function
Parameter
filename
oflag
Return
NULL
error return
other
Be
applicable
NEW7110
in
Notes
5.5.4.
epp_close
Prototype
Function
Parameter
cfginput
Return
Be
applicable
in
NEW7110
Notes
after close, EPP port parameter handle cfg will be invalid and can not
use again
5.5.5.
Prototype
Function
Parameter:
epp_init
int epp_init(EPP_CFG *cfg, const EppAuthKey_t *eppkey)
Modify current key configure.
1if use default configure, do not need to call this interface
2 if dont use default configure, initial configuration each time when
starting device
cfginput
eppkey
configure key
eppkey-> AppName : application name have max
16bytes
eppkey->Lck 16 bytes LCK key
eppkey->MTEK 24 bytes MTEK key
eppkey->AKDAK 16 bytes AKDAK key
eppkey->AKUAK 16 bytes AKUAK key
eppkey->MDTEK 24 bytes MDTEK key
eppkey->MUTEK 24 bytes MUTEK key
Return
Be
applicable
NEW7110
in
Notes
5.5.6.
Prototype
Function
epp_download_lck_mtek
int epp_download_lck_mtek(EPP_CFG *cfg)
Inject the LCK and MTEK into the N20 PINPAD. And the N20 EPP will
execute format operation, and then save the LCK and MTEK.
Parameter:
cfginput
Return
Be
applicable
in
NEW7110
Notes
5.5.7.
Prototype
Function
epp_download_aik
int epp_download_aik(EPP_CFG *cfg)
Save the current AIK to the N20 PINPAD. AIK includes 4 keys of
AppName and AKDAK/AKUAK/MDTEK/MUTEK and etc. All the key of
this application will be cleared.
Parameter:
cfginput
Return
Be
applicable
in
NEW7110
Notes
5.5.8.
Prototype
epp_download_appkey
int epp_download_appkey(EPP_CFG
*appkey)
*cfg,
const
EppAppKey_t
Function
Parameter:
cfginput
appkey
Return
Be
applicable
in
NEW7110
Notes
5.5.9.
epp_download_dukpt_key
Prototype
Function
Inject DUKPT key into external N20 PINPAD. Only the DUKPT version
support.
Parameter:
cfg inp
ut
KeyInde
x
pBDK
pKSN
content of KSN
KSNLen
KSN length[1,10]
Return
Be
applicable
in
NEW7110
Notes
5.5.10. epp_get_mac
Prototype
Function
Parameter:
cfg input
KeyType
Parameter:
KeyIndex
MAC key index. If the key is MAC or Fixed MAC the key
index value from 1 to 100. If the key is DUKPT MAC, this
parameter has no use.
Mode
Algorithm select
0x00
Algorithm 1
0x01
Algorithm 2
0x02
EMV2000 Algorithm
0x03
CUP Algorithm
pData
MAC data
DataLen
pMacOu
output
Return
Be
applicable
in
NEW7110
Notes
See below
Notes
Algorithm 1
8bytes
8bytes
8bytes(end)
encryption
encryption
encryption
encryption
MAC
First 8 bytes do DES/3DES encryption one time, the result will do xor with
next set of data(8 bytes), and do DES/3DES encryption one time again,after
the final set of data have done one DES/3DES encryption,get MAC operation
result(8 bytes).
Algorithm 2
8bytes(start)
8bytes
8bytes
8bytes(end)
encryption
MAC
8bytes(start)
8bytes
8bytes
8bytes(end)
First 8 characters
Last 8 characters
encryption
encryption
5.5.11. epp_get_pin
Prototype
Function
Parameter:
cfginput
KeyType
Key type:
KEY_TYPE_PIN /
KEY_TYPE_FIXED_PIN /
KEY_TYPE_DUKPT
KeyIndex
Key index.
If the key type is PIN or Fixed PIN, it value is from 1
to 100.
If the key type is DUKPT PIN, this parameter is no
using.
Return
DisplayMode
AlgMode
Algorithm select.
0x00 : means choose Format0 mode
algorithm;
0x01 : means choose Format EMV mode
algorithm;
0x0a : means choose Format EPS mode
alforithm.
pCardInfo
Card information
pLenInfo
pPinBlockOut
output
please refer to section 4.12.1
Be
applicable
in
NEW7110
Notes
Notes
(1) ANSI X3.92 standard is belowFormat 0 mode
Format of data string:1234+ISN[6 bytes]+PIN[bytes bits];
If the PIN less than 6 bytes, fill 0 before the PIN;
Change data string above into BCD code, use TPK to do
DES/3DES encryption on BCD code.
ANSI X9.8 standard is follow, Format EPS mode:
String 1: 0000 add last 12 bit of card number;
Change string1 into BCD code;
String 2: PIN length[ASC code, 2 bytes]+PIN[ASC code];
If the string2 is less than 16 bytes,fill F after string2, then
change it into BCD code;
Do xor between string1s BCD code and string2s BCD code,
use TPK to do DES/3DES encryption on it .
(2) Format EMV mode:
User input PIN characters+number of characters F,and make
up into a character string of 16 characters, then change the
5.5.12. epp_get_tdea
Prototype
Function
Parameter:
cfginp
ut
Mode
algorithm select.
TDEA_ENCRYPT : Encrypt
TDEA_DECRYPT : Decrypt
TDEA_MODE_ECB--- ECB algorithm mode
TDEA_MODE_CBC--- CBC algorithm mode
Please refer to the NEW7110 SDK macro define.
KeyTyp
e
Key type
0x01 : Master key;
0x02 : PIN Key;
0x03 : MAC Key;
0x04 : DUKPT MAC Key;
0x05 : DUKPT PIN Key;
0x10 : Fixed MAC Key;
0x11 : Fixed PIN Key.
KeyInde
x
Key index.
If the key type is Master, MAC, PIN, Fixed MAC or Fixed
PIN, it value is from 1 to 100.
If the key type is DUKPT MAC or DUKPT PIN, this
parameter is no using.
pDataIn
Compute data.
DataLe
n
pDataO
ut out
put
Return
Be
applicable
NEW7110
in
Notes
5.5.13. epp_set_pin_input_timeout
Prototype
Function
Parameter:
cfg input
TimeoutMs
Return
Be
applicable
in
NEW7110
Notes
5.5.14. epp_set_tdes_iv
Prototype
Function
Set TDES initial vector of into external N20 PINPAD, only effect CBC
algorithm.
Parameter:
cfg inp
ut
pIvData
Return
Be
applicable
in
NEW7110
Notes
Call this interface to set initial vector will effect CBC algorithms initial
vector that is called by epp_get_tdea(), and it will not effect other
interface, after restart N20, initial vector will recover to 8 zero.
5.5.15. epp_get_rand
Prototype
Function
Parameter:
cfg
input
size
pRandBuf
Return
Be
applicable
in
output
please refer to section 4.12.1
NEW7110
Notes
5.5.16.
epp_clear_key
Prototype
Function
Parameter:
cfginput
KeyType
key type
0x01 : Master key;
0x02 : MAC key;
0x03 : PIN key;
0x10 : Fixed MAC key;
0x11 : Fixed PIN key;
KeyIndex
Key index.
If the key type is Master, MAC, PIN, Fixed MAC or
Fixed PIN, it value is from 1 to 100.
If the key type is DUKPT MAC or DUKPT PIN, this
parameter is no using.
Return
Be
applicable
in
NEW7110
Notes
5.5.17. epp_clear_appkey
Prototype
Function
Parameter:
cfginput
Return
Be
applicable
in
NEW7110
Notes
5.5.18. epp_format_ped
Prototype
Function
Parameter:
cfginput
Return
Be
applicable
in
NEW7110
Notes
5.5.19. epp_set_idle_logo
Prototype
Function
Parameter:
cfginput
pBmpIdleLogo
In
Return
Be
applicable
in
NEW7110
Notes
5.5.20. epp_resume_default_idle_logo
Prototype
Function
Parameter:
cfginput
Return
Be
applicable
in
NEW7110
Notes
5.5.21. epp_display_logo
Prototype
Function
Parameter:
cfg inp
ut
pBmpLo
goIn
Return
Be
applicable
in
NEW7110
Notes
5.5.22.
epp_display_string
Prototype
Function
Parameter:
cfgin
put
Mode
st
iStrLen
Return
Be
applicable
in
NEW7110
Notes
5.5.23.
epp_clear_screen
Prototype
Function
Parameter:
cfg
Return
Be
applicable
in
NEW7110
Notes
5.5.24.
epp_get_system_info
Prototype
int epp_get_system_info(EPP_CFG
*pvInfoOut)
Function
Get N20 PINPAD info. We are normally used this API to check the N20
EPP connect status.
Parameter:
cfg input
Type
*cfg,
uint32_t
Type,
void
output
please refer to section 4.12.1
NEW7110
Notes
5.5.25. epp_beep
Prototype
Function
Parameter:
cfginput
Frequency
TimeMs
Return
Be
applicable
in
NEW7110
Notes
5.5.26. epp_light
Prototype
Function
Parameter:
cfginput
TimeMs
Return
Be
applicable
in
NEW7110
Notes
5.5.27. epp_kb_get_string
Prototype
Function
Parameter:
iMode
D31
D9
Be
applicable
in
Notes
rev
D8
D7
D6
10 biglittlefont
D5
10 yesnoinput digital
D4
10 yesnoinput character
D3
10 yesnopassword way
D2
10 leftrightaligned input
D1
10 yesnodecimal point
D0
10 normalreversedisplay
iMinLen
min length
iMaxLen
max length
iTimeOutMs
timeout time
strBuffoutput
Return
5.6. Printer
Printer is a character device, using general file operations(openwriteioctlclose) can
complete operation on printer, for convenience of application developer, we package it
,let operation on printer audio-visually.
Printer module provides blocking and non-blocking operation.
In the blocking mode, when the program writing printed data into the printer, if the
printer internal print buffer is full, then the application writes data to the printer's
operation will block until the printer will have printed some data, there is room for
internal buffer blocked when the operation will be re-awakened, continue to write
data.
In the non-blocking mode, when the program will write the data to be printed in the
printer, if the printer internal print buffer is full, then the application writes data to the
printers operation will immediately failure and returns, and without blocking.
Print module just provide the lattice data will be printed to print, as to how to populate
the lattice data, self-completed by the developer, the printer is a shared device,
different applications can open the device and print at the same time, thus may
cause the print data confusion, so the developers should open the device to operate
only when it is need to call, when the operation is complete the device should be
closed immediately.
API functions of this module was defined in the printer.h, posapi.h; libpos.so must be
used when linking.
5.6.1.
printer_open
Prototype
Function
Parameter:
oflags
Return
>= 0
others
Support
NEW8210
Notes
5.6.2.
printer_close
Prototype
Function
Parameter
fd
Return
others
Support
NEW8210
Notes
5.6.3.
printer_read
Prototype
Function
Parameter:
fd
buf
nbytes
Return
>=
0
other
Support
NEW8210
Notes
5.6.4.
printer_write
Prototype
Function
Parameter:
Return
buf
nbytes
>= 0
others
Support
NEW8210
Notes
After calling this function, the printer will automatically begin to print.
In the blocking mode, the function may block until the printer can
accept data, on no exceptional condition, printer will complete print
submitted data, if an exception occurs(such as printing out of
paper,print head temperature is too high), function will return
immediately.
In the non-blocking mode, the printer will try to accept the data to be
printed, if the printer internal print buffer is full, this function will
immediately return the number of types have been received, in the
case of internal print buffer is full, continue to call this function will
return error(not by the failure of the printer ).
Note that calling this function, the printer may not accept all of the
data one time, so application should loop call printer_write, until all
of data are printed.
5.6.5.
printer_get_status
Prototype
Function
Parameter:
status
status
Return
voltage
temperature
bit
others
Support
NEW8210
Notes
The got status of printer is defined by bit, you should test status>status & 1<<PRINTER_STATUS_BUSY to determine wether
the printer is ldle
5.6.6.
printer_get_param
Prototype
Function
Parameter:
Return
param
ro_width
ro_bits_per_pixe
l
rw_gray
rw_hi_temp
rw_lo_temp
others
Support
NEW8210
Notes
5.6.7.
printer_set_param
Prototype
Function
Parameter:
Return
param
ro_width
ro_bits_per_pixe
l
rw_gray
rw_hi_temp
rw_lo_temp
Set OK
Others
Support
NEW8210
Notes
5.6.8.
printer_feed_start
Prototype
Function
Parameter:
Return
step
Set OK
others
Support
NEW8210
Notes
After calling this function, if the printer is idle, then the printer will
begin to feed, there has a largest number of feed steps limit inside
the printer, if setted step is bigger than the step, then it will feed
5.6.9.
printer_feed_stop
Prototype
Function
Parameter:
fd
Return
Operate OK
others
Support
NEW8210
Notes
5.6.10. printer_reset
Prototype
Function
Parameter:
fd
Return
operate success
others
Support
NEW8210
Notes
5.6.11. print_surface
Prototype
Function
Parameter:
fb_surface
Return
print_height
Operate success
others
Support
NEW8210
Notes
In the blocking mode, when the program calling to read magnetic card data , if the
magnetic stripe reader has no data, then the application will block until user swipes
card, when magnetic card module received data the blocked program will be reawakened, application will get data from magnetic card module.
In the non-blocking mode, when the program calling to read magnetic card data , if the
magnetic stripe reader has no data, the application will not be blocked ,calling the
magstripe_read will leads to error and returns immediately.(not the fault of magnetic card
module)
For the convenience of developer, we also provide read and write function with
timeout, if the reader can not read and write data at a set period of time, function will
exit.
API functions of this module was defined in the magstripe.h; libpos.so must be used
when linking.
5.7.1.
magstripe_open
Prototype
Function
Parameter:
Return
magnetic
stripe
name/dev/magcard0,/dev/magcard1
reader
oflags
>= 0
others
Support
NEW8210
Notes
5.7.2.
magstripe_close
Prototype
Function
Parameter:
fd
Return
others
Support
NEW8210
Notes
5.7.3.
magstripe_read
Prototype
Function
Parameter:
Return
Support
cardinf
o
magcardtrac
k
[0,1,2]
trackn
o
Track number012
status
Decoding state
MAGCARD_DECODE_OK:
success
MAGCARD_DECODE_ERR_RA
W
MAGCARD_DECODE_ERR_LR
C
MAGCARD_DECODE_ERR_OD
D
size
data
>0
others
NEW8210
Notes
5.7.4.
magstripe_read_timeout
Prototype
Function
Parameter:
cardinf
o
magcardtrac
k
[0,1,2]
ms
Return
Support
Notes
trackn
o
Track number012
status
Decoding state
MAGCARD_DECODE_OK:
success
MAGCARD_DECODE_ERR_RA
W
MAGCARD_DECODE_ERR_LR
C
MAGCARD_DECODE_ERR_OD
D
size
data
timeout time,unit:ms
>0
-ETIME
read timeout
others
NEW8210
5.7.5.
magstripe_write
Prototype
Function
Parameter:
Return
cardinfo
magcardtrac
k
[0,1,2]
trackno
Track number012
status
ignore
size
data
>0
others
Support
none
Notes
5.7.6.
magstripe_write_timeout
Prototype
Function
Parameter:
cardinfo
magcardtrac
k
[0,1,2]
ms
Return
trackno
Track number012
status
ignore
size
data
timeout time,unit:ms
>0
-ETIME
read timeout
others
Support
none
Notes
5.7.7.
magstripe_get_trackset
Prototype
Function
Parameter:
Return
fd
tradckinfo
bit_pre_code
start_flag
Start flag
end_flag
End flag
base
Base value
>0
success
others
Support
NEW8210
Notes
5.7.8.
magstripe_set_trackset
Prototype
Function
Parameter:
Return
tradckinfo
bit_pre_code
start_flag
Start flag
end_flag
End mark
base
Base value
success
others
Support
NEW8210
Notes
5.8. IC card
NEW8210 support one user card slot and three PSAM card slots currently, corresponding
card slot device name are listed as follow:
/dev/usercard ----- user card slot
/dev/samcard1 ------ PSAM1 card slot
/dev/samcard2 ------ PSAM2 card slot
/dev/samcard3 ------ PSAM3 card slot
Above them PSAM card slot just supports T=0 T=1 asynchronous operation of CPU
card, and user card not only supports T=0T=1 asynchronous operation of CPU card, but
also supports various synchronization card, such as SLE4428SLE4442 and AT24 series
memory card.
When developing application, please includes iccard.h sle4442.h sle4428.h and
at24xx.h
Please link to libiccard.so lib file when compiling.
5.8.1.
iccard_open_cardslot
Prototype
Function
Parameter:
filename
Return
>= 0
-1
Support
NEW8210
Notes
1 NEW8210 supports one user card slot and three SAM card slot
2 Please refer to iccard.h
5.8.2.
iccard_close_cardslot
Prototype
Function
Parameter:
fd
Return
-1
Support
NEW8210
Notes
5.8.3.
iccard_check_card_in_slot
Prototype
Function
Parameter:
fd
Return
Card Detected
-1
Support
NEW8210
Notes
1 Only user card supports card in place check, the other three
SAM card slot always regards as card is exist.
2 Please refer to iccard.h
5.8.4.
iccard_power_up
Prototype
Function
int iccard_power_up(int fd, int vcc, int mode, int *len, void *atr)
power on and reset asynchronous CPU card of IC card slot when
contacting
Parameter:
Return
fd
vcc
mode
len outp
ut
atroutpu
t
-1
Support
NEW8210
Notes
5.8.5.
Prototype
iccard_exchange_apdu
int
Function
Parameter:
fd
void
void
Return
sendlen
senddata
recvleno
utput
recvdata
output
0
-1
Support
NEW8210
Notes
5.8.6.
iccard_power_down
Prototype
Function
Parameter:
fd
Return
-1
Support
NEW8210
Notes
sle4428_open
Prototype
Function
Parameter:
fd
Return
-1
Support
NEW8210
Notes
5.9.2.
sle4428_close
Prototype
Function
Parameter:
fd
Return
-1
Support
NEW8210
Notes
5.9.3.
sle4428_read
Prototype
Function
Parameter:
fd
start_addr
start address
len
data out
put
-1
Return
Support
NEW8210
Notes
5.9.4.
sle4428_read_error_count
Prototype
Function
Parameter:
Return
count ou
tput
-1
Support
NEW8210
Notes
5.9.5.
sle4428_verify_pwd
Prototype
Function
Parameter:
fd
pwd
-1
Return
Support
NEW8210
Notes
5.9.6.
sle4428_change_key
Pototype
Function
Parameter:
Return
new_pwd
-1
Support
NEW8210
Notes
5.9.7.
sle4428_lock
Pototype
Function
Parameter:
fd
Return
-1
Support
NEW8210
Notes
5.9.8.
sle4428_read_status
Prototype
Function
Parameter:
Return
addr
statusou
tput
-1
Support
NEW8210
Notes
5.9.9.
sle4428_write
Prototype
Function
Parameter:
Return
start_addr
len
data
-1
Support
NEW8210
Notes
5.9.10. sle4428_write_protect
Prototype
Function
Parameter:
Return
start_addr
len
data
-1
Support
NEW8210
Notes
5.9.11. sle4428_check_data
Prototype
Function
Parameter:
addr
data
Return
write success
-1
Support
NEW8210
Notes
Function
Parameter:
fd
Return
-1
Support
NEW8210
Notes
5.10.2. sle4442_close
Prototype
Function
Parameter:
fd
Return
-1
Support
NEW8210
Notes
5.10.3. sle4442_verify
Prototype
Function
Parameter:
Return
pwd
-1
Support
NEW8210
Notes
5.10.4. sle4442_read_error_count
Prototype
Function
Parameter:
Return
count ou
tput
-1
Support
NEW8210
Notes
5.10.5. sle4442_change_key
Prototype
Function
Parameter:
Return
new_pwd
-1
Support
NEW8210
Notes
5.10.6. sle4442_lock
Prototype
Function
Parameter:
fd
Return
-1
Support
NEW8210
Notes
5.10.7. sle4442_read
Prototype
Function
Parameter:
Return
start_addr
start address
len
data out
put
-1
Support
NEW8210
Notes
5.10.8. sle4442_write
Prototype
Function
Parameter:
Return
start_addr
len
data
-1
Support
NEW8210
Notes
5.10.9. sle4442_read_status
Prototype
Function
Parameter:
Return
addr
statusou
tput
-1
Support
NEW8210
Notes
5.10.10. sle4442_check_data
Prototype
Function
Parameter:
Return
addr
data
-1
Support
NEW8210
Notes
5.11.1.
5.11.1.1. mif_open
Prototype
Function
Parameter:
filename
Return
>= 0
-1
Support
NEW8210
Notes
5.11.1.2. mif_close
Prototype
Function
Parameter:
fd
Return
operate success
-1
Support
NEW8210
Notes
5.11.1.3. mif_set_timeout
Prototype
Function
Parameter:
ptime
Return
operate OK
-1
Support
NEW8210
Notes
5.11.1.4. mif_get_timeout
Prototype
Function
Parameter:
ptime
Return
output
0
operate OK
-1
Support
NEW8210
Notes
5.11.1.5. iso14443_delay_etu
Prototype
Function
Parameter:
fd[i]
numofet
u
Return
Success
-1
Support
NEW8210
Notes
5.11.1.6. iso14443_reset_picc
Prototype
Function
Parameter:
fd[i]
Return
Success
-1
Support
NEW8210
Notes
5.11.1.7. mif_select_carrier_type
Prototype
Function
Parameter:
Return
Support
type
Operate OK
-1
NEW8210
Notes
5.11.1.8. iso14443_ReqA
Prototype
Function
Parameter:
Return
atqaoutpu
t
operate OK
-1
Support
NEW8210
Notes
5.11.1.9. iso14443_WupA
Prototype
Function
Parameter
Return
atqaoutpu
t
operate OK
-1
Support
NEW8210
Notes
5.11.1.10. iso14443_Anticollision
Prototype
Function
Parameter:
Return
sel
anti-conflict layer
0x93 ------ first level
0x95 ------ second level
0x97 ------ third level
uid output
operate OK
-1
Support
NEW8210
Notes
5.11.1.11. iso14443_Select
Prototype
Function
Parameter:
Return
sel
Choose layer
0x93 ------ first level
0x95 ------ second level
0x97 ------ third level
uid
sak output
operate OK
-1
Support
NEW8210
Notes
5.11.1.12. Iso1443_get_typeA_uid
Prototype
Function
Parameter:
fd[i]
Return
Success
-1
Support
NEW8210
Notes
5.11.1.13. Iso1443_get_cardtype
Prototype
uint8_t iso14443_get_cardtype(void);
Function
Parameter:
Return
0 Success
- Operate failure, please get the actual error code by errno:
1 EINVAL input parameter error
other value : other error code
Support
NEW8210
Notes
5.11.1.14. iso14443_HaltA
Prototype
Function
Parameter:
Return
operate OK
-1
Support
NEW8210
Notes
5.11.1.15. iso14443_RATS
Prototype
Function
Parameter:
Return
cid
fsdi
atslen o
utput
ats outp
ut
operate OK
-1
Support
NEW8210
Notes
5.11.1.16. iso14443_PPS
Prototype
Function
Parameter:
Return
cid
br
operate OK
-1
Support
NEW8210
Notes
5.11.1.17. iso14443_ReqB
Prototype
Function
Parameter:
Return
int iso14443_ReqB(int
*lenofatqb, void *atqb)
fd,uint8_t
afi,uint8_t
slotnum,uint8_t
afi
slotnum
lenofatqb
output
atqb out
put
atqb information
operate OK
-1
Support
NEW8210
Notes
5.11.1.18. iso14443_WupB
Prototype
Function
Parameter:
Return
int iso14443_WupB(int
*lenofatqb, void *atqb)
fd,uint8_t
afi,uint8_t
slotnum,uint8_t
afi
slotnum
lenofatqb
output
atqb out
put
atqb information
operate OK
-1
Support
NEW8210
Notes
5.11.1.19. iso14443_SlotMarker
Prototype
Function
Parameter:
Return
slot
lenofatqb
output
atqb out
put
atqb information
operate OK
-1
Support
NEW8210
Notes
5.11.1.20. iso14443_AttriB
Prototype
Function
Parameter:
fsdi,const
void
cid
fsdi
uid
br
info_len
input/
output
Return
cid,uint8_t
info inp
ut/
output
operate OK
-1
Support
NEW8210
Notes
5.11.1.21. iso14443_HaltB
Prototype
Function
Parameter:
Return
uid
operate OK
-1
Support
NEW8210
Notes
5.11.1.22. iso14443_tcl_poll
Prototype
int
iso14443_tcl_poll(int
fd,int
mode,uint8_t
*cardinfo_len,void
Function
Parameter:
Return
*cardinfo)
polling inductive area if there exists T=CL protocol card, is there
have , choose it
fd
mode
cardinfo_len
output
cardinfoou
tput
operate OK
-1
Support
NEW8210
Notes
5.11.1.23. iso14443_tcl_active
Prototype
Function
Parameter:
uint8_t
cid,
uint8_t
br,uint8_t
cid
br
info_len
TypeA card:
Length of ATS information that info_len returns
TypeB card:
When is used to input, info_len means length of Higherlayer INF information of ArttriB command
When is used to output, info_lens returns cards
response data length
input/
output
Return
info inp
ut/
output
TypeA card:
ATS information that info_len returns
TypeB card:
When is used to input, info means Higher-layer INF
information of ArttriB command
When is used to output, info returns cards response
data
operate OK
-1
Support
NEW8210
Notes
5.11.1.24. iso14443_tcl_exchange
Prototype
Function
Parameter:
Return
sendlen
senddata
recvleno
utput
recvdata
output
0
operate OK
-1
Support
NEW8210
Notes
5.11.1.25. iso14443_tcl_deactive
Prototype
Function
Parameter:
fd
Return
operate OK
-1
Support
NEW8210
Notes
5.11.1.26. iso14443_no_tcl_exchange
Prototyep
Function
Parameter:
fd
sendlen
senddata
recvleno
utput
recvdata
output
timeout
operate OK
-1
Return
Support
NEW8210
Notes
5.11.1.27. mif_check_multi_card
Prototype
Function
Parameter:
fd
Return
operate OK
-1
Support
NEW8210
Notes
5.11.1.28. felica_exchange
Prototype
Function
Parameter
Fd[i]
Sendlen
[i]
Senddat
a[i]
Receive
len[o]
Receive
data[o]
Timeout
[i]
Return
Success
-1
Support
NEW8210
Notes
5.11.1.29. emv_contactless_active
Prototype
Function
Parameter:
fd
Return
Success
-1
Support
NEW8210
Notes
5.11.1.30. emv_contactless_deactive_picc
Prototype
Function
fd
Return
Success
-1
Support:
NEW8210
Notes
5.11.1.31. emv_contactless_obtain_status
Prototype
Function
Get status
Parameter:
fd
status
status
Success
-1
Return
Support
NEW8210
Notes
5.11.1.32. emv_contactless_get_lasterror
Prototype
Function
Parameter:
fd
error
Error number
Success
Return
-1
Support
NEW8210
Notes
5.11.1.33. emv_contactless_exchange_apdu
Prototype
Function
Parameter:
fd
sendlen
senddata
Apdu Command
recvlen
recvdata
Apdu Response
Success
-1
Return
Support
NEW8210
Notes
5.11.1.34. compat_InATR
Prototype
Function
Parameter:
fd
RespLen
ATRInfo
Return
Success
-1
Support
NEW8210
Notes
5.11.1.35. compat_InPSL
Prototype
Function
Parameter:
fd
Brit
BRti
Return
Success
-1
Support
NEW8210
Notes
5.11.1.36. Compat_InListPassiveTarget
Prototype
Function
Parameter:
fd
Mode
InitLen
InitInfo
CardInfoLen
pCardInfo
Return
Success
-1
Support
NEW8210
Notes
5.11.1.37. compat_InDataExchange
Prototype
Function
Parameter:
fd
Brit
BRti
Return
Success
-1
Support
NEW8210
Notes
5.11.1.38. Compat_InRelease
Prototype
Function
Parameter:
fd
Return
Success
-1
Support
NEW8210
Notes
5.11.1.39. compat_mifCheckOnlyOneCard
Prototype
Function
Parameter:
fd
Mode
Return
Success
-1
Support
NEW8210
Notes
5.11.2.1. mifare_one_poll
Prototype
Function
Parameter:
Return
mode
uid output
cardtype o
utput
-1
Support
NEW8210
Notes
5.11.2.2. mifare_one_halt
Prototype
Function
Parameter:
fd
Return
reset OK
-1
Support
NEW8210
Notes
5.11.2.3. mifare_one_authenticate
Prototype
Function
Parameter:
Return
blockno
keytype
key
uid
-1
Support
NEW8210
Notes
5.11.2.4. mifare_one_read_block
Prototype
Function
Parameter:
Return
blockno
blockdatao
utput
-1
Support
NEW8210
Notes
5.11.2.5. mifare_one_write_block
Prototype
Function
Parameter:
Return
blockno
blockdata
-1
Support
NEW8210
Notes
5.11.2.6. mifare_one_set_value
Prototype
Function
Parameter:
Return
blockno
value
-1
Support
NEW8210
Notes
5.11.2.7. mifare_one_increment
Prototype
Function
Parameter:
Return
blockno
value
-1
Support
NEW8210
Notes
5.11.2.8. mifare_one_decrement
Prototype
Function
Parameter:
Return
blockno
value
-1
Support
NEW8210
Notes
5.11.2.9. mifare_one_restore
Prototype
Function
Parameter:
Return
blockno
-1
Support
NEW8210
Notes
5.11.2.10. mifare_one_transfer
Prototype
Function
Parameter:
Return
blockno
-1
Support
NEW8210
Notes
5.11.2.11. mifare_one_get_value
Prototype
Function
Parameter:
Return
blockno
valueoutpu
t
-1
Support
NEW8210
Notes
5.11.3.1. mifare_ultralight_poll
Prototype
Function
Parameter:
Return
mode
uid output
-1
Support
NEW8210
Notes
5.11.3.2. mifare_ultralight_halt
Prototype
Function
Parameter:
fd
Return
reset OK
-1
Support
NEW8210
Notes
5.11.3.3. mifare_ultralight_read_page
Prototype
Function
Parameter:
Return
page
dataoutput
-1
Support
NEW8210
Notes
5.11.3.4. mifare_ultralight_write_page
Prototype
Function
Parameter:
Return
Support
page
data
-1
NEW8210
Notes
5.11.3.5. mifare_ultralight_write_page16
Prototype
Function
Parameter:
Return
Support
fd
page
Page number0~15
data
Data to write
Success
-1
NEW8210
Notes
5.11.4.1. desfire_poll
Prototype
Function
Parameter:
mode
Return
uid output
atslen outp
ut
ats output
-1
Support
NEW8210
Notes
5.11.4.2. desfire_deactive
Prototype
Function
Parameter:
fd
Return
Operate OK
-1
Be
applicable
Notes
NEW8210
5.11.4.3. desfire_authenticate
Prototype
Function
Parameter:
Return
fd
keyno
key
operate success
-1
Support
NEW8210
Notes
5.11.4.4. desfire_authenticate_iso
Prototype
Function
Parameter:
Return
keyno
key
operate success
-1
Support
NEW8210
Notes
5.11.4.5. desfire_authenticate_aes
Prototype
Function
Parameter:
Return
keyno
key
operate success
-1
Support
NEW8210
Notes
5.11.4.6. desfire_change_key_settings
Prototype
Function
Parameter:
Return
fd
key_settings
operate success
-1
Support
NEW8210
Notes
5.11.4.7. desfire_get_key_settings
Prototype
Function
Parameter:
key_settings
output
max_key_num
Return
output
0
-1
Support
NEW8210
Notes
5.11.4.8. desfire_change_picc_masterkey
Prototype
Function
Parameter:
fd
type
Return
key
version
operate success
-1
Support
NEW8210
Notes
5.11.4.9. desfire_change_app_key
Prototype
Function
Parameter:
fd
keysetting
applications
parameter
type
keyno
oldkey
newkey
version
operate success
Return
master
key
configuration
attribute
-1
Support
NEW8210
Notes
5.11.4.10. desfire_get_key_version
Prototype
Function
Parameter:
Return
keyno
key number
versionout
put
operate success
-1
Support
NEW8210
Notes
5.11.4.11. desfire_create_application
Prototype
Function
Parameter:
Return
info
application information
operate success
-1
Support
NEW8210
Notes
5.11.4.12. desfire_delete_application
Prototype
Function
Parameter:
Return
aid
operate success
-1
Support
NEW8210
Notes
5.11.4.13. desfire_get_application_ids
Prototype
Function
Parameter:
Return
numoutpu
t
aid output
operate success
-1
Support
NEW8210
Notes
5.11.4.14. desfire_get_dfnames
Prototype
Function
Parameter:
Return
appnum o
utput
info output
0
-1
operate success
Operate failure, please get the actual error code by
errno:
EINVAL input parameter error
EIO read card chip error
ECOMM Parity error or CRC check error of card
returned data
EPROTO Card doesnt comply with ISO14443
standard
EBADE error of length of card returned data
ETIME timeout return
ENODATA card in inductive is not a mifare
DESFire card or card had not been activated
other value : other error code
Support
NEW8210
Notes
5.11.4.15. desfire_select_application
Prototype
Function
Parameter:
Return
aid
operate success
-1
Support
NEW8210
Notes
5.11.4.16. desfire_format_picc
Prototype
Function
Parameter:
fd
Return
operate success
-1
Support
NEW8210
Notes
5.11.4.17. desfire_get_version
Prototype
Function
Parameter:
Return
versionout
put
operate success
-1
Support
NEW8210
Notes
5.11.4.18. desfire_set_configuration
Prototype
Function
Parameter:
Return
option
len
info
operate success
-1
Support
NEW8210
Notes
5.11.4.19. desfire_free_memory
Prototype
Function
Parameter:
Return
freesizeou
tput
operate success
-1
Support
NEW8210
Notes
5.11.4.20. desfire_get_card_uid
Prototype
Function
Parameter:
Return
uid output
0
-1
operate success
Operate failure, please get the actual error code by
errno:
EINVAL input parameter error
EIO read card chip error
ECOMM Parity error or CRC check error of card
returned data
EPROTO Card doesnt comply with ISO14443
standard
EBADE error of length of card returned data
ETIME timeout return
ENODATA card in inductive is not a mifare
DESFire card or card had not been activated
other value : other error code
Support
NEW8210
Notes
5.11.4.21. desfire_get_fids
Prototype
Function
Parameter:
fd
numoutpu
t
fid output
operate success
Return
-1
Support
NEW8210
Notes
5.11.4.22. desfire_get_iso_fids
Prototype
Function
Parameter:
Return
numoutpu
t
fid output
-1
operate success
Support
NEW8210
Notes
5.11.4.23. desfire_get_filesetting
Prototype
Function
Parameter:
Return
fileno
file number
filesetting
output
operate success
-1
Support
NEW8210
Notes
5.11.4.24. desfire_change_filesetting
Prototype
new_change_access_keyno)
Function
Parameter:
fd
fileno
file number
comm_set
old_change_access_keyno
new_read_access_keyno
new_write_access_keyno
new_read_write_access_keyno
new_change_access_keyno
operate success
-1
Return
Support
NEW8210
Notes
5.11.4.25. desfire_create_std_datafile
Prototype
Function
Parameter:
fd
fileno
file number
fileinfo
operate success
-1
Return
Support
NEW8210
Notes
5.11.4.26. desfire_create_backup_datafile
Prototype
Function
Parameter:
fd
fileno
file number
fileinfo
operate success
Return
-1
Support
NEW8210
Notes
5.11.4.27. desfire_create_valuefile
Prototype
Function
Parameter:
Return
fileno
file number
fileinfo
operate success
-1
Support
NEW8210
Notes
5.11.4.28. desfire_create_linear_recordfile
Prototype
Function
Parameter:
Return
fileno
file number
fileinfo
operate success
-1
Support
NEW8210
Notes
5.11.4.29. desfire_create_cyclic_recordfile
Prototype
Function
Parameter:
fd
fileno
file number
fileinfo
operate success
-1
Return
Support
NEW8210
Notes
5.11.4.30. desfire_delete_file
Prototype
Function
Parameter:
Return
fileno
file number
operate success
-1
Support
NEW8210
Notes
5.11.4.31. desfire_read_data
Prototype
Function
Parameter:
fd
fileno
file number
comm_set
Return
offset
len
outlenoutput
dataout output
operate success
-1
Support
NEW8210
Notes
5.11.4.32. desfire_write_data
Prototype
Function
write data into general data file or into backup data file
Parameter:
fd
fileno
file number
comm_set
offset
len
datain
Return
operate success
-1
Support
NEW8210
Notes
5.11.4.33. desfire_get_value
Prototype
Function
Parameter:
Return
comm_set
value output
-1
Support
NEW8210
Notes
5.11.4.34. desfire_credit
Prototype
Function
Parameter:
Return
fileno
file number
comm_set
value
size of recharge
operate success
-1
Support
NEW8210
Notes
5.11.4.35. desfire_debit
Prototype
Function
Parameter:
Return
fileno
file number
comm_set
value
Value to deduct
operate success
-1
Support
NEW8210
Notes
5.11.4.36. desfire_limited_credit
Prototype
Function
Parameter:
Return
fileno
file number
comm_set
value
size fo recharge
operation
-1
Support
NEW8210
Notes
5.11.4.37. desfire_write_record
Prototype
Function
Parameter:
fd
fileno
file number
comm_set
Return
offset
len
info
operate success
-1
Support
NEW8210
Notes
5.11.4.38. desfire_read_records
Prototype
Function
Parameter:
Return
fileno
file number
comm_set
recordsize
length of log
first
num
outlen output
infooutput
-1
Support
NEW8210
Notes
5.11.4.39. desfire_clear_recordfile
Prototype
Function
Parameter:
Return
fileno
file number
operate success
-1
Be
application
in
NEW8210
Notes
5.11.4.40. desfire_commit_transaction
Prototype
Function
Parameter:
fd
Return
operate success
-1
Support
NEW8210
Notes
5.11.4.41. desfire_abort_transaction
Prototype
Function
Parameter:
fd
Return
operate success
EINVAL
EIO
ECOMM
EPROTO
EBADE
EACCES
ETIME
other value
Support
NEW8210
Notes
Function
Parameter:
fd
Return
-1
Support
NEW8210
Notes
5.12.2. at24_read
Prototype
Function
Parameter:
Return
card_type
start_addr
start address
len
data out
put
read data
-1
Support
NEW8210
Notes
5.12.3. at24_write
Prototype
Function
Parameter:
Return
card_type
start_add
r
start address
len
data
-1
Support
NEW8210
Notes
5.12.4. at24_close
Prototype
Function
Parameter:
fd
Return
-1
Support
NEW8210
Notes
5.13. Modem
Modem supports 1200bps and 2400bps sync dial, supports up to 336000bps async dial,
supports ppp dial.
Please refer to PPPLogin, PPPLogout and PPPCheck to get the information for ppp
dial.
The following introduce the sync dial and async dial.
Definition
Description
MODEM_STATE_NOT_INIT
MODEM_STATE_NO_SET_MODE
MODEM_STATE_SYNC_MODE
MODEM_STATE_ASYN_MODE
MODEM_STATE_DISCONNECT
MODEM_STATE_WAITTING
MODEM_STATE_DAILING
MODEM_STATE_CONNECT_SDLC
MODEM_STATE_CONNECT
Dial modes:
Definition
Description
MODEM_DAIL_DTMF
DTMF mode
MODEM_DAIL_PULSE
PULSE mode
Definition
Description
MODEM_COMM_ASYNC
Async mode
MODEM_COMM_SYNC
Definition
Description
MODEM_ERRNO_OK
OK
MODEM_ERRNO_CONNECT
Link connected
MODEM_ERRNO_ERROR
MODEM_ERRNO_BUSY
Modem is busy
MODEM_ERRNO_NO_DIALTONE
No dial tone
MODEM_ERRNO_NO_CARRIER
No carrier
MODEM_ERRNO_NO_LINE
No line in
MODEM_ERRNO_NO_ANSWER
No answer
MODEM_ERRNO_OFF_HOOK
MODEM_ERRNO_LINE_IN_USE
Line in use
MODEM_ERRNO_UN_OBTAINABLE
Unobtainable
MODEM_ERRNO_LINE_REVERSAL
Line reversal
MODEM_ERRNO_EXTENSION_IN_USE
Definition
Description
MODEM_CONNECT_1200BPS
1200bps
sync/async
MODEM_CONNECT_2400BPS
2400bps
sync/async
MODEM_CONNECT_4800BPS
4800bps
MODEM_CONNECT_7200BPS
7200bps
async
MODEM_CONNECT_9600BPS
9600bps
async
MODEM_CONNECT_12000BPS
12000bps
async
MODEM_CONNECT_14400BPS
14400bps
async
MODEM_CONNECT_16800BPS
16800bps
async
MODEM_CONNECT_19200BPS
19200bps
async
MODEM_CONNECT_21600BPS
21600bps
async
MODEM_CONNECT_24000BPS
24000bps
async
MODEM_CONNECT_26400BPS
26400bps
async
MODEM_CONNECT_28800BPS
28800bps
async
async
MODEM_CONNECT_31200BPS
31200bps
async
MODEM_CONNECT_33600BPS
33600bps
async
MODEM_CONNECT_48000BPS
48000bps
async
MODEM_CONNECT_56000BPS
56000bps
async
char
cmd[256];
char
maybe[760];
char
rsp[1024];
} ModemAtCmd_t;
timeo:
timeout of waiting AT command response, 0-keep waiting, < 0- dont wait for
response
reserved:
had better set to 0
cmd:
AT command string, such as ATH0
maybe:
The possible key words of the response string, such as 2 0x00 indicate the
end of string or {O, K, \0, E, R, R, O, R, \0, \0}
rps:
to store the response from the modem
5.13.3. modem_open
Prototype:
Function:
Parameter:
pathname(Input
)
The
device
name
of
Modem,
such
as
/dev/ttyS1(NEW8210) or /dev/modem0 (NEW8110)
oflags(Input)
Open mode
Return:
Read/write (required)
O_NONBLOCK
non-blocking
(optional)
>=0
<0
Be
Applicable
In:
NEW8210
Notes:
Example:
O_RDWR
Example 1:
int fd;
if ((fd = modem_open(/dev/ttyS1, O_RDWR)) < 0) {
// error
}
Example 2:
if ((fd = modem_open(/dev/ttyS1, O_RDWR | O_NONBLOCK)) < 0) {
// error
}
5.13.4. modem_close
Prototype:
Function:
Parameter:
fd(Input)
Return:
others
Be
Applicable
In:
NEW8210
Notes:
Example:
5.13.5. modem_write
Prototype:
Function:
Send data via modem. Can be used in sync and async mode.
Parameter:
fd(Input)
buf(Input)
nbytes(Input)
>=0
<0
Return:
Be
Applicable
In:
NEW8210
Notes:
Example:
5.13.6. modem_write_timeout
Prototype:
Function:
Send data via modem with specified timeout. Can be used in sync and
async mode.
Parameter:
fd(Input)
buf(Input)
nbytes(Input)
timeoutms(Input
)
>=0
<0
Return:
of
buffer
which
are
sended
Be
Applicable
In:
NEW8210
Notes:
Example:
5.13.7. modem_wait_until_sent
Prototype:
Function:
Wait for all data in the send buffer are sent completly.
Parameter:
fd(Input)
Return:
OK
Others
Be
Applicable
In:
NEW8210
Notes:
The data are not sent out immediately when the application invokes
modem_write and modem_write_timeout. While the data are stored into
the send buffer and sent in the background. This function is used to wait
for data sent complete. This function wont return until all data are sent
complete.
It is recommended to invoke this function to make sure that all data are
sent out before hand up or close modem device.
Example:
5.13.8. modem_read
Prototype:
Function:
Receive data via modem. Can be used in sync and async mode.
Parameter:
fd(Input)
buf(Output)
nbytes(Input)
>=0
<0
Return:
Be
Applicable
In:
NEW8210
Notes:
Example:
5.13.9. modem_read_timeout
Prototype:
Function:
Receive data via modem with specified timeout. Can be used in sync and
async mode.
Parameter:
fd(Input)
Return:
buf(Output)
nbytes(Input)
timeoutms(Input
)
>=0
<0
Be
Applicable
In:
NEW8210
Notes:
Example:
5.13.10. modem_dialing
Prototype:
Function:
dialing.
Parameter:
fd(Input)
telephone(Input)
OK
Others
Return:
Be
Applicable
In:
NEW8210
Notes:
}
for (keep=1; keep; ) {
if ((retval = modem_get_status(modem, &status))) {
// failed to invoke function
break;
}
if (status & 0x80000000) // operation not completed
continue;
switch (status & 0x7FFFFFFF) {
case MODEM_STATE_CONNECT_SDLC:
// now sdlc link connecting
break;
case MODEM_STATE_CONNECT:
// OK, link is connected
keep = 0;
break;
case MODEM_STATE_DISCONNECT:
default:
// error, failed to connect
keep = 0;
break;
}
}
5.13.11. modem_hangup
Prototype:
Function:
Parameter:
fd(Input)
Return:
Hangs up successfully.
Others
Be
Applicable
In:
NEW8210
Notes:
Example:
5.13.12. modem_get_status
Prototype:
Function:
Parameter:
fd(Input)
status(Output)
OK
others
Return:
Be
Applicable
In:
NEW8210
Notes:
Example:
break;
if (status & 0x80000000) {
/* waitting operation completed */
if (wait_func)
wait_func(arg);
continue;
}
*state = status & 0x7FFFFFFF;
break;
}
return retval;
}
5.13.13. modem_get_last_errno
Prototype:
Function:
Parameter
fd(Input)
The handle of
modem_open.
err(Output)
OK
Others
:
Return:
modem
which
is
get
from
Be
Applicable
In:
NEW8210
Notes:
This function is used to get errno after modem operates failed not used to
get error code after send/receive failed. Modem operation includes
initialization, set dial parameters, dial, set automatic answer mode, and
hand up. This function can not be used to get error code after
modem_write or modem_read return error (use PosixGeterrno to get
the corresponding code).
If this function return 0, the error code is stored in err. Please refer to the
definition of MODEM_ERRNO_xxxx.
Example:
5.13.14. modem_set_dial_parms
Prototype:
Function:
Parameter:
fd(Input)
dp(Input)
OK
Others
Return:
Be
Applicable
In:
NEW8210
Notes:
This
function
can
only
be
invoked
at
the
state
MODEM_STATE_NO_SET_MODE and MODEM_STATE_DISCONNECT.
After this function returns, modem will handle the parameters at the
background, and modem is at an unstable state. Application need invokes
modem_get_status to wait for the setting complete. If set complete,
modem turns to the state MODEM_STATE_DISCONNECT.
Example:
5.13.15. modem_get_dial_parms
Prototype:
Function:
Parameter:
fd(Input)
dp(Output)
OK
Others
Return:
Be
Applicable
In:
NEW8210
Notes:
This
function
can
only
be
used
at
the
state
MODEM_STATE_NO_SET_MODE and MODEM_STATE_DISCONNECT.
Example:
5.13.16. modem_get_sdlc_parms
Prototype:
Function:
Parameter:
fd(Input)
The handle of
modem_open.
sp(Output)
OK
Others
Return:
Be
Applicable
In:
modem
which
is
get
from
NEW8210
Notes:
Example:
5.13.17. modem_set_sdlc_parms
Prototype:
Function:
Parameter:
fd(Input)
sp(Input)
OK
Others
Return:
Support:
NEW8210
Notes:
Example:
5.13.18. modem_enter_auto_answer
Prototype
Function
Parameter
fdInput
Return
Success
Other
Support
NEW8210
Notes
5.13.19. modem_exit_auto_answer
Prototype
Function
Parameter
fdInput
Return
Success
Other
Support
NEW8210
Notes
5.13.20. modem_check_extension
Prototype:
Function:
Parameter:
fd(Input)
Return:
MODEM_ERRNO_EXTENSION_IN_USE
Extension is in use
MODEM_ERRNO_NO_LINE
No line in
Others
Failed
Be
Applicable
In:
NEW8210
Notes:
This function is used to check the line and extension. Before dial via
modem_dialing, modem will check automatically. So application neednt
check before dial.
Example:
5.13.21. modem_exec_at_command
Prototype:
Function:
Parameter:
fd(Input)
At(Input)
Input: at command
Output: response of at command
OK
Others
Return:
Be
Applicable
In:
NEW8210
Notes:
Example:
5.13.22. modem_power_control
Prototype
Function
Parameter:
onoffinput
1-power on
0-power off
Return
OK
Support
NEW8210
Notes
If you use a dial-up Modem for PPP, you need to open the modem power,
and call this function to close the modem power after used;
When using modem synchronous / asynchronous communication,
modem_open () will automatically open modem power supply, need not to
call the function.
Example:
5.14. PPP
Use PPP module, need to contain head file ppp.h.
PPP module supports these authentication protocol:
PAP
CHAP
MSCHAP V1/V2
Return code of PPP:
Return
Reason
-100
-1032
-4001
An error was detected in processing the options given, such as two mutually
exclusive options being used.
-4003
-4004
The kernel does not support PPP, for example, the PPP kernel driver is not
included or cannot be loaded.
-4005
-4006
-4007
-4008
-4009
The command specified as the argument to the pty option could not be run.
-4010
The PPP negotiation failed, that is, it didnt reach the point where at least
one network protocol (e.g. IP) was running.
-4011
-4012
The link was established successfully and terminated because it was idle.
-4013
The link was established successfully and terminated because the connect
time limit was reached.
-4014
-4015
The link was terminated because the peer is not responding to echo
requests.
-4016
-4017
-4018
-4019
5.14.1.
ppp_open
Prototype
Function
Parameter:
devname
chat
user
passwd
Return
auth
authentication
PPP_ALG_PAP
PPP_ALG_CHAP
PPP_ALG_MSCHAPV1
PPP_ALG_MSCHAPV2
timeout
operate success
other
Support
NEW8210
Notes
"'OK'
'ATDT*99***1#'"
"'CONNECT'
''"
"\n"
"\n"
};
The same as modem ppp, AT start is all module initialization command,
the line before CONNECT is number of PPP dialing*99***1#
CDMA PPP chat
char cdma_chat_file[] = {
"ABORT
'NO CARRIER'"
"\n"
"ABORT
'NO DIALTONE'"
"\n"
"ABORT
'ERROR'"
"\n"
"ABORT
'NO ANSWER'"
"\n"
"ABORT
'BUSY'"
"\n"
"TIMEOUT
'60'"
"\n"
"''
'ATZ'"
"\n"
"'OK'
'ATH0'"
"\n"
"'OK'
'ATDT#777'"
"\n"
"'CONNECT'
''"
"\n"
};
The same as modem ppp, AT start is all module initialization command,
the line before CONNECT is number of PPP dialing#777
Examples above is all examples of ppp dialing in china mainland, if in
other countries or regions, it will need to configure it again on the basis of
local condition.
When MODEM PPP be used, the communication device is
/dev/ttyS1; When GPRS/CDMA PPP be use, you should call
wnet_getmodinfo to obtain the dial device name(Pppdev)
wnet_moduleinfo_t modinfo;
memset(&modinfo, 0, sizeof(wnet_moduleinfo_t));
If (wnet_getmodinfo(&modinfo)) {
//
}
......
Retval = ppp_open(modinfo.Pppdev, gprs_chat_file, card, card,
PPP_ALG_PAP, 45);
......
5.14.2. ppp_close
Prototype
Function
Parameter:
devname
Return
-ENETDOWN
other
Support
NEW8210
Notes
If the application does not need to use ppp linking any more, you had
better call this function to break ppp linking, to avoid additional
communication costs.
5.14.3. ppp_check
Prototype
Function
Parameter:
devname
Return
-PPP_LINK_BUILDING
-ENETDOWN
other
Support
NEW8210
Notes
5.14.4. ppp_set_dns
Prototype
Function
Parameter:
mode
other
Return
Support
NEW8210
Notes
This function must be called after ppp link is successful built(call it after
have called ppp_check and return 0), after set it all dns will be parsed by
ppp link assigned dns server. If have closed ppp link, developer must call
this function to recover previous dns server addresss configuration.
5.15. GPRS/CDMA
5.15.1. Return Codes
#define WNET_OK
(0)
#define WNET_DLOPEN_ERR
#define WNET_DLSYM_ERR
#define WNET_INIT_ERR
#define WNET_NOINIT_ERR
#define WNET_PARAM_ERR
#define WNET_GET_OP_ERR
#define WNET_NO_FUN_ERR
#define WNET_POWER_DOWN_ERR
#define WNET_BEEN_USE_ERR
#define WNET_SUSPEND_ERR
#define
#define
#define
#define
#define
#define
#define
#define
WNET_NO_MODULE_ERR
WNET_RECV_TIMEOUT_ERR
WNET_USER_CANCEL_ERR
WNET_RECV_DATA_ERR
WNET_MOD_RESP_ERR
WNET_SEND_DATA_ERR
WNET_COMM_OPEN_ERR
WNET_SMS_DIV_ERR
5.15.2. Structure
typedef struct{
int arfcn;
int rxlev;
int bsic;
int cell_id;
int lac;
int mnc;
int mcc;
int aiRev[5];
}tBaseStationGPRS;
typedef struct{
int BandClass;
int Channel;
int SID;
int NID;
int BaseStationPRev;
int PilotPNoffset;
int BaseStationID;
int SlotCycleIndex;
int RawEcIo;
int RxPower;
int TxPower;
int TxAdj;
}tBaseStationCDMA;
typedef struct{
int iFlag; // 1:GPRS, 2:CDMA
union{
tBaseStationGPRS oGprs;
tBaseStationCDMA oCdma;
} Wnet;
}tBaseStation;
typedef struct{
unsigned char byLength;
// number length
unsigned char byType;
// type,0x91:international, 0x81:Inland
unsigned char abyNumber[30]; // number content
}tTelInfo;
typedef struct{
char strSca[64]; // server central tel number
char strDstAddr[64]; // Destination address
unsigned char byPid;
// Protocol ID, the default value is 0x00
unsigned char byDcs;
// Decord Standard
unsigned char byUniqueID;
// Decord Standard
unsigned char byTpVp; // SMS Validity Period
unsigned char abyPduType[MAX_SMS_NUMBER]; // PDU type
int aiContentLength[MAX_SMS_NUMBER];
// the length of sms content
int aiCompressLength[MAX_SMS_NUMBER];
// the length of sms content
char strContentData[MAX_SMS_NUMBER*PDU_SMS_CONTENT_LENGTH];
the content of sms
unsigned char abyRev[24];
//
}tPduSmsSend;
//
typedef struct{
int index;
// the index in the sms memory
char
strScts[16]; // the time of sms server, like "12032718250032" --- 2012-03-27
18:25:00 32
char strSca[64]; // server central tel number
char strOa[64]; // Orient address
unsigned char byStatus; // 0:"REC UNREAD", 1:"REC READ", 2:"STO UNSENT",
3:"STO SENT", 4:"ALL"
unsigned char byPduType; // PDU type
unsigned char byPid;
// Protocol ID
unsigned char byDcs;
// Decord Standard
int iContentLength;
// the length of sms content
char strContentData[336];
// the content of sms
}tPduSmsRecv;
typedef struct{
int index;
// the index in the sms memory
unsigned char abyTime[8]; // the time of sms server, format:YYMMDDHHMMSSZZ, ZZ
is zone
// like "\x12\x03\x27\x18\x25\x00\x32\x00" --- 2012-03-27 18:25:00 32
tTelInfo oSca; // server central tel number
tTelInfo oOa; // Orient address
// Such as "\x05\x10\x08\x6F"---->"10086"
// Such as "\x0d\x86\x18\x92\x84\x84\x80\x8f"---->"8618928484808"
unsigned char byStatus; // 0:"REC UNREAD", 1:"REC READ", 2:"STO UNSENT",
3:"STO SENT", 4:"ALL"
unsigned char byCurItem; // From 0 to TotalNum-1
unsigned char byTotalNum; // TotalNum >= 1
unsigned char byDecodeStandard;// 0x00:ASCII; 0x08:UCS2(UNICODE 16); 0x04:Hex
data
int iSmsLength;
// the length of sms content
unsigned char abyUniqueID[2]; // SMS unique ID
char stSmsData[170];
// the content of sms
}tSmsRecv; // 256 bytes
typedef struct{
tTelInfo oSca; // server central tel number
tTelInfo oDstAddr;
int iSmsLength;
// the length of sms content
unsigned char abySmsData[3080]; // the content of sms
// ASCII Maxin length 3060 bytes
5.15.3. wnet_power_on
Prototype
int wnet_power_on(void)
Function
Input
Parameter:
None
Output
Parameter:
None
Return
Support
NEW8210
Notes
5.15.4. wnet_power_down
Prototype
int wnet_power_down(void)
Function
Input
Parameter:
None
Output
Parameter:
None
Return
Support
NEW8210
Notes
Power off the modelmust call wnet_power_on to power on the model and
call wnet_init to initialize the model before use it.
5.15.5. wnet_init
Prototype
Function
Input
Parameter:
comm_dev
Output
Parameter:
None
Return
Support
NEW8210
Notes
5.15.6. wnet_reset
Prototype
int wnet_reset(void)
Function
Input
Parameter:
None
Output
Parameter:
None
Return
Support
NEW8210
Notes
After this API called, the module perform a physical reset, the PPP linking
and configures are all invalid, the module is in factory state, before next
using, wnet_init will be needed.
5.15.7. wnet_set_attached
Prototype
Function
Input
Parameter:
flag
Output
Parameter:
None
Return
Support
NEW8210
Notes
Network detached or attached depends on the parameter flag. need to call the
function until the return success to ensure that the network is attached/detached
correctly.
5.15.8. wnet_signal
Prototype
Function
Input
Parameter:
NONE
Output
Parameter:
signal_num
Return
Support
NEW8210
Notes
5.15.9. wnet_checksim
Prototype
int wnet_checksim(void)
Function
Input
Parameter:
None
Output
None
Parameter:
Return
Support
NEW8210
Notes
5.15.10. wnet_getimei
Prototype
Function
Input
Parameter:
None
Output
Parameter:
IMEI
Return
Support
NEW8210
Return IMEI
Notes
5.15.11. wnet_getmodinfo
Prototype
Function
Input
Parameter:
None
Output
Parameter:
info
Return
Support:
NEW8210
Notes
5.15.12. wnet_sms_getlist
Prototype:
Function:
Input
Parameter:
listtype
SMS
Type
NEW SMS
READED SMS
ALL SMS
maxno
Output
Parameter:
sms
SmsNum
Return:
Support:
NEW8210
Notes:
5.15.13. wnet_sms_send
Prototype
Function
Send a SMS
Input
Parameter:
sms
Output
Parameter:
None
Return
Support
NEW8210
Message
Notes
5.15.14. wnet_sms_read
Prototype
Function
Read a SMS
Input
Parameter:
index
Output
sms
Message buffer
Parameter:
Return
Support
NEW8210
Notes
5.15.15. wnet_sms_delete
Prototype
Function
Delete a SMS
Input
Parameter:
index
Output
Parameter:
None
Return
Support
NEW8210
Notes
5.15.16. wnet_phone_status
Prototype
Function
Input
Parameter:
uiBuffSize
Buffer size
Output
Parameter:
PhoneNumb
er
Return
Support
NEW8210
Notes
5.15.17. wnet_phone_answer
Prototype
int wnet_phone_answer(void)
Function
Answer call
Input
Parameter:
None
Output
Parameter:
None
Return
Support
NEW8210
Notes
5.15.18. wnet_phone_hangup
Prototype
int wnet_phone_hangup(void)
Function
Hangup
Input
Parameter:
None
Output
Parameter:
None
Return
Support
NEW8210
Notes
5.15.19. wnet_phone_call
Prototype
Function
Call a phone
Input
Parameter:
PhoneNum
Output
Parameter:
None
Return
Support
NEW8210
Notes
Phone number
5.15.20. wnet_get_basestation_info
Prototype
Function
Input
Parameter:
None
Output
Parameter:
psBaseStationInf
o
Return
Support
NEW8210
Notes
If the return value is success, it will get the right base station info.
5.15.21. wnet_get_neighbourbasestation_info
Prototype
int wnet_get_neighbourbasestation_info(tBaseStation
*psBaseStationInfo, int iNum, int *piOutNum)
Function
Input
Parameter:
iNum
Output
Parameter:
psBaseStationInf
o
Return
piOutNum
Support
Notes
NEW8210
5.15.22. wnet_read_simcardID
Prototype
Function
Input
Parameter:
iLen
Buffer size
Output
Parameter:
psSimCardID
Return
Support
NEW8210
Notes
5.15.23. wnet_read_simcardIMSI
Prototype
Function
Input
Parameter:
iLen
Buffer size
Output
Parameter:
IMSI
Return
Support
NEW8210
Notes
5.15.24. wnet_get_current_sim
Prototype
int wnet_get_current_sim(void)
Function
Input
Parameter:
None
Output
Parameter:
None
Return
SIM 1
SIM 2
others
Support
NEW8210
Notes
5.15.25. wnet_select_sim
Prototype
Function
Input
Parameter:
simno
Output
Parameter:
None
Return
Successfully
others
Support
NEW8210
Notes
Before call this function, the wireless module must be power down
status, otherwise this function will return WNET_POWER_DOWN_ERR.
For example:
int simno;
simno = wnet_get_current_sim();
if (simno < 0)
report_error();
else {
simno ^= 1;
wnet_power_down();
if (wnet_select_sim(simno))
report_error();
}
Notice: If the terminal is not the Dual-SIM version, call this function has no
effect, it always operate the same SIM card.
5.16.1.
bar_open
Prototype:
Function:
Parameter:
Return:
pathname(Input
)
The
device
name
of
scanner,
such
/dev/ttyS2(NEW8210) or /dev/bar0 (NEW8110)
oflags(Input)
Open mode
O_RDONLY
O_NONBLOCK
non-blocking
(optional)
>=0
<0
Be
Applicable
In:
NEW8210
Notes:
Example:
Example 1:
int fd;
if ((fd = bar_open(/dev/ttyS2, O_RDONLY)) < 0) {
// error
}
Example 2:
if ((fd = bar_open(/dev/ttyS2, O_RDONLY | O_NONBLOCK)) < 0) {
// error
}
5.16.2. bar_close
Prototype:
Function:
Parameter:
fd(Input)
Return:
others
Be
Applicable
In:
as
NEW8210
Notes:
Example:
5.16.3.
bar_scan
Prototype:
Function:
Start/Stop scan.
Parameter:
fd(Input)
onoff(Input)
stop scanning
non-zero
Return:
start to scan
Successfully.
non-zero
Be
Applicable
In:
NEW8210
Notes:
If start to scan, you can call Bar_scan, and the onoff is non-zero.
If stop scanning, you can call Bar_scan, and the onoff is zero.
It returns immediately after calling this function of bar_scan.
Example:
5.16.4.
bar_read
Prototype:
Function:
Parameter:
fd(Input)
buf(Output)
nbytes(Input)
>=0
<0
Return:
Be
Applicable
In:
NEW8210
Notes:
Example:
5.16.5.
bar_read_timeout
Prototype:
Function:
Parameter:
fd(Input)
buf(Output)
nbytes(Input)
timeoutms(Input
)
>=0
<0
Return:
Be
Applicable
In:
NEW8210
Notes:
Example:
5.17. VPDN
API functions of this module was defined in the vpdn.h; libvpdn.so must be used when
linking.
typedef enum {
VPDN_NO_ERROR,
/* vpdn dial successfullyconnection to server is established
*/
VPDN_IS_CONNECTING,
/* vpdn dial is on the way */
VPDN_IS_DISCONNECTED,
/* vpdn connection to server is disconnected */
VPDN_ERROR,
/* other error */
VPDN_CERT_FILE_UNAVAILABLE, /* vpdn certification file is unavailable */
VPDN_NO_DEFAULT_ROUTE,
/* no default route to vpdn server */
} RESULT_ERROR_ENUM;
5.17.1. vpdn_open
Prototype:
Function:
Parameter:
debug_mode
(input)
Normal mode
other
OK
other
Return:
Be
Applicable
In:
NEW8210
Notes:
This API will create a channel to vpdn manager process, the one you
send command to later.
This API must be called before calling any other interface.
Example:
5.17.2. vpdn_close
Prototype:
int vpdn_close(void)
Function:
Parameter:
None
Return:
OK
other
Be
Applicable
In:
NEW8210
Notes:
This API will delete the channel to vpdn manager process. But it does
not disconnect the connection to remote vpdn server. If you wanna
disconnect the connection to remote vpdn server, vpdn_disconnect
must be called before vpdn_close.
Example:
5.17.3. vpdn_call_pptp
Prototype:
Function:
Parameter:
arg
func
The function which will be called when the dialing result is sent back by
vpdn manager process.
Prototype: typedef void (*result_notify_func_t)(result_arg_t *arg);
typedef struct {
int
error;
/*
VPDN_NO_ERROR
means
OK.
See
down */
} result_arg_t;
Return:
OK
other
Be
Applicable
In:
NEW8210
Notes:
Example:
5.17.4. vpdn_call_l2tp_psk
Prototype:
Function:
Parameter:
arg
Return:
func
OK
other
Be
Applicable
In:
NEW8210
Notes:
Example:
5.17.5. vpdn_call_l2tp_cert
Prototype:
Function:
Parameter:
arg
typedef struct {
struct in_addr server; /* vpdn server ip address */
char domain[32];
Return:
func
OK
other
Be
Applicable
In:
NEW8210
Notes:
Example:
5.17.6. vpdn_disconnect
Prototype:
Function:
Parameter:
func
Return:
OK
other
Be
Applicable
In:
NEW8210
Notes:
Example:
6. Uart
Uart device file name: /dev/ttyS3
6.1. tty_property_config
Prototype:
int tty_property_config(int fd, int baudrate, int databits, int parity, int
stopbits, int flow)
Function:
Parameter:
ifd
baudrate
Baud rate
databits
Bits
parity
Parity
stopbits
Stop bits
flow
flow
Return
Support:
NEW8210/NEW8110P
Notes:
7. Network Program
Socket TCP/IP
Please refer linux network program documents
ssl
Please refer openssl documents.
8. File Access
Please refer linux c/c++ documents.