diff --git a/samples/bluetooth/channel_sounding_ras_initiator/src/main.c b/samples/bluetooth/channel_sounding_ras_initiator/src/main.c index f38089260e24..6c6fdcd024d0 100644 --- a/samples/bluetooth/channel_sounding_ras_initiator/src/main.c +++ b/samples/bluetooth/channel_sounding_ras_initiator/src/main.c @@ -165,6 +165,18 @@ static void ranging_data_cb(struct bt_conn *conn, uint16_t ranging_counter, int LOG_DBG("Ranging data received for ranging counter %d", ranging_counter); + if (latest_local_steps.len == 0) { + LOG_WRN("All subevents in ranging counter %u were aborted", + most_recent_local_ranging_counter); + net_buf_simple_reset(&latest_local_steps); + k_sem_give(&sem_local_steps); + + if (!(ras_feature_bits & RAS_FEAT_REALTIME_RD)) { + net_buf_simple_reset(&latest_peer_steps); + } + return; + } + /* This struct is static to avoid putting it on the stack (it's very large) */ static cs_de_report_t cs_de_report; @@ -347,13 +359,13 @@ static void connected_cb(struct bt_conn *conn, uint8_t err) if (err) { bt_conn_unref(conn); connection = NULL; - } - - connection = bt_conn_ref(conn); + } else { + connection = bt_conn_ref(conn); - k_sem_give(&sem_connected); + k_sem_give(&sem_connected); - dk_set_led_on(CON_STATUS_LED); + dk_set_led_on(CON_STATUS_LED); + } } static void disconnected_cb(struct bt_conn *conn, uint8_t reason) @@ -710,8 +722,8 @@ int main(void) for (uint8_t ap = 0; ap < MAX_AP; ap++) { cs_de_dist_estimates_t distance_on_ap = get_distance(ap); - LOG_INF("Distance estimates on antenna path %u: ifft: %f, " - "phase_slope: %f, rtt: %f", + LOG_INF("Latest distance estimates on antenna path %u: ifft: %f, " + "phase_slope: %f, rtt: %f meters", ap, (double)distance_on_ap.ifft, (double)distance_on_ap.phase_slope, (double)distance_on_ap.rtt); diff --git a/samples/bluetooth/channel_sounding_ras_reflector/src/main.c b/samples/bluetooth/channel_sounding_ras_reflector/src/main.c index 3f74945a1dd0..87906c4933a4 100644 --- a/samples/bluetooth/channel_sounding_ras_reflector/src/main.c +++ b/samples/bluetooth/channel_sounding_ras_reflector/src/main.c @@ -44,13 +44,13 @@ static void connected_cb(struct bt_conn *conn, uint8_t err) if (err) { bt_conn_unref(conn); connection = NULL; - } - - connection = bt_conn_ref(conn); + } else { + connection = bt_conn_ref(conn); - k_sem_give(&sem_connected); + k_sem_give(&sem_connected); - dk_set_led_on(CON_STATUS_LED); + dk_set_led_on(CON_STATUS_LED); + } } static void disconnected_cb(struct bt_conn *conn, uint8_t reason)