|
|
@@ -406,7 +406,7 @@ def input_call(client):
|
|
|
userinput = None
|
|
|
if g_download_cfg["Number"] == 0: #非批量获取配置的状态下
|
|
|
try:
|
|
|
- userinput = inputimeout(prompt='请命令序号:', timeout=g_config["def_cfg"]["input_interval"])
|
|
|
+ userinput = inputimeout(prompt='请命令序号:', timeout=60)
|
|
|
except TimeoutOccurred:
|
|
|
userinput = None
|
|
|
if userinput:
|
|
|
@@ -499,7 +499,6 @@ async def ble_main():
|
|
|
except Exception as e:
|
|
|
logger.error("Err in {}[{}]:\n {}".format(os.path.basename(e.__traceback__.tb_frame.f_globals["__file__"]), e.__traceback__.tb_lineno, e))
|
|
|
|
|
|
- time.sleep(0.01)
|
|
|
logger.info("结束:{}".format(inspect.currentframe().f_code.co_name))
|
|
|
|
|
|
def test_aes():
|
|
|
@@ -546,7 +545,7 @@ def ble_recv_handler():
|
|
|
while g_run:
|
|
|
data = mq.get("ble_recv")
|
|
|
if not data:
|
|
|
- time.sleep(0.1)
|
|
|
+ time.sleep(0.01)
|
|
|
continue
|
|
|
|
|
|
if g_config["def_cfg"]["recv_detail_print"]:
|
|
|
@@ -610,26 +609,28 @@ def ble_recv_handler():
|
|
|
|
|
|
# 特殊处理:升级
|
|
|
out = batch_split_key_value(dec_str)
|
|
|
- if "upgrade_req" in out.keys():
|
|
|
- values = out["upgrade_req"]
|
|
|
- if len(values) == 2:
|
|
|
+ if "fwreq" in out.keys():
|
|
|
+ values = out["fwreq"]
|
|
|
+ if len(values) == 3:
|
|
|
file = str(values[0])
|
|
|
- page = int(values[1])
|
|
|
+ addr = int(values[1])
|
|
|
+ size = int(values[2])
|
|
|
+ filesize = os.stat(file).st_size
|
|
|
with open(file, "rb") as f:
|
|
|
- f.seek(page*(1024+4)) #位移到最后 SEEK_END(值为2) SEEK_CUR(值为1) SEEK_SET(值为0)
|
|
|
- datas = f.read(1024+4)
|
|
|
+ f.seek(addr) #位移到最后 SEEK_END(值为2) SEEK_CUR(值为1) SEEK_SET(值为0)
|
|
|
+ datas = f.read(size)
|
|
|
f.close()
|
|
|
|
|
|
# 发送
|
|
|
- byte_array = bytearray("set:upgrade_data=", encoding="utf8")+bytearray(datas)
|
|
|
+ byte_array = bytearray("set:fwdata={}/{},".format(addr, filesize), encoding="utf8")+bytearray(datas)
|
|
|
byte_array = ev_packing(byte_array)
|
|
|
send_data = bytes(byte_array)
|
|
|
mq.add("ble_send", send_data)
|
|
|
+ logger.info("add event:fwdata" )
|
|
|
|
|
|
# 清理
|
|
|
recv_data.clear()
|
|
|
|
|
|
- time.sleep(0.1)
|
|
|
|
|
|
logger.info("结束:{}".format(inspect.currentframe().f_code.co_name))
|
|
|
|
|
|
@@ -663,7 +664,7 @@ def main_handler():
|
|
|
heart_beart_time = time.time()
|
|
|
heart_beat_call(None)
|
|
|
|
|
|
- time.sleep(0.1)
|
|
|
+
|
|
|
|
|
|
logger.info("结束:{}".format(inspect.currentframe().f_code.co_name))
|
|
|
|