Commit 2f40e8fc authored by winckel's avatar winckel

Added user interface (AT command interface) initialization and processing in NAS UE task.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4666 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 819ff010
...@@ -31,14 +31,43 @@ ...@@ -31,14 +31,43 @@
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
# include "intertask_interface.h" # include "intertask_interface.h"
# include "nas_ue_task.h" # include "nas_ue_task.h"
# include "UTIL/LOG/log.h"
# include "nas_log.h"
# include "nas_user.h" # include "nas_user.h"
# include "user_api.h" # include "user_api.h"
# include "nas_parser.h"
# define NAS_UE_AUTOSTART 1
extern unsigned char NB_eNB_INST; extern unsigned char NB_eNB_INST;
static int user_fd;
static int nas_ue_process_events(struct epoll_event *events, int nb_events, unsigned int Mod_id)
{
int event;
int exit_loop = FALSE;
LOG_I(NAS, "[UE %d] Received %d events\n", Mod_id, nb_events);
for (event = 0; event < nb_events; event++) {
if (events[event].events != 0)
{
/* If the event has not been yet been processed (not an itti message) */
if (events[event].data.fd == user_fd) {
exit_loop = user_api_receive_and_process(&user_fd);
} else {
LOG_E(NAS, "[UE %d] Received an event from an unknown fd %d!\n", Mod_id, events[event].data.fd);
}
}
}
return (exit_loop);
}
void *nas_ue_task(void *args_p) { void *nas_ue_task(void *args_p) {
int nb_events;
struct epoll_event *events;
MessageDef *msg_p; MessageDef *msg_p;
const char *msg_name; const char *msg_name;
instance_t instance; instance_t instance;
...@@ -46,19 +75,39 @@ void *nas_ue_task(void *args_p) { ...@@ -46,19 +75,39 @@ void *nas_ue_task(void *args_p) {
itti_mark_task_ready (TASK_NAS_UE); itti_mark_task_ready (TASK_NAS_UE);
/* Initialize NAS */ /* Initialize UE NAS (EURECOM-NAS) */
// nas_log_init(0x2F); {
/* Initialize user interface (to exchange AT commands with user process) */
{
if (user_api_initialize (NAS_PARSER_DEFAULT_USER_HOSTNAME, NAS_PARSER_DEFAULT_USER_PORT_NUMBER, NULL,
NULL) != RETURNok) {
LOG_E(NAS, "[UE] user interface initialization failed!");
exit (EXIT_FAILURE);
}
user_fd = user_api_get_fd ();
itti_subscribe_event_fd (TASK_NAS_UE, user_fd);
}
/* Initialize NAS user */
nas_user_initialize (&user_api_emm_callback, &user_api_esm_callback, FIRMWARE_VERSION); nas_user_initialize (&user_api_emm_callback, &user_api_esm_callback, FIRMWARE_VERSION);
}
while(1) { while(1) {
// Wait for a message // Wait for a message or an event
itti_receive_msg (TASK_NAS_UE, &msg_p); itti_receive_msg (TASK_NAS_UE, &msg_p);
if (msg_p != NULL) {
msg_name = ITTI_MSG_NAME (msg_p); msg_name = ITTI_MSG_NAME (msg_p);
instance = ITTI_MSG_INSTANCE (msg_p); instance = ITTI_MSG_INSTANCE (msg_p);
Mod_id = instance - NB_eNB_INST; Mod_id = instance - NB_eNB_INST;
switch (ITTI_MSG_ID(msg_p)) { switch (ITTI_MSG_ID(msg_p)) {
case INITIALIZE_MESSAGE:
LOG_I(NAS, "[UE %d] Received %s\n", Mod_id, msg_name);
#if defined(NAS_UE_AUTOSTART)
#endif
break;
case TERMINATE_MESSAGE: case TERMINATE_MESSAGE:
itti_exit_task (); itti_exit_task ();
break; break;
...@@ -68,7 +117,8 @@ void *nas_ue_task(void *args_p) { ...@@ -68,7 +117,8 @@ void *nas_ue_task(void *args_p) {
break; break;
case NAS_DOWNLINK_DATA_IND: case NAS_DOWNLINK_DATA_IND:
LOG_I(NAS, "[UE %d] Received %s: UEid %u, lenght %u\n", Mod_id, msg_name, NAS_DOWNLINK_DATA_IND (msg_p).UEid, NAS_DOWNLINK_DATA_IND (msg_p).nasMsg.length); LOG_I(NAS, "[UE %d] Received %s: UEid %u, length %u\n", Mod_id, msg_name,
NAS_DOWNLINK_DATA_IND (msg_p).UEid, NAS_DOWNLINK_DATA_IND (msg_p).nasMsg.length);
break; break;
default: default:
...@@ -79,5 +129,13 @@ void *nas_ue_task(void *args_p) { ...@@ -79,5 +129,13 @@ void *nas_ue_task(void *args_p) {
itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
msg_p = NULL; msg_p = NULL;
} }
nb_events = itti_get_events(TASK_NAS_UE, &events);
if ((nb_events > 0) && (events != NULL)) {
if (nas_ue_process_events(events, nb_events, Mod_id) == TRUE) {
LOG_E(NAS, "[UE %d] Received exit loop\n", Mod_id);
}
}
}
} }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment