UART 비활성화
- main.c: main문의 uart_init(); 주석 처리 - 전력 소모 방지(약 1mA)
This commit is contained in:
@@ -149,7 +149,7 @@
|
||||
#define APP_ADV_INTERVAL 64 /* 광고 간격: 64 x 0.625ms = 40ms */
|
||||
|
||||
#if FEATURE_NO_SLEEP
|
||||
#define APP_ADV_DURATION 0 /* 슬립 비활성화 시: 무한 광고 */
|
||||
#define APP_ADV_DURATION 0 /* 슬립 비활성화(테스트) 시: 무한 광고 */
|
||||
#else
|
||||
#define APP_ADV_DURATION 18000 /* 광고 지속시간: 18000 x 10ms = 3분 → 타임아웃 시 슬립 */
|
||||
#endif
|
||||
@@ -268,13 +268,13 @@ bool device_reset = true; /* 부팅 중 플래그 (true=아직 미부팅) *
|
||||
bool erase_bonds; /* 본딩 삭제 플래그 (부팅 시 버튼 상태에 따라 설정) */
|
||||
#endif
|
||||
|
||||
volatile bool ble_connection_st; /* BLE 연결 상태 (1=연결됨, 0=미연결) */
|
||||
volatile bool data_tx_in_progress = false; /* 바이너리 TX 진행 중 플래그 */
|
||||
volatile bool ble_connection_st; /* BLE 연결 상태 (1=연결됨, 0=미연결) */
|
||||
volatile bool data_tx_in_progress = false; /* 바이너리 TX 진행 중 플래그 */
|
||||
|
||||
|
||||
/* 2026-03-17: cmd_parse.c에서 main.c로 이동한 전역변수 */
|
||||
char m_static_passkey[PASSKEY_LENGTH] = "123456"; /* 정적 패스키 (6자리, FDS에서 로드) */
|
||||
char SERIAL_NO[SERIAL_NO_LENGTH]; /* 시리얼 번호 (BLE 디바이스 이름으로 사용) */
|
||||
char HW_NO[HW_NO_LENGTH]; /* 하드웨어 번호 (FDS 저장/읽기) */
|
||||
char HW_NO[HW_NO_LENGTH]; /* 하드웨어 번호 (FDS 저장/읽기) */
|
||||
bool bond_data_delete; /* 본딩 데이터 삭제 요청 플래그 */
|
||||
uint32_t m_life_cycle; /* 디바이스 수명 사이클 카운터 */
|
||||
uint8_t resetCount = 0; /* 통신 타임아웃 카운터 (리셋 감지용) */
|
||||
@@ -1040,7 +1040,7 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
|
||||
m_tx_in_progress = false;
|
||||
|
||||
maa_async_abort(); // 비동기 측정 상태에 의한 먹통 현상 방지
|
||||
|
||||
|
||||
if (device_status == true)
|
||||
{
|
||||
if (device_sleep_mode() == 0)
|
||||
@@ -1506,7 +1506,6 @@ void dr_sd_delay_ms(uint32_t ms)
|
||||
nrf_delay_ms(ms);
|
||||
}
|
||||
|
||||
/* 2026-03-17: cmd_parse.c에서 main.c로 이동 */
|
||||
extern int SEGGER_RTT_vprintf(unsigned, const char *, va_list *);
|
||||
static void log_printf(const char *fmt, ...)
|
||||
{
|
||||
@@ -1559,29 +1558,40 @@ void dr_binary_tx_safe(uint8_t const *ble_bin_buff, uint16_t length) // BLE
|
||||
uint16_t send_len = total_len; /* 매 반복마다 리셋 필수 - ble_nus_data_send()가 값을 변경함! */
|
||||
err_code = ble_nus_data_send(&m_nus, tx_buffer, &send_len, m_conn_handle);
|
||||
|
||||
if (err_code == NRF_SUCCESS) { // 전송 성공 -> 루프 탈출
|
||||
/* TX queued successfully */
|
||||
if (err_code == NRF_SUCCESS) // 전송 성공 시 루프 탈출
|
||||
{
|
||||
break;
|
||||
} else if (err_code == NRF_ERROR_RESOURCES) { // TX 큐가 가득 찬 경우 5ms 대기 후 재시도 (최대 100회, ~500ms)
|
||||
}
|
||||
else if (err_code == NRF_ERROR_RESOURCES) // TX 큐가 가득 찬 경우 5ms 대기 후 재시도 (최대 100회, ~500ms)
|
||||
{
|
||||
/* BLE TX 큐 가득 참 - 연결 이벤트가 TX를 완료할 때까지 대기 */
|
||||
/* BLE 스택이 TX 완료 이벤트를 처리할 수 있도록 짧은 딜레이 */
|
||||
nrf_delay_ms(5); /* ~5ms 대기하여 TX 슬롯 확보 */
|
||||
nrf_delay_ms(5); /* ~5ms 대기하여 TX 슬롯 확보 -> 대기 중 3.2mA 전력 소모 */
|
||||
|
||||
retry_count++;
|
||||
} else if (err_code == NRF_ERROR_INVALID_STATE || err_code == NRF_ERROR_NOT_FOUND) { // 연결 끊김, 리턴
|
||||
}
|
||||
else if (err_code == NRF_ERROR_INVALID_STATE || err_code == NRF_ERROR_NOT_FOUND) // 연결 끊김, 리턴
|
||||
{
|
||||
DBG_PRINTF("[BLE TX] Disconnected\r\n");
|
||||
data_tx_in_progress = false;
|
||||
return;
|
||||
} else { // 기타 에러 -> 로그 출력 후 리턴
|
||||
}
|
||||
else // 기타 에러 -> 로그 출력 후 리턴
|
||||
{
|
||||
DBG_PRINTF("[BLE TX] Err:0x%X\r\n", err_code);
|
||||
data_tx_in_progress = false;
|
||||
return;
|
||||
}
|
||||
} while (retry_count < MAX_RETRIES);
|
||||
}
|
||||
while (retry_count < MAX_RETRIES);
|
||||
|
||||
if (retry_count > 0) {
|
||||
if (retry_count > 0)
|
||||
{
|
||||
DBG_PRINTF("[BLE TX] retry=%u (+%ums)\r\n", retry_count, retry_count * 5);
|
||||
}
|
||||
if (retry_count >= MAX_RETRIES) { // 최대 재시도(100회) 초과 시 해당 패킷 드롭, 연결은 유지
|
||||
|
||||
if (retry_count >= MAX_RETRIES){ // 최대 재시도(100회) 초과 시 해당 패킷 드롭, 연결은 유지
|
||||
|
||||
DBG_PRINTF("[BLE TX] FAIL %u retries\r\n", retry_count);
|
||||
data_tx_in_progress = false;
|
||||
/* ble_connection_st = 0 설정하지 않음 - 해당 패킷만 드롭하고 연결은 유지 */
|
||||
@@ -1700,7 +1710,7 @@ int main(void)
|
||||
if (power_off_duble_prohibit) return 0;
|
||||
cnt_s = 0;
|
||||
|
||||
uart_init();
|
||||
//uart_init(); UART 비활성화
|
||||
log_init();
|
||||
|
||||
DBG_PRINTF("\r\n========================================\r\n");
|
||||
|
||||
Reference in New Issue
Block a user