summaryrefslogtreecommitdiff
path: root/cesar/cp/beacon/src/beacon.c
diff options
context:
space:
mode:
authorYacine Belkadi2013-04-02 17:38:42 +0200
committerYacine Belkadi2013-05-22 10:53:37 +0200
commit46b9d84d9dfca1a27cea6f3b85af148cd72a2434 (patch)
treeed6cf26bf8bbb5a634b6ce758d7fad484160d271 /cesar/cp/beacon/src/beacon.c
parent21ef1bf39c7cbbeff2c333e74b24c8ad426006e3 (diff)
cesar/{bsu,cp}/beacon: make bsu send a fake beacon to cp when no beacon is received
On a Sta, when an expected beacon is not received, make the bsu send a fake beacon to the cp. This allows the bsu to communicate with the cp when no beacon is received, and will be used in following commits.
Diffstat (limited to 'cesar/cp/beacon/src/beacon.c')
-rw-r--r--cesar/cp/beacon/src/beacon.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index f509711638..bb1c34270f 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -260,7 +260,8 @@ cp_beacon_receive (void *ul, bsu_beacon_t *beacon)
dbg_assert (ul);
dbg_assert (beacon);
interface_beacon (ctx->interface, beacon);
- if (beacon->params.direction == BSU_BEACON_DIRECTION_FROM_PLC)
+ if (beacon->params.direction == BSU_BEACON_DIRECTION_FROM_PLC
+ || beacon->params.direction == BSU_BEACON_DIRECTION_FROM_BSU)
{
beacon->next = NULL;
slist_push_back (ctx->beacon.list., beacon, bare);
@@ -605,6 +606,19 @@ cp_beacon_process_bmi_eks (cp_t *ctx, const bsu_beacon_t *beacon)
}
/**
+ * Handle the non-reception of a beacon, as reported by the bsu which sends a
+ * fake one.
+ * \param ctx cp context.
+ * \param fake_beacon A fake beacon.
+ */
+static void
+cp_beacon__bsu_inform__beacon_not_received (cp_t *ctx,
+ const bsu_beacon_t *fake_beacon)
+{
+ dbg_assert (!cp_sta_own_data_get_cco_status (ctx));
+}
+
+/**
* Process the first beacon in the received list.
* \param ctx the control plane context.
*/
@@ -622,13 +636,20 @@ cp_beacon_get_and_process_beacon (cp_t *ctx)
arch_dsr_lock ();
beacon = slist_pop_front (ctx->beacon.list., bare);
arch_dsr_unlock ();
- /** Beacon received ok. */
- GPIO_TOGGLE (LED_BEACON_TX_RX);
- CP_TRACE_VERBOSE (
- BEACON_BEACON_PROCESS, phy_date(), beacon->vf.nid,
- beacon->params.rx_parameters.snid, beacon->vf.stei,
- beacon->vf.bt, beacon->params.rx_parameters.bts);
- cp_beacon_process_beacon (ctx, beacon);
+ if (beacon->params.direction == BSU_BEACON_DIRECTION_FROM_BSU)
+ {
+ cp_beacon__bsu_inform__beacon_not_received (ctx, beacon);
+ }
+ else
+ {
+ /** Beacon received ok. */
+ GPIO_TOGGLE (LED_BEACON_TX_RX);
+ CP_TRACE_VERBOSE (
+ BEACON_BEACON_PROCESS, phy_date(), beacon->vf.nid,
+ beacon->params.rx_parameters.snid, beacon->vf.stei,
+ beacon->vf.bt, beacon->params.rx_parameters.bts);
+ cp_beacon_process_beacon (ctx, beacon);
+ }
/** Release the beacon. */
blk_release (beacon);
}