보관함 전체 상태 데이터 요청 코드 추가

This commit is contained in:
2025-12-10 11:22:30 +09:00
parent 913ca9136a
commit 5f478a806c
2 changed files with 42 additions and 1 deletions

View File

@@ -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<bool> sendCommand({
@@ -40,6 +40,37 @@ class LockerApi {
}
}
Future<Map<String, dynamic>?> 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)