summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorlaranjeiro2010-05-17 10:03:06 +0000
committerlaranjeiro2010-05-17 10:03:06 +0000
commit2b7e031b84a7d87f081e5daad662ee7e93b21c45 (patch)
treeecca8635ae13f578914f870d4ea3f8ded9d08c6e /cesar
parent4be715f3d2c0320145d2caa9245573bd201ab066 (diff)
cesar/cp/beacon: some fixes
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7077 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar')
-rw-r--r--cesar/cp/beacon/src/beacon.c18
-rw-r--r--cesar/cp/beacon/src/beacon_discover.c13
2 files changed, 17 insertions, 14 deletions
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index d3dddde43d..9966b52b5a 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -95,7 +95,8 @@ cp_beacon_fill_share_memory (cp_t *ctx)
beacon = cp_get_next_beacon_shared_memory (ctx);
dbg_assert (beacon);
-
+ beacon->beacon_period_start_date =
+ bsu_aclf_beacon_period_start_date_next (ctx->bsu_aclf);
sta = cp_sta_mgr_get_sta_own_data (ctx);
if (cp_sta_own_data_get_tei (ctx))
net = cp_sta_mgr_get_our_avln (ctx);
@@ -573,8 +574,6 @@ cp_beacon_init (cp_t *ctx)
(hal_timer_instance_cb_t)cp_beacon_timer_expires);
// Initialise the mem_share_slot_id so that the next slot is 0.
ctx->beacon.shared_mem_slot_id = CP_SHARED_MEM_SLOT_NB - 1;
- ctx->beacon.last_countdown_date = phy_date ();
- ctx->beacon.countdown_limit_date = ctx->beacon.last_countdown_date;
/* Setup beacon indicator. */
GPIO_SETUP (LED_BEACON_TX_RX, GPIO_DIRECTION_OUT);
GPIO_SET (LED_BEACON_TX_RX, 0);
@@ -647,7 +646,8 @@ void
cp_beacon_poweron_init (cp_t *ctx)
{
dbg_assert (ctx);
-
+ ctx->beacon.countdown_limit_date =
+ ctx->beacon.last_countdown_date = phy_date ();
/* Generate the beacon and send. */
bsu_beacon_t *beacon = cp_beacon_fill_share_memory (ctx);
bsu_update (beacon, BSU_UPDATE_STA_TYPE_STA);
@@ -689,7 +689,8 @@ cp_beacon_get_and_process_beacon (cp_t *ctx)
&((cp_beacon_payload_t*)pb_beacon->data)->bsu_params;
snid = bsu_params->rx_parameters.snid;
- if (!bsu_beacon_read (pb_beacon, &beacon_data, &type, (u8*)&tei,
+ u8 btei;
+ if (!bsu_beacon_read (pb_beacon, &beacon_data, &type, &btei,
&mac_address))
{
/* The beacon contains some strange values. */
@@ -699,6 +700,7 @@ cp_beacon_get_and_process_beacon (cp_t *ctx)
blk_release_desc ((blk_t *)pb_beacon);
return;
}
+ tei = btei;
/** Beacon received ok. */
GPIO_TOGGLE (LED_BEACON_TX_RX);
@@ -716,8 +718,9 @@ cp_beacon_get_and_process_beacon (cp_t *ctx)
cp_net_set_slot_id_and_usage (ctx, net, beacon_data.vf.slotid,
beacon_data.vf.slotusage);
+ dbg_assert (tei == MAC_TEI_UNASSOCIATED || MAC_TEI_IS_STA (tei));
sta = cp_beacon_update_sta_peer (ctx, &beacon_data, net, type, tei,
- mac_address);
+ mac_address);
/** Check handover in progress status. */
if ((!ctx->beacon.hoip.hoipcd)
@@ -959,9 +962,6 @@ cp_beacon_reconfigure_timer (cp_t *ctx, bool cco)
hal_timer_instance_cancel (ctx->hal_timer, &ctx->beacon.leon_timer);
hal_timer_instance_program (ctx->hal_timer, &ctx->beacon.leon_timer,
date);
-
- dbg_assert (phy_date () < date);
-
CP_TRACE_VERBOSE (BEACON_TIMER_PRGM, phy_date (), date);
}
diff --git a/cesar/cp/beacon/src/beacon_discover.c b/cesar/cp/beacon/src/beacon_discover.c
index 241cd0db2e..7bca48c96e 100644
--- a/cesar/cp/beacon/src/beacon_discover.c
+++ b/cesar/cp/beacon/src/beacon_discover.c
@@ -60,13 +60,16 @@ cp_beacon_discover_uninit (cp_beacon_discover_t *ctx)
void
cp_beacon_discover_compute_interval (cp_t *ctx)
{
- cp_net_t *our_net;
dbg_assert (ctx);
- our_net = cp_sta_mgr_get_our_avln (ctx);
- // Compute the number of beacon period between to requests.
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
+ u32 bp = bsu_aclf_beacon_period (ctx->bsu_aclf);
+
+ dbg_assert (bp);
+
ctx->beacon.discover.discover_interval_bp =
- ctx->pwl.discover_period_max_bp
- / (cp_net_get_num_stas (ctx, our_net) + 1);
+ MAC_MS_TO_TCK (MAC_SEC_TO_MS(CP_DISCOVER_PERIOD_MAX_S)) /
+ (bp * (cp_net_get_num_stas (ctx, our_net) + 1));
+
/* If the countdown is greater store it to the new value. */
if (lesseq_mod2p32 (ctx->beacon.discover.discover_interval_bp,
ctx->beacon.discover.countdown_bp))