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
edd1c072
Commit
edd1c072
authored
Feb 14, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
平台升级数据包应答消息完成
parent
8a781e7c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
1 deletion
+103
-1
lib/protocol/message/PlateformUpdateRes_msg.py
lib/protocol/message/PlateformUpdateRes_msg.py
+100
-0
lib/socket/messageTest.py
lib/socket/messageTest.py
+3
-1
No files found.
lib/protocol/message/PlateformUpdateRes_msg.py
0 → 100644
View file @
edd1c072
#encoding:utf-8
'''
定义终端心跳消息
'''
from
lib.protocol.message.MessageBase
import
MessageBase
class
PlateformUpdateRes_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
generateMsg_GUI
(
self
,
msgID
=
"8FF1"
,
phoneNum
=
"13146201119"
,
msgWaterCode
=
1
,
encryptionType
=
0
,
subPkg
=
0
):
msg
=
""
msgHeader
=
self
.
getMsgHeader_GUI
(
msgID
,
phoneNum
,
msgWaterCode
,
encryptionType
,
subPkg
)
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
=
""
firmwareVersionLen
=
self
.
int2hexStringByBytes
(
12
)
#固件版本号长度
firmwareVersion
=
self
.
str2Hex
(
"ver_12.34.10"
)
#固件版本号
upgradeFileSize
=
self
.
int2hexStringByBytes
(
2048000
,
4
)
#升级文件总大小
upgradeFileCheck
=
self
.
int2hexStringByBytes
(
205000
,
4
)
#升级文件总校验
offsetAddress
=
self
.
int2hexStringByBytes
(
48000
,
4
)
#偏移量地址
upgradePkgContent
=
self
.
str2Hex
(
"upgrade_content_11.22.33"
)
#升级数据包内容
msg
=
msg
+
firmwareVersionLen
+
firmwareVersion
+
upgradeFileSize
+
upgradeFileCheck
+
offsetAddress
+
upgradePkgContent
return
msg
#######################################################
# 获取消息头
#######################################################
def
getMsgHeader
(
self
):
# msgID = self.int2hexStringByBytes(102,2) #消息id
msgID
=
"8FF1"
subPkg
=
0
msgBodyProperty
=
self
.
getMsgBodyProperty
(
msgBodyLen
=
int
(
len
(
self
.
getMsgBody
())
/
2
),
subPkg
=
subPkg
)
#消息体属性
phoneNum
=
self
.
int2BCD
(
13146201119
)
#终端手机号
msgWaterCode
=
self
.
int2hexStringByBytes
(
1
,
2
)
#消息流水号
if
subPkg
!=
8192
:
subPkgContent
=
""
#消息包封装项
else
:
subPkgContent
=
self
.
getMsgPackage
()
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
#获取消息体属性,针对图形界面,可传递参数
def
getMsgBodyProperty_GUI
(
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
if
__name__
==
"__main__"
:
print
(
TerminalHeartbeat_msg
()
.
generateMsg
())
print
(
TerminalHeartbeat_msg
()
.
getMsgBodyProperty
())
\ No newline at end of file
lib/socket/messageTest.py
View file @
edd1c072
...
...
@@ -5,6 +5,7 @@ import socket
from
lib.protocol.message.DataUpstreamTransport_msg
import
DataUpstreamTransport_msg
from
lib.protocol.message.LocationDataBatchUpdate_msg
import
LocationDataBatchUpdate_msg
from
lib.protocol.message.Location_msg
import
Location_msg
from
lib.protocol.message.PlateformUpdateRes_msg
import
PlateformUpdateRes_msg
from
lib.protocol.message.TerminalAuthenticate_msg
import
TerminalAuthenticate_msg
from
lib.protocol.message.TerminalCommonMsgRes_msg
import
TerminalCommonMsgRes_msg
from
lib.protocol.message.TerminalHeartbeat_msg
import
TerminalHeartbeat_msg
...
...
@@ -30,7 +31,8 @@ port = 9001
# msg = DataUpstreamTransport_msg().generateMsg() #数据上行透传消息
# msg = TerminalUpdataResult_msg().generateMsg() #终端升级结果通知
# msg = LocationDataBatchUpdate_msg().generateMsg() #定位数据批量上传
msg
=
TextInfoUpload_msg
()
.
generateMsg
()
#文本信息上传
# msg = TextInfoUpload_msg().generateMsg() #文本信息上传
msg
=
PlateformUpdateRes_msg
()
.
generateMsg
()
#平台升级数据包应答
#发送单条消息
def
sendSingleMsg
(
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