Compare commits
3 Commits
36c8958e03
...
69c4e20f34
| Author | SHA1 | Date | |
|---|---|---|---|
| 69c4e20f34 | |||
| ba6f0e452e | |||
| 39e7895057 |
@@ -525,6 +525,7 @@ static void connected(struct bt_conn *conn, uint8_t err)
|
|||||||
|
|
||||||
conn_param_update_attempts = 0U;
|
conn_param_update_attempts = 0U;
|
||||||
last_rx_conn_param_update_ms = 0;
|
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)
|
#if IS_ENABLED(CONFIG_BT_SMP)
|
||||||
err = bt_conn_set_security(conn, BLE_REQUIRED_SECURITY_LEVEL);
|
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);
|
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)
|
#if IS_ENABLED(CONFIG_BT_SMP)
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ int cmd_mbb(const uint8_t *data, uint8_t data_len)
|
|||||||
int16_t gyro[3];
|
int16_t gyro[3];
|
||||||
|
|
||||||
processing = true;
|
processing = true;
|
||||||
power_button_suspend(true);
|
|
||||||
DBG_PRINTF("[MBB] cmd start\r\n");
|
DBG_PRINTF("[MBB] cmd start\r\n");
|
||||||
|
|
||||||
int batt_mv = -1;
|
int batt_mv = -1;
|
||||||
@@ -77,7 +76,6 @@ int cmd_mbb(const uint8_t *data, uint8_t data_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
piezo_power_off();
|
piezo_power_off();
|
||||||
power_button_suspend(false);
|
|
||||||
DBG_PRINTF("[MBB] done\r\n");
|
DBG_PRINTF("[MBB] done\r\n");
|
||||||
cmd_send_response_u16("raa:", (uint16_t)status); // 최종 상태 raa: 전송
|
cmd_send_response_u16("raa:", (uint16_t)status); // 최종 상태 raa: 전송
|
||||||
DBG_PRINTF("[CMD] mbb status=0x%04X\r\n", status);
|
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;
|
bool fifo_started = false;
|
||||||
|
|
||||||
processing = true;
|
processing = true;
|
||||||
power_button_suspend(true);
|
|
||||||
DBG_PRINTF("[MTB] cmd start\r\n");
|
DBG_PRINTF("[MTB] cmd start\r\n");
|
||||||
|
|
||||||
int imu_ret = imu_fifo_start();
|
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);
|
DBG_PRINTF("[CMD] mtb status=0x%04X\r\n", status);
|
||||||
|
|
||||||
piezo_power_off();
|
piezo_power_off();
|
||||||
power_button_suspend(false);
|
|
||||||
DBG_PRINTF("[CMD] mtb status=0x%04X rim=%u\r\n", status, rim_count);
|
DBG_PRINTF("[CMD] mtb status=0x%04X rim=%u\r\n", status, rim_count);
|
||||||
|
|
||||||
processing = false;
|
processing = false;
|
||||||
@@ -221,12 +217,20 @@ int cmd_mim(const uint8_t *data, uint8_t data_len)
|
|||||||
ARG_UNUSED(data);
|
ARG_UNUSED(data);
|
||||||
ARG_UNUSED(data_len);
|
ARG_UNUSED(data_len);
|
||||||
|
|
||||||
|
if (processing)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
processing = true;
|
||||||
|
|
||||||
uint16_t rim_count = 0U;
|
uint16_t rim_count = 0U;
|
||||||
int imu_ret = imu_fifo_start();
|
int imu_ret = imu_fifo_start();
|
||||||
if (imu_ret != 0)
|
if (imu_ret != 0)
|
||||||
{
|
{
|
||||||
DBG_PRINTF("[MTB] fifo start fail ret=%d\r\n", imu_ret);
|
DBG_PRINTF("[MTB] fifo start fail ret=%d\r\n", imu_ret);
|
||||||
cmd_send_response_rim(tx_rim_samples, 0U);
|
cmd_send_response_rim(tx_rim_samples, 0U);
|
||||||
|
processing = false;
|
||||||
return 1;
|
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: 전송
|
cmd_send_response_rim(tx_rim_samples, rim_count); // IMU FIFO 15 samples rim: 전송
|
||||||
imu_fifo_stop();
|
imu_fifo_stop();
|
||||||
|
processing = false;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +266,6 @@ int cmd_maa(const uint8_t *data, uint8_t data_len)
|
|||||||
uint8_t session = cmd_next_echo_session();
|
uint8_t session = cmd_next_echo_session();
|
||||||
|
|
||||||
processing = true;
|
processing = true;
|
||||||
power_button_suspend(true);
|
|
||||||
|
|
||||||
int status = piezo_measure_start_session();
|
int status = piezo_measure_start_session();
|
||||||
|
|
||||||
@@ -280,7 +284,6 @@ int cmd_maa(const uint8_t *data, uint8_t data_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
piezo_power_off();
|
piezo_power_off();
|
||||||
power_button_suspend(false);
|
|
||||||
cmd_send_response_u16("raa:", (uint16_t)status); // 최종 상태 raa: 전송
|
cmd_send_response_u16("raa:", (uint16_t)status); // 최종 상태 raa: 전송
|
||||||
DBG_PRINTF("[CMD] maa status=0x%04X\r\n", status);
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
power_button_suspend(true);
|
|
||||||
|
|
||||||
if (piezo_init() != 0)
|
if (piezo_init() != 0)
|
||||||
{
|
{
|
||||||
power_button_suspend(false);
|
|
||||||
cmd_send_response_u16("rpc:", 0);
|
cmd_send_response_u16("rpc:", 0);
|
||||||
return 1;
|
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)
|
if (piezo_select_channel((uint8_t)(piezo_ch % PIEZO_NUM_CHANNELS)) != 0)
|
||||||
{
|
{
|
||||||
piezo_power_off();
|
piezo_power_off();
|
||||||
power_button_suspend(false);
|
|
||||||
cmd_send_response_u16("rpc:", 0);
|
cmd_send_response_u16("rpc:", 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
piezo_burst_sw_freq((uint8_t)freq_option, cycles);
|
piezo_burst_sw_freq((uint8_t)freq_option, cycles);
|
||||||
piezo_power_off();
|
piezo_power_off();
|
||||||
power_button_suspend(false);
|
|
||||||
|
|
||||||
cmd_send_response_u16("rpc:", cycles);
|
cmd_send_response_u16("rpc:", cycles);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -422,7 +421,6 @@ int cmd_mec(const uint8_t *data, uint8_t data_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
processing = true;
|
processing = true;
|
||||||
power_button_suspend(true);
|
|
||||||
|
|
||||||
int status = piezo_measure_start_session();
|
int status = piezo_measure_start_session();
|
||||||
if (status == ECHO_STATUS_OK)
|
if (status == ECHO_STATUS_OK)
|
||||||
@@ -436,7 +434,6 @@ int cmd_mec(const uint8_t *data, uint8_t data_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
piezo_power_off();
|
piezo_power_off();
|
||||||
power_button_suspend(false);
|
|
||||||
cmd_send_response_u16("raa:", (uint16_t)status);
|
cmd_send_response_u16("raa:", (uint16_t)status);
|
||||||
processing = false;
|
processing = false;
|
||||||
return 1;
|
return 1;
|
||||||
@@ -468,7 +465,6 @@ int cmd_mad(const uint8_t *data, uint8_t data_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
processing = true;
|
processing = true;
|
||||||
power_button_suspend(true);
|
|
||||||
|
|
||||||
int status = piezo_measure_start_session();
|
int status = piezo_measure_start_session();
|
||||||
if (status == ECHO_STATUS_OK)
|
if (status == ECHO_STATUS_OK)
|
||||||
@@ -482,7 +478,6 @@ int cmd_mad(const uint8_t *data, uint8_t data_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
piezo_power_off();
|
piezo_power_off();
|
||||||
power_button_suspend(false);
|
|
||||||
cmd_send_response_u16("raa:", (uint16_t)status);
|
cmd_send_response_u16("raa:", (uint16_t)status);
|
||||||
DBG_PRINTF("[CMD] mad status=0x%04X ch=%u samples=%u avg=%u\r\n",
|
DBG_PRINTF("[CMD] mad status=0x%04X ch=%u samples=%u avg=%u\r\n",
|
||||||
status,
|
status,
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ int cmd_msp(const uint8_t *data, uint8_t data_len)
|
|||||||
ARG_UNUSED(data);
|
ARG_UNUSED(data);
|
||||||
ARG_UNUSED(data_len);
|
ARG_UNUSED(data_len);
|
||||||
|
|
||||||
|
if (processing)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int16_t accel[3], gyro[3];
|
int16_t accel[3], gyro[3];
|
||||||
|
|
||||||
int ret = imu_read(accel, gyro);
|
int ret = imu_read(accel, gyro);
|
||||||
|
|||||||
Reference in New Issue
Block a user