websocket+json protocol2.4
websocket+json protocol2.4
cloud solution
WEBSOCKET+JSON
protocol
cloud solution protocol
Revision history
Catalog
Note:.................................................................................................................................................4
1)Terminal active send data to server.................................................................................................4
1. Register............................................................................................................................4
2. Send the logs................................................................................................................... 5
3. Send user information.....................................................................................................6
2)Server active push message to terminal......................................................................................... 7
1. Get user list..................................................................................................................... 7
2. Get user information.......................................................................................................9
3. Download user information.......................................................................................... 11
4. Delete user information................................................................................................ 12
5. Get user name............................................................................................................... 12
6. Set user name................................................................................................................13
7. Enable user.................................................................................................................... 13
8. Disable user................................................................................................................... 14
9. Clean all users................................................................................................................14
10. Get new logs.............................................................................................................. 15
11. Get all logs................................................................................................................. 16
12. Clean all logs.............................................................................................................. 18
13. Initialize system......................................................................................................... 19
14. Reboot....................................................................................................................... 19
15. Clean all administrators.............................................................................................19
16. settime.......................................................................................................................20
17. Set terminal parameter............................................................................................. 20
18. Get terminal parameter............................................................................................ 22
19. Open door..................................................................................................................23
20. Set the access paramete........................................................................................... 23
21. Get the access parameter......................................................................................... 26
22. Get the user access parameter................................................................................. 28
23. Set the users access parameter.................................................................................28
cloud solution protocol
Note:
1. Use websocket protocol to communication,the websocket version is RFC6455 13,The default
listen port is 7788,no TLS encrypt.
2. The data format use Json.you can use javascript to Serializer and Deserialize very easy.
3. All the key value of json use lower-char.the name or all chinese char use UTF8 encoded.
4. About backupnum:0~9:fingerprint 10:password; 11:rfid card. 20-27:static face ,30-37 i:parlm,
50 :photo(format is base64)One user can have 10 fingerprints and one password and one
one rfid card.
1. Register
}
Server response message:
Success:
{
"ret":"reg", //command
"result":true,
"cloudtime":"2016-03-25 13:49:30”//server now time
“nosenduser”:true, //tell the terminal ,aoto send the new user message or not
}
Fail:
{
"ret":"reg",
"result":false,
"reason":”did not reg”, //this message will display on screen
}
}
cloud solution protocol
]
}
Server response message:
Success:
{
"ret":"sendlog",
"result":true,
“count”:2, //add 2019-03-27
“logindex”:10, //add 2019-03-27
"cloudtime":"2016-03-25 13:49:30",
“access”:1, //1 for open the door ,0 can not open the door ,extern function,
"message":"message" //When AI face is set to Servermode, return device interface
information
}
Fail:
{
"ret":"sendlog",
"result":false,
"reason":1
}
Note: about the logs
When the enrollid != 0 then :
Mode: 0 fp, 1,card 2,password : it means the user use the fingerprint/card/password to
access
Inout: //0 in 1:out :it means the user use the master machine or the child machine to
access(the access controler can add a child machine to work.
Normal the master machine inside the door and the child
machine ouside the door)
Event: 0~16 : customization ,must work with the software, some machine have the key
(F1~F4).when press F1 key and verifyed ok ,the value is
1.and the software can set this key as onduty
When the enrollid = 0 then
Mode: 0;
Inout : 1:
Enent: the status or the event of the door.
typedef enum
{
UI_MGLOG_CLOSED,//door is closed
UI_MGLOG_OPENED, //dorr is opened
UI_MGLOG_HAND_OPEN, //use exit button to open the door
UI_MGLOG_PROG_OPEN, //use software to open the door
UI_MGLOG_PROG_CLOSE, //use software to close the door
UI_MGLOG_ILLEGAL_OPEN, //the door is illegal opend
UI_MGLOG_ILLEGAL_REMOVE, //the machine is removed
cloud solution protocol
Note:When use keypad to add new user,and then send this message to server
Terminal send the message:
Fingerprint:
{
"cmd":"senduser",
“enrollid”:1,
“name”:”chingzou”,
“backupnum”:0, //0~9 fingerprint ,20-27 is static face,30-37 is parlm,50 is photo
“admin”:0,
“record”,”kajgksjgaglas” //the string length less then 1620 for THbio3.0 and less 1024 for
THbio1.0
}
Rfid card:
{
"cmd":"senduser",
“enrollid”:1,
“name”:”chingzou”,
“backupnum”:11,
“admin”:0,
“record”,2352253
}
password:
{
"cmd":"senduser",
“enrollid”:1,
“name”:”chingzou”,
“backupnum”:10,
“admin”:0,
“record”,12345678 //max 8 digit
}
Server response message:
Success:
{
"ret":”senduser ",
"result":true,
"cloudtime":"2016-03-25 13:49:30"
}
Fail:
{
"ret":”senduser ",
cloud solution protocol
"result":false,
"reason":1
}
"cmd":"getuserlist",
“stn”:false//response package,should set to false
}
Terminal send the second package again:
{
"ret":"getuserlist",
"result":true,
"count ":40, //1~40
“from”:40,
“to”:79,
“record ":[
{
“enrollid ":1234,
"admin ":0,
"backupnum ":0
},
{
“enrollid ":2345,
"admin ":1,
"backupnum ":0
},
{
“enrollid ":5677,
"admin ":0,
"backupnum ":10
},
......
]
}
........
Whe users is empty :the machine return:
{
"ret":"getuserlist",
"result":true,
"count ":0,
“from”:0,
“to”:0,
“record ":[]
}
Fail:
{
"ret":"getuserlist",
"result":false,
"reason":1
cloud solution protocol
Fingerprint:
{
"cmd":" getuserinfo "
"enrollid ":1,
"backupnum ":0
}
Terminal response message:
success:
{
"ret":" getuserinfo ",
"result":true,
“enrollid":1,
“name”:”chingzou”,
“backupnum":0,
“admin":0,
"record":"aabbccddeeffggddssiifdjdkjfkjdsjlkjal",
}
Fail:
{
"ret":”getuserinfo ",
"result":false,
"reason":1
}
Photo:
{
"cmd":" getuserinfo "
"enrollid ":1,
"backupnum ":50
}
Terminal response message:
success:
{
"ret":" getuserinfo ",
"result":true,
“enrollid":1,
“name”:”chingzou”,
“backupnum":50,
“admin":0,
"record":"aabbccddeeffggddssiifdjdkjfkjdsjlkjal",//Base64
}
Fail:
cloud solution protocol
{
"ret":”getuserinfo ",
"result":false,
"reason":1
}
Rfid card:
{
"cmd":”getuserinfo "
"enrollid ":1,
"backupnum ":11
}
Terminal response message:
Success:
{
"ret":”getuserinfo ",
"result":true,
“enrollid":1,
“name”:”chingzou”,
“backupnum":11,
“admin":0,
"record":23532253
}
Fail:
{
"ret":”getuserinfo ",
"result":false,
"reason":1
}
Password:
{
"cmd":”getuserinfo "
"enrollid ":1,
"backupnum ":10
}
Terminal response message:
Success:
{
"ret":”getuserinfo ",
"result":true,
“enrollid":1,
“name”:”chingzou”,
“backupnum":10,
“admin":0,
cloud solution protocol
"record":23532253
}
Fail:
{
"ret":”getuserinfo ",
"result":false,
"reason":1
}
Fingerprint:
Server send message:
{
"cmd":"setuserinfo",
"enrollid":1,
“name”:”chingzou”,
"backupnum",0,
"admin":0,
"record":"aabbccddeeffggddssiifdjdkjfkjdsjlkjalflsgsadg"
}
Photo:
Server send message:
{
"cmd":"setuserinfo",
"enrollid":1,
“name”:”chingzou”,
"backupnum",50,
"admin":0,
"record":"aabbccddeeffggddssiifdjdkjfkjdsjlkjalflsgsadg"//Base64
}
Password:
{
"cmd":"setuserinfo",
"enrollid":1,
“name”:”chingzou”,
"backupnum",10,
"admin":0,
"record":12345678
}
Rfid card:
{
"cmd":"setuserinfo",
"enrollid":1,
“name”:”chingzou”,
cloud solution protocol
"backupnum",11,
"admin":0,
"record":2352253
}
2、Terminal response message:
Success:
{
"ret":"setuserinfo ",
"result":true
}
Fail:
{
"ret":"setuserinfo ",
"result":false,
"reason":1
}
{
"ret":"getusername",
"result":true,
"record":"chingzou”//utf8 or ascii
}
Fail:
{
"ret":"getusername",
"result":false,
"reason":1
}
7. Enable user
8. Disable user
“record ":[]
}
Fail:
{
"ret":"getnewlog ",
"result":false
"reason":1
}
"cmd":"getalllog",
“stn”:false
}
Terminal send the second package:
{
"ret":"getalllog",
"result":true,
"count":1000,
“from”:50,
“to”:99,
"record":[
{
"enrollid":111,
"time":"2016-03-25 13:49:30",
"mode":0, //0 fp 1:card 2:pwd
"inout":0, //0 in 1:out
"event":0
}
{
"enrollid":112,
“time ":"2016-03-25 13:49:30",
"mode":0, //0 fp 1:card 2:pwd
"inout":0, //0 in 1:out
"event":1
}
......
]
}
Whe newlog is empty :the machine return:
{
"ret":"getalllog ",
"result":true,
"count ":0,
“from”:0,
“to”:0,
“record ":[]
}
Fail:
{
"ret":"getalllog",
"result":false
"reason":1
}
cloud solution protocol
Note: intialize system will delete all users and all logs,and the setting still not change.
Server send message:
{
"cmd":"initsys"
}
Terminal response message:
Success:
{
"ret":" initsys",
"result":true
}
Fail:
{
"ret":" initsys ",
"result":false
"reason":1
}
14. Reboot
16. settime
“reverifytime”:0
}
Fail:
{
"ret":" getdevinfo ",
"result":false
"reason":1
}
Note:setting the access all common paramete,the items are option, if your don’t want to set this
item you can ignore them.the command so complex,ha ha ha!!!
Server send message:
{
"cmd":"setdevlock",
“opendelay”:5, //open door delay
“doorsensor”:0, //the door sensor type: 0:disable 1:NC(normal close) 2:NO(normal open)
“alarmdelay”:0, //door sensor alarm:when open the door and not close,the time more then
1~255 minute the access will alarm. 0:disable.
“threat”:0, //theat alarm: 0:disable 1.open the door and alarm 2.just alarm 3.just open the door
“InputAlarm”:0, //0.disable 1,alarm1 output 2.alarm2 output
“antpass”: 0 ,//0.disable 1,host machine is inside.2.host machine is outside
“interlock”:0 ,//0:disable.1.enable
cloud solution protocol
“mutiopen”:0, //0:disable;1~4:must 1~4 people press finger at the same time to open the door
“tryalarm”:0, //0:disable 1~10:when try press the wrong finger 1~10 times ,the access will alarm
“tamper”:0, //0:disable 1.enable
“wgformat”:0, //weigand format 0 :26 1:34
“wgoutput”: 0, //weigand output data:0,:enroll id ;1:1+enroll id ;2:device id+enroll id
“cardoutput”:0, //if this user register a rfid card,they press finger ,weigand directly output rfid
card number;0:disable;1:enable;
“dayzone”:[ //8 groups at most. one group means one day,and have 5 sections per day at
most.you can change one or more sections or groups as you want,and ignore the
remain
{
“day”: [
{“section”:”06:00~07:00”},
{“section”:”08:30~12:00”},
{“section”:”13:00~17:00”},
{“section”:”18:00~21:00”},
{“section”:”22:00~23:30”},
]
},
{
“day”: [
{“section”:”00:01~23:59”},
]
},
……..
],
“weekzone”:[ //8 groups at most,one group means one week,you can change one or more
groups what you want and ignore the remain
{“week”:[
{“day”:1}, //monday
{“day”:1}, //tuesday
{“day”:1}, //wednesday
{“day”:1}, //thursday
{“day”:1}, //friday
{“day”:2}, //saturday
{“day”:2}, //sunday
]
},
{“week”:[ //the second weed zone
{“day”:1},
{“day”:1},
{“day”:1},
{“day”:1},
{“day”:1},
cloud solution protocol
{“day”:2},
{“day”:2},
]
},
……..
],
“lockgroup”:[
{“group”:1234},
{“group”:126},
{“group”:348},
{“group”:139},
{“group”:15}
]
}
Terminal response message:
Success:
{
"ret":" setdevlock ",
"result":true
}
Fail:
{
"ret":" setdevlock ",
"result":false
"reason":1
}
Tips:1, if you just have one dayzone and one weekzone,you can send the short message like this:
{“cmd”:”setdevlock”,
“dayzone”:[ {“day”,[ {“section”:”07:00~18:00”}]}],
“weekzone”:[ {“week”,[ {“day”:1}]}]
}
2,the relationship dayzone and weekzone like this:
(user access parameter of weekzone =3)-> weekzone[3]-> Monday[1]->dayzone[1]->sections
->Tuesday[2]->dayzone[2]->sections
If(day zone [1] section is ”00:01~23:59”) and (day zone [2] section is ”00:00~00:00”)
If this user press finger, first check his access parameter of weekzone is 3.
And then find the weekzone 3 , and find today is Monday, and then find Monday
setting is dayzone 1 .
Continue find the dayzone 1, finding this dayzone just have one section:00:01~23:59
It means all day can access,then the the last action: open the door.
If today is Tuesday: oh!! this dayzone section is”00:00~00:00” allday can not access.
So the last action: refuse this user access the door.
Then this user Monday can open the door ,but Tuesday can not open the door allday.
Hope you can understand.or you can take a machine byhand,try and try.
cloud solution protocol
{“section”:”13:00~17:00”},
{“section”:”18:00~21:00”},
{“section”:”22:00~23:30”},
]
},
{
“day”: [
{“section”:”00:01~23:59”},
]
},
……..
],
“weekzone”:[
{“week”:[
{“day”:1},
{“day”:1},
{“day”:1},
{“day”:1},
{“day”:1},
{“day”:2},
{“day”:2},
]
},
{“week”:[
{“day”:1},
{“day”:1},
{“day”:1},
{“day”:1},
{“day”:1},
{“day”:2},
{“day”:2},
]
},
……..
],
“lockgroup”:[
{“group”:1234},
{“group”:126},
{“group”:348},
{“group”:139},
{“group”:15}
]
}
Fail:
cloud solution protocol
{
"ret":" setdevlock ",
"result":false
"reason":1
}
“group”:1,
“starttime”:”2016-03-25 01:00:00”,
“endtime”: ”2099-03-25 23:59:00”
},
{
“enrollid”:2,
“weekzone”:1,
“group”:1,
“starttime”:”2016-03-25 01:00:00”,
“endtime”: ”2099-03-25 23:59:00”
},
……..
]
}
Terminal response message:
Success:
{
"ret":" setuserlock ",
"result":true
}
Fail:
{
"ret":" setuserlock ",
"result":false
"reason":1
}
26. gettime
“enrollid”:10,
"username":"tom",
""messagel":"ok"
}
"endday": "02-07",
"shift": 0,
"dayzone": 0
},
{
"name": "holiday3",
"startday": "05-01",
"endday": "05-03",
"shift": 0,
"dayzone": 0
}
]
}
{
"ret": "setholiday",
"sn": "AI07F1234567",
"result": true
}
Fail:
{
"ret":”setholiday ",
"result":false,
"reason":1
}