add keep-alive

This commit is contained in:
“zj”
2026-04-04 21:26:16 +08:00
parent 2169847926
commit 1aa8f7b608
4 changed files with 79 additions and 51 deletions

View File

@@ -103,6 +103,9 @@ def generate_listener(device, global_config, mappings, command_sets, global_comm
# 确定使用哪个 sender 脚本(每个设备独立的 sender
sender_file = f"{global_config['base_dir']}/bin/sender_{device['id']}.py"
# 获取 keep_alive 配置仅TCP有效默认False
keep_alive = device.get('keep_alive', False)
# 替换模板变量
content = template.format(
device_id=device['id'],
@@ -115,7 +118,8 @@ def generate_listener(device, global_config, mappings, command_sets, global_comm
python_path=global_config['python_path'],
command_mappings=mappings_str,
sender_file=sender_file,
device_protocol=device_protocol.upper()
device_protocol=device_protocol.upper(),
keep_alive='True' if keep_alive else 'False'
)
output_file = os.path.join(global_config['base_dir'], 'bin', f"{device['id']}.py")