From 0a281fa5642f9efa1716c995bc52cb6c7b5f3ca0 Mon Sep 17 00:00:00 2001 From: ming <1006400273@qq.com> Date: Sat, 28 Feb 2026 07:30:11 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20test=5Fjson=5Fchunk=5Fsend?= =?UTF-8?q?er.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_json_chunk_sender.py | 72 --------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 test_json_chunk_sender.py diff --git a/test_json_chunk_sender.py b/test_json_chunk_sender.py deleted file mode 100644 index 8f181a1..0000000 --- a/test_json_chunk_sender.py +++ /dev/null @@ -1,72 +0,0 @@ -import json -import time - -def simulate_json_chunk_sending(data, chunk_size=15): - """ - 模拟JSON数据分包发送 - """ - json_string = json.dumps(data) - print(f"原始JSON数据: {json_string}") - print(f"数据总长度: {len(json_string)} 字符") - - chunks = [] - # 分包 - for i in range(0, len(json_string), chunk_size): - chunk = json_string[i:i+chunk_size] - chunks.append(chunk) - - print(f"\n分包结果 ({len(chunks)} 个包):") - for i, chunk in enumerate(chunks): - print(f" 包 {i+1}: {chunk}") - - return chunks - -def create_sample_json_data(): - """ - 创建示例JSON数据 - """ - return { - "type": "radarData", - "deviceId": 1001, - "timestamp": int(time.time() * 1000), - "presence": 1, - "heartRate": 72.5, - "breathRate": 16.2, - "motion": 0, - "rssi": -45, - "heartbeatWaveform": 120, - "breathingWaveform": 45, - "rawSignal": -25 - } - -def create_status_json_data(): - """ - 创建状态JSON数据 - """ - return { - "type": "status", - "wifiConfigured": True, - "wifiConnected": True, - "ipAddress": "192.168.1.100", - "deviceId": 1001 - } - -def main(): - print("=== JSON分包发送模拟测试 ===\n") - - # 测试雷达数据 - print("1. 雷达数据分包测试:") - radar_data = create_sample_json_data() - simulate_json_chunk_sending(radar_data, 15) - - print("\n" + "="*50 + "\n") - - # 测试状态数据 - print("2. 状态数据分包测试:") - status_data = create_status_json_data() - simulate_json_chunk_sending(status_data, 15) - - print("\n=== 测试完成 ===") - -if __name__ == "__main__": - main() \ No newline at end of file