Skip to content

Commit 5037324

Browse files
eriksandgrenhermabe
authored andcommitted
bluetooth: cs_de: Less strict reqs to accept measurements as OK quality
Updates the requirements for how we determine if a ranging has enough good tones to calculate distance estimates. From requiring no more than 4 channels with "bad" tones to requiring at least 15 channels with "good" tones. Note that CS requires at least 15 channels to be enabled. The reason for making this change is that the requirement of no more than 4 channels with "bad" tones becomes quite hard to satisfy at ranges over a few meters, especially in noisy environements, which would prevcent cs_de from producing new distance estimates. By changing the requirement we can produce new distance estimates more regularly, even if the estimates may be less accurate. The reasoning here is that even if the estimates are less accurate it is better to have regular updates, and filters can be applied on top of the estimates produced to filter out outliers/bad estimates. Signed-off-by: Erik Sandgren <[email protected]>
1 parent 57ce743 commit 5037324

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

subsys/bluetooth/cs_de/cs_de.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ LOG_MODULE_REGISTER(cs_de, CONFIG_BT_CS_DE_LOG_LEVEL);
2626
#define CHANNEL_INDEX_OFFSET (2)
2727
#define NUM_CHANNELS (75)
2828

29-
#define TONE_QI_BAD_TONE_COUNT_THRESHOLD (4)
29+
#define TONE_QI_OK_TONE_COUNT_THRESHOLD (15)
3030

3131
#define PHASE_INVALID (2 * PI)
3232

@@ -250,16 +250,16 @@ static void calculate_dist_rtt(cs_de_report_t *p_report)
250250
}
251251
}
252252

253-
static bool m_is_tone_quality_bad(cs_de_tone_quality_t *p_tone_qi, uint8_t channel_map[10])
253+
static bool m_is_tone_quality_ok(cs_de_tone_quality_t *p_tone_qi, uint8_t channel_map[10])
254254
{
255-
uint8_t bad_tones_count = 0;
255+
uint8_t ok_tones_count = 0;
256256
for (uint8_t i = 0; i < NUM_CHANNELS; ++i) {
257257
if (BT_LE_CS_CHANNEL_BIT_GET(channel_map, i + CHANNEL_INDEX_OFFSET) &&
258-
p_tone_qi[i] == CS_DE_TONE_QUALITY_BAD) {
259-
bad_tones_count += 1;
258+
p_tone_qi[i] == CS_DE_TONE_QUALITY_OK) {
259+
ok_tones_count += 1;
260260
}
261261
}
262-
return (bad_tones_count > TONE_QI_BAD_TONE_COUNT_THRESHOLD);
262+
return (ok_tones_count >= TONE_QI_OK_TONE_COUNT_THRESHOLD);
263263
}
264264

265265
static void cumulate_mean(float *avg, float new_value, uint16_t *N)
@@ -412,10 +412,10 @@ void cs_de_populate_report(struct net_buf_simple *local_steps, struct net_buf_si
412412
p_report->distance_estimates[ap].rtt = NAN;
413413
p_report->distance_estimates[ap].best = NAN;
414414

415-
if (m_is_tone_quality_bad(&m_tone_quality_indicators[ap][0], config->channel_map)) {
416-
p_report->tone_quality[ap] = CS_DE_TONE_QUALITY_BAD;
417-
} else {
415+
if (m_is_tone_quality_ok(&m_tone_quality_indicators[ap][0], config->channel_map)) {
418416
p_report->tone_quality[ap] = CS_DE_TONE_QUALITY_OK;
417+
} else {
418+
p_report->tone_quality[ap] = CS_DE_TONE_QUALITY_BAD;
419419
}
420420
}
421421
}

0 commit comments

Comments
 (0)