summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorstevanovic2009-08-25 15:59:39 +0000
committerstevanovic2009-08-25 15:59:39 +0000
commit56b77cd96a8504f6f0058bef2af3f11fb4024a9f (patch)
tree51e7acc4d5ed32f0bff161a01059081bb2071b94 /cesar
parentf00f134171e5807f55125d817d3365993c8c1306 (diff)
[EOC](cp/eoc/multi_sta_fsm updated
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5294 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar')
-rw-r--r--cesar/cp/eoc/multi_sta_fsm/fsm.h16
-rw-r--r--cesar/cp/eoc/multi_sta_fsm/inc/context.h7
-rw-r--r--cesar/cp/eoc/multi_sta_fsm/inc/events.h2
-rw-r--r--cesar/cp/eoc/multi_sta_fsm/src/events.c6
-rw-r--r--cesar/cp/eoc/multi_sta_fsm/src/fsm.c79
-rw-r--r--cesar/cp/eoc/multi_sta_fsm/src/fsm/template_defs.h3
-rw-r--r--cesar/cp/eoc/multi_sta_fsm/test/utest/Config1
-rw-r--r--cesar/cp/eoc/multi_sta_fsm/test/utest/Makefile1
-rw-r--r--cesar/cp/eoc/multi_sta_fsm/test/utest/inc/scenario_defs.h18
-rw-r--r--cesar/cp/eoc/multi_sta_fsm/test/utest/override/cp/sta/mgr/sta.h108
-rw-r--r--cesar/cp/eoc/multi_sta_fsm/test/utest/src/fsm_stub.c80
-rw-r--r--cesar/cp/eoc/multi_sta_fsm/test/utest/src/test_fsm.c131
-rw-r--r--cesar/cp/eoc/multi_sta_fsm/test/utest/src/utest.fsm18
-rw-r--r--cesar/cp/sta/mgr/Config1
-rw-r--r--cesar/cp/sta/mgr/sta.h11
15 files changed, 304 insertions, 178 deletions
diff --git a/cesar/cp/eoc/multi_sta_fsm/fsm.h b/cesar/cp/eoc/multi_sta_fsm/fsm.h
index be963839dc..fd19fa3b31 100644
--- a/cesar/cp/eoc/multi_sta_fsm/fsm.h
+++ b/cesar/cp/eoc/multi_sta_fsm/fsm.h
@@ -27,23 +27,35 @@ BEGIN_DECLS
* \param ctx control plane context
*/
void
-cp_eoc_multi_sta_fsm_init (cp_t *ctx);
+cp_eoc_multi_sta_fsm_init (cp_t *ctx, cp_sta_t* sta);
/**
* Uninitialise the Multi STA FSM
* \param ctx control plane context
*/
void
-cp_eoc_multi_sta_fsm_uninit (cp_t *ctx);
+cp_eoc_multi_sta_fsm_uninit (cp_t *ctx, cp_sta_t* sta);
/**
* Process one event
* \param ctx control plane context
+ * \param sta active station
+ * \param event event to process
*/
void
cp_eoc_multi_sta_fsm_handled_event (cp_t *ctx, cp_sta_t *sta,
cp_eoc_multi_sta_fsm_event_t *e);
+
+
+/**
+ * Select a branch during a transition.
+ * \param ctx control plane context
+ * \param branch branch to select
+ * \param sta active station
+ *
+ * The selected branch must correspond to the current handled transition.
+ */
void
cp_eoc_multi_sta_fsm_branch_ (cp_t *ctx, cp_eoc_multi_sta_fsm_branch_t branch,
cp_sta_t *sta);
diff --git a/cesar/cp/eoc/multi_sta_fsm/inc/context.h b/cesar/cp/eoc/multi_sta_fsm/inc/context.h
index 54bf3e8118..79de8a61bb 100644
--- a/cesar/cp/eoc/multi_sta_fsm/inc/context.h
+++ b/cesar/cp/eoc/multi_sta_fsm/inc/context.h
@@ -15,9 +15,14 @@
#include "lib/slab.h"
-/** FSM context. */
+/** Multi STA FSM context. */
struct cp_eoc_multi_sta_fsm_t
{
+ /** current state */
+ cp_eoc_multi_sta_fsm_state_t state;
+
+ /** event currently handled*/
+ cp_eoc_multi_sta_fsm_event_t *handled_event;
};
typedef struct cp_eoc_multi_sta_fsm_t cp_eoc_multi_sta_fsm_t;
diff --git a/cesar/cp/eoc/multi_sta_fsm/inc/events.h b/cesar/cp/eoc/multi_sta_fsm/inc/events.h
index c46105d9e3..9e882fa6b2 100644
--- a/cesar/cp/eoc/multi_sta_fsm/inc/events.h
+++ b/cesar/cp/eoc/multi_sta_fsm/inc/events.h
@@ -13,10 +13,8 @@
* \ingroup cp_eoc_multi_sta_fsm
*/
-
/* This is a auto-generated file, check your Makefile if it is not found. */
#include "cp_eoc_multi_sta_fsm_defs.h"
-
#include "cp/sta/mgr/sta.h"
/**
diff --git a/cesar/cp/eoc/multi_sta_fsm/src/events.c b/cesar/cp/eoc/multi_sta_fsm/src/events.c
index f1430945e8..6db92881fe 100644
--- a/cesar/cp/eoc/multi_sta_fsm/src/events.c
+++ b/cesar/cp/eoc/multi_sta_fsm/src/events.c
@@ -25,9 +25,10 @@ cp_eoc_multi_sta_fsm_event_handler (cp_t *ctx, cp_sta_t *sta,
cp_eoc_multi_sta_fsm_event_t *event,
cp_eoc_multi_sta_fsm_transition_t transition)
{
- dbg_assert (ctx);
+ dbg_assert_ptr (ctx);
dbg_assert_ptr (event);
dbg_assert (transition);
+ dbg_assert_ptr (sta);
cp_eoc_multi_sta_fsm_event_transition_t t = transition;
/* Call transition. */
t (ctx, sta);
@@ -38,8 +39,9 @@ cp_eoc_multi_sta_fsm_event_new (cp_t *ctx,
cp_eoc_multi_sta_fsm_event_type_t type,
cp_eoc_multi_sta_fsm_event_t *event)
{
- dbg_assert (ctx);
+ dbg_assert_ptr (ctx);
dbg_assert (type < CP_EOC_MULTI_STA_FSM_EVENT_TYPE_NB);
+ dbg_assert_ptr (event);
event->type = type;
event->handler = cp_eoc_multi_sta_fsm_event_handler;
return;
diff --git a/cesar/cp/eoc/multi_sta_fsm/src/fsm.c b/cesar/cp/eoc/multi_sta_fsm/src/fsm.c
index 3f71a563c3..2f41b9bbb4 100644
--- a/cesar/cp/eoc/multi_sta_fsm/src/fsm.c
+++ b/cesar/cp/eoc/multi_sta_fsm/src/fsm.c
@@ -19,38 +19,45 @@
#include "cp/sta/mgr/sta.h"
void
-cp_eoc_multi_sta_fsm_init (cp_t *ctx)
+cp_eoc_multi_sta_fsm_init (cp_t *ctx, cp_sta_t *sta)
{
+ dbg_assert_ptr (ctx);
+ dbg_assert_ptr (sta);
+ /* only one initial state allowed */
+ dbg_assert (CP_EOC_MULTI_STA_FSM_INITIAL_NB==1);
+ sta->fsm.state = cp_eoc_multi_sta_fsm_initials_table[0];
+ if (cp_eoc_multi_sta_fsm_enter_table[0])
+ cp_eoc_multi_sta_fsm_enter_table[0](ctx,sta);
}
void
-cp_eoc_multi_sta_fsm_uninit (cp_t *ctx)
+cp_eoc_multi_sta_fsm_uninit (cp_t *ctx, cp_sta_t *sta)
{
}
/**
* Execute callbacks attached to enter and leave action of states.
* \param ctx control plane context
- * \param i active state index
+ * \param sta active station
* \param to state entered
*/
static void
cp_eoc_multi_sta_fsm_leave_enter (cp_t *ctx, cp_sta_t *sta, cp_eoc_multi_sta_fsm_state_t to)
{
- dbg_assert (ctx);
- dbg_assert (sta);
+ dbg_assert_ptr (ctx);
+ dbg_assert_ptr (sta);
dbg_assert (to < CP_EOC_MULTI_STA_FSM_STATE_NB);
- cp_eoc_multi_sta_fsm_state_t from = sta->fsm_state;
+ cp_eoc_multi_sta_fsm_state_t from = sta->fsm.state;
dbg_assert (from < CP_EOC_MULTI_STA_FSM_STATE_NB);
/* Do not call leave/enter callbacks if staying in the same state. */
if (from != to)
{
CP_TRACE (FSM_CHANGE_STATE, from, to);
if (cp_eoc_multi_sta_fsm_leave_table[from])
- cp_eoc_multi_sta_fsm_leave_table[from] (ctx);
- sta->fsm_state = to;
+ cp_eoc_multi_sta_fsm_leave_table[from] (ctx, sta);
+ sta->fsm.state = to;
if (cp_eoc_multi_sta_fsm_enter_table[to])
- cp_eoc_multi_sta_fsm_enter_table[to] (ctx);
+ cp_eoc_multi_sta_fsm_enter_table[to] (ctx, sta);
}
}
@@ -59,80 +66,92 @@ cp_eoc_multi_sta_fsm_leave_enter (cp_t *ctx, cp_sta_t *sta, cp_eoc_multi_sta_fsm
* Handle event for one active state.
* \param ctx control plane context
* \param e event to handle
- * \param i active state index
+ * \param sta active station
*/
void
cp_eoc_multi_sta_fsm_handled_event (cp_t *ctx, cp_sta_t *sta,
cp_eoc_multi_sta_fsm_event_t *e)
{
- dbg_assert (ctx);
- dbg_assert (e);
- dbg_assert (sta);
+ dbg_assert_ptr (ctx);
+ dbg_assert_ptr (e);
+ dbg_assert_ptr (sta);
cp_eoc_multi_sta_fsm_transition_t t =
- cp_eoc_multi_sta_fsm_transition_table[sta->fsm_state][e->type];
+ cp_eoc_multi_sta_fsm_transition_table[sta->fsm.state][e->type];
if (t)
{
/* Transition with action. */
- sta->handled_event = e;
+ sta->fsm.handled_event = e;
e->handler (ctx, sta, e, t);
/* If state has not been set, this means that there is one and
* only one branch for this transition. Check this and change
* state. */
- if (sta->handled_event)
+ if (sta->fsm.handled_event)
{
cp_eoc_multi_sta_fsm_state_t to =
- cp_eoc_multi_sta_fsm_only_branch_table[sta->fsm_state][e->type];
+ cp_eoc_multi_sta_fsm_only_branch_table
+ [sta->fsm.state][e->type];
dbg_assert_print (to != CP_EOC_MULTI_STA_FSM_STATE_NB,
"no branch selected");
dbg_assert (to < CP_EOC_MULTI_STA_FSM_STATE_NB);
if (to != CP_EOC_MULTI_STA_FSM_STATE_NB)
/* Be clement for errors.*/
cp_eoc_multi_sta_fsm_leave_enter (ctx, sta, to);
- sta->handled_event = NULL;
+ sta->fsm.handled_event = NULL;
}
}
else
{
/* Transition without action. */
cp_eoc_multi_sta_fsm_state_t to =
- cp_eoc_multi_sta_fsm_only_branch_table[sta->fsm_state][e->type];
+ cp_eoc_multi_sta_fsm_only_branch_table
+ [sta->fsm.state][e->type];
if (to != CP_EOC_MULTI_STA_FSM_STATE_NB)
{
dbg_assert (to < CP_EOC_MULTI_STA_FSM_STATE_NB);
cp_eoc_multi_sta_fsm_leave_enter (ctx, sta, to);
- sta->handled_event = NULL;
+ sta->fsm.handled_event = NULL;
}
}
}
+/**
+ * Select a branch during a transition.
+ * \param ctx control plane context
+ * \param branch branch to select
+ * \param sta active station
+ *
+ * The selected branch must correspond to the current handled transition.
+ *
+ */
void
cp_eoc_multi_sta_fsm_branch_ (cp_t *ctx, cp_eoc_multi_sta_fsm_branch_t branch,
cp_sta_t *sta)
{
- dbg_assert (ctx);
- dbg_assert (sta);
+ dbg_assert_ptr (ctx);
+ dbg_assert_ptr (sta);
/* Check handled transition. */
- dbg_assert (sta->fsm_state < CP_EOC_MULTI_STA_FSM_STATE_NB);
- dbg_assert_print (sta->handled_event,
+ dbg_assert (sta->fsm.state < CP_EOC_MULTI_STA_FSM_STATE_NB);
+ dbg_assert_print (sta->fsm.handled_event,
"not in transition or duplicated branch");
/* Check there is actually several branches. */
dbg_assert_print
- (cp_eoc_multi_sta_fsm_only_branch_table[sta->fsm_state]
- [sta->handled_event->type] ==
+ (cp_eoc_multi_sta_fsm_only_branch_table[sta->fsm.state]
+ [sta->fsm.handled_event->type] ==
CP_EOC_MULTI_STA_FSM_STATE_NB,
"no branch");
/* Check this correspond to the current transition. */
cp_eoc_multi_sta_fsm_state_t state = ((uint) branch >> 16) & 0xff;
- cp_eoc_multi_sta_fsm_event_type_t event_type = ((uint) branch >> 8) & 0xff;
- dbg_assert_print (state == sta->fsm_state
- && event_type == sta->handled_event->type,
+ cp_eoc_multi_sta_fsm_event_type_t event_type = ((uint) branch >> 8) &
+0xff;
+ dbg_assert_print (state == sta->fsm.state
+ && event_type == sta->fsm.handled_event->type,
"bad branch");
/* Select this branch. */
cp_eoc_multi_sta_fsm_state_t to = ((uint) branch) & 0xff;
cp_eoc_multi_sta_fsm_leave_enter (ctx, sta, to);
- sta->handled_event = NULL;
+ sta->fsm.handled_event = NULL;
}
diff --git a/cesar/cp/eoc/multi_sta_fsm/src/fsm/template_defs.h b/cesar/cp/eoc/multi_sta_fsm/src/fsm/template_defs.h
index d61762c492..224552483b 100644
--- a/cesar/cp/eoc/multi_sta_fsm/src/fsm/template_defs.h
+++ b/cesar/cp/eoc/multi_sta_fsm/src/fsm/template_defs.h
@@ -40,7 +40,8 @@ typedef enum %(prefix)s_branch_t %(prefix)s_branch_t;
typedef void *%(prefix)s_transition_t;
/* %(name)s enter/leave type. */
-typedef void (*%(prefix)s_enter_leave_t) (cp_t *ctx);
+struct cp_sta_t;
+typedef void (*%(prefix)s_enter_leave_t) (cp_t *ctx, struct cp_sta_t *sta);
/* Value to use to follow a given branch. */
#define %(PREFIX)s_BRANCH(state, event, branch) \
diff --git a/cesar/cp/eoc/multi_sta_fsm/test/utest/Config b/cesar/cp/eoc/multi_sta_fsm/test/utest/Config
index ce0edb6106..3414403f28 100644
--- a/cesar/cp/eoc/multi_sta_fsm/test/utest/Config
+++ b/cesar/cp/eoc/multi_sta_fsm/test/utest/Config
@@ -1,2 +1,3 @@
CONFIG_DEBUG_FATAL_CATCH = y
CONFIG_CP_EOC_MULTI_STA_FSM_DEF = "cp/eoc/multi_sta_fsm/test/utest/src/utest.fsm"
+CONFIG_CP_STA_MGR_EOC = y \ No newline at end of file
diff --git a/cesar/cp/eoc/multi_sta_fsm/test/utest/Makefile b/cesar/cp/eoc/multi_sta_fsm/test/utest/Makefile
index 9247c47e7c..7237aa60c8 100644
--- a/cesar/cp/eoc/multi_sta_fsm/test/utest/Makefile
+++ b/cesar/cp/eoc/multi_sta_fsm/test/utest/Makefile
@@ -8,5 +8,6 @@ test_fsm_MODULES = lib lib/scenario cp/eoc/multi_sta_fsm cp
cp_eoc_multi_sta_fsm_MODULE_SOURCES = fsm.c events.c
cp_MODULE_MODULES =
cp_MODULE_SOURCES = $(if $(filter y,$(CONFIG_TRACE)),trace.c,)
+test_fsm_MODULES_CONFIG = cp/sta/mgr
include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/eoc/multi_sta_fsm/test/utest/inc/scenario_defs.h b/cesar/cp/eoc/multi_sta_fsm/test/utest/inc/scenario_defs.h
index 55d95eb433..ce50d547a5 100644
--- a/cesar/cp/eoc/multi_sta_fsm/test/utest/inc/scenario_defs.h
+++ b/cesar/cp/eoc/multi_sta_fsm/test/utest/inc/scenario_defs.h
@@ -37,9 +37,9 @@ void scenario_action_process_cb (scenario_globals_t *globals,
#define SCENARIO_DEFS_EVENTS \
+ cp_eoc_multi_sta_fsm__STATE1__enter, \
cp_eoc_multi_sta_fsm__STATE1__event1, \
cp_eoc_multi_sta_fsm__STATE2__event2, \
- cp_eoc_multi_sta_fsm__STATE3__event3, \
cp_eoc_multi_sta_fsm__STATE3__event1, \
cp_eoc_multi_sta_fsm__STATE3__event2, \
cp_eoc_multi_sta_fsm__STATE4__event1, \
@@ -47,7 +47,9 @@ void scenario_action_process_cb (scenario_globals_t *globals,
cp_eoc_multi_sta_fsm__STATE5__event1, \
cp_eoc_multi_sta_fsm__STATE5__event5, \
cp_eoc_multi_sta_fsm__STATE6__event1, \
- cp_eoc_multi_sta_fsm__STATE6__event6
+ cp_eoc_multi_sta_fsm__STATE6__event6, \
+ cp_eoc_multi_sta_fsm__STATE6__enter, \
+ cp_eoc_multi_sta_fsm__STATE6__leave
typedef struct
{
@@ -61,15 +63,15 @@ typedef struct
} scenario_event_transition_t;
typedef scenario_event_transition_t
+scenario_event_cp_eoc_multi_sta_fsm__STATE1__enter_t;
+
+typedef scenario_event_transition_t
scenario_event_cp_eoc_multi_sta_fsm__STATE1__event1_t;
typedef scenario_event_transition_with_branch_t
scenario_event_cp_eoc_multi_sta_fsm__STATE2__event2_t;
typedef scenario_event_transition_t
-scenario_event_cp_eoc_multi_sta_fsm__STATE3__event3_t;
-
-typedef scenario_event_transition_t
scenario_event_cp_eoc_multi_sta_fsm__STATE3__event1_t;
typedef scenario_event_transition_t
@@ -93,4 +95,10 @@ scenario_event_cp_eoc_multi_sta_fsm__STATE6__event1_t;
typedef scenario_event_transition_t
scenario_event_cp_eoc_multi_sta_fsm__STATE6__event6_t;
+typedef scenario_event_transition_t
+scenario_event_cp_eoc_multi_sta_fsm__STATE6__enter_t;
+
+typedef scenario_event_transition_t
+scenario_event_cp_eoc_multi_sta_fsm__STATE6__leave_t;
+
#endif /* inc_scenario_defs_h */
diff --git a/cesar/cp/eoc/multi_sta_fsm/test/utest/override/cp/sta/mgr/sta.h b/cesar/cp/eoc/multi_sta_fsm/test/utest/override/cp/sta/mgr/sta.h
deleted file mode 100644
index 63a689f92f..0000000000
--- a/cesar/cp/eoc/multi_sta_fsm/test/utest/override/cp/sta/mgr/sta.h
+++ /dev/null
@@ -1,108 +0,0 @@
-#ifndef override_cp_sta_mgr_sta_h
-#define override_cp_sta_mgr_sta_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file override/cp/sta/mgr/sta.h
- * \brief Stations data structure override
- * \ingroup test
- *
- */
-#include "common/defs/homeplugAV.h"
-#include "lib/set.h"
-#include "cp/types.h"
-#include "cp/mme.h"
-#include "mac/common/store.h"
-
-/**
- * Control plane station.
- */
-struct cp_sta_t
-{
- /**
- * Indicate if the station is Backup CCo.
- */
- bool is_backup_cco;
-
- /**
- * Last date seen in the AVLN.
- */
- uint last_seen_ms;
-
- /**
- * The tei expiration date.
- */
- uint tei_lease_ms;
-
- /**
- * The station CCo capability.
- */
- u8 cco_cap;
-
- /**
- * Indicate if the station can be PCo.
- */
- bool pco_cap;
-
- /**
- * Indicate if the stations can be backup CCo.
- */
- bool backup_cco_cap;
-
- /**
- * Number of discover stations.
- */
- u8 numDisSta;
-
- /**
- * Number of discover networks.
- */
- u8 numDisNet;
-
- /**
- * The average BLE.
- */
- u8 average_ble;
-
- /**
- * PCo the station acting as Proxy for this station.
- */
- cp_tei_t pco;
-
- /**
- * The last assoc request date emitted by the station.
- */
- uint assoc_req_last_ms;
-
- /**
- * Soft handover
- */
- bool soft_handover;
-
- /** Set net node. */
- set_node_t node_net;
-
- /** Set sta_mgr node*/
- set_node_t node_sta_mgr;
-
- /** Release list node. */
- list_node_t release_node;
-
- /** Heap CCo selection node. */
- heap_node_t cco_selection_node;
-
- /* current state in the Multi STA FSM*/
- cp_eoc_multi_sta_fsm_state_t fsm_state;
-
- cp_eoc_multi_sta_fsm_event_t *handled_event;
-
-};
-typedef struct cp_sta_t cp_sta_t;
-
-
-#endif /* override_cp_sta_mgr_sta_h */
diff --git a/cesar/cp/eoc/multi_sta_fsm/test/utest/src/fsm_stub.c b/cesar/cp/eoc/multi_sta_fsm/test/utest/src/fsm_stub.c
index 720562b7e1..591eb4d0c7 100644
--- a/cesar/cp/eoc/multi_sta_fsm/test/utest/src/fsm_stub.c
+++ b/cesar/cp/eoc/multi_sta_fsm/test/utest/src/fsm_stub.c
@@ -17,17 +17,18 @@
#include "cp/eoc/multi_sta_fsm/fsm.h"
#include "cp/eoc/multi_sta_fsm/inc/tables.h"
+int cp_fsm__STATE1__enter_nb;
void
-cp_eoc_multi_sta_fsm__STATE1__event1 (cp_t *ctx);
+cp_eoc_multi_sta_fsm__STATE1__enter (cp_t *ctx, cp_sta_t *sta);
void
-cp_eoc_multi_sta_fsm__STATE2__event2 (cp_t *ctx, cp_sta_t *sta);
+cp_eoc_multi_sta_fsm__STATE1__event1 (cp_t *ctx, cp_sta_t *sta);
void
-cp_eoc_multi_sta_fsm__STATE3__event3 (cp_t *ctx);
+cp_eoc_multi_sta_fsm__STATE2__event2 (cp_t *ctx, cp_sta_t *sta);
void
-cp_eoc_multi_sta_fsm__STATE3__event1 (cp_t *ctx);
+cp_eoc_multi_sta_fsm__STATE3__event1 (cp_t *ctx, cp_sta_t *sta);
void
-cp_eoc_multi_sta_fsm__STATE3__event2 (cp_t *ctx);
+cp_eoc_multi_sta_fsm__STATE3__event2 (cp_t *ctx, cp_sta_t *sta);
void
cp_eoc_multi_sta_fsm__STATE4__event1 (cp_t *ctx);
void
@@ -40,16 +41,31 @@ void
cp_eoc_multi_sta_fsm__STATE6__event1 (cp_t *ctx);
void
cp_eoc_multi_sta_fsm__STATE6__event6 (cp_t *ctx);
-
-
-
-
+void
+cp_eoc_multi_sta_fsm__STATE1__error_event_no_branch (cp_t *ctx, cp_sta_t
+*sta);
+void
+cp_eoc_multi_sta_fsm__STATE1__error_event_bad_branch (cp_t *ctx, cp_sta_t
+*sta);
+void
+cp_eoc_multi_sta_fsm__STATE1__error_event_dup_branch (cp_t *ctx, cp_sta_t
+*sta);
+void
+cp_eoc_multi_sta_fsm__STATE6__enter (cp_t *ctx, cp_sta_t *sta);
+void
+cp_eoc_multi_sta_fsm__STATE6__leave (cp_t *ctx, cp_sta_t *sta);
/* Include generated tables. */
#include "cp_eoc_multi_sta_fsm_tables.h"
void
-cp_eoc_multi_sta_fsm__STATE1__event1 (cp_t *ctx)
+cp_eoc_multi_sta_fsm__STATE1__enter (cp_t *ctx, cp_sta_t *sta)
+{
+ cp_fsm__STATE1__enter_nb++;
+}
+
+void
+cp_eoc_multi_sta_fsm__STATE1__event1 (cp_t *ctx, cp_sta_t *sta)
{
scenario_event (cp_eoc_multi_sta_fsm__STATE1__event1);
}
@@ -63,19 +79,13 @@ cp_eoc_multi_sta_fsm__STATE2__event2 (cp_t *ctx, cp_sta_t *sta)
}
void
-cp_eoc_multi_sta_fsm__STATE3__event3 (cp_t *ctx)
-{
- scenario_event (cp_eoc_multi_sta_fsm__STATE3__event3);
-}
-
-void
-cp_eoc_multi_sta_fsm__STATE3__event1 (cp_t *ctx)
+cp_eoc_multi_sta_fsm__STATE3__event1 (cp_t *ctx, cp_sta_t *sta)
{
scenario_event (cp_eoc_multi_sta_fsm__STATE3__event1);
}
void
-cp_eoc_multi_sta_fsm__STATE3__event2 (cp_t *ctx)
+cp_eoc_multi_sta_fsm__STATE3__event2 (cp_t *ctx, cp_sta_t *sta)
{
scenario_event (cp_eoc_multi_sta_fsm__STATE3__event2);
}
@@ -118,3 +128,37 @@ cp_eoc_multi_sta_fsm__STATE6__event6 (cp_t *ctx)
scenario_event (cp_eoc_multi_sta_fsm__STATE6__event6);
}
+void
+cp_eoc_multi_sta_fsm__STATE1__error_event_no_branch (cp_t *ctx, cp_sta_t *sta)
+{
+ /* Do not choose branch. */
+}
+
+void
+cp_eoc_multi_sta_fsm__STATE1__error_event_bad_branch (cp_t *ctx,
+ cp_sta_t *sta)
+{
+ cp_eoc_multi_sta_fsm_branch (ctx, STATE4, event4, branch1, sta);
+}
+
+void
+cp_eoc_multi_sta_fsm__STATE1__error_event_dup_branch (cp_t *ctx,
+ cp_sta_t *sta)
+{
+ cp_eoc_multi_sta_fsm_branch (ctx, STATE1, error_event_dup_branch,
+ branch1, sta);
+ cp_eoc_multi_sta_fsm_branch (ctx, STATE1, error_event_dup_branch,
+ branch2, sta);
+}
+
+void
+cp_eoc_multi_sta_fsm__STATE6__enter (cp_t *ctx, cp_sta_t *sta)
+{
+ scenario_event (cp_eoc_multi_sta_fsm__STATE6__enter);
+}
+
+void
+cp_eoc_multi_sta_fsm__STATE6__leave (cp_t *ctx, cp_sta_t *sta)
+{
+ scenario_event (cp_eoc_multi_sta_fsm__STATE6__leave);
+} \ No newline at end of file
diff --git a/cesar/cp/eoc/multi_sta_fsm/test/utest/src/test_fsm.c b/cesar/cp/eoc/multi_sta_fsm/test/utest/src/test_fsm.c
index bac9683194..c6cda82209 100644
--- a/cesar/cp/eoc/multi_sta_fsm/test/utest/src/test_fsm.c
+++ b/cesar/cp/eoc/multi_sta_fsm/test/utest/src/test_fsm.c
@@ -20,6 +20,8 @@
#include "cp/eoc/multi_sta_fsm/fsm.h"
#include "cp/inc/context.h"
+extern int cp_fsm__STATE1__enter_nb;
+
void
test_fsm_basic_test_case (test_t t)
{
@@ -33,7 +35,8 @@ test_fsm_basic_test_case (test_t t)
test_begin (t, "regular")
{
- cp_eoc_multi_sta_fsm_init(&ctx);
+ cp_fsm__STATE1__enter_nb=0;
+ cp_eoc_multi_sta_fsm_init(&ctx, sta);
scenario_entry_t entries[] = {
/* STATE1 */
SCENARIO_ACTION (process,
@@ -53,8 +56,7 @@ test_fsm_basic_test_case (test_t t)
SCENARIO_ACTION (process,
.sta = sta,
.type = CP_EOC_MULTI_STA_FSM_EVENT_TYPE_event3),
- SCENARIO_EVENT (cp_eoc_multi_sta_fsm__STATE3__event3,
- .sta=sta),
+ /*no SCENARIO_EVENT */
/* STATE4 */
SCENARIO_ACTION (process,
.sta = sta,
@@ -77,6 +79,8 @@ test_fsm_basic_test_case (test_t t)
.type = CP_EOC_MULTI_STA_FSM_EVENT_TYPE_event5),
SCENARIO_EVENT (cp_eoc_multi_sta_fsm__STATE5__event5,
.sta=sta),
+ SCENARIO_EVENT (cp_eoc_multi_sta_fsm__STATE6__enter,
+ .sta=sta),
/* STATE6 */
SCENARIO_ACTION (process,
.sta = sta,
@@ -84,17 +88,27 @@ test_fsm_basic_test_case (test_t t)
SCENARIO_EVENT (cp_eoc_multi_sta_fsm__STATE6__event6,
.sta=sta),
/* STATE6 */
+ SCENARIO_ACTION (process,
+ .sta = sta,
+ .type = CP_EOC_MULTI_STA_FSM_EVENT_TYPE_event1),
+ SCENARIO_EVENT (cp_eoc_multi_sta_fsm__STATE6__event1,
+ .sta=sta),
+ SCENARIO_EVENT (cp_eoc_multi_sta_fsm__STATE6__leave,
+ .sta=sta),
+ /* STATE1 */
SCENARIO_END
};
scenario_globals_t globals = {
.cp = &ctx,
};
scenario_run (t, entries, &globals);
- test_fail_unless (sta->fsm_state ==
- CP_EOC_MULTI_STA_FSM_STATE_STATE6);
- cp_eoc_multi_sta_fsm_uninit (&ctx);
+ test_fail_unless (sta->fsm.state ==
+ CP_EOC_MULTI_STA_FSM_STATE_STATE1);
+ test_fail_unless (cp_fsm__STATE1__enter_nb == 2);
+ cp_eoc_multi_sta_fsm_uninit (&ctx, sta);
} test_end;
+
slab_release (sta);
slab_cache_uninit (&cache);
#if CONFIG_TRACE
@@ -104,10 +118,115 @@ test_fsm_basic_test_case (test_t t)
}
void
+test_fsm_error_test_case (test_t t)
+{
+ test_case_begin (t, "error");
+ cp_t cp;
+ cp_trace_init (&cp);
+
+ slab_cache_t cache;
+ slab_cache_init (&cache, "dummy", 1, NULL);
+ cp_sta_t *sta = slab_alloc (&cache);
+
+ test_begin (t, "no branch")
+ {
+ cp_eoc_multi_sta_fsm_init (&cp, sta);
+
+ cp_eoc_multi_sta_fsm_event_t e;
+ cp_eoc_multi_sta_fsm_event_new (&cp,
+ CP_EOC_MULTI_STA_FSM_EVENT_TYPE_error_event_no_branch, &e);
+
+ const char *asserted = NULL;
+ dbg_fatal_try_begin
+ {
+ cp_eoc_multi_sta_fsm_handled_event (&cp, sta, &e);
+ }
+ dbg_fatal_try_catch (const char *msg)
+ {
+ asserted = msg;
+ }
+ dbg_fatal_try_end;
+ test_fail_unless (asserted);
+ cp_eoc_multi_sta_fsm_uninit (&cp, sta);
+ } test_end;
+ test_begin (t, "bad branch")
+ {
+ cp_eoc_multi_sta_fsm_init (&cp, sta);
+
+ cp_eoc_multi_sta_fsm_event_t e;
+ cp_eoc_multi_sta_fsm_event_new (&cp,
+ CP_EOC_MULTI_STA_FSM_EVENT_TYPE_error_event_bad_branch, &e);
+
+ const char *asserted = NULL;
+ dbg_fatal_try_begin
+ {
+ cp_eoc_multi_sta_fsm_handled_event (&cp, sta, &e);
+ }
+ dbg_fatal_try_catch (const char *msg)
+ {
+ asserted = msg;
+ }
+ dbg_fatal_try_end;
+ test_fail_unless (asserted);
+ cp_eoc_multi_sta_fsm_uninit (&cp, sta);
+ } test_end;
+ test_begin (t, "dup branch")
+ {
+ cp_eoc_multi_sta_fsm_init (&cp, sta);
+
+ cp_eoc_multi_sta_fsm_event_t e;
+ cp_eoc_multi_sta_fsm_event_new (&cp,
+ CP_EOC_MULTI_STA_FSM_EVENT_TYPE_error_event_dup_branch, &e);
+
+ const char *asserted = NULL;
+ dbg_fatal_try_begin
+ {
+ cp_eoc_multi_sta_fsm_handled_event (&cp, sta, &e);
+ }
+ dbg_fatal_try_catch (const char *msg)
+ {
+ asserted = msg;
+ }
+ dbg_fatal_try_end;
+ test_fail_unless (asserted);
+ cp_eoc_multi_sta_fsm_uninit (&cp, sta);
+ } test_end;
+ test_begin (t, "not in transition")
+ {
+ cp_eoc_multi_sta_fsm_init (&cp, sta);
+ cp_eoc_multi_sta_fsm_event_t e;
+
+ const char *asserted = NULL;
+ dbg_fatal_try_begin
+ {
+ cp_eoc_multi_sta_fsm_handled_event (&cp, sta, &e);
+ }
+ dbg_fatal_try_catch (const char *msg)
+ {
+ asserted = msg;
+ }
+ dbg_fatal_try_end;
+ test_fail_unless (asserted);
+ cp_eoc_multi_sta_fsm_uninit (&cp, sta);
+ } test_end;
+
+ slab_release (sta);
+ slab_cache_uninit (&cache);
+
+#if CONFIG_TRACE
+ trace_buffer_dbg_dump (&cp.trace);
+#endif /* CONFIG_TRACE */
+ cp_trace_uninit (&cp);
+}
+
+
+
+void
test_fsm_test_suite (test_t t)
{
test_suite_begin (t, "fsm");
test_fsm_basic_test_case (t);
+ test_fsm_error_test_case (t);
}
int
diff --git a/cesar/cp/eoc/multi_sta_fsm/test/utest/src/utest.fsm b/cesar/cp/eoc/multi_sta_fsm/test/utest/src/utest.fsm
index 8a2e7a8ced..d50d50da74 100644
--- a/cesar/cp/eoc/multi_sta_fsm/test/utest/src/utest.fsm
+++ b/cesar/cp/eoc/multi_sta_fsm/test/utest/src/utest.fsm
@@ -2,12 +2,12 @@ Slave STA FSM
FSM for slave stations
States:
- STATE1
+ STATE1 [enter=cp_eoc_multi_sta_fsm__STATE1__enter]
STATE2
STATE3
STATE4
STATE5
- STATE6
+ STATE6 [enter=cp_eoc_multi_sta_fsm__STATE6__enter leave=cp_eoc_multi_sta_fsm__STATE6__leave]
Events:
event1
@@ -16,15 +16,27 @@ Events:
event4
event5
event6
+ error_event_no_branch
+ test error conditions: no branch selected
+ error_event_bad_branch
+ test error conditions: branch not for this event
+ error_event_dup_branch
+ test error conditions: branch selected two times
STATE1:
event1 -> STATE2
+ error_event_no_branch: branch1 -> .
+ error_event_no_branch: branch2 -> .
+ error_event_bad_branch: branch1 -> .
+ error_event_bad_branch: branch2 -> .
+ error_event_dup_branch: branch1 -> .
+ error_event_dup_branch: branch2 -> .
STATE2:
event2: branch1 -> STATE3
event2: branch2 -> STATE1
STATE3:
event1 -> STATE1
- event3 -> STATE4
+ event3 -> STATE4 [NULL]
event2 -> STATE2
STATE4:
event1 -> STATE1
diff --git a/cesar/cp/sta/mgr/Config b/cesar/cp/sta/mgr/Config
new file mode 100644
index 0000000000..b4aed654b3
--- /dev/null
+++ b/cesar/cp/sta/mgr/Config
@@ -0,0 +1 @@
+CONFIG_CP_STA_MGR_EOC = n
diff --git a/cesar/cp/sta/mgr/sta.h b/cesar/cp/sta/mgr/sta.h
index 9f6dec99af..c97421cbe6 100644
--- a/cesar/cp/sta/mgr/sta.h
+++ b/cesar/cp/sta/mgr/sta.h
@@ -19,6 +19,11 @@
#include "cp/mme.h"
#include "mac/common/store.h"
+#include "config/cp/sta/mgr/eoc.h"
+#if CONFIG_CP_STA_MGR_EOC
+#include "cp/eoc/multi_sta_fsm/inc/context.h"
+#endif /* CONFIG_CP_STA_MGR_EOC */
+
/** Enum */
enum cp_sta_visible_status_t
{
@@ -137,6 +142,12 @@ struct cp_sta_t
/** Heap CCo selection node. */
heap_node_t cco_selection_node;
+
+#if CONFIG_CP_STA_MGR_EOC
+ /** Multi STA FSM */
+ cp_eoc_multi_sta_fsm_t fsm;
+#endif /* CONFIG_CP_STA_MGR_EOC */
+
};
typedef struct cp_sta_t cp_sta_t;