summaryrefslogtreecommitdiff
path: root/cesar/bsu/src/bsu.c
diff options
context:
space:
mode:
authorNélio Laranjeiro2010-12-03 09:16:22 +0100
committerNélio Laranjeiro2011-01-11 15:39:45 +0100
commit21a62f1168746cda1b5eb68d76593938dc371db1 (patch)
tree1eb325785b5c191dfd7e0f5b59622c33ea6aa65d /cesar/bsu/src/bsu.c
parentc6a459052635a62ebf4745a75d72dd091a57068c (diff)
cesar/bsu: modify schedules for CSMA only mode on beacon reception, closes #2198
Diffstat (limited to 'cesar/bsu/src/bsu.c')
-rw-r--r--cesar/bsu/src/bsu.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index cded996ce7..d5e6ba8c80 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -371,29 +371,29 @@ bsu_ca_schedules_settings (bsu_t *ctx, bsu_avln_t *avln,
* If the network is in CSMA only mode, check the current schedule is
* permanent and with a full CSMA period.
* \param ctx the module context.
- * \param avln the AVLN structure to change the schedules.
+ * \param beacon the beacon to modify.
*
* If the schedules are not compatible with the network mode, the default will
* be applied.
*/
inline void
-bsu_ca_schedules_nm_csma_only (bsu_t *ctx, bsu_avln_t *avln)
+bsu_ca_schedules_nm_csma_only (bsu_t *ctx, bsu_beacon_t *beacon)
{
- if (avln->beacon.vf.nm == BSU_BEACON_NM_CSMA_ONLY)
+ if (beacon->vf.nm == BSU_BEACON_NM_CSMA_ONLY)
{
- if (avln->beacon.bmis.ps.nb == 0
- || !(avln->beacon.bmis.ps.nb == 1
+ if (beacon->bmis.ps.nb == 0
+ || !(beacon->bmis.ps.nb == 1
&& BSU_BEACON_PERSISTENT_ALLOC_IS_PERMANENT(
- avln->beacon.bmis.ps.ps[0])))
+ beacon->bmis.ps.ps[0])))
{
- avln->beacon.bmis.nps.ns = 0;
- avln->beacon.bmis.ps.nb = 1;
- avln->beacon.bmis.ps.ps[0].ns = 1;
- avln->beacon.bmis.ps.ps[0].pscd = 0;
- avln->beacon.bmis.ps.ps[0].cscd =
+ beacon->bmis.nps.ns = 0;
+ beacon->bmis.ps.nb = 1;
+ beacon->bmis.ps.ps[0].ns = 1;
+ beacon->bmis.ps.ps[0].pscd = 0;
+ beacon->bmis.ps.ps[0].cscd =
BSU_BEACON_PERSISTENT_SCHEDULES_PERMANENT_COUNTDOWN;
- avln->beacon.bmis.ps.ps[0].sais[0].stpf = false;
- avln->beacon.bmis.ps.ps[0].sais[0].glid = MAC_LID_SHARED_CSMA & 0x7f;
+ beacon->bmis.ps.ps[0].sais[0].stpf = false;
+ beacon->bmis.ps.ps[0].sais[0].glid = MAC_LID_SHARED_CSMA & 0x7f;
}
}
}
@@ -441,7 +441,6 @@ bsu_ca_schedules__timer_event (bsu_t *ctx, bsu_avln_t *avln)
{
dbg_assert (avln);
ca_beacon_period_t beacon_period[BSU_BEACON_SCHEDULES_MAX];
- bsu_ca_schedules_nm_csma_only (ctx, avln);
bsu_aclf_beacon_period_start_date (
ctx->aclf, &beacon_period[0].start_date, 1);
beacon_period[0].schedule_index = ctx->ca_index_last_first;
@@ -463,7 +462,6 @@ bsu_ca_schedules__beacon_reception (bsu_t *ctx, bsu_avln_t *avln)
ca_beacon_period_t beacon_period[BSU_BEACON_SCHEDULES_MAX];
ctx->ca_index_last_first =
(ctx->ca_index_last_first + CA_SCHEDULE_NB / 2) % CA_SCHEDULE_NB;
- bsu_ca_schedules_nm_csma_only (ctx, avln);
bsu_aclf_beacon_period_start_date (
ctx->aclf, &beacon_period[0].start_date, 1);
beacon_period[0].schedule_index = ctx->ca_index_last_first;
@@ -857,6 +855,7 @@ bsu_beacon_process (bsu_t *ctx, pb_beacon_t *beacon,
if (bsu_beacon_read (beacon, &bsu_beacon))
{
ctx->beacon_nb_recv[bsu_beacon.vf.bt]++;
+ bsu_ca_schedules_nm_csma_only (ctx, &bsu_beacon);
if (bsu_beacon.vf.bt == BSU_BEACON_TYPE_CENTRAL)
{
/* It the beacon from our AVLN ? */
@@ -1052,7 +1051,6 @@ bsu_power_on (u8 snid)
dbg_assert (ctx->sta_avln->beacon.bmis.ps.nb != 0
|| ctx->sta_avln->beacon.bmis.nps.ns != 0);
/* Create the first schedule. */
- bsu_ca_schedules_nm_csma_only (ctx, ctx->sta_avln);
ctx->ca_index_last_first =
(ctx->ca_index_last_first + CA_SCHEDULE_NB / 2) %
CA_SCHEDULE_NB;