From f1995e10f6192ad2f4f267991090961312e38846 Mon Sep 17 00:00:00 2001 From: jhChun Date: Tue, 31 Mar 2026 14:01:02 +0900 Subject: [PATCH] =?UTF-8?q?LED=20=EC=83=81=ED=83=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20=EB=AA=85=EB=A0=B9=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - BLE 명령으로 LED 상태 설정 --- pc_firm/parser.c | 38 ++++++++++++++++++- .../ble_app_bladder_patch/led_control.c | 2 +- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/pc_firm/parser.c b/pc_firm/parser.c index 1f36d83..b94f570 100644 --- a/pc_firm/parser.c +++ b/pc_firm/parser.c @@ -32,7 +32,8 @@ #include "dr_util.h" #include "main.h" #include "dr_adc121s051.h" - +#include "led_control.h" +#include "app_timer.h" /*============================================================================== * 외부 함수 선언부 @@ -408,6 +409,9 @@ static int Cmd_mbb(const ParsedCmd *cmd); /* mbb? 6채널 캡처 + 센서 측 static int Cmd_mcf(const ParsedCmd *cmd); /* mcf? 피에조 파라미터 읽기 (FDS) */ static int Cmd_mcs(const ParsedCmd *cmd); /* mcs? 피에조 파라미터 쓰기 (FDS) */ +/* E. LED 제어 */ +static int Cmd_mls(const ParsedCmd *cmd); /* mls? LED 상태 설정 (앱 → 기기) */ + /* ---- 명령 테이블 ---- */ @@ -452,6 +456,9 @@ static CmdEntry g_cmd_table[] = { { "mbb?", true, Cmd_mbb }, { "mcf?", true, Cmd_mcf }, { "mcs?", true, Cmd_mcs }, + + /* F. LED 제어 */ + { "mls?", true, Cmd_mls }, }; /* 명령 테이블 엔트리 수 (컴파일 타임 계산) */ @@ -1194,6 +1201,35 @@ static int Cmd_mcs(const ParsedCmd *cmd) } +/** + * @brief mls? - LED 상태 설정 (앱 → 기기) + * + * 파라미터: [state(2)] - led_state_t enum 값 + * 0: OFF, 4: DETACH_WARNING, 5: ALIGN_SEARCHING, 6: ALIGN_COMPLETE + * 응답: rls: [state(2)] - 에코 + */ +static int Cmd_mls(const ParsedCmd *cmd) +{ + if (cmd->data_len < 2) { + dr_ble_return_1("rls:", 0xFFFF); + return 1; + } + + uint16_t state; + dr_get_u16(cmd, 0, &state); + + if (state > LED_STATE_ERROR) { + dr_ble_return_1("rls:", 0xFFFE); + return 1; + } + + led_set_state((led_state_t)state); + dr_ble_return_1("rls:", state); + + return 1; +} + + /*============================================================================== * 설정: HW/시리얼 넘버 FDS 읽기/쓰기 * diff --git a/project/ble_peripheral/ble_app_bladder_patch/led_control.c b/project/ble_peripheral/ble_app_bladder_patch/led_control.c index f543819..bd16c79 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/led_control.c +++ b/project/ble_peripheral/ble_app_bladder_patch/led_control.c @@ -253,7 +253,7 @@ void led_init(void) void led_set_state(led_state_t state) { if (state >= LED_STATE_COUNT) return; - + /* 이전 패턴 중단 */ app_timer_stop(m_led_timer); led_all_off();