summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorlaranjeiro2010-05-21 16:07:11 +0000
committerlaranjeiro2010-05-21 16:07:11 +0000
commit67125c79538a976c6fdab6931f5f5eb82acf07a8 (patch)
tree529e2cafa1116d4fa253ad2e492934adcb563488 /cesar
parent3c9e1c47fd7029e08716667a91818cd4eb061796 (diff)
cesar/bsu/aclf: fix beacon period start date computation
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7129 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar')
-rw-r--r--cesar/bsu/aclf/src/aclf.c24
-rw-r--r--cesar/bsu/aclf/test/utest/src/bpsd.c47
2 files changed, 61 insertions, 10 deletions
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
@@ -21,6 +21,9 @@
#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);
void
@@ -222,10 +225,54 @@ test_case_aclf_shift_bpsd (test_t t)
}
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)
{
test_suite_begin (t, "Beacon Period Start Date accurate");
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);
}