LED 상태 설정 명령 추가

- BLE 명령으로 LED 상태 설정
This commit is contained in:
jhChun
2026-03-31 14:01:02 +09:00
parent 29fa5fa3e6
commit f1995e10f6
2 changed files with 38 additions and 2 deletions

View File

@@ -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 읽기/쓰기
*