fix
This commit is contained in:
@@ -33,6 +33,9 @@ COMMAND_MAPPINGS = {command_mappings}
|
|||||||
def process_command(buf):
|
def process_command(buf):
|
||||||
"""处理接收到的命令,返回对应的操作指令"""
|
"""处理接收到的命令,返回对应的操作指令"""
|
||||||
buf = buf.strip()
|
buf = buf.strip()
|
||||||
|
# 状态查询或心跳检测,返回特殊标记
|
||||||
|
if buf == "state=?" or buf == "":
|
||||||
|
return "status_check"
|
||||||
if buf in COMMAND_MAPPINGS:
|
if buf in COMMAND_MAPPINGS:
|
||||||
return COMMAND_MAPPINGS[buf]
|
return COMMAND_MAPPINGS[buf]
|
||||||
return "nodata"
|
return "nodata"
|
||||||
@@ -68,7 +71,13 @@ def main():
|
|||||||
|
|
||||||
operation = process_command(buf)
|
operation = process_command(buf)
|
||||||
|
|
||||||
if operation == "nodata":
|
if operation == "status_check":
|
||||||
|
# 状态查询或心跳检测,直接回复 ok
|
||||||
|
logstr = "===" + datetime_str + " 状态查询/心跳检测,回复 ok"
|
||||||
|
logging.info(logstr)
|
||||||
|
print(logstr)
|
||||||
|
connection.send(b'ok')
|
||||||
|
elif operation == "nodata":
|
||||||
logstr = "===" + datetime_str + " 未知指令: '" + str(buf) + "'"
|
logstr = "===" + datetime_str + " 未知指令: '" + str(buf) + "'"
|
||||||
logging.warning(logstr)
|
logging.warning(logstr)
|
||||||
print(logstr)
|
print(logstr)
|
||||||
|
|||||||
Reference in New Issue
Block a user