summaryrefslogtreecommitdiff
path: root/cesar/bsu/src/bsu.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/bsu/src/bsu.c')
-rw-r--r--cesar/bsu/src/bsu.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index 589d6989ce..054815a36b 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -392,6 +392,7 @@ bsu_init (bsu_aclf_t *aclf, mac_config_t *mac_config, phy_t *phy,
timer, &ctx->timer,
bsu_aclf_beacon_period_start_date_next (ctx->aclf)
- MAC_US_TO_TCK (BSU_WAKEUP_DELAY_MS));
+ ctx->activate = false;
return ctx;
}
@@ -510,7 +511,8 @@ bsu_update (bsu_beacon_t *beacon, bool is_sta)
< beacon->bmis.ps.ps[1].pscd));
/* If the data provided are for the next beacon period. */
if (lesseq_mod2p32 (bsu_aclf_beacon_period_start_date_next (ctx->aclf),
- beacon->beacon_period_start_date))
+ beacon->beacon_period_start_date)
+ || !ctx->activate)
ctx->beacon = *beacon;
/* Data in the beacon are had already expired. */
else
@@ -559,11 +561,36 @@ bsu_update (bsu_beacon_t *beacon, bool is_sta)
}
void
-bsu_track_avln (bsu_t *ctx, u64 nid, u16 snid, u8 tei)
+bsu_track_avln (u64 nid, u16 snid, u8 tei)
{
- dbg_assert (ctx);
+ bsu_t *ctx = &bsu_global;
ctx->nid_track = nid;
ctx->snid_track = snid;
ctx->tei_track = tei;
ctx->sta_avln = bsu_avln_add (ctx, nid, snid);
}
+
+void
+bsu_activate (bool status)
+{
+ bsu_t *ctx = &bsu_global;
+ dbg_assert (status != ctx->activate);
+ ctx->activate = status;
+ if (status)
+ {
+ u32 bpsd[BSU_BEACON_PERIOD_NB];
+ /* Frequency detection. */
+ bsu_aclf_acl_frequency_detection (ctx->aclf);
+ /* Program the first schedules in the CA. */
+ bsu_aclf_ac_compute_beacon_period_start_date (ctx->aclf);
+ bsu_aclf_beacon_period_start_date (ctx->aclf, bpsd, COUNT (bpsd));
+ bsu_ca_schedules (ctx, ctx->sta_avln);
+ /* Reprogram the timer. */
+ hal_timer_instance_program (ctx->hal_timer, &ctx->timer,
+ bpsd[1]
+ - MAC_MS_TO_TCK (BSU_WAKEUP_DELAY_MS));
+ }
+ /* Stops BSU. */
+ else
+ hal_timer_instance_cancel (ctx->hal_timer, &ctx->timer);
+}