Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
new-socketemulator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李远洪
new-socketemulator
Commits
419a5b42
Commit
419a5b42
authored
Feb 05, 2020
by
李远洪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成终端鉴权消息开发
parent
a5c34dcc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
2 deletions
+70
-2
lib/protocol/message/TerminalAuthenticate_msg.py
lib/protocol/message/TerminalAuthenticate_msg.py
+64
-0
lib/protocol/message/TerminalRegister_msg.py
lib/protocol/message/TerminalRegister_msg.py
+3
-1
lib/socket/messageTest.py
lib/socket/messageTest.py
+3
-1
No files found.
lib/protocol/message/TerminalAuthenticate_msg.py
0 → 100644
View file @
419a5b42
#encoding:utf-8
'''
定义终端鉴权消息
'''
from
lib.protocol.message.MessageBase
import
MessageBase
class
TerminalAuthenticate_msg
(
MessageBase
):
def
__init__
(
self
):
super
()
.
__init__
()
#不执行该方法,无法使用父类里面定义的属性
pass
#######################################################
# 生成一条完整的消息
#######################################################
def
generateMsg
(
self
):
msg
=
""
msgHeader
=
self
.
getMsgHeader
()
msgBody
=
self
.
getMsgBody
()
checkCode
=
self
.
getCheckCode
(
msgHeader
+
msgBody
)
msg
=
msg
+
self
.
IDENTIFY
info
=
msgHeader
+
msgBody
+
checkCode
info
=
self
.
replace7e7d
(
info
)
msg
=
msg
+
info
msg
=
msg
+
self
.
IDENTIFY
return
msg
#######################################################
# 获取消息体
#######################################################
def
getMsgBody
(
self
):
msg
=
""
#鉴权码
authenticateCode
=
str
(
"asuyx7"
.
encode
(
"gbk"
))
authenticateCode
=
authenticateCode
[
2
:
len
(
authenticateCode
)
-
1
]
authenticateCode
=
self
.
str2Hex
(
authenticateCode
)
msg
=
authenticateCode
return
msg
#######################################################
# 获取消息头
#######################################################
def
getMsgHeader
(
self
):
# msgID = self.int2hexStringByBytes(102,2) #消息id
msgID
=
"0102"
msgBodyProperty
=
self
.
getMsgBodyProperty
(
len
(
self
.
getMsgBody
()))
#消息体属性
phoneNum
=
self
.
int2BCD
(
13146201119
)
#终端手机号
msgWaterCode
=
self
.
int2BCD
(
1
)
#消息流水号
subPkgContent
=
""
#消息包封装项
data
=
msgID
+
msgBodyProperty
+
phoneNum
+
msgWaterCode
+
subPkgContent
return
data
#获取消息体属性
def
getMsgBodyProperty
(
self
,
msgBodyLen
=
128
,
encryptionType
=
0
,
subPkg
=
0
):
if
msgBodyLen
>=
512
:
raise
RuntimeError
(
'消息体长度超长!'
)
msgBodyLen
=
msgBodyLen
#消息体长度
encryptionType
=
encryptionType
#加密方式
subPkg
=
subPkg
#分包
retain
=
0
#保留位
data
=
msgBodyLen
+
encryptionType
+
subPkg
+
retain
dataHex
=
self
.
int2hexStringByBytes
(
data
,
2
)
return
dataHex
\ No newline at end of file
lib/protocol/message/TerminalRegister_msg.py
View file @
419a5b42
...
@@ -42,7 +42,9 @@ class TerminalRegister_msg(MessageBase):
...
@@ -42,7 +42,9 @@ class TerminalRegister_msg(MessageBase):
#车牌颜色 (车牌颜色,按照 JT/T415-2006 的 5.4.12。未上牌时,取值 为 0) 1:蓝色 2:黄色 3:黑色 4:白色 9:其他
#车牌颜色 (车牌颜色,按照 JT/T415-2006 的 5.4.12。未上牌时,取值 为 0) 1:蓝色 2:黄色 3:黑色 4:白色 9:其他
licencePlateColor
=
self
.
int2hexStringByBytes
(
1
)
licencePlateColor
=
self
.
int2hexStringByBytes
(
1
)
#车辆标识 (车牌颜色为 0 时,表示车辆 VIN;否则,表示公安交通管理 部门颁发的机动车号牌)
#车辆标识 (车牌颜色为 0 时,表示车辆 VIN;否则,表示公安交通管理 部门颁发的机动车号牌)
carSign
=
self
.
str2Hex
(
str
(
"渝B23CX"
.
encode
(
"gbk"
)))
carSign
=
str
(
"渝B23CX"
.
encode
(
"gbk"
))
carSign
=
carSign
[
2
:
len
(
carSign
)
-
1
]
carSign
=
self
.
str2Hex
(
carSign
)
msg
=
msg
+
provinceId
+
manufacturerId
+
terminalType
+
terminalId
+
licencePlateColor
+
carSign
msg
=
msg
+
provinceId
+
manufacturerId
+
terminalType
+
terminalId
+
licencePlateColor
+
carSign
return
msg
return
msg
...
...
lib/socket/messageTest.py
View file @
419a5b42
...
@@ -4,6 +4,7 @@ import socket
...
@@ -4,6 +4,7 @@ import socket
from
lib.protocol.message.Location_msg
import
Location_msg
from
lib.protocol.message.Location_msg
import
Location_msg
from
lib.protocol.message.MessageBase
import
MessageBase
from
lib.protocol.message.MessageBase
import
MessageBase
from
lib.protocol.message.TerminalAuthenticate_msg
import
TerminalAuthenticate_msg
from
lib.protocol.message.TerminalHeartbeat_msg
import
TerminalHeartbeat_msg
from
lib.protocol.message.TerminalHeartbeat_msg
import
TerminalHeartbeat_msg
from
lib.protocol.message.TerminalRegister_msg
import
TerminalRegister_msg
from
lib.protocol.message.TerminalRegister_msg
import
TerminalRegister_msg
from
lib.protocol.message.data.TerminalCancle_msg
import
TerminalCancle_msg
from
lib.protocol.message.data.TerminalCancle_msg
import
TerminalCancle_msg
...
@@ -15,7 +16,8 @@ port = 9001
...
@@ -15,7 +16,8 @@ port = 9001
# msg = MessageBase().generateMsg()
# msg = MessageBase().generateMsg()
# msg = TerminalHeartbeat_msg().generateMsg() #终端心跳
# msg = TerminalHeartbeat_msg().generateMsg() #终端心跳
# msg = TerminalRegister_msg().generateMsg() #终端注册
# msg = TerminalRegister_msg().generateMsg() #终端注册
msg
=
TerminalCancle_msg
()
.
generateMsg
()
#终端注销
# msg = TerminalCancle_msg().generateMsg() #终端注销
msg
=
TerminalAuthenticate_msg
()
.
generateMsg
()
#终端鉴权
# msg = Location_msg().generateMsg() #位置信息汇报
# msg = Location_msg().generateMsg() #位置信息汇报
print
(
msg
)
print
(
msg
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment