summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
Diffstat (limited to 'cesar')
-rw-r--r--cesar/bsu/inc/context.h2
-rw-r--r--cesar/bsu/src/bsu.c29
-rw-r--r--cesar/bsu/test/utest/src/bsut.c18
3 files changed, 26 insertions, 23 deletions
diff --git a/cesar/bsu/inc/context.h b/cesar/bsu/inc/context.h
index 2e6992d1c5..7a4fe11b0d 100644
--- a/cesar/bsu/inc/context.h
+++ b/cesar/bsu/inc/context.h
@@ -98,6 +98,8 @@ struct bsu_t
u32 beacon_nb_recv[BSU_BEACON_TYPE_NB];
/** NEK switch. */
uint nek_switch;
+ /** Station's discover info updated by CP. */
+ bsu_beacon_bmi_discover_info_t discover_info;
#if CONFIG_TRACE
/** Trace system. */
trace_buffer_t trace;
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index da12e6d185..d7b58cb220 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -522,19 +522,20 @@ bsu_avln_schedules_decrease_countdown (bsu_t *ctx, bsu_avln_t *avln)
* Create the beacon to be send over the PLC.
* \param ctx the module context.
* \param type the beacon type.
+ * \param bsu_beacon the beacon to use to write the PB.
*/
static void
-bsu_beacon_send_prepare (bsu_t *ctx, bsu_beacon_type_t type)
+bsu_beacon_send_prepare (bsu_t *ctx, bsu_beacon_type_t type,
+ bsu_beacon_t *bsu_beacon)
{
pb_beacon_t *beacon;
pbproc_tx_beacon_params_t params;
bsu_aclf_bto (ctx->aclf, (s16*) params.bto, COUNT (params.bto));
- beacon = bsu_beacon_write (&ctx->sta_avln->beacon, type,
- ctx->mac_config, &params);
+ bsu_beacon->bmis.discover_info = ctx->discover_info;
+ beacon = bsu_beacon_write (bsu_beacon, type, ctx->mac_config, &params);
/* Reset the updated flag in the discover info beacon entry. */
if (type == BSU_BEACON_TYPE_DISCOVER)
- bitstream_direct_write (
- &ctx->sta_avln->beacon.bmis.discover_info.info_data, 0, 0, 1);
+ bitstream_direct_write (&ctx->discover_info.info_data, 0, 0, 1);
/* Send the beacon. */
bsu_beacon_send (ctx, type, beacon, &params);
}
@@ -576,14 +577,16 @@ bsu_timer_event_process (void *ud)
ctx->pbproc,
bsu_aclf_beacon_period_start_date_next (ctx->aclf)
+ bsu_aclf_beacon_period_tck (ctx->aclf));
- bsu_beacon_send_prepare (ctx, BSU_BEACON_TYPE_CENTRAL);
+ bsu_beacon_send_prepare (ctx, BSU_BEACON_TYPE_CENTRAL,
+ &ctx->sta_avln->beacon);
}
if (ctx->is_sta == BSU_UPDATE_STA_TYPE_UCCO
|| (ctx->sta_avln->beacon.bmis.discover.present
&& ctx->sta_avln->beacon.bmis.discover.tei
== ctx->mac_config->tei))
{
- bsu_beacon_send_prepare (ctx, BSU_BEACON_TYPE_DISCOVER);
+ bsu_beacon_send_prepare (ctx, BSU_BEACON_TYPE_DISCOVER,
+ &ctx->sta_avln->beacon);
/* Not UCCo discover beacon had been sent set the flag to
* false to avoid to resend a discover beacon on next wake up. */
if (ctx->is_sta != BSU_UPDATE_STA_TYPE_UCCO)
@@ -740,7 +743,8 @@ bsu_beacon_process (bsu_t *ctx, pb_beacon_t *beacon,
if (ctx->sta_avln->beacon.bmis.discover.present
&& ctx->sta_avln->beacon.bmis.discover.tei
== ctx->mac_config->tei)
- bsu_beacon_send_prepare (ctx, BSU_BEACON_TYPE_DISCOVER);
+ bsu_beacon_send_prepare (ctx, BSU_BEACON_TYPE_DISCOVER,
+ &bsu_beacon);
ctx->sta_avln->beacon.beacon_period_start_date = params->bts -
ctx->sta_avln->sync.ntb_offset_tck;
avln = ctx->sta_avln;
@@ -1034,13 +1038,12 @@ bsu_update_discover_info (bsu_beacon_bmi_discover_info_t *discover)
arch_dsr_lock ();
bool discover_updated = bitstream_direct_read
(&discover->info_data, 0, 1);
- bool current_discover_updated = bitstream_direct_read
- (&ctx->sta_avln->beacon.bmis.discover_info.info_data, 0, 1);
- ctx->sta_avln->beacon.bmis.discover_info = *discover;
+ bool current_discover_updated =
+ bitstream_direct_read (&ctx->discover_info.info_data, 0, 1);
+ ctx->discover_info = *discover;
/* BSU is responsible for reseting the updated flag in this entry. */
if (current_discover_updated || discover_updated)
- bitstream_direct_write (
- &ctx->sta_avln->beacon.bmis.discover_info.info_data, 0, 1, 1);
+ bitstream_direct_write (&ctx->discover_info.info_data, 0, 1, 1);
arch_dsr_unlock ();
}
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index b1b99e6a29..dba57c8913 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -732,15 +732,14 @@ test_case_bsu_discover_update (test_t test)
sizeof (bsu_beacon_bmi_discover_info_t)) != 0);
bsu_update_discover_info (&beacon.bmis.discover_info);
test_fail_unless (memcmp (&beacon.bmis.discover_info,
- &t.bsu->sta_avln->beacon.bmis.discover_info,
+ &t.bsu->discover_info,
sizeof (bsu_beacon_bmi_discover_info_t)) == 0);
/* change update flag. */
bitstream_direct_write (&beacon.bmis.discover_info.info_data, 0, 1,
1);
bsu_update_discover_info (&beacon.bmis.discover_info);
test_fail_unless (
- memcmp (&beacon.bmis.discover_info,
- &t.bsu->sta_avln->beacon.bmis.discover_info,
+ memcmp (&beacon.bmis.discover_info, &t.bsu->discover_info,
sizeof (bsu_beacon_bmi_discover_info_t)) == 0);
/* change update flag. */
bitstream_direct_write (&beacon.bmis.discover_info.info_data, 0, 0,
@@ -751,18 +750,17 @@ test_case_bsu_discover_update (test_t test)
&t.bsu->sta_avln->beacon.bmis.discover_info,
sizeof (bsu_beacon_bmi_discover_info_t)) != 0);
test_fail_unless (
- bitstream_direct_read
- (&t.bsu->sta_avln->beacon.bmis.discover_info.info_data, 0, 1) == true);
+ bitstream_direct_read (
+ &t.bsu->discover_info.info_data, 0, 1) == true);
/* Simulate BSU reset the flag after sending a discover beacon. */
- t.bsu->sta_avln->beacon.bmis.discover_info = beacon.bmis.discover_info;
+ t.bsu->discover_info = beacon.bmis.discover_info;
bsu_update_discover_info (&beacon.bmis.discover_info);
test_fail_unless (
- memcmp (&beacon.bmis.discover_info,
- &t.bsu->sta_avln->beacon.bmis.discover_info,
+ memcmp (&beacon.bmis.discover_info, &t.bsu->discover_info,
sizeof (bsu_beacon_bmi_discover_info_t)) == 0);
test_fail_unless (
- bitstream_direct_read
- (&t.bsu->sta_avln->beacon.bmis.discover_info.info_data, 0, 1) == false);
+ bitstream_direct_read (
+ &t.bsu->discover_info.info_data, 0, 1) == false);
bsu_test_uninit (&t);
}
test_end;