PUSH SDK Communication Protocol V2.0.1
PUSH SDK Communication Protocol V2.0.1
Version:Ver. 2.0.1
Date:2011.8
1 Preface
1.1 Objective
This document presents the prototype design requirements of customers and developers so as to guide the firmware and
server development engineers through the software development.
1.3 Terminology
Upload: Refers to the sending of data from the equipment to the server.
Download: Refers to the downloading of data from the server to the equipment.
2 General Design
Considering that the equipment judges whether the server properly responds and synchronizes with the equipment time
according to the HTTP header, the server provides standard HTTP header information in returned data, for example:
HTTP/1.1 200 OK
Content-Type: text/plain
Date: Thu, 19 Feb 2008 15:52:10 GMT
C language formatting strings are commonly used for data formatting. All formulated formatting characters start with
Character “%”. The following formats are used in this document:
%d: Indicates a decimal integer.
%s: Indicates a character string.
%x or %X: Indicates an unsigned integer in hexadecimal format.
The inserted digit between "%" and the regulated formatting character indicates the maximum field width. For example,
%3d indicates a 3 decimal integer. If there are less than 3 digits, pad blank spaces to the leftmost side. %8s indicates an
8-character string. If there are less than 8 characters, pad blank spaces to the leftmost side. If the string length or
number of integer digits exceeds the field width, export the string in accordance with its actual length. Furthermore,
you can pad a string with zeros by adding a “0” before the field width item. For example, %04d indicates that when
there are less than 4 digits, zeros are padded on the leftmost to make the result a four-digit string. The default padding
place is on the left, but it can be on the right if you set the field width to a negative number.
2. Server Configuration Information Reading
The equipment must first read configuration information on the server, and then perform data communication with the
server as required.
The equipment sends:
GET /iclock/cdata?SN=xxxxxx&options=all&pushver=2.0.1&language=XX
Where xxxxxx indicates the equipment serial number (SN). 2.0.1 indicates current PUSH SDK library protocol release.
Older releases do not support the protocol version number. XX indicates the language ID. For details, see the firmware
language ID description as follows:
Identifier Description
s83 Chinese
69 English
… …
Where:
GET OPTION FROM: Followed by the SN of the corresponding equipment.
Stamp: Followed by the latest record timestamp tag of attendance records last uploaded by the equipment. (This field is
available for protocol firmware of previous versions but unavailable for those of updated versions.)
OpStamp: Followed by the latest operation record timestamp tag of personnel data last uploaded by the equipment.
(This field is available for protocol firmware of previous versions but unavailable for those of updated versions.)
PhotoStamp: Followed by the record timestamp tag of onsite verification photos last uploaded by the equipment. (This
field is available for protocol firmware of previous versions but unavailable for those of updated versions.)
ErrorDelay: Indicates the interval (unit: second) between attempts to reconnect to the server after a network connection
failure occurs.
Delay: Indicates the interval (unit: second) between attempts to connect to the server in the event of proper network
connection.
TransTimes: Indicates the time (time: minute in a 24-hour format) to regularly check and transfer data. A semicolon is
used to separate a maximum amount of ten time settings.
TransInterval: Indicates the interval (unit: minute) during which new data is checked and transferred.
TransFlag: Specifies which data IDs are to be transferred from the equipment to the server.
Return “1111000000" or other similar character array IDs if protocol firmware of previous versions are adopted.
Return ”0000000000” if previous Att2008 attendance software is adopted to upload attendance picture IDs only. New
Att2008 requires you to set the attendance picture ID uploading. 0 indicates that this type of data is forbidden to be
uploaded automatically. 1 Indicates that this type of data is allowed to be uploaded automatically. Table 2-1 lists the
IDs of data types that can be automatically uploaded by current hardware in a standard configuration state.
Return “TransData AttLog\tOpLog\tAttPhoto” or other similar string IDs if current version of firmware is adopted. If
you want to automatically upload data of a specified type, set relevant string IDs. Table 2-1 lists the IDs of data types
that can be automatically uploaded by current hardware in a standard configuration state.
To automatically upload users and fingerprints, you must set automatic operation log uploading
Table 2-1
Realtime: Indicates whether to realtime transfer new records. When Realtime=1, new data, if any, is transferred to the
server. When Realtime=0, the data is transferred at the time specified by TransTimes and TransInterval.
Encrypt: Indicates whether to encrypt the transferred data (Granding-specified encryption algorithm is used for
encrypted transfers). Return 0.
ServerVer: Indicates the server version and time (The time format is undetermined. The protocol firmware of previous
versions supports this parameter).
TableNameStamp: Indicates automatically uploaded data timestamps. TableName corresponds to the name of a table
and is consistent with the registered name of the firmware. Stamp is a fixed label. All timestamps of automatically
uploaded data tables must be returned to the equipment. The timestamp of each data table occupies a line by adopting
the following form:
TableNameStamp=XXXXX
For example, ATTLOGStamp=82983982 indicates the attendance record timestamp.
Table 2-2 lists the table names supported by the firmware in a standard configuration state (the table names must be
capitalized).
OPERLOG Operation log Y (including operation data of operation logs and records, for
example modified users and registered fingerprints)
Table 2-2
Relationship of TransTimes, TransInterval, and Realtime:
1) If Realtime is set to 1, immediately update the data regardless of whether the other two items are configured.
2) If TransInterval is larger than 0, upload the data at a specified time regardless of whether the other two items
are configured.
3) If TransTimes specifies the time. This setting is of no use if other two items are configured with a valid
value.
3. Data Updating
1. Upload the Attendance Record
The equipment sends:
Where xxxxxx indicates the equipment SN. ATTLOG indicates the attendance record table name of current firmware
(see Table 2-2) in a standard configuration state. 99999999 indicates the latest record timestamp of the data updated
this time. The server records the timestamp to ATTLOGStamp (see Table 2-2) for this equipment to easily return from
reading configuration information.
According to specific equipment configurations, a piece of record contains multiple fields separated with a tab \t. These
fields include:
PIN——User attendance number
TIME——Attendance time
STATUS——Attendance status (see Table 2-3)
VERIFY——Verification mode (see Table 2-3)
WORKCODE——Work code
RESERVED1——Reserved 1
RESERVED2——Reserved 2
Some attendance machines do not have the last three fields.
0——Clock in
1—— Clock out
0 ——Password 2—— Out
1 —— Fingerprint 3—— Return from an out
2 —— Card 4——Clock in for overtime
9 ——Others 5—— Clock out for overtime
8——Meal start
9—— Meal end
Table 2-3
The server returns:
OK
If the server returns an error page (HTTP 404 or 500) or fails to respond for a long time (overtime), this equipment
thinks that this data transfer fails and sends this data again.
2. Update the User Information and System Log
The equipment sends:
POST /iclock/cdata?SN=xxxxxx&table=OPERLOG&Stamp=99999999
USER PIN=982 Name=Richard Passwd=9822 Card=[09E4812202] Grp=1 TZ=
POST /iclock/cdata?SN=xxxxxx&table=OPERLOG&Stamp=99999999
FP PIN=982 FID=1 Valid=1 TMP=ocoRgZPRN8EwJNQxQTY......
Where xxxxxx indicates the equipment SN. OPERLOG indicates the operation log table name of current firmware (see
Table 2-2) in a standard configuration state. 99999999 indicates the latest operation record timestamp of the data
updated this time. The server records the timestamp to OPERLOGStamp (see Table 2-3) for this equipment to easily
return from reading configuration information.
Each record begins with a start tag indicating contents of this record followed by a space and field values of this record,
and ends with a line feed character “\n”. Between those file characters are a tab \t. Each field is generally assigned a
value by way of FieldName=Value. For details about specific formats and contents, see Table 2-4 and Table 2-5.
Operation log
Administrator ID
Time
OPLOG Administrator operation log Operation object 1 **
Operation object 2
Operation object 3
Operation object 4
Table 2-4
Description:
1. ID card number format: The square bracket [”,“] encloses either complete card number data in hexadecimal format
or the same number as displayed on the screen when you slide your card.
2. Four “operation objects” in the operation log: Indicate parameters relevant to an operation, as shown in Figure 2-5.
Operation
Operation Content Parameter Description
Code
7 Enroll a password.
14 Create an MF card.
15 Enroll an MF card.
16 Register an MF card.
22 Factory setting
29 Perform unlocking.
30 Enroll a user.
32 Duress alarm.
Table 2-5
The server returns:
OK
3. Update the Onsite Photo
If the attendance machine is configured with a camera to support onsite photo collection and uploading functions, it can
collect onsite photos during user authentication, and upload those photos to the server.
The equipment sends:
POST /iclock/cdata?SN=xxxxxx&table=ATTPHOTO&Stamp=99999999
PIN=iid
SN=xxxxxx
size=ssss
CMD=type\0BINARY IMAGE DATA
Where:
SN=xxxxxx: Indicates the equipment SN.
table=ATTPHOTO: Indicates the attendance photo table name of current firmware of standard configurations (see
Table 2-2).
PIN=iid: Indicates a unique image ID that supports two formats:
PIN=DATETIME-U: DATETIME indicates the user authentication time in YYYYMMDDHHNNSS format. U
indicates the user attendance number. This format indicates that user authentication passes.
PIN=DATETIME: Indicates that user authentication fails.
Stamp=285528079: Indicates the timestamp tag of this photo. The server records this timestamp to ATTPHOTOStamp
(see Table 2-2) for this equipment to easily return the read configuration information.
size=ssss: Indicates the photo file size.
CMD=type: Indicates the photo transmission type. CMD=uploadphoto indicates that the photo is transmitted through
the background. CMD=realupload indicates that the photo is transmitted in realtime.
\0: Indicates the C language string zero terminator.
BINARY IMAGE DATA: Indicates binary contents of onsite photos in .jpg format.
The server returns:
OK
GET /iclock/getrequest?SN=xxxxxx
C:ID1:CMD1
C:ID2:CMD2
C:ID3:CMD3
The server can return multiple commands at a time. The total number of returned commands must not exceed 200 and
the total lengths must not exceed 40 KByte. Those commands are divided into multiple lines, each beginning with a
“C:”. IDx indicates the SN of this command and is used to uniquely identify all commands. CMDx indicates specific
command contents and adopts a line feed character “\n” to mark the end of a command. The following sections
will describe the command set and command formats supported by this system.
After executing the command, the equipment returns the execution results by using the following requests:
POST /iclock/devicecmd?SN=xxxxxx
ID=iiii&Return=vvvv&CMD=ssss (This data appears along with the
POST command and is not appended to the URL request.) )
Where, xxxxxx indicates the equipment SN. POST contains returned results of the command execution . ID=iii
indicates the SN corresponding to a command. Return=vvvv indicates the command execution return code. CMD=ssss
indicates additional data returned after the command execution. When the command execution return code equals 0, the
command execution succeeds; if it equals -1, the command execution fails. For other values, see specific command
explanation.
Upon receipt of this request, the server thinks that the corresponding command is already executed and can be cleared
from the command buffer.
Note 1: All commands are not immediately transferred from the server to the equipment. To address the problem, the
system must send an R-CMD message to the UDP 4374 port of the equipment simultaneously when buffering data on
the server. This mechanism greatly accelerates the response speed of server command delivery. It, however, is only
applicable to situations where the server can directly connect to the equipment, for example, the equipment possesses
an IP address of the public network on the LAN or Internet.
Note 2: When the equipment requests for commands from the server for the first time or the equipment has new
registered users or fingerprints and new attendance records, the URL path format contains basic information items
including INFO=Hardware version number, number of registered users, fingerprints, and attendance records, and
attendance machine IP address.
GET http://host/iclock/getrequest?SN=xxxx&INFO=Ver
6.39 Apr 28 2008,2,0,0,192.168.1.201
ID=iiii
SN=xxxx
Return=vvvv
CMD=Shell
FILENAME=shellout.txt
Content=ssss
Where, vvvv is the return value of the system command and ssss is the output content (probably multi-line text) after
command execution.
2) When a system command is executed unsuccessfully or in incorrect format, the returned data format is
ID=iiii&Return=-1&CMD=Shell.
2. Check data update
Format:
CHECK
Function:
The equipment needs to read its configuration information from the server and then check whether any data is updated
on the equipment itself. If so, the equipment must send new data to the server instantly.
Return data:
The POST content is ID=iiii&SN=xxxx&Return=0&CMD=CHECK.
3. Clear data
Format 1:
CLEAR LOG
Function:
Clear attendance logs.
Format 2:
CLEAR DATA
Function:
Clear all data.
Format 3:
CLEAR PHOTO
Function:
Clear the onsite collected photos.
Return data:
The POST content is ID=iiii&Return=0.
4. Send equipment information to server
Format:
INFO
Return data:
If this command is executed successfully, the equipment POST content is:
ID=iiii&Return=0&CMD=INFO
OPTIONS
OPTIONS indicates equipment information and valid configuration items and contains multi-line text. Each line is in
the format “Item=Value”. These configuration items include:
Item Meaning
…… ……
Item Meaning
VOLUME Volume
256 + minute
The following time setting items all adopt
this format.
DSM
AADelay
Note: Some items are supported only by specific equipment. For example, AntiPassbackOn is supported only by some
devices with the advanced access control function; WIFI can be enabled only on the devices with built-in WiFi module.
Return data:
The POST content is ID=iiii&SN=xxxx&Return=0&CMD=SET OPTION.
6. Reboot
Format:
REBOOT
Function:
Reboot the equipment.
Note:
If the server returns several commands to the equipment, the REBOOT command must be the last one; otherwise, the
subsequent commands will be neglected.
7. Data command
Format:
DATA <SUBCMD>
<SUBCMD> includes the following subcommands:
USER tablename value: This subcommand is used to update or modify data in tablename table.
DEL_USER tablename key: This subcommand is used to delete data from tablename table according to key
QUERY tablename key: This subcommand is used to query tablename table data according to key
For table names, see Table 2-2.
1) Add or modify a user profile:
DATA USER PIN=
%d\tName=%s\tPri=%d\tPasswd=%s\tCard=[%02x%02x%02x%02x%02x]\tGrp=%d\tTZ=%d
For meanings of all fields, see the following:
DATA: Data adding or modification
USER: Data table name
PIN: A user ID
Name: A user name.
{This function may not be available for some models. Return value description:
0 indicates a successful registration. 2 indicates the user fingerprint already exists.
6 indicates registration cancellation
5 indicates the registered fingerprint already exists in fingerprint database (fingerprint repetition)
{4 indicates registration failure. Normally, this is either due to poor fingerprint quality or because you have input
incorrect fingerprints in three consecutive times.
10. Check and upload new data
Format:
LOG
Function:
Check whether there is new data. If there is, upload the new data to server immediately.
Return value description:
The return value of POST is ID=iii&Return=0&CMD=LOG
Output a unlocking signal
Format:
AC_UNLOCK
Function:
The access control equipment outputs a unlocking signal.
Return value description:
The return value of POST is ID=iii&Return=0&CMD=LOG
Cancel alarm signal output
Format:
AC_UNALARM
Function:
The access control equipment cancels alarm signal output.
Return value description:
The return value of POST is ID=iii&Return=0&CMD=LOG
Obtain files in the equipment
Format:
GetFile FilePath
Function:
The equipment sends system file FilePath to server. The file path is specified by FilePath.
Return value description:
POST return value:
ID=1234
SN=99999
FILENAME=FilePath
CMD=GetFile
Return=999
Content=ssss
Where,
ID=1234 is command ID
SN=999999 is equipment serial number
FILENAME=FilePath is file name
Return=999 indicates the size of file (bytes)
Content=ssss is file content ssss is either multi-line text or binary content.
14. Send files to equipment
Format:
PutFile URL FilePath
Function:
Download the file from the server, and save the downloaded file to a directory specified by FilePath (for a .tgz file, the
equipment will automatically untar it to a directory specified by FilePath. If the directory is not specified, it will untar
the tgz file under the /mnt/mtdblock directory. For files of other formats, the file path and file name must be
specified).The file must be downloaded over HTTP from the server, and the URL for the file must be given.
If the URL starts with http: //, the equipment will deem it as a complete URL address. Otherwise, the /iclock/ of the
server will be added to a specified URL by the equipment. Fro example:
PutFile file/fw/X938/main.tgz main.tgz
or
PutFile file/fw/X938/main.tgz
Download main.tgz from http://server/iclock/file/fw/X938/main.tgz, and untar it to the /mnt/mtdblock directory.
PutFile file/fw/X938/main.tgz /mnt/
Download main.tgz from http://server/iclock/file/fw/X938/main.tgz, and untar it to the /mnt/ directory.
PutFile file/fw/X938/ssruser.dat /mnt/mtdblock/ssruser.dat
Download ssruser.dat from http://server/iclock/file/fw/X938/ssruser.dat, and save it to the /mnt/mtdblock/ssruser.dat
directory.
Return value description:
Return value is the size of downloaded file (bytes).