From 67125c79538a976c6fdab6931f5f5eb82acf07a8 Mon Sep 17 00:00:00 2001 From: laranjeiro Date: Fri, 21 May 2010 16:07:11 +0000 Subject: cesar/bsu/aclf: fix beacon period start date computation git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7129 017c9cb6-072f-447c-8318-d5b54f68fe89 --- cesar/bsu/aclf/src/aclf.c | 24 ++++++++++-------- cesar/bsu/aclf/test/utest/src/bpsd.c | 47 ++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 10 deletions(-) (limited to 'cesar') diff --git a/cesar/bsu/aclf/src/aclf.c b/cesar/bsu/aclf/src/aclf.c index 3b552f14f8..6a3119129f 100644 --- a/cesar/bsu/aclf/src/aclf.c +++ b/cesar/bsu/aclf/src/aclf.c @@ -72,8 +72,7 @@ bsu_aclf_shift_beacon_period_start_date (bsu_aclf_t *ctx) { for (i = 0; i < BSU_ACLF_BPSD_NB - 1; i++) ctx->bpsd[i] = ctx->bpsd[i+1]; - ctx->bpsd[i] += - ctx->bpsd[BSU_ACLF_BPSD_NB-1] - ctx->bpsd[BSU_ACLF_BPSD_NB-2]; + ctx->bpsd[i] += ctx->bp; ctx->beacon_period = ctx->bpsd[1] - ctx->bpsd[0]; } } @@ -209,16 +208,21 @@ bsu_aclf_compute_beacon_period_start_date (bsu_aclf_t *ctx, const u32 bts_ntb, dbg_assert (ctx); u32 bts_date = bts_ntb - ntb_offset_tck - bpsto; ctx->bpsd[0] = bts_date; - for (i = 0; i < HPAV_BEACON_BTO_NB; i++) + for (i = 0; i < BSU_ACLF_BPSD_NB - 1; i++) { - ctx->bto[i] = bto[i]; - /* BTO is valid use it to compute. */ - if (bto[i] != HPAV_BEACON_BTO_INVALID) - ctx->bpsd[i+1] = bts_date + (i+1)*ctx->bp + bto[i]; - /* BTO is not valid, STA assumes the beacon period start date has no - * offset (FIXME: Good idea ?) */ + if (i < HPAV_BEACON_BTO_NB) + { + ctx->bto[i] = bto[i]; + /* BTO is valid use it to compute. */ + if (bto[i] != HPAV_BEACON_BTO_INVALID) + ctx->bpsd[i+1] = bts_date + (i+1)*ctx->bp + bto[i]; + /* BTO is not valid, STA assumes the beacon period start date has + * no offset (FIXME: Good idea ?) */ + else + ctx->bpsd[i+1] = bts_date + (i+1)*ctx->bp; + } else - ctx->bpsd[i+1] = bts_date + (i+1)*ctx->bp; + ctx->bpsd[i+1] = ctx->bpsd[i] + ctx->bp; } } diff --git a/cesar/bsu/aclf/test/utest/src/bpsd.c b/cesar/bsu/aclf/test/utest/src/bpsd.c index 808556ce03..f26ee9381f 100644 --- a/cesar/bsu/aclf/test/utest/src/bpsd.c +++ b/cesar/bsu/aclf/test/utest/src/bpsd.c @@ -20,6 +20,9 @@ #include "result_increase.h" #include "result_decrease.h" +void +bsu_aclf_acl_frequency_detection (bsu_aclf_t *ctx); + void bsu_aclf_ac_compute_beacon_period_start_date (bsu_aclf_t *ctx); @@ -221,6 +224,49 @@ test_case_aclf_shift_bpsd (test_t t) test_end; } +void +test_case_aclf_shift_compute_shift_bpsd (test_t t) +{ + test_case_begin (t, "Shift compute and shift bpsd"); + test_begin (t, "no name") + { + uint i, j; + u32 now = phy_date (); + bsu_aclf_test_t test; + bsu_aclf_test_init (&test); + bsu_aclf_acl_frequency_detection (test.aclf); + for (j = 0; j < 3; j++) + { + for (i = 0; i < COUNT (test.aclf->bpsd); i++) + test.aclf->bpsd[i] = i * BSU_ACLF_BP_50HZ_TCK + now; + test.aclf->beacon_period = BSU_ACLF_BP_50HZ_TCK; + test.phy->phy = test.aclf->bpsd[1]; + if (j != 1) + bsu_aclf_shift_beacon_period_start_date (test.aclf); + else + { + u32 ntb_tick_offset = 1043; + u32 bts = test.aclf->bpsd[0] + ntb_tick_offset + test.aclf->bp; + s16 bto[4] = {0, 0, 0, 0}; + uint k; + for (k = 0; k < BSU_ACLF_BPSD_NB; k++) + test.aclf->bpsd[k] = 0; + bsu_aclf_compute_beacon_period_start_date (test.aclf, + bts, bto, 0, + ntb_tick_offset); + } + test_fail_unless ( + test.aclf->bpsd[1] + == bsu_aclf_beacon_period_start_date_next (test.aclf)); + for (i = 0; i < BSU_ACLF_BPSD_NB; i++) + test_fail_unless (test.aclf->bpsd[i] == now + (i+1) * + BSU_ACLF_BP_50HZ_TCK); + } + bsu_aclf_test_uninit (&test); + } + test_end; +} + void test_suite_aclf__bpsd_accurate (test_t t) { @@ -228,4 +274,5 @@ test_suite_aclf__bpsd_accurate (test_t t) test_case_aclf_estimate_beacon_period (t); test_case_aclf_compute_bto (t); test_case_aclf_shift_bpsd (t); + test_case_aclf_shift_compute_shift_bpsd (t); } -- cgit v1.2.3