Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue_django_test
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
周田
vue_django_test
Commits
02be7add
Commit
02be7add
authored
Aug 25, 2023
by
周田
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:接收从 device 过来的数据
parent
64744a23
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
7 deletions
+12
-7
Device_datastruct_pb2.py
mqtt/auto_generate_python/Device_datastruct_pb2.py
+1
-1
mqtt.py
mqtt/mqtt.py
+7
-4
utils.py
mqtt/utils.py
+1
-1
settings.py
vue_django/settings.py
+3
-1
No files found.
mqtt/auto_generate_python/Device_datastruct_pb2.py
View file @
02be7add
...
@@ -13,7 +13,7 @@ _sym_db = _symbol_database.Default()
...
@@ -13,7 +13,7 @@ _sym_db = _symbol_database.Default()
from
google.protobuf
import
any_pb2
as
google_dot_protobuf_dot_any__pb2
from
google.protobuf
import
any_pb2
as
google_dot_protobuf_dot_any__pb2
from
google.protobuf
import
timestamp_pb2
as
google_dot_protobuf_dot_timestamp__pb2
from
google.protobuf
import
timestamp_pb2
as
google_dot_protobuf_dot_timestamp__pb2
import
TDSCmd_pb2
as
TDSCmd_
_pb2
from
.
import
TDSCmd_pb2
as
TDSCmd
_pb2
DESCRIPTOR
=
_descriptor_pool
.
Default
()
.
AddSerializedFile
(
b
'
\n\x17\x44\x65
vice_datastruct.proto
\x1a\x19
google/protobuf/any.proto
\x1a\x1f
google/protobuf/timestamp.proto
\x1a\x0c
TDSCmd.proto
\"
o
\n\x12
Proto3DeviceAllCMD
\x12\n\n\x02
ID
\x18\x01
\x01
(
\x05\x12\x10\n\x08\x44\x45
V_NAME
\x18\x02
\x01
(
\t\x12\x15\n\r
PROTOCOL_NAME
\x18\x03
\x01
(
\t\x12
$
\n\x04\x43
MDs
\x18\x04
\x03
(
\x0b\x32\x16
.Proto3DeviceCMDDefine
\"
~
\n\x15
Proto3DeviceCMDDefine
\x12\x10\n\x08\x43
MD_NAME
\x18\x01
\x01
(
\t\x12\x0e\n\x06\x45
NCODE
\x18\x02
\x01
(
\t\x12\x1f\n\x17
Timing_CMD_Cycle_period
\x18\x03
\x01
(
\x05\x12\"\n\x06\x66\x65
lids
\x18\x04
\x03
(
\x0b\x32\x12
.Proto3CMDFieldCfg
\"\x9d\x01\n\x17
Proto3ForReloadProtocol
\x12\x10\n\x08\x64\x65
v_name
\x18\x01
\x01
(
\t\x12\x10\n\x08\x63
md_name
\x18\x02
\x01
(
\t\x12
-
\n\x05\x66
lags
\x18\x03
\x01
(
\x0e\x32\x1e
.Proto3ForReloadProtocol.Flags
\"
/
\n\x05\x46
lags
\x12\x13\n\x0f
NORMAL_DISPATCH
\x10\x00\x12\x11\n\r
FULL_DISPATCH
\x10\x01\"\xa8\x01\n\x19
Proto3TableDevCmdNamePoll
\x12\n\n\x02
id
\x18\x01
\x01
(
\x05\x12\x15\n\r
protocol_name
\x18\x02
\x01
(
\t\x12\x10\n\x08\x63
md_name
\x18\x03
\x01
(
\t\x12\x10\n\x08\x63
md_type
\x18\x04
\x01
(
\t\x12\x0e\n\x06\x65
ncode
\x18\x05
\x01
(
\t\x12\x1f\n\x17
timing_cmd_cycle_period
\x18\x06
\x01
(
\x05\x12\x13\n\x0b\x63
md_explain
\x18\x07
\x01
(
\t\"\x85\x03\n\x1a
Proto3TableAllDevCmdDefine
\x12\n\n\x02
id
\x18\x01
\x01
(
\x05\x12\x10\n\x08\x63
md_name
\x18\x02
\x01
(
\t\x12\x10\n\x08\x63
md_type
\x18\x03
\x01
(
\t\x12\x12\n\n
fieldindex
\x18\x04
\x01
(
\x05\x12\x11\n\t
fieldname
\x18\x05
\x01
(
\t\x12\x11\n\t
fieldsize
\x18\x06
\x01
(
\x05\x12\r\n\x05
value
\x18\x07
\x01
(
\t\x12\x10\n\x08
minvalue
\x18\x08
\x01
(
\t\x12\x10\n\x08
maxvalue
\x18\t
\x01
(
\t\x12\x10\n\x08\x64\x61
tatype
\x18\n
\x01
(
\x05\x12\x14\n\x0c
operation_in
\x18\x0b
\x01
(
\x05\x12\x18\n\x10
operation_in_num
\x18\x0c
\x01
(
\x05\x12\x15\n\r
operation_out
\x18\r
\x01
(
\x05\x12\x19\n\x11
operation_out_num
\x18\x0e
\x01
(
\x05\x12\x12\n\n
operabo_in
\x18\x0f
\x01
(
\x05\x12\x13\n\x0b
operabo_out
\x18\x10
\x01
(
\x05\x12\x15\n\r
lua_script_in
\x18\x11
\x01
(
\t\x12\x16\n\x0e
lua_script_out
\x18\x12
\x01
(
\t\"\xa2\x03\n\x13
Proto3DeviceInfoCfg
\x12\n\n\x02
ID
\x18\x01
\x01
(
\x05\x12\x0e\n\x06
STA_ID
\x18\x02
\x01
(
\t\x12\x0e\n\x06\x44\x45
V_ID
\x18\x03
\x01
(
\x05\x12\x10\n\x08\x44\x45
V_NAME
\x18\x04
\x01
(
\t\x12\x14\n\x0c\x44\x45
V_NAME_CHN
\x18\x05
\x01
(
\t\x12\x15\n\r
PROTOCOL_NAME
\x18\x06
\x01
(
\t\x12\x16\n\x0e\x43
MD_EXCEL_PATH
\x18\x07
\x01
(
\t\x12\x17\n\x0f\x43
OMUNITATE_MODE
\x18\x08
\x01
(
\t\x12\x0e\n\x06
TCP_IP
\x18\t
\x01
(
\t\x12\x10\n\x08
TCP_PORT
\x18\n
\x01
(
\x05\x12\x12\n\n
UDP_IP_SRC
\x18\x0b
\x01
(
\t\x12\x14\n\x0c
UDP_PORT_SRC
\x18\x0c
\x01
(
\x05\x12\x12\n\n
UDP_IP_DST
\x18\r
\x01
(
\t\x12\x14\n\x0c
UDP_PORT_DST
\x18\x0e
\x01
(
\x05\x12\x10\n\x08
UDPMC_IP
\x18\x0f
\x01
(
\t\x12\x13\n\x0b
UDPMC_IP_TX
\x18\x10
\x01
(
\t\x12\x15\n\r
UDPMC_PORT_TX
\x18\x11
\x01
(
\x05\x12\x13\n\x0b
UDPMC_IP_RX
\x18\x12
\x01
(
\t\x12\x15\n\r
UDPMC_PORT_RX
\x18\x13
\x01
(
\x05\x12\x0f\n\x07
REMARKS
\x18\x14
\x01
(
\t\"\xed\x02\n\x11
Proto3CMDFieldCfg
\x12\n\n\x02
ID
\x18\x01
\x01
(
\x05\x12\x12\n\n
fieldIndex
\x18\x02
\x01
(
\x05\x12\x11\n\t
fieldName
\x18\x03
\x01
(
\t\x12\x11\n\t
fieldSize
\x18\x04
\x01
(
\x05\x12\r\n\x05
value
\x18\x05
\x01
(
\t\x12\x10\n\x08
minValue
\x18\x06
\x01
(
\t\x12\x10\n\x08
maxValue
\x18\x07
\x01
(
\t\x12\x10\n\x08\x64\x61
taType
\x18\x08
\x01
(
\x05\x12\x14\n\x0c
operation_in
\x18\t
\x01
(
\x05\x12\x18\n\x10
operation_in_num
\x18\n
\x01
(
\x05\x12\x15\n\r
operation_out
\x18\x0b
\x01
(
\x05\x12\x19\n\x11
operation_out_num
\x18\x0c
\x01
(
\x05\x12\x12\n\n
operaBO_in
\x18\r
\x01
(
\x05\x12\x13\n\x0b
operaBO_out
\x18\x0e
\x01
(
\x05\x12\x15\n\r
Lua_Script_in
\x18\x0f
\x01
(
\t\x12\x16\n\x0e
Lua_Script_out
\x18\x10
\x01
(
\t\x12\x13\n\x0b
value_bytes
\x18\x13
\x01
(
\x0c\"\xaa\x01\n\x1c
Proto3TableSoftLimitAngleCfg
\x12\n\n\x02
ID
\x18\x01
\x01
(
\x05\x12\x0e\n\x06
STA_ID
\x18\x02
\x01
(
\t\x12\x10\n\x08\x44\x45
V_NAME
\x18\x03
\x01
(
\t\x12\x14\n\x0c\x44\x45
V_NAME_CHN
\x18\x04
\x01
(
\t\x12\x15\n\r
PROTOCOL_NAME
\x18\x05
\x01
(
\t\x12\x1e\n\x16
PITCH_SOFT_LIMIT_ANGLE
\x18\x06
\x01
(
\t\x12\x0f\n\x07
REMARKS
\x18\x07
\x01
(
\t\"\xd9\x02\n\x0b
TDSDBC_CURD
\x12\r\n\x05
table
\x18\x01
\x01
(
\t\x12
!
\n\x05\x66
lags
\x18\x02
\x01
(
\x0e\x32\x12
.TDSDBC_CURD.Flags
\x12
)
\n\t
operation
\x18\x03
\x01
(
\x0e\x32\x16
.TDSDBC_CURD.Operation
\x12\x18\n\x04\x63
ode
\x18\x04
\x01
(
\x0e\x32\n
.CodeValue
\x12\x0b\n\x03
msg
\x18\x05
\x01
(
\t\x12\x0f\n\x07
msg_CHN
\x18\x06
\x01
(
\t\x12
&
\n\x08\x61
ny_data
\x18\x07
\x03
(
\x0b\x32\x14
.google.protobuf.Any
\"
/
\n\x05\x46
lags
\x12\x13\n\x0f
NORMAL_DISPATCH
\x10\x00\x12\x11\n\r
FULL_DISPATCH
\x10\x01\"\\\n\t
Operation
\x12\x11\n\r
OPERATION_ADD
\x10\x00\x12\x11\n\r
OPERATION_DEL
\x10\x01\x12\x14\n\x10
OPERATION_UPDATE
\x10\x02\x12\x13\n\x0f
OPERATION_QUERY
\x10\x03\"\xbc\x01\n\x11
TDSXDC_Device_cmd
\x12\x10\n\x08\x44\x65
viceID
\x18\x01
\x01
(
\r\x12\x10\n\x08\x64\x65
v_name
\x18\x02
\x01
(
\t\x12\x10\n\x08\x63
md_name
\x18\x03
\x01
(
\t\x12\x15\n\r
protocol_name
\x18\x04
\x01
(
\t\x12\x18\n\x04\x63
ode
\x18\x05
\x01
(
\x0e\x32\n
.CodeValue
\x12\x0b\n\x03
msg
\x18\x06
\x01
(
\t\x12\x0f\n\x07
msg_CHN
\x18\x07
\x01
(
\t\x12\"\n\x06\x66
ields
\x18\x08
\x03
(
\x0b\x32\x12
.Proto3CMDFieldCfg*
\x7f\n\x0e\x41
larmID_define
\x12\x0b\n\x07
ID_Base
\x10\x00\x12\x15\n\x0e\x44\x65
vAla_id_Base
\x10\x80\x87\xa7\x0e\x12\x18\n\x11\x44\x65
vAla_id_Offline
\x10\x81\x87\xa7\x0e\x12
/
\n
(DevAla_id_Antenna_pitch_angle_soft_limit
\x10\x82\x87\xa7\x0e\x42\x0c
Z
\n
../protogob
\x06
proto3'
)
DESCRIPTOR
=
_descriptor_pool
.
Default
()
.
AddSerializedFile
(
b
'
\n\x17\x44\x65
vice_datastruct.proto
\x1a\x19
google/protobuf/any.proto
\x1a\x1f
google/protobuf/timestamp.proto
\x1a\x0c
TDSCmd.proto
\"
o
\n\x12
Proto3DeviceAllCMD
\x12\n\n\x02
ID
\x18\x01
\x01
(
\x05\x12\x10\n\x08\x44\x45
V_NAME
\x18\x02
\x01
(
\t\x12\x15\n\r
PROTOCOL_NAME
\x18\x03
\x01
(
\t\x12
$
\n\x04\x43
MDs
\x18\x04
\x03
(
\x0b\x32\x16
.Proto3DeviceCMDDefine
\"
~
\n\x15
Proto3DeviceCMDDefine
\x12\x10\n\x08\x43
MD_NAME
\x18\x01
\x01
(
\t\x12\x0e\n\x06\x45
NCODE
\x18\x02
\x01
(
\t\x12\x1f\n\x17
Timing_CMD_Cycle_period
\x18\x03
\x01
(
\x05\x12\"\n\x06\x66\x65
lids
\x18\x04
\x03
(
\x0b\x32\x12
.Proto3CMDFieldCfg
\"\x9d\x01\n\x17
Proto3ForReloadProtocol
\x12\x10\n\x08\x64\x65
v_name
\x18\x01
\x01
(
\t\x12\x10\n\x08\x63
md_name
\x18\x02
\x01
(
\t\x12
-
\n\x05\x66
lags
\x18\x03
\x01
(
\x0e\x32\x1e
.Proto3ForReloadProtocol.Flags
\"
/
\n\x05\x46
lags
\x12\x13\n\x0f
NORMAL_DISPATCH
\x10\x00\x12\x11\n\r
FULL_DISPATCH
\x10\x01\"\xa8\x01\n\x19
Proto3TableDevCmdNamePoll
\x12\n\n\x02
id
\x18\x01
\x01
(
\x05\x12\x15\n\r
protocol_name
\x18\x02
\x01
(
\t\x12\x10\n\x08\x63
md_name
\x18\x03
\x01
(
\t\x12\x10\n\x08\x63
md_type
\x18\x04
\x01
(
\t\x12\x0e\n\x06\x65
ncode
\x18\x05
\x01
(
\t\x12\x1f\n\x17
timing_cmd_cycle_period
\x18\x06
\x01
(
\x05\x12\x13\n\x0b\x63
md_explain
\x18\x07
\x01
(
\t\"\x85\x03\n\x1a
Proto3TableAllDevCmdDefine
\x12\n\n\x02
id
\x18\x01
\x01
(
\x05\x12\x10\n\x08\x63
md_name
\x18\x02
\x01
(
\t\x12\x10\n\x08\x63
md_type
\x18\x03
\x01
(
\t\x12\x12\n\n
fieldindex
\x18\x04
\x01
(
\x05\x12\x11\n\t
fieldname
\x18\x05
\x01
(
\t\x12\x11\n\t
fieldsize
\x18\x06
\x01
(
\x05\x12\r\n\x05
value
\x18\x07
\x01
(
\t\x12\x10\n\x08
minvalue
\x18\x08
\x01
(
\t\x12\x10\n\x08
maxvalue
\x18\t
\x01
(
\t\x12\x10\n\x08\x64\x61
tatype
\x18\n
\x01
(
\x05\x12\x14\n\x0c
operation_in
\x18\x0b
\x01
(
\x05\x12\x18\n\x10
operation_in_num
\x18\x0c
\x01
(
\x05\x12\x15\n\r
operation_out
\x18\r
\x01
(
\x05\x12\x19\n\x11
operation_out_num
\x18\x0e
\x01
(
\x05\x12\x12\n\n
operabo_in
\x18\x0f
\x01
(
\x05\x12\x13\n\x0b
operabo_out
\x18\x10
\x01
(
\x05\x12\x15\n\r
lua_script_in
\x18\x11
\x01
(
\t\x12\x16\n\x0e
lua_script_out
\x18\x12
\x01
(
\t\"\xa2\x03\n\x13
Proto3DeviceInfoCfg
\x12\n\n\x02
ID
\x18\x01
\x01
(
\x05\x12\x0e\n\x06
STA_ID
\x18\x02
\x01
(
\t\x12\x0e\n\x06\x44\x45
V_ID
\x18\x03
\x01
(
\x05\x12\x10\n\x08\x44\x45
V_NAME
\x18\x04
\x01
(
\t\x12\x14\n\x0c\x44\x45
V_NAME_CHN
\x18\x05
\x01
(
\t\x12\x15\n\r
PROTOCOL_NAME
\x18\x06
\x01
(
\t\x12\x16\n\x0e\x43
MD_EXCEL_PATH
\x18\x07
\x01
(
\t\x12\x17\n\x0f\x43
OMUNITATE_MODE
\x18\x08
\x01
(
\t\x12\x0e\n\x06
TCP_IP
\x18\t
\x01
(
\t\x12\x10\n\x08
TCP_PORT
\x18\n
\x01
(
\x05\x12\x12\n\n
UDP_IP_SRC
\x18\x0b
\x01
(
\t\x12\x14\n\x0c
UDP_PORT_SRC
\x18\x0c
\x01
(
\x05\x12\x12\n\n
UDP_IP_DST
\x18\r
\x01
(
\t\x12\x14\n\x0c
UDP_PORT_DST
\x18\x0e
\x01
(
\x05\x12\x10\n\x08
UDPMC_IP
\x18\x0f
\x01
(
\t\x12\x13\n\x0b
UDPMC_IP_TX
\x18\x10
\x01
(
\t\x12\x15\n\r
UDPMC_PORT_TX
\x18\x11
\x01
(
\x05\x12\x13\n\x0b
UDPMC_IP_RX
\x18\x12
\x01
(
\t\x12\x15\n\r
UDPMC_PORT_RX
\x18\x13
\x01
(
\x05\x12\x0f\n\x07
REMARKS
\x18\x14
\x01
(
\t\"\xed\x02\n\x11
Proto3CMDFieldCfg
\x12\n\n\x02
ID
\x18\x01
\x01
(
\x05\x12\x12\n\n
fieldIndex
\x18\x02
\x01
(
\x05\x12\x11\n\t
fieldName
\x18\x03
\x01
(
\t\x12\x11\n\t
fieldSize
\x18\x04
\x01
(
\x05\x12\r\n\x05
value
\x18\x05
\x01
(
\t\x12\x10\n\x08
minValue
\x18\x06
\x01
(
\t\x12\x10\n\x08
maxValue
\x18\x07
\x01
(
\t\x12\x10\n\x08\x64\x61
taType
\x18\x08
\x01
(
\x05\x12\x14\n\x0c
operation_in
\x18\t
\x01
(
\x05\x12\x18\n\x10
operation_in_num
\x18\n
\x01
(
\x05\x12\x15\n\r
operation_out
\x18\x0b
\x01
(
\x05\x12\x19\n\x11
operation_out_num
\x18\x0c
\x01
(
\x05\x12\x12\n\n
operaBO_in
\x18\r
\x01
(
\x05\x12\x13\n\x0b
operaBO_out
\x18\x0e
\x01
(
\x05\x12\x15\n\r
Lua_Script_in
\x18\x0f
\x01
(
\t\x12\x16\n\x0e
Lua_Script_out
\x18\x10
\x01
(
\t\x12\x13\n\x0b
value_bytes
\x18\x13
\x01
(
\x0c\"\xaa\x01\n\x1c
Proto3TableSoftLimitAngleCfg
\x12\n\n\x02
ID
\x18\x01
\x01
(
\x05\x12\x0e\n\x06
STA_ID
\x18\x02
\x01
(
\t\x12\x10\n\x08\x44\x45
V_NAME
\x18\x03
\x01
(
\t\x12\x14\n\x0c\x44\x45
V_NAME_CHN
\x18\x04
\x01
(
\t\x12\x15\n\r
PROTOCOL_NAME
\x18\x05
\x01
(
\t\x12\x1e\n\x16
PITCH_SOFT_LIMIT_ANGLE
\x18\x06
\x01
(
\t\x12\x0f\n\x07
REMARKS
\x18\x07
\x01
(
\t\"\xd9\x02\n\x0b
TDSDBC_CURD
\x12\r\n\x05
table
\x18\x01
\x01
(
\t\x12
!
\n\x05\x66
lags
\x18\x02
\x01
(
\x0e\x32\x12
.TDSDBC_CURD.Flags
\x12
)
\n\t
operation
\x18\x03
\x01
(
\x0e\x32\x16
.TDSDBC_CURD.Operation
\x12\x18\n\x04\x63
ode
\x18\x04
\x01
(
\x0e\x32\n
.CodeValue
\x12\x0b\n\x03
msg
\x18\x05
\x01
(
\t\x12\x0f\n\x07
msg_CHN
\x18\x06
\x01
(
\t\x12
&
\n\x08\x61
ny_data
\x18\x07
\x03
(
\x0b\x32\x14
.google.protobuf.Any
\"
/
\n\x05\x46
lags
\x12\x13\n\x0f
NORMAL_DISPATCH
\x10\x00\x12\x11\n\r
FULL_DISPATCH
\x10\x01\"\\\n\t
Operation
\x12\x11\n\r
OPERATION_ADD
\x10\x00\x12\x11\n\r
OPERATION_DEL
\x10\x01\x12\x14\n\x10
OPERATION_UPDATE
\x10\x02\x12\x13\n\x0f
OPERATION_QUERY
\x10\x03\"\xbc\x01\n\x11
TDSXDC_Device_cmd
\x12\x10\n\x08\x44\x65
viceID
\x18\x01
\x01
(
\r\x12\x10\n\x08\x64\x65
v_name
\x18\x02
\x01
(
\t\x12\x10\n\x08\x63
md_name
\x18\x03
\x01
(
\t\x12\x15\n\r
protocol_name
\x18\x04
\x01
(
\t\x12\x18\n\x04\x63
ode
\x18\x05
\x01
(
\x0e\x32\n
.CodeValue
\x12\x0b\n\x03
msg
\x18\x06
\x01
(
\t\x12\x0f\n\x07
msg_CHN
\x18\x07
\x01
(
\t\x12\"\n\x06\x66
ields
\x18\x08
\x03
(
\x0b\x32\x12
.Proto3CMDFieldCfg*
\x7f\n\x0e\x41
larmID_define
\x12\x0b\n\x07
ID_Base
\x10\x00\x12\x15\n\x0e\x44\x65
vAla_id_Base
\x10\x80\x87\xa7\x0e\x12\x18\n\x11\x44\x65
vAla_id_Offline
\x10\x81\x87\xa7\x0e\x12
/
\n
(DevAla_id_Antenna_pitch_angle_soft_limit
\x10\x82\x87\xa7\x0e\x42\x0c
Z
\n
../protogob
\x06
proto3'
)
...
...
mqtt/mqtt.py
View file @
02be7add
...
@@ -20,7 +20,9 @@ def send_websocket_message(message, group_name="chat_mqtt"):
...
@@ -20,7 +20,9 @@ def send_websocket_message(message, group_name="chat_mqtt"):
def
on_connect
(
mqtt_client
,
userdata
,
flags
,
rc
):
def
on_connect
(
mqtt_client
,
userdata
,
flags
,
rc
):
if
rc
==
0
:
if
rc
==
0
:
print
(
'Connected successfully'
)
print
(
'Connected successfully'
)
mqtt_client
.
subscribe
(
'django/mqtt'
)
mqtt_client
.
subscribe
([(
'/1/0/0/6'
,
2
),
(
'/1/1/0/6'
,
2
),
(
'/1/1/1/6'
,
2
)])
else
:
else
:
print
(
'Bad connection. Code:'
,
rc
)
print
(
'Bad connection. Code:'
,
rc
)
...
@@ -29,9 +31,10 @@ def on_message(mqtt_client, userdata, msg):
...
@@ -29,9 +31,10 @@ def on_message(mqtt_client, userdata, msg):
# 接收mqtt消息的代码
# 接收mqtt消息的代码
# mqtt_message_received.send(sender=None, message=msg.payload)
# mqtt_message_received.send(sender=None, message=msg.payload)
# print(f'Received message on topic: {msg.topic} with payload: {msg.payload}')
# print(f'Received message on topic: {msg.topic} with payload: {msg.payload}')
# data = parse_proto(msg.payload)
data
=
parse_proto
(
msg
.
payload
)
data
=
msg
.
payload
.
decode
(
'utf-8'
)
# data = msg.payload.decode('utf-8')
send_websocket_message
(
data
)
print
(
f
'Received message on topic: {msg.topic} with payload: {data}'
)
# send_websocket_message(data)
client
=
mqtt
.
Client
()
client
=
mqtt
.
Client
()
...
...
mqtt/utils.py
View file @
02be7add
import
json
import
json
from
.auto_generate_python
import
TDSCmd_pb2
,
OAM_datastruct_pb2
from
.auto_generate_python
import
TDSCmd_pb2
,
OAM_datastruct_pb2
,
Device_datastruct_pb2
from
google.protobuf.json_format
import
MessageToJson
from
google.protobuf.json_format
import
MessageToJson
...
...
vue_django/settings.py
View file @
02be7add
...
@@ -144,12 +144,14 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
...
@@ -144,12 +144,14 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
ASGI_APPLICATION
=
'vue_django.asgi.application'
ASGI_APPLICATION
=
'vue_django.asgi.application'
MQTT_SERVER
=
'192.168.0.89'
# mqtt 设置
MQTT_SERVER
=
'192.168.0.176'
MQTT_PORT
=
1883
MQTT_PORT
=
1883
MQTT_KEEPALIVE
=
60
MQTT_KEEPALIVE
=
60
MQTT_USER
=
""
MQTT_USER
=
""
MQTT_PASSWORD
=
""
MQTT_PASSWORD
=
""
# channel 的 websocket 设置
CHANNEL_LAYERS
=
{
CHANNEL_LAYERS
=
{
'default'
:
{
'default'
:
{
'BACKEND'
:
'channels.layers.InMemoryChannelLayer'
,
'BACKEND'
:
'channels.layers.InMemoryChannelLayer'
,
...
...
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