feat: Foreground Service + Detachment 개선 + Placement 가이드 모드

Foreground Service (BleForegroundService.kt):
- BLE 연결 시 자동 시작, 해제 시 자동 중단
- PARTIAL_WAKE_LOCK (최대 4시간)
- Notification: "VesiScan - BLE 기기 연결 중..."
- connectedDevice foregroundServiceType
- Doze 모드에서도 BLE 통신 유지
- keepScreenOn도 유지 (추가 안전장치)

Detachment 개선:
- THR_MEAN/STD 100→30 (완전 탈착만 감지, 거리 약화 무시)
- 6채널 모두 수신됐을 때만 체크 (BLE 거리 문제와 구분)
- Placement: if(false) 제거 → 활성화 + "센서가 부착되지 않았습니다"
- Monitoring: 정상 복귀 시 LED OFF

Placement 가이드 모드:
- Simple (기본): 3+채널 → 바로 좌우 (기존)
- Boundary: 올라갔다 내려오기 패턴 (경계 감지 → 최적점 복귀)
- 설정 톱니바퀴에 Simple/Boundary 스위치

BLE 로그:
- 역순 표시 (최신이 위) — 스크롤 위치 유지

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-04 16:09:54 +09:00
parent 48df4370bc
commit 258bad9a26
8 changed files with 255 additions and 42 deletions
@@ -17,8 +17,8 @@ object DetachmentDetection {
const val WINDOW_END = 80
const val BASELINE_WINDOW_START = 80
const val BASELINE_WINDOW_END = 100
const val THR_MEAN = 100.0
const val THR_STD = 100.0
const val THR_MEAN = 30.0
const val THR_STD = 30.0
const val N_CENTER_CH = 4
data class DetachmentResult(
@@ -13,10 +13,12 @@ package com.example.medilightv2android.managers
* 각 상수의 의미와 영향 범위를 아래 주석 참고.
*/
enum class DetectionMethod { METHOD_A, METHOD_B, METHOD_C }
enum class PlacementGuideMode { SIMPLE, BOUNDARY }
object GreenZoneConstants {
var detectionMethod: DetectionMethod = DetectionMethod.METHOD_C
var placementGuideMode: PlacementGuideMode = PlacementGuideMode.SIMPLE
// ═══════════════════════════════════════════════════════════
// 신호 범위