summaryrefslogtreecommitdiff
path: root/cesar/cp/beacon/test/central_beacon/src/usta.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/cp/beacon/test/central_beacon/src/usta.c')
-rw-r--r--cesar/cp/beacon/test/central_beacon/src/usta.c184
1 files changed, 184 insertions, 0 deletions
diff --git a/cesar/cp/beacon/test/central_beacon/src/usta.c b/cesar/cp/beacon/test/central_beacon/src/usta.c
new file mode 100644
index 0000000000..35501755c9
--- /dev/null
+++ b/cesar/cp/beacon/test/central_beacon/src/usta.c
@@ -0,0 +1,184 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/beacon/test/central_beacon/src/usta.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include <stdio.h>
+
+#include "lib/test.h"
+
+#include "cp/beacon/beacons.h"
+#include "cp/secu/secu.h"
+#include "cp/station/station.h"
+#include "cp/cco/cco.h"
+
+#include "cl/cl.h"
+
+#include "hal/phy/phy.h"
+#include "mac/ca/ca.h"
+#include "mac/pbproc/pbproc.h"
+#include "mac/common/store.h"
+#include "mac/common/config.h"
+#include "mac/common/ntb.h"
+
+#include "cp/beacon/inc/beacons_ctx.h"
+#include "cp/beacon/test/central_beacon/inc/phy_stub.h"
+
+#include "hal/timer/timer.h"
+
+static ca_schedule_t sched;
+test_t test;
+
+void
+cp_beacon_expired (void *user_data)
+{
+
+}
+
+
+int
+main (void)
+{
+ cp_beacon_t *cp_beacon;
+ phy_t *phy;
+ cp_sta_t *sta;
+ cp_secu_t *secu;
+ ca_t *ca;
+ pbproc_t *pbproc;
+ mac_store_t *mac_store;
+ mac_config_t *mac_config;
+ cl_t *cl;
+ cp_cco_t *cco;
+ hal_timer_t *timer;
+
+ test_init (test, 0, NULL);
+ phy = blk_alloc ();
+ mac_config = blk_alloc ();
+ cl = blk_alloc ();
+ pbproc = blk_alloc ();
+ ca = blk_alloc ();
+
+ mac_store = mac_store_init ();
+
+ cco = cp_cco_init ();
+ sta = cp_station_init (mac_store, cl, pbproc, mac_config);
+// secu = cp_secu_init ();
+
+ mac_ntb_init (phy, mac_config);
+ timer = hal_timer_init (phy);
+ cp_beacon = cp_beacon_init((interface_t *) phy, phy, sta, secu, ca, pbproc, mac_store, cco,
+ timer, NULL, cp_beacon_expired );
+
+ // Verify the schedule.
+ cp_beacon_create_default_schedule (cp_beacon);
+
+ cp_cco_uninit(cco);
+ mac_store_uninit (mac_store);
+ cp_beacon_uninit (cp_beacon);
+ hal_timer_uninit (timer);
+// cp_secu_uninit (secu);
+ cp_station_uninit (sta);
+ blk_release (phy);
+ blk_release (mac_config);
+ blk_release (cl);
+ blk_release (pbproc);
+ blk_release (ca);
+
+ test_begin(test, "memory test")
+ {
+ test_fail_if(blk_check_memory() == false, "Memory not freed");
+ }
+ test_end;
+
+ test_result (test);
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}
+
+ca_schedule_t *
+ca_alloc_get_schedule (ca_t *ctx, uint index)
+{
+ return &sched;
+}
+
+void
+ca_alloc_update_beacon_periods (ca_t *ctx,
+ ca_beacon_period_t *beacon_periods,
+ uint beacon_periods_nb)
+{
+ dbg_assert (ctx);
+ dbg_assert (beacon_periods);
+ dbg_assert (beacon_periods_nb);
+
+ test_case_begin (test, "schedule");
+ test_begin (test, "beacon periods schedule")
+ {
+ test_fail_if (beacon_periods[0].start_date != 10, "Wrong schedule.");
+ test_fail_if (beacon_periods[1].start_date != 0xFFFFFF + 10, "Wrong schedule.");
+ test_fail_if (beacon_periods[2].start_date != 2 *0xFFFFFF + 10, "Wrong schedule.");
+ }
+ test_end;
+}
+
+
+bool
+ca_mfs_remove (ca_t *ctx, mfs_tx_t *mfs)
+{
+ return true;
+}
+
+void
+ca_mfs_add (ca_t *ctx, mfs_tx_t *mfs)
+{
+ dbg_assert (ctx);
+ dbg_assert (mfs);
+}
+
+
+void
+ca_mfs_update (ca_t *ctx, mfs_tx_t *mfs)
+{
+}
+
+void
+ca_mfs_hold (ca_t *ctx, mfs_tx_t *mfs)
+{
+}
+
+/**
+ * Get date of last zero-cross.
+ * \param ctx phy context
+ * \return last zero-cross date
+ * set errno to:
+ * - EINVAL if ctx is null
+ */
+u32
+phy_clock_get_zero_cross_captured_date (phy_t *ctx)
+{
+ phy_test_t *phy;
+ dbg_assert(ctx);
+
+ phy = (phy_test_t *) ctx;
+
+ if(phy->freq_test == 50)
+ {
+ phy->ntb += 250000;
+ }
+ else if (phy->freq_test == 60)
+ {
+ phy->ntb += 208333;
+ }
+
+ return phy->ntb;
+}
+