Compare commits

...

3 Commits

Author SHA1 Message Date
jh.chun 69c4e20f34 BLE 연결 파라미터 협상 복구
- 연결 5초 후 15 ms connection interval 요청
- Latency 0, supervision timeout 10 s 설정 요청
- 목표 파라미터 미적용 시 30초 간격으로 최대 3회 재요청
- Central이 최종 적용 여부 결정
- 요청 실패 또는 미적용 시에도 연결은 유지

* 연결 직후에는 pairing/security/초기 GATT 처리 때문에 요청이 무시되거나 늦게 반영될 수 있음
* 첫 요청 타이밍에 폰 상태가 안 좋아서 preferred 값이 안 먹을 수 있음
* 일정 시간 뒤 다시 요청하면 그때는 받아질 가능성이 있음
* 실패해도 연결을 끊지 않으므로 리스크가 크지 않음
2026-07-15 10:54:30 +09:00
jh.chun ba6f0e452e 캡처 중 전원 버튼 허용 2026-07-15 10:46:09 +09:00
jh.chun 39e7895057 IMU FIFO 캡처 중 msp/mim 동시 접근 방지
- IMU FIFO 캡처 중인 경우 조용히 무시
2026-07-15 09:41:03 +09:00
3 changed files with 21 additions and 15 deletions
+6
View File
@@ -525,6 +525,7 @@ static void connected(struct bt_conn *conn, uint8_t err)
conn_param_update_attempts = 0U;
last_rx_conn_param_update_ms = 0;
k_work_schedule(&conn_param_update_work, K_MSEC(BLE_CONN_PARAM_FIRST_DELAY_MS));
#if IS_ENABLED(CONFIG_BT_SMP)
err = bt_conn_set_security(conn, BLE_REQUIRED_SECURITY_LEVEL);
@@ -596,6 +597,11 @@ static void le_param_updated(struct bt_conn *conn, uint16_t interval,
{
k_work_cancel_delayable(&conn_param_update_work);
}
else if (conn_param_update_attempts < BLE_CONN_PARAM_MAX_ATTEMPTS)
{
k_work_schedule(&conn_param_update_work,
K_MSEC(BLE_CONN_PARAM_RETRY_INTERVAL_MS));
}
}
#if IS_ENABLED(CONFIG_BT_SMP)
+9 -14
View File
@@ -42,7 +42,6 @@ int cmd_mbb(const uint8_t *data, uint8_t data_len)
int16_t gyro[3];
processing = true;
power_button_suspend(true);
DBG_PRINTF("[MBB] cmd start\r\n");
int batt_mv = -1;
@@ -77,7 +76,6 @@ int cmd_mbb(const uint8_t *data, uint8_t data_len)
}
piezo_power_off();
power_button_suspend(false);
DBG_PRINTF("[MBB] done\r\n");
cmd_send_response_u16("raa:", (uint16_t)status); // 최종 상태 raa: 전송
DBG_PRINTF("[CMD] mbb status=0x%04X\r\n", status);
@@ -107,7 +105,6 @@ int cmd_mtb(const uint8_t *data, uint8_t data_len)
bool fifo_started = false;
processing = true;
power_button_suspend(true);
DBG_PRINTF("[MTB] cmd start\r\n");
int imu_ret = imu_fifo_start();
@@ -155,7 +152,6 @@ int cmd_mtb(const uint8_t *data, uint8_t data_len)
DBG_PRINTF("[CMD] mtb status=0x%04X\r\n", status);
piezo_power_off();
power_button_suspend(false);
DBG_PRINTF("[CMD] mtb status=0x%04X rim=%u\r\n", status, rim_count);
processing = false;
@@ -221,12 +217,20 @@ int cmd_mim(const uint8_t *data, uint8_t data_len)
ARG_UNUSED(data);
ARG_UNUSED(data_len);
if (processing)
{
return 1;
}
processing = true;
uint16_t rim_count = 0U;
int imu_ret = imu_fifo_start();
if (imu_ret != 0)
{
DBG_PRINTF("[MTB] fifo start fail ret=%d\r\n", imu_ret);
cmd_send_response_rim(tx_rim_samples, 0U);
processing = false;
return 1;
}
@@ -241,6 +245,7 @@ int cmd_mim(const uint8_t *data, uint8_t data_len)
cmd_send_response_rim(tx_rim_samples, rim_count); // IMU FIFO 15 samples rim: 전송
imu_fifo_stop();
processing = false;
return 1;
}
@@ -261,7 +266,6 @@ int cmd_maa(const uint8_t *data, uint8_t data_len)
uint8_t session = cmd_next_echo_session();
processing = true;
power_button_suspend(true);
int status = piezo_measure_start_session();
@@ -280,7 +284,6 @@ int cmd_maa(const uint8_t *data, uint8_t data_len)
}
piezo_power_off();
power_button_suspend(false);
cmd_send_response_u16("raa:", (uint16_t)status); // 최종 상태 raa: 전송
DBG_PRINTF("[CMD] maa status=0x%04X\r\n", status);
@@ -359,11 +362,9 @@ int cmd_mpc(const uint8_t *data, uint8_t data_len)
return 1;
}
power_button_suspend(true);
if (piezo_init() != 0)
{
power_button_suspend(false);
cmd_send_response_u16("rpc:", 0);
return 1;
}
@@ -373,14 +374,12 @@ int cmd_mpc(const uint8_t *data, uint8_t data_len)
if (piezo_select_channel((uint8_t)(piezo_ch % PIEZO_NUM_CHANNELS)) != 0)
{
piezo_power_off();
power_button_suspend(false);
cmd_send_response_u16("rpc:", 0);
return 1;
}
piezo_burst_sw_freq((uint8_t)freq_option, cycles);
piezo_power_off();
power_button_suspend(false);
cmd_send_response_u16("rpc:", cycles);
return 1;
@@ -422,7 +421,6 @@ int cmd_mec(const uint8_t *data, uint8_t data_len)
}
processing = true;
power_button_suspend(true);
int status = piezo_measure_start_session();
if (status == ECHO_STATUS_OK)
@@ -436,7 +434,6 @@ int cmd_mec(const uint8_t *data, uint8_t data_len)
}
piezo_power_off();
power_button_suspend(false);
cmd_send_response_u16("raa:", (uint16_t)status);
processing = false;
return 1;
@@ -468,7 +465,6 @@ int cmd_mad(const uint8_t *data, uint8_t data_len)
}
processing = true;
power_button_suspend(true);
int status = piezo_measure_start_session();
if (status == ECHO_STATUS_OK)
@@ -482,7 +478,6 @@ int cmd_mad(const uint8_t *data, uint8_t data_len)
}
piezo_power_off();
power_button_suspend(false);
cmd_send_response_u16("raa:", (uint16_t)status);
DBG_PRINTF("[CMD] mad status=0x%04X ch=%u samples=%u avg=%u\r\n",
status,
+5
View File
@@ -39,6 +39,11 @@ int cmd_msp(const uint8_t *data, uint8_t data_len)
ARG_UNUSED(data);
ARG_UNUSED(data_len);
if (processing)
{
return 1;
}
int16_t accel[3], gyro[3];
int ret = imu_read(accel, gyro);