diff --git a/app/api/v1/endpoints/adb.py b/app/api/v1/endpoints/adb.py index 1001d4b..313ef31 100644 --- a/app/api/v1/endpoints/adb.py +++ b/app/api/v1/endpoints/adb.py @@ -1,7 +1,7 @@ from fastapi import APIRouter, HTTPException, status, UploadFile, File from typing import Optional from app.core.device.manager import device_manager -from app.core.dispatcher import dispatcher +from app.core.device.dispatcher import device_dispatcher from app.schemas.adb import ( ClickRequest, InputRequest, ScreenshotResponse, InstallRequest, InstallResponse, LogcatRequest, LogcatResponse @@ -32,7 +32,7 @@ async def click_device(device_id: str, click_request: ClickRequest): ) # 执行点击操作 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="click", @@ -73,7 +73,7 @@ async def input_text(device_id: str, input_request: InputRequest): # 执行输入操作 if device.protocol_type == 'adb': - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="input_text", @@ -81,7 +81,7 @@ async def input_text(device_id: str, input_request: InputRequest): clear_first=input_request.clear_first ) else: # atx - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="input_text", @@ -120,7 +120,7 @@ async def get_screenshot(device_id: str): ) # 执行截图操作 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="screenshot" @@ -157,7 +157,7 @@ async def install_apk(device_id: str, install_request: InstallRequest): ) # 执行安装操作 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="install_apk", @@ -201,7 +201,7 @@ async def get_logcat( ) # 执行日志获取操作 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="get_logcat", @@ -234,7 +234,7 @@ async def get_device_info(device_id: str): ) # 获取设备信息 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="get_device_info" diff --git a/app/api/v1/endpoints/at.py b/app/api/v1/endpoints/at.py index 61acf4a..811d6c3 100644 --- a/app/api/v1/endpoints/at.py +++ b/app/api/v1/endpoints/at.py @@ -1,6 +1,6 @@ from fastapi import APIRouter, HTTPException, status from app.core.device.manager import device_manager -from app.core.dispatcher import dispatcher +from app.core.device.dispatcher import device_dispatcher from app.schemas.at import ATCommandRequest, ATCommandResponse from app.utils.log import get_logger @@ -28,7 +28,7 @@ async def send_at_command(device_id: str, at_request: ATCommandRequest): ) # 发送AT指令 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="send_at_command", @@ -68,7 +68,7 @@ async def send_multiple_at_commands(device_id: str, commands: list, delay_betwee ) # 发送多个AT指令 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="send_multiple_commands", @@ -112,7 +112,7 @@ async def test_at_connection(device_id: str): ) # 测试连接 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="test_connection" @@ -153,7 +153,7 @@ async def get_at_device_info(device_id: str): ) # 获取设备信息 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="get_device_info" diff --git a/app/api/v1/endpoints/plnk.py b/app/api/v1/endpoints/plnk.py index 98a9871..c272c3d 100644 --- a/app/api/v1/endpoints/plnk.py +++ b/app/api/v1/endpoints/plnk.py @@ -1,6 +1,6 @@ from fastapi import APIRouter, HTTPException, status from app.core.device.manager import device_manager -from app.core.dispatcher import dispatcher +from app.core.device.dispatcher import device_dispatcher from app.schemas.plnk import PLNKRequest, PLNKResponse from app.utils.log import get_logger @@ -28,7 +28,7 @@ async def send_plnk_data(device_id: str, plnk_request: PLNKRequest): ) # 发送PLNK数据 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="send_plnk_data", @@ -68,7 +68,7 @@ async def get_plnk_connection_status(device_id: str): ) # 获取连接状态 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="get_connection_status" @@ -105,7 +105,7 @@ async def test_plnk_connection(device_id: str): ) # 测试连接 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="test_connection" @@ -140,7 +140,7 @@ async def send_hex_data(device_id: str, hex_data: str, timeout: int = 30): # 根据协议类型选择不同的发送方式 if device.protocol_type == 'plnk': - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="send_plnk_data", @@ -152,7 +152,7 @@ async def send_hex_data(device_id: str, hex_data: str, timeout: int = 30): # 对于AT协议,将十六进制转换为ASCII try: ascii_data = bytes.fromhex(hex_data.replace(' ', '')).decode('ascii', errors='ignore') - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="send_at_command", diff --git a/app/api/v1/endpoints/ssh.py b/app/api/v1/endpoints/ssh.py index a2532d1..81c7517 100644 --- a/app/api/v1/endpoints/ssh.py +++ b/app/api/v1/endpoints/ssh.py @@ -1,6 +1,6 @@ from fastapi import APIRouter, HTTPException, status from app.core.device.manager import device_manager -from app.core.dispatcher import dispatcher +from app.core.device.dispatcher import device_dispatcher from app.schemas.ssh import SSHExecRequest, SSHExecResponse from app.utils.log import get_logger @@ -28,7 +28,7 @@ async def exec_ssh_command(device_id: str, exec_request: SSHExecRequest): ) # 执行SSH命令 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="exec_command", @@ -68,7 +68,7 @@ async def upload_file(device_id: str, local_path: str, remote_path: str): ) # 执行文件上传 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="upload_file", @@ -107,7 +107,7 @@ async def download_file(device_id: str, remote_path: str, local_path: str): ) # 执行文件下载 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="download_file", @@ -146,7 +146,7 @@ async def test_ssh_connection(device_id: str): ) # 测试连接 - result = await dispatcher.execute_operation( + result = await device_dispatcher.execute_operation( device_id=device_id, protocol_type=device.protocol_type, operation="test_connection" diff --git a/app/core/device/__pycache__/dispatcher.cpython-310.pyc b/app/core/device/__pycache__/dispatcher.cpython-310.pyc index 8eb5a45..1def697 100644 Binary files a/app/core/device/__pycache__/dispatcher.cpython-310.pyc and b/app/core/device/__pycache__/dispatcher.cpython-310.pyc differ diff --git a/app/schemas/__pycache__/at.cpython-310.pyc b/app/schemas/__pycache__/at.cpython-310.pyc new file mode 100644 index 0000000..3c26ade Binary files /dev/null and b/app/schemas/__pycache__/at.cpython-310.pyc differ diff --git a/app/schemas/__pycache__/plnk.cpython-310.pyc b/app/schemas/__pycache__/plnk.cpython-310.pyc new file mode 100644 index 0000000..05843f7 Binary files /dev/null and b/app/schemas/__pycache__/plnk.cpython-310.pyc differ diff --git a/app/services/__pycache__/atx_service.cpython-310.pyc b/app/services/__pycache__/atx_service.cpython-310.pyc new file mode 100644 index 0000000..1f5ee3b Binary files /dev/null and b/app/services/__pycache__/atx_service.cpython-310.pyc differ diff --git a/app/services/__pycache__/plnk_service.cpython-310.pyc b/app/services/__pycache__/plnk_service.cpython-310.pyc new file mode 100644 index 0000000..2d26c31 Binary files /dev/null and b/app/services/__pycache__/plnk_service.cpython-310.pyc differ diff --git a/app/services/__pycache__/ssh_service.cpython-310.pyc b/app/services/__pycache__/ssh_service.cpython-310.pyc index 5dd3f57..3631302 100644 Binary files a/app/services/__pycache__/ssh_service.cpython-310.pyc and b/app/services/__pycache__/ssh_service.cpython-310.pyc differ diff --git a/logs/app.services.at_service.log b/logs/app.services.at_service.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/app.services.plnk_service.log b/logs/app.services.plnk_service.log new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt index ec75347..5ab3016 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ pydantic-settings==2.10.1 tornado==6.4 # 设备控制相关 -adbutils==2.0.0 +adbutils==2.10.0 uiautomator2==2.16.23 pyserial==3.5