From 5f478a806cae6c9dbdc3b6a04ad91d2b2bd05205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=ED=9D=AC=EC=84=B1?= Date: Wed, 10 Dec 2025 11:22:30 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B3=B4=EA=B4=80=ED=95=A8=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20=EC=83=81=ED=83=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/home_screen_content.dart | 10 ++++++++++ lib/services/locker_api.dart | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lib/home_screen_content.dart b/lib/home_screen_content.dart index a89739d..5ffa194 100644 --- a/lib/home_screen_content.dart +++ b/lib/home_screen_content.dart @@ -45,6 +45,15 @@ Future _runLockerAction(String name, Future Function() action) async // 25.12.03 지은 추가 끝 + void test() async { + final data = await _api.getTimeseries(target: "*", limit: 200); + + if (data != null) { + print("받은 데이터 길이: ${data['samples'].length}"); + print(data['samples'][0]); // 첫 번째 데이터 출력 + } + } + int _selectedImageIndex = 0; static const BoxShadow _cleanShadow = BoxShadow( @@ -63,6 +72,7 @@ Future _runLockerAction(String name, Future Function() action) async @override Widget build(BuildContext context) { + test(); return Container( color: _pageBackgroundColor, child: Column( diff --git a/lib/services/locker_api.dart b/lib/services/locker_api.dart index f8adae0..c7e04d7 100644 --- a/lib/services/locker_api.dart +++ b/lib/services/locker_api.dart @@ -5,7 +5,7 @@ class LockerApi { // 안드로이드 에뮬레이터: "http://10.0.2.2:8182" // iOS 시뮬레이터: "http://127.0.0.1:8182" // "http://192.168.0.82:8182" - static const String baseUrl = "http://192.168.0.81:8182"; + static const String baseUrl = "http://192.168.0.81:8182"; // 명령 전송 공통 함수 Future sendCommand({ @@ -40,6 +40,37 @@ class LockerApi { } } + Future?> getTimeseries({ + String target = "*", + int limit = 200, + }) async { + final url = Uri.parse('$baseUrl/timeseries/get'); + + try { + final response = await http.post( + url, + headers: {"Content-Type": "application/json"}, + body: jsonEncode({ + "target": target, + "limit": limit, + }), + ); + + if (response.statusCode == 200) { + final jsonData = jsonDecode(response.body); + + print("Timeseries 수신 성공"); + return jsonData; + } else { + print("Timeseries 조회 실패: ${response.body}"); + return null; + } + } catch (e) { + print("서버 연결 오류: $e"); + return null; + } + } + // --- [기능별 동작 함수] --- // 1. 잠금 해제 (주소: 0x0016 / 값: 1)