Professional Documents
Culture Documents
2
目录 Content
版本历史 Version Histor.y..........................................................................................................................................................
II
1 基本名词定义 Basic Noun Definition ...........................................................................................................................................
5
1.1 基本名字定义 Basic....N ...a..m ....e...D ...e ...f.i.n..i.t..i.o..n.............................................................................................
5
1.2 功能码表 Function code table .........................................................................................
5
2 通讯协议模板 Commun.i.c.a..t.i.o..n...p..r.o..t.o..c..o..l..t.e..m ...p..l.a..t.e.......................................................................................
6
2.1 通讯协议模板C ...o..m ...m ...u..n..ic..a..t.i.o..n...p..r.o..t.o..c..o..l..t.e..m ...p..l.a..t.e............................................................................
6
3 通讯协议规
范.C..o..m
...m
...u
..n
...ic..a..t.i.o..n...p..r.o..t.o..c..o..l..s..p..e..c.i.f.i.c..a..t.i.o..n................................................................................
7
3.1 登陆及响应.L.o ...g..in...a..n..d...r..e..s.p..o..n..s..e......................................................................................................
7
3.1.1 机柜上行报文.C ...a..b..i.n..e..t..U..p..l.i.n..k...M ...e..s.s..a..g..e......................................................................................
7
3.1.2 服务器下行报文..S..e..r.v..e..r..d..o..w ...n..l.in..k...m
...e..s..s..a..g..e...............................................................................
8
3.1.3 报文示例...M...e..s.s..a..g..e...e..x..a..m ...p..l.e......................................................................................................
8
3.2 心跳及响应.H ...e..a..r.t.b..e..a..t..a..n..d...R...e..s.p..o..n..s..e.............................................................................................
8
3.2.1 机柜上行报文.C..a..b..i.n..e..t..U ...p..l.in..k...M...e..s..s..a..g..e......................................................................................
8
3.2.2 服务器下行报文.S..e..r.v..e..r..d..o..w ...n..l.i.n..k..m...e..s..s..a..g..e................................................................................
9
3.2.3 报文示例.M ...e..s..s.a..g..e...e..x..a..m ...p..l.e........................................................................................................
9
3.3 查询机柜软件版本号.Q..u..e..r..y..c..a..b..i.n..e..t..s..o..f.t.w..a..r..e...v.e ..r..s.i.o..n....................................................................
9
3.3.1 服务器下行报文..S..e..r.v..e..r..d..o..w ...n..l.in..k...m
...e..s..s..a..g..e...............................................................................
9
3
3.3.2 机柜上行报文C ...a..b..i.n..e..t..U..p..l.i.n..k...M...e..s.s..a..g..e.....................................................................................
10
3.3.3 报文示例.M ...e..s..s..a..g..e...e..x..a..m ...p..le......................................................................................................
10
3.4 设置服务器地址及响应..S..e..t..s..e..r.v..e..r..a..d..d..r.e..s..s...a..n..d...r.e..s..p..o..n..s..e.........................................................
10
3.4.1 服务器下行报文.S..e ..r..v.e ..r...d..o..w..n..l.i.n..k...m...e..s..s.a..g..e..............................................................................
10
3.4.2 机柜上行报文.C ...a..b..i.n..e..t..U..p..l.i.n..k...M ...e..s.s..a..g..e....................................................................................
11
3.4.3 报文示例.M ...e..s..s..a..g..e...e..x..a..m ...p..le......................................................................................................
11
3.5 查询机柜库存及响应.I.n..q..u..ir..y..c..a..b..i.n..e..t..i.n..v..e..n..t.o..r.y...a..n..d...r.e..s..p..o..n..s.e ......................................................
11
3.5.1 服务器下行报文..S..e..r.v..e..r..d..o..w ...n..l.in..k...m...e..s..s..a..g..e.............................................................................
11
3.5.2 机柜上行报文...C..a..b..i.n..e..t..U ...p..l.in..k...M...e..s..s..a..g..e..................................................................................
12
3.5.3 报文示例..M ...e..s..s..a..g..e...e..x.a ..m...p..l.e.....................................................................................................
12
3.6 借充电宝..B..o..r.r..o..w...p..o..w...e..r..b..a..n..k.......................................................................................................
12
3.6.1 服务器下行报文.S..e ..r..v.e ..r...d..o..w..n..l.i.n..k...m...e..s..s.a..g..e..............................................................................
13
3.6.2 机柜上行报文.C ...a..b..in..e..t..U...p..l.i.n..k..M...e..s..s..a..g..e....................................................................................
13
M e ss a g e e x a m p le
3.6.3 报文示例.... .. .............. .. ... .. .......................................................................................................
13
3.7 还充电宝..R..e..t.u..r.n
...p..o..w...e..r..b..a..n..k........................................................................................................
14
3.7.1 机柜上行报文C ...a..b..i.n..e..t..U..p..l.i.n..k...M
...e..s.s..a..g..e.....................................................................................
14
Server downlink message
3.7.2 服务器下行报文......................................................................................................................
14
Message example
3.7.3 报文示例 ..................................................................................................................................
15
3.8 远程重启机柜..R ...e..m ...o..t.e...r.e..s..t.a..r.t..c..a..b..i.n..e..t........................................................................................
15
3.8.1 服务器下行报文.S ...e..r.v..e..r..d..o..w ...n..li.n..k...m...e..s..s..a..g..e.............................................................................
15
3.8.2 机柜上行报文..C ...a..b..i.n..e..t..U...p..li.n..k...M ...e..s..s..a..g..e..................................................................................
15
3.8.3 报文示例.M ...e..s..s..a..g..e...e..x..a..m...p..le......................................................................................................
16
3.9 远程升级..R..e..m...o..t.e...u..p..g..r..a..d..e...........................................................................................................
16
4
3.9.1 服务器下行报文..S ...e..r.v..e..r..d..o..w ...n..li.n..k...m...e..s..s..a..g..e............................................................................
16
3.9.2 机柜上行报文..C..a..b..i.n..e..t..U ...p..li.n..k...M...e..s..s..a..g..e...................................................................................
17
3.9.3 报文示例...M ...e..s.s..a..g..e...e..x..a..m ...p..l.e....................................................................................................
17 3.10 查询 query
ICCID.................................................................................................................................17
3.10.1 服务器下行报文..S ...e..r.v..e..r..d..o..w..n ..l.i.n..k...m
...e..s..s.a
..g
..e
.............................................................................
17
3.10.2 机柜上行报文.C ...a..b..in..e..t..U
...p..l.i.n..k..M ...e..s..s..a..g..e....................................................................................
17
3.10.3 报文示例.M ...e..s..s..a..g..e...e..x..a..m ...p..le......................................................................................................
18
3.11 查询服务器地址及响应 ..in..q..u..i.r.y...s..e..r.v..e..r..a..d..d..r.e..s..s...a..n..d...r.e..s..p..o..n..s..e................................................ 18
3.11.1 服务器下行报文S..e..r.v..e..r..d..o..w ...n..l.in..k...m
...e..s..s..a..g..e...............................................................................
18
3.11.2 机柜上行报文.C ...a..b..in..e..t..U
...p..l.i.n..k..M...e..s..s..a..g..e....................................................................................
18
3.11.3 报文示例.M
...e..s..s..a..g..e...e..x..a..m...p..le......................................................................................................
19
3.12 查询机柜库存充电宝数量..I.n..q..u..i.r.y...c..a..b..in..e..t..i.n..v..e..n..t.o..r.y...a..n..d...t.h..e...n..u..m ...b..e..r..o..f..p..o..w
...e..r..b..a..n..k..s..... 19
3.12.1 服务器下行报文S ...e..r.v..e..r..d..o..w..n..l.i.n..k...m...e..s..s.a..g..e...............................................................................
19
3.12.2 机柜上行报文..C ...a..b..in..e..t..U
...p..l.i.n..k..M...e..s..s..a..g..e...................................................................................
19
3.12.3 报文示例M
...e..s..s.a
...g..e...e..x.a..m ...p..l.e.......................................................................................................
20
3.13 强制弹出充电宝f.o..r..c.e..d...t.o...p..o..p...o..f..p..o..w ...e..r..b..a..n..k..s.............................................................................. 20
3.13.1 服务器下行报文S ...e..r.v..e..r..d..o..w...n..li.n..k...m
...e..s..s..a..g..e..............................................................................
20
3.13.2 机柜上行报文C ...a..b..in..e..t..U...p..l.i.n..k..M...e..s..s..a..g..e.....................................................................................
20
3.13.3 报文示例.M ...e..s..s..a..g..e...e..x..a..m ...p..le......................................................................................................
21
4 机柜唯一码 SN
C
...a..b..i.n..e..t..u..n..i.q..u..e...c.o..d..e...S ...N...................................................................................................
22
4.1 定义规则.D..e..f.i.n..i.t.i.o..n...r.u..l.e.................................................................................................................
22 4.2 设备类型 device type
...................................................................................................................................... 22
4.3 示例 ....a..m
e x ...p..l.e................................................................................................................................................ 22
5 终端唯一码
t e r m i n a l u n i q u e c o d e I D
ID .... .... ... .. .. .. .. ... .. ... ..............................................................................................................
23
5.1 定义规则 D ...e..f.i.n..it.i.o..n...r.u
..l.e..................................................................................................................
23
5
5.2 示例e..x..a..m
...p..l.e..................................................................................................................................
23
6
6
深圳市皓乐科技有限公司 技术文档
1 基本名词定义
Basic noun definition
1.2 功能码表
Function code table
名称 Item 功能码 function
code 备 注 Action
机柜登陆及响应 Cabinet login
and response 0x60 机柜-->服务器 Cabinet--->Server
心跳及响应 Heartbeat and response 0x61 机柜-->服务器 Cabinet--->Server
查询机柜软件版本号及响应 0x62
Query cabinet software version and respo nse
服务器-->机柜 Server--->Cabinet
PacketLen
数据包的长度
Uint16 2
Length of data packet
7
深圳市皓乐科技有限公司 技术文档
Comman 命令字
d Byte 1
CW (Command word)
VSN 协议版本号 1
Protocol version number
Byte
CheckSu 有效数据的字节异或 Byte 1
m The byte of valid data
Token 会话令牌 Session token Uint32 4
Payload 有效数据,不定长 Byte
Valid data, variable length
注意:所有的字符串数据内容都需要以 0x00 结束,字符串的长度包含 0x00。
Remark: All string data conten t needs to end with 0x00 and the length of the string contains 0x00
命令字,0x60
Command Byte 1
CW (Command word), 0x60
VSN 协议版本号 Byte 1
Protocol version number
CheckSum 有效数据的字节异或 Byte 1
The byte of valid data
Token 会话令牌 Session token Uint32 4
Rand 随机数 random number Uint32 4
8
深圳市皓乐科技有限公司 技术文档
注意:Token/Rand/ReqDataLen/ReqData 字段需要携带,但是并未对数据进行处理,
待后续添加。Token 字段标识当前时间,如果时间与当前时间相差超过 3 秒,则服务器会返回
登录失败,机柜时间错误,需要机柜去更新当前时间为北京时间。Rand 字段机柜带 4 个字节
的随机数。ReqData 字段为如下算法计算的值:AES(Rand+ruilianbox1818168),加密密码为:
zhuohua19199+Token
Remark: Token/Rand/Re。 qDataLen/ReqData the fields needs to be carried, but the data is not processed
and is to be added later. The token field identifies the current time. If the difference between the time and
the current time is more than 3 seconds, the server will return to login failure, the cabinet time is wrong,
and the cabinet needs to update the current time to Beijing time. Random number of 4 bytes in rand field
cabinet. The regdata field is the value calculated by the following algorithm:
AES(Rand+ruilianbox1818168), The encryption password is: zhuohua19199+Token
服务器 00 08 60 01 00 12 34 43 21 01
Server
复,机柜以此探测服务器是否工作正常。如果机柜连续几个心跳包没有收到回应则认为服务
器异常,此时机柜关闭之前的连接并启用新的连接进行通信。服务器也可根据心跳来判断机
柜是否通信正常。
After the successful login of the cabinet, the heartbeat message is sent to the server every 30 seconds, the server receives
the heartbeat message and responds as it is. According to this, the cabinet detects whether the server is working properly.
If the cabinet does not receive a response from several heartbeat packets in a row, the server is considered abnormal,
at which point the cabinet closes the previous connection and enables a new connection to communicate
The server can also determine whether the cabinet is in communication according to the heartbeat
深圳市皓乐科技有限公司 技术文档
机柜 Cabinet 00 07 61 01 00 11 22 33 44
服务器Server 00 07 61 01 00 11 22 33 44
10
深圳市皓乐科技有限公司 技术文档
机柜 Cabinet 00 07 62 01 33 00 00 12 34
服务器 Server 00 14 62 01 6a 11 22 33 44 00 0b 41 2e 30 39 2e 30 31 2e 30 36 00
机柜 Cabinet 00 07 63 01 00 11 22 33 44
12
深圳市皓乐科技有限公司 技术文档
13
深圳市皓乐科技有限公司 技术文档
机柜 Cabinet 00 11 65 01 74 11 22 33 44 03 01 52 4c 31 41 7c 00 00 64
14
深圳市皓乐科技有限公司 技术文档
机柜每次登陆成功后都会将每个槽位的充电宝逐个上报归还,避免客户在关机/无信号
等场景下归还充电宝后不结束订单的情况。
After each successful login of the cabinet, power bank of each slot will be reported and returned one by one
so as to avoid the situation that the customer will not end the deduction after returning power banks
in the scene of mobile phone shutdown or no signal.
15
深圳市皓乐科技有限公司 技术文档
服务器 Server 00 09 66 01 41 11 22 33 44 01 01
16
深圳市皓乐科技有限公司 技术文档
17
深圳市皓乐科技有限公司 技术文档
18
深圳市皓乐科技有限公司 技术文档
19
深圳市皓乐科技有限公司 技术文档
20
深圳市皓乐科技有限公司 技术文档
3.12 查询机柜库存充电宝数量 Query the quantity of power banks in the inventory of cabinets
可通过该命令来查询机柜当前库存充电宝数量。
The command can query the current inventory of power banks from the cabinets
1:成功 1: success
充电宝 ID power bank ID
TerminalID Byte 8
22
深圳市皓乐科技有限公司 技术文档
4.3 示 Exampl
例 e
客户代码 设备型号 设备子型号 批次年月 批次序列号
Customer Equipment model Batch year & month Batch serial number
code Equipment submodel
3 个字符 1 个字母 2 个数字 4 个数字 6 个数字 0~999999
3 c haracters 1 letter 2 numbers 4 numbers 6 numbers 0~999999
RL1 A 03 1711 000123
RL1A031711000123 充电柜类产品
RL1A031711000123 Charging cabinet products
23
深圳市皓乐科技有限公司 技术文档
5.2 示例 Example
客户代码 产品子型号 批次年 批次月 批次序列号
Customer Product Batch year Batch month Batch serial number
code Submodel
3 个大写字母 1 个大写字母 1 个数字 1 个十六进制数 6 位流水号
3 up percase letters 1 uppercase le tters 1 hexadecimal 6 bit serial number
1 number number
RL1 A 7(2017 年) B(11 月) 000123
7 (year of 2017) 8 ( Nov.)
RL1A7B000123 终端 ID
16 进制存储/传输内容:52 4C 31 41 7B 00 01 23
RL1A78000123Terminal ID
Hexadecimal storage/Transmission content: 52 4C 31 41 7B 00 01 23
24