git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4234 818b1a75-f10b-46b9-bf7c-635c3b92a50f

This commit is contained in:
Cedric Roux
2013-10-21 08:08:15 +00:00
parent ff4360527c
commit d7c8c99e2d
860 changed files with 212101 additions and 0 deletions
@@ -0,0 +1,21 @@
ifndef PROJDIR
PROJDIR = $(PWD)/../../..
INCLUDES = -I. -I$(INCDIR) -I$(UTILDIR) -I$(IESDIR) -I$(EMMMSGDIR) -I$(ESMMSGDIR)
endif
include $(PROJDIR)/Makerules
include $(PROJDIR)/Makefile.inc
all: $(OBJS)
%.o: %.c Makefile
@echo Compiling $<
@$(CC) $(CFLAGS) -c $< -o $@
clean:
$(RM) $(OBJS) *.bak *~
depend:
makedepend -- ${CFLAGS} -- ${SRCS}
# DO NOT DELETE THIS LINE -- make depend depends on it.
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,839 @@
/*****************************************************************************
Eurecom OpenAirInterface 3
Copyright(c) 2012 Eurecom
Source at_command.h
Version 0.1
Date 2012/03/07
Product NAS stack
Subsystem Application Programming Interface
Author Frederic Maurel
Description Defines the ATtention (AT) command set supported by the NAS
sublayer protocol
*****************************************************************************/
#ifndef __AT_COMMAND_H__
#define __AT_COMMAND_H__
#include "userDef.h"
#include "networkDef.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/* Bit masks indicating presence of AT command's optional parameters */
#define AT_COMMAND_PARAM0 0x0000 /* no any parameter is present */
#define AT_COMMAND_PARAM1 0x0001 /* first parameter is present */
#define AT_COMMAND_PARAM2 0x0002 /* 2nd parameter is present */
#define AT_COMMAND_PARAM3 0x0004 /* 3rd parameter is present */
#define AT_COMMAND_PARAM4 0x0008 /* 4th parameter is present */
#define AT_COMMAND_PARAM5 0x0010 /* 5th parameter is present */
#define AT_COMMAND_PARAM6 0x0020 /* 6th parameter is present */
#define AT_COMMAND_PARAM7 0x0040 /* 7th parameter is present */
#define AT_COMMAND_PARAM8 0x0080 /* 8th parameter is present */
#define AT_COMMAND_PARAM9 0x0100 /* 9th parameter is present */
#define AT_COMMAND_PARAM10 0x0200 /* 10th parameter is present */
#define AT_COMMAND_PARAM11 0x0400 /* 11th parameter is present */
#define AT_COMMAND_PARAM12 0x0800 /* 12th parameter is present */
#define AT_COMMAND_PARAM13 0x1000 /* 13th parameter is present */
#define AT_COMMAND_PARAM14 0x2000 /* 14th parameter is present */
#define AT_COMMAND_PARAM15 0x4000 /* 15th parameter is present */
#define AT_COMMAND_PARAM16 0x8000 /* 16th parameter is present */
/* Value of the mask parameter for AT commands without any parameters */
#define AT_COMMAND_NO_PARAM AT_COMMAND_PARAM0
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/*
* AT command identifiers
* ----------------------
* Those currently supported by our Mobile Equipment (ME)
*/
typedef enum {
/*
* General commands
* ----------------
*/
AT_CGSN=1, /* Request Product Serial Number identification (IMEI) */
AT_CGMI, /* Request manufacturer identification */
AT_CGMM, /* Request model identification */
AT_CGMR, /* Request revision identification */
AT_CIMI, /* Request International Mobile Subscriber Identity */
/*
* Mobile Termination control and status commands
* ----------------------------------------------
*/
AT_CFUN, /* Set phone functionality */
AT_CPIN, /* Enter PIN */
AT_CSQ, /* Signal quality */
AT_CESQ, /* Extented signal quality */
AT_CLAC, /* List all available AT commands */
/*
* Mobile Termination errors
* -------------------------
*/
AT_CMEE, /* Report mobile termination error */
/*
* Network service related commands
* ---------------------------------
*/
AT_CNUM, /* Subscriber number */
AT_CLCK, /* Facility lock */
AT_COPS, /* PLMN selection */
AT_CREG, /* Network registration */
/*
* Commands for Packet Domain
* ---------------------------
*/
AT_CGATT, /* PS attach/detach */
AT_CGREG, /* GPRS network registration status */
AT_CEREG, /* EPS network registration status */
AT_CGDCONT, /* Define PDP Context */
AT_CGACT, /* PDP context activate or deactivate */
AT_CGPADDR, /* Show PDP address(es) */
AT_CGEV, /* Packet Domain event unsolicited result code */
AT_COMMAND_ID_MAX
} at_command_id_t;
/*
* AT command types
* ----------------
* - AT action command, used to execute a particular function, which
* generally involves more than the simple storage of a value.
* - AT set parameter command, used to store a value or values of
* subparameters.
* - AT read parameter command, used to check the current values of
* subparameters.
* - AT test parameter command, used to test the existence of the
* command and to give information about the type of its subparameters.
*/
typedef enum {
AT_COMMAND_ACT, /* AT action command (ATCMD) */
AT_COMMAND_SET, /* AT set parameter command (ATCMD=) */
AT_COMMAND_GET, /* AT read parameter command (ATCMD?) */
AT_COMMAND_TST, /* AT test parameter command (ATCMD=?) */
AT_COMMAND_TYPE_MAX
} at_command_type_t;
/*
* ================
* General commands
* ================
*/
/* CGSN: Request Product Serial Number identification (IMEI)
* ---------------------------------------------------------
* Returns information text intended to permit the user to identify the
* individual Mobile Equipment to which it is connected to.
* Action command:
* no parameters
*/
/* CGSN AT command type */
#define AT_COMMAND_CGSN_MASK AT_COMMAND_NO_PARAM
typedef struct at_cgsn_s {} at_cgsn_t;
/* CGMI: Request manufacturer identification
* -----------------------------------------
* Returns information text intended to permit the user to identify the
* manufacturer of the Mobile Equipment to which it is connected to.
* Action command:
* no parameters
*/
/* CGMI AT command type */
#define AT_COMMAND_CGMI_MASK AT_COMMAND_NO_PARAM
typedef struct at_cgmi_s {} at_cgmi_t;
/* CGMM: Request model identification
* ----------------------------------
* Returns information text intended to permit the user to identify the
* specific model of the Mobile Equipment to which it is connected to.
* Action command:
* no parameters
*/
/* CGMM AT command type */
#define AT_COMMAND_CGMM_MASK AT_COMMAND_NO_PARAM
typedef struct at_cgmm_s {} at_cgmm_t;
/* CGMR: Request revision identification
* -------------------------------------
* Returns information text intended to permit the user to identify the
* version, revision level or date, or other pertinent information of the
* Mobile Equipment to which it is connected to.
* Action command:
* no parameters
*/
/* CGMR AT command type */
#define AT_COMMAND_CGMR_MASK AT_COMMAND_NO_PARAM
typedef struct at_cgmr_s {} at_cgmr_t;
/* CIMI: Request International Mobile Subscriber Identity
* ------------------------------------------------------
* Returns <IMSI>, which is intended to permit the user to identify the
* individual SIM card or active application in the UICC (GSM or USIM)
* which is attached to the Mobile Equipment to which it is connected to.
* Action command:
* no parameters
*/
/* CIMI AT command type */
#define AT_COMMAND_CIMI_MASK AT_COMMAND_NO_PARAM
typedef struct at_cimi_s {} at_cimi_t;
/*
* ==============================================
* Mobile Termination control and status commands
* ==============================================
*/
/* CFUN: Set phone functionality
* -----------------------------
* Used to set the Mobile Equipment to different power consumption states
* Parameter command:
* +CFUN=[<fun>[,<rst>]]
* <fun> level of functionality
* <rst> resetting parameter
*/
/* Functionality levels */
#define AT_CFUN_MIN 0 /* minimum functionality */
#define AT_CFUN_FULL 1 /* full functionality */
#define AT_CFUN_SEND 2 /* disable phone transmit RF circuits only */
#define AT_CFUN_RECV 3 /* disable phone receive RF circuits only */
#define AT_CFUN_BOTH 4 /* disable phone both transmit and receive
* RF circuits */
#define AT_CFUN_MAX AT_CFUN_BOTH
/* Maximum value of supported functionality
* level */
#define AT_CFUN_FUN_DEFAULT AT_CFUN_MIN
/* Default functionality level applied when
* no value is given */
/* Resetting parameter values */
#define AT_CFUN_NORST 0 /* do not reset the ME before setting it
* to <fun> power level (default when <rst>
* is not given) */
#define AT_CFUN_RST 1 /* reset the ME before setting it to <fun>
* power level */
#define AT_CFUN_RST_DEFAULT AT_CFUN_NORST
/* Default resetting action applied when
* no value is given */
/* Optional parameter bitmask */
#define AT_CFUN_FUN_MASK AT_COMMAND_PARAM1
#define AT_CFUN_RST_MASK AT_COMMAND_PARAM2
/* CFUN AT command type */
typedef struct {
int fun;
int rst;
} at_cfun_t;
/* CPIN: Enter PIN
* ---------------
* Used to enter MT passwords which are needed before any other
* functionality of the MT can be used
* Parameter command:
* +CPIN=<pin>[,<newpin>]
* <pin> personal identification number
* <newpin> new personal identification number
*/
/* Optional parameter bitmask */
#define AT_CPIN_NEWPIN_MASK AT_COMMAND_PARAM2
/* CPIN AT command type */
typedef struct {
#define AT_CPIN_SIZE USER_PIN_SIZE /* Number of characters in pin parameter */
char pin[AT_CPIN_SIZE+1];
char newpin[AT_CPIN_SIZE+1];
} at_cpin_t;
/* CSQ: Signal quality
* -------------------
* Returns received signal strength indication and channel bit error rate
* from the Mobile Equipment
* Action command:
* no parameters
*/
/* CSQ AT command type */
#define AT_COMMAND_CSQ_MASK AT_COMMAND_NO_PARAM
typedef struct at_csq_s {} at_csq_t;
/* CESQ: Extented signal quality
* -----------------------------
* Returns received signal quality parameters.
* Action command:
* no parameters
*/
/* CESQ AT command type */
#define AT_COMMAND_CESQ_MASK AT_COMMAND_NO_PARAM
typedef struct at_cesq_s {} at_cesq_t;
/* CLAC: List all available AT commands
* ------------------------------------
* Returns one or more lines of AT Commands that are available for the user.
* Action command:
* no parameters
*/
/* CLAC AT command type */
#define AT_COMMAND_CLAC_MASK AT_COMMAND_NO_PARAM
typedef struct at_clac_s {} at_clac_t;
/*
* =========================
* Mobile Termination errors
* =========================
*/
/*
* CMEE: Report mobile termination error
* -------------------------------------
* Disables or enables the use of final result code +CME ERROR: <err> as an
* indication of an error relating to the functionality of the MT.
* <n> = 0, disables result code and displays ERROR instead.
* <n> = 1, enables result code and displays numeric <err>
* <n> = 2, enables result code and displays verbose <err>
* Parameter command:
* +CMEE=[<n>]
* <n> numeric parameter
*/
/* Numeric parameter values */
#define AT_CMEE_OFF 0 /* disable result code */
#define AT_CMEE_NUMERIC 1 /* enable numeric result code */
#define AT_CMEE_VERBOSE 2 /* enable verbose result code */
#define AT_CMEE_N_MIN AT_CMEE_OFF
/* Minimum value of supported numeric parameter */
#define AT_CMEE_N_MAX AT_CMEE_VERBOSE
/* Maximum value of supported numeric parameter */
#define AT_CMEE_N_DEFAULT AT_CMEE_OFF
/* Default value of supported numeric parameter */
/* Optional parameter bitmask */
#define AT_CMEE_N_MASK AT_COMMAND_PARAM1
/* CMEE AT command type */
typedef struct {
int n;
} at_cmee_t;
/*
* ================================
* Network service related commands
* ================================
*/
/* CNUM: Subscriber number
* -----------------------
* Returns the MSISDNs related to the subscriber.
* Action command:
* no parameters
*/
/* CNUM AT command type */
#define AT_COMMAND_CNUM_MASK AT_COMMAND_NO_PARAM
typedef struct at_cnum_s {} at_cnum_t;
/* CLCK: Facility lock
* -------------------
* Used to lock, unlock or interrogate a MT or a network facility <fac>.
* Action command:
* +CLCK=<fac>,<mode>[,<passwd>]
* <fac> facility value
* <mode> operation mode
* <passwd> password (pin code)
*/
/* Facility values */
#define AT_CLCK_SC "SC" /* SIM lock/unlock */
/* Operation mode */
#define AT_CLCK_UNLOCK 0 /* Unlock (enable) a service */
#define AT_CLCK_LOCK 1 /* Lock (disable) a service */
#define AT_CLCK_STATUS 2 /* Query the status of a network service */
/* Optional parameter bitmask */
#define AT_CLCK_PASSWD_MASK AT_COMMAND_PARAM3
/* CLCK AT command type */
typedef struct {
#define AT_CLCK_FAC_SIZE 2
char fac[AT_CLCK_FAC_SIZE+1];
int mode;
#define AT_CLCK_PASSWD_SIZE USER_PIN_SIZE
char passwd[AT_CLCK_PASSWD_SIZE+1];
} at_clck_t;
/* COPS: PLMN selection
* --------------------
* Forces an attempt to select and register the GSM/UMTS/EPS network operator
* using the SIM/USIM card installed in the currently selected card slot.
* Parameter command:
* +COPS=[<mode>[,<format>[,<oper>[,<AcT>]]]]
* <mode> operation mode of the network selection
* <format> representation format of the network operator
* <oper> APN operator identifier
* <AcT> access technology
*/
/* Network selection operation modes */
#define AT_COPS_AUTO 0 /* automatic mode */
#define AT_COPS_MANUAL 1 /* manual mode */
#define AT_COPS_DEREG 2 /* deregister from network */
#define AT_COPS_FORMAT 3 /* set only <format> for read command +COPS? */
#define AT_COPS_MANAUTO 4 /* manual/automatic mode; if manual selection
* fails, automatic mode is entered */
#define AT_COPS_MODE_DEFAULT AT_COPS_AUTO
/* Default operation mode applied when no
* value is given */
/* Representation formats */
#define AT_COPS_LONG NET_FORMAT_LONG /* long format alphanumeric */
#define AT_COPS_SHORT NET_FORMAT_SHORT /* short format alphanumeric */
#define AT_COPS_NUM NET_FORMAT_NUM /* numeric */
#define AT_COPS_FORMAT_MIN AT_COPS_LONG
/* Minimum value of supported representation
* format */
#define AT_COPS_FORMAT_MAX AT_COPS_NUM
/* Maximum value of supported representation
* format */
#define AT_COPS_FORMAT_DEFAULT AT_COPS_LONG
/* Default representation format applied when
* no value is given */
/* Access technology indicators */
#define AT_COPS_GSM NET_ACCESS_GSM /* GSM */
#define AT_COPS_COMPACT NET_ACCESS_COMPACT /* GSM Compact */
#define AT_COPS_UTRAN NET_ACCESS_UTRAN /* UTRAN */
#define AT_COPS_EGPRS NET_ACCESS_EGPRS /* GSM w/EGPRS */
#define AT_COPS_HSDPA NET_ACCESS_HSDPA /* UTRAN w/HSDPA */
#define AT_COPS_HSUPA NET_ACCESS_HSUPA /* UTRAN w/HSUPA */
#define AT_COPS_HSDUPA NET_ACCESS_HSDUPA /* w/HSDPA and HSUPA */
#define AT_COPS_EUTRAN NET_ACCESS_EUTRAN /* E-UTRAN */
#define AT_COPS_ACT_MIN AT_COPS_GSM
/* Minimum value of supported access
* technology */
#define AT_COPS_ACT_MAX AT_COPS_EUTRAN
/* Maximum value of supported access
* technology */
#define AT_COPS_ACT_DEFAULT AT_COPS_GSM
/* Default access technology applied when
* no value is given */
/* Optional parameter bitmask */
#define AT_COPS_MODE_MASK AT_COMMAND_PARAM1
#define AT_COPS_FORMAT_MASK AT_COMMAND_PARAM2
#define AT_COPS_OPER_MASK AT_COMMAND_PARAM3
#define AT_COPS_ACT_MASK AT_COMMAND_PARAM4
/* COPS AT command type */
typedef struct {
int mode;
int format;
#define AT_COPS_NUM_SIZE NET_FORMAT_NUM_SIZE
/* Size of numeric representation format */
#define AT_COPS_LONG_SIZE NET_FORMAT_LONG_SIZE
/* Size of long alphanumeric representation format */
#define AT_COPS_SHORT_SIZE NET_FORMAT_SHORT_SIZE
/* Size of short alphanumeric representation format */
network_plmn_t plmn;
int AcT;
} at_cops_t;
/* CREG: network registration
* --------------------------
* When <n>=1, returns +CREG: <stat>, the Mobile Equipment's circuit mode
* network registration status in GERA/UTRA/E-UTRA Network.
* When <n>=2, returns +CREG: <stat>[,<lac>,<ci>[,<AcT>]], the Mobile
* Equipment's circuit mode network registration status and location information
* in GERA/UTRA/E-UTRA Network.
* Parameter command:
* +CREG=[<n>]
* <n> numeric parameter
*/
/* Numeric parameter values */
#define AT_CREG_OFF 0 /* disable network registration unsolicited
* result code */
#define AT_CREG_ON 1 /* enable network registration unsolicited
* result code +CREG: <stat> */
#define AT_CREG_BOTH 2 /* enable network registration and location
* information unsolicited result code
* +CREG: <stat>[,<lac>,<ci>[,<AcT>]] */
#define AT_CREG_N_MIN AT_CREG_OFF
/* Minimum value of supported unsolicited
* result code */
#define AT_CREG_N_MAX AT_CREG_BOTH
/* Maximum value of supported unsolicited
* result code */
#define AT_CREG_N_DEFAULT AT_CREG_OFF
/* Default unsolicited result code applied
* when no value is given */
/* Optional parameter bitmask */
#define AT_CREG_N_MASK AT_COMMAND_PARAM1
/* CREG AT command type */
typedef struct {
int n;
} at_creg_t;
/*
* ==========================
* Commands for Packet Domain
* ==========================
*/
/* CGATT: EPS service attach/detach
* --------------------------------
* Used to attach the MT to, or detach the MT from, the EPS service.
* Action command (with optional parameters):
* +CGATT=[<state>]
* <state> numeric parameter that indicates the state of EPS attachment
*/
/* PS attachment status */
#define AT_CGATT_DETACHED 0 /* To detach from EPS service */
#define AT_CGATT_ATTACHED 1 /* To attach from EPS service */
#define AT_CGATT_STATE_MIN AT_CGATT_DETACHED
/* Minimum value of EPS attachment code */
#define AT_CGATT_STATE_MAX AT_CGATT_ATTACHED
/* Maximum value of EPS attachment code */
/* Optional parameter bitmask */
#define AT_CGATT_STATE_MASK AT_COMMAND_PARAM1
/* CGATT AT command type */
typedef struct {
int state;
} at_cgatt_t;
/* CGREG: GPRS network registration status
* ---------------------------------------
* When <n>=1, returns +CGREG: <stat>, the Mobile Equipment's GPRS network
* registration status in GERA/UTRA Network.
* When <n>=2, returns +CGREG: <stat>[,<lac>,<ci>[,<AcT>,<rac>]], the Mobile
* Equipment's GPRS network registration status and location information in
* GERA/UTRA Network.
* Parameter command:
* +CGREG=[<n>]
* <n> numeric parameter
*/
/* Numeric parameter values */
#define AT_CGREG_OFF 0 /* disable network registration unsolicited
* result code */
#define AT_CGREG_ON 1 /* enable network registration unsolicited
* result code +CGREG: <stat> */
#define AT_CGREG_BOTH 2 /* enable network registration and location
* information unsolicited result code
* +CGREG: <stat>[,<lac>,<ci>[,<AcT>,<rac>]] */
#define AT_CGREG_N_MIN AT_CGREG_OFF
/* Minimum value of supported unsolicited
* result code */
#define AT_CGREG_N_MAX AT_CGREG_BOTH
/* Maximum value of supported unsolicited
* result code */
#define AT_CGREG_N_DEFAULT AT_CGREG_OFF
/* Default unsolicited result code applied
* when no value is given */
/* Optional parameter bitmask */
#define AT_CGREG_N_MASK AT_COMMAND_PARAM1
/* CGREG AT command type */
typedef struct {
int n;
} at_cgreg_t;
/* CEREG: EPS network registration status
* --------------------------------------
* When <n>=1, returns +CEREG: <stat>, the Mobile Equipment's EPS services
* registration status in EUTRA Network.
* When <n>=2, returns +CEREG: <stat>[,<tac>,<ci>[,<AcT>]], the Mobile
* Equipment's EPS services registration status and location information in
* EUTRA Network.
* Parameter command:
* +CEREG=[<n>]
* <n> numeric parameter
*/
/* Numeric parameter values */
#define AT_CEREG_OFF 0 /* disable network registration unsolicited
* result code */
#define AT_CEREG_ON 1 /* enable network registration unsolicited
* result code +CEREG: <stat> */
#define AT_CEREG_BOTH 2 /* enable network registration and location
* information unsolicited result code
* +CEREG: <stat>[,<tac>,<ci>[,<AcT>]] */
#define AT_CEREG_N_MIN AT_CEREG_OFF
/* Minimum value of supported unsolicited
* result code */
#define AT_CEREG_N_MAX AT_CEREG_BOTH
/* Maximum value of supported unsolicited
* result code */
#define AT_CEREG_N_DEFAULT AT_CEREG_OFF
/* Default unsolicited result code applied
* when no value is given */
/* Optional parameter bitmask */
#define AT_CEREG_N_MASK AT_COMMAND_PARAM1
/* CEREG AT command type */
typedef struct {
int n;
} at_cereg_t;
/* CGDCONT: Define PDP Context
* ---------------------------
* Specifies PDP context parameter values for a PDP context identified by
* the (local) context identification parameter, <cid>.
* Parameter command:
* +CGDCONT=[<cid>[,<PDP_type>[,<APN>[,<PDP_addr>[,<d_comp>[,<h_comp>
* [,<IPv4AddrAlloc>[,<emergency indication>[,<P-CSCF_discovery>
* [,<IM_CN_Signalling_Flag_Ind>]]]]]]]]]]
* <cid> a numeric parameter which specifies a particular PDP
* context definition
* <PDP_type> type of packet data protocol ("IP", "IPV6", "IPV4V6")
* <APN> Access Point logical Name
* <PDP_addr> Mobile Equipment PDP address (not applicable to EPS)
* <d_comp> PDP data compression parameter
* <h_comp> PDP header compression parameter
* <IPv4AddrAlloc> IPv4 address allocation parameter
* <emergency indication> emergency bearer services support indication
* <P-CSCF_discovery> P-CSCF address discovery parameter
* <IM_CN_Signalling_Flag_Ind> IM CN subsystem-related signalling
* support indication
*/
/* PDP context identifier */
#define AT_CGDCONT_CID_MIN 1 /* Minimum value of context identifier */
#define AT_CGDCONT_CID_DEFAULT AT_CGDCONT_CID_MIN
/* PDP data compression parameter values */
#define AT_CGDCONT_D_COMP_OFF 0 /* PDP data compression is disabled */
#define AT_CGDCONT_D_COMP_ON 1 /* manufacturer preferred compression */
#define AT_CGDCONT_D_COMP_V42B 2 /* V.42bis */
#define AT_CGDCONT_D_COMP_V44 3 /* V.44 */
#define AT_CGDCONT_D_COMP_MIN AT_CGDCONT_D_COMP_OFF
#define AT_CGDCONT_D_COMP_MAX AT_CGDCONT_D_COMP_V44
#define AT_CGDCONT_D_COMP_DEFAULT AT_CGDCONT_D_COMP_OFF
/* PDP header compression parameter values */
#define AT_CGDCONT_H_COMP_OFF 0 /* PDP header compression is disabled */
#define AT_CGDCONT_H_COMP_ON 1 /* manufacturer preferred compression */
#define AT_CGDCONT_H_COMP_1144 2 /* RFC1144 (applicable for SNDCP only) */
#define AT_CGDCONT_H_COMP_2507 3 /* RFC2507 */
#define AT_CGDCONT_H_COMP_3095 4 /* RFC3095 (applicable for PDCP only) */
#define AT_CGDCONT_H_COMP_MIN AT_CGDCONT_H_COMP_OFF
#define AT_CGDCONT_H_COMP_MAX AT_CGDCONT_H_COMP_3095
#define AT_CGDCONT_H_COMP_DEFAULT AT_CGDCONT_H_COMP_OFF
/* IPv4AddrAlloc parameter values */
#define AT_CGDCONT_IPV4_NAS 0 /* IPv4 Address Allocation through NAS
* Signalling */
#define AT_CGDCONT_IPV4_DHCP 1 /* IPv4 Address Allocation through DHCP */
#define AT_CGDCONT_IPV4_MIN AT_CGDCONT_IPV4_NAS
#define AT_CGDCONT_IPV4_MAX AT_CGDCONT_IPV4_DHCP
#define AT_CGDCONT_IPV4_DEFAULT AT_CGDCONT_IPV4_NAS
/* emergency_indication parameter values */
#define AT_CGDCONT_EBS_OFF 0 /* PDP context is not for emergency bearer
* services */
#define AT_CGDCONT_EBS_ON 1 /* PDP context is for emergency bearer
* services */
#define AT_CGDCONT_EBS_MIN AT_CGDCONT_EBS_OFF
#define AT_CGDCONT_EBS_MAX AT_CGDCONT_EBS_ON
#define AT_CGDCONT_EBS_DEFAULT AT_CGDCONT_EBS_OFF
/* P_CSCF_discovery parameter values */
#define AT_CGDCONT_PCSCF_OFF 0 /* Preference of P-CSCF address discovery
* not influenced by +CGDCONTPDP */
#define AT_CGDCONT_PCSCF_NAS 1 /* Preference of P-CSCF address discovery
* through NAS Signalling */
#define AT_CGDCONT_PCSCF_DHCP 2 /* Preference of P-CSCF address discovery
* through DHCP */
#define AT_CGDCONT_PCSCF_MIN AT_CGDCONT_PCSCF_OFF
#define AT_CGDCONT_PCSCF_MAX AT_CGDCONT_PCSCF_DHCP
#define AT_CGDCONT_PCSCF_DEFAULT AT_CGDCONT_PCSCF_OFF
/* IM_CN_Signalling_Flag_Ind parameter values */
#define AT_CGDCONT_IM_CN_OFF 0 /* UE indicates that the PDP context is not
* for IM CN subsystem-related signalling
* only */
#define AT_CGDCONT_IM_CN_ON 1 /* UE indicates that the PDP context is for
* IM CN subsystem-related signalling
* only */
#define AT_CGDCONT_IM_CM_MIN AT_CGDCONT_IM_CN_OFF
#define AT_CGDCONT_IM_CM_MAX AT_CGDCONT_IM_CN_ON
#define AT_CGDCONT_IM_CM_DEFAULT AT_CGDCONT_IM_CN_OFF
/* Optional parameter bitmask */
#define AT_CGDCONT_CID_MASK AT_COMMAND_PARAM1
#define AT_CGDCONT_PDP_TYPE_MASK AT_COMMAND_PARAM2
#define AT_CGDCONT_APN_MASK AT_COMMAND_PARAM3
#define AT_CGDCONT_PDP_ADDR_MASK AT_COMMAND_PARAM4
#define AT_CGDCONT_D_COMP_MASK AT_COMMAND_PARAM5
#define AT_CGDCONT_H_COMP_MASK AT_COMMAND_PARAM6
#define AT_CGDCONT_IPV4ADDRALLOC_MASK AT_COMMAND_PARAM7
#define AT_CGDCONT_EMERGECY_INDICATION_MASK AT_COMMAND_PARAM8
#define AT_CGDCONT_P_CSCF_DISCOVERY_MASK AT_COMMAND_PARAM9
#define AT_CGDCONT_IM_CN_SIGNALLING_FLAG_IND_MASK AT_COMMAND_PARAM10
/* CGDCONT AT command type */
typedef struct {
int cid;
#define AT_CGDCONT_PDP_SIZE 6 /* PDP_type may be "IP", "IPV6", "IPV4V6" */
char PDP_type[AT_CGDCONT_PDP_SIZE+1];
#define AT_CGDCONT_APN_SIZE 100 /* number of characters in APN parameter */
char APN[AT_CGDCONT_APN_SIZE+1];
#define AT_CGDCONT_ADDR_SIZE 63 /* number of characters in PDP addr
* parameter (IPv6 address notation) */
char PDP_addr[AT_CGDCONT_ADDR_SIZE+1]; /* Does not apply to EPS */
int d_comp;
int h_comp;
int IPv4AddrAlloc;
int emergency_indication;
int P_CSCF_discovery;
int IM_CN_Signalling_Flag_Ind;
} at_cgdcont_t;
/* CGACT: PDP context activate or deactivate
* -----------------------------------------
* Used to activate or deactivate the specified PDP context(s).
* Action command (with optional parameters):
* +CGACT=[<state>[,<cid>[,<cid>[,...]]]]
* <state> numeric parameter that indicates the state of PDP context
* activation
* <cid> a numeric parameter which specifies a particular PDP context
* definition
*/
/* PDP context identifier */
#define AT_CGACT_CID_MIN 1 /* Minimum value of context identifier */
/* PDP context activation status */
#define AT_CGACT_DEACTIVATED 0 /* To deactivate the PDP context */
#define AT_CGACT_ACTIVATED 1 /* To activate the PDP context */
#define AT_CGACT_STATE_MIN AT_CGACT_DEACTIVATED
#define AT_CGACT_STATE_MAX AT_CGACT_ACTIVATED
#define AT_CGACT_STATE_DEFAULT AT_CGACT_DEACTIVATED
/* Optional parameter bitmask */
#define AT_CGACT_STATE_MASK AT_COMMAND_PARAM1
#define AT_CGACT_CID_MASK AT_COMMAND_PARAM2
/* CGACT AT command type */
typedef struct {
int state;
int cid;
} at_cgact_t;
/* CGPADDR: Show PDP address(es)
* -----------------------------
* Returns a list of PDP addresses for the specified context identifiers.
* +CGPADDR=[<cid>[,<cid>[,...]]]
* <cid> a numeric parameter which specifies a particular PDP
* context definition
*/
/* PDP context identifier */
#define AT_CGPADDR_CID_MIN 1 /* Minimum value of context identifier */
/* Optional parameter bitmask */
#define AT_CGPADDR_CID_MASK AT_COMMAND_PARAM1
/* CGPADDR AT command type */
typedef struct {
int cid;
} at_cgpaddr_t;
/*
* =================================
* Global AT command type definition
* =================================
*/
/* AT command type */
typedef struct {
at_command_id_t id; /* AT command identifier */
at_command_type_t type; /* AT command type */
int mask; /* Optional parameter bitmask */
union {
at_cgsn_t cgsn;
at_cgmm_t cgmm;
at_cgmr_t cgmr;
at_cimi_t cimi;
at_cfun_t cfun;
at_cpin_t cpin;
at_csq_t csq;
at_cesq_t cesq;
at_clac_t clac;
at_cmee_t cmee;
at_cnum_t cnum;
at_clck_t clck;
at_cops_t cops;
at_cgatt_t cgatt;
at_creg_t creg;
at_cgreg_t cgreg;
at_cereg_t cereg;
at_cgdcont_t cgdcont;
at_cgact_t cgact;
at_cgpaddr_t cgpaddr;
} command;
} at_command_t;
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
/****************************************************************************
** **
** Name: at_command_decode() **
** **
** Description: Parses AT command line and accordingly fills data struc- **
** ture. The main functions of the AT command parser are: **
** - check the AT command syntax **
** - fill parameter values into the data structure **
** **
** Inputs: buffer: Pointer to the buffer containing AT com- **
** mand line **
** length: Number of bytes that should be processed **
** Others: None **
** **
** Outputs: at_command: AT command data structure to be filled **
** Return: The number of AT commands successfully **
** decoded; RETURNerror if an error occurred **
** Others: None **
** **
***************************************************************************/
int at_command_decode(const char* buffer, int length, at_command_t* at_command);
/****************************************************************************
** **
** Name: at_command_get_list() **
** **
** Description: Returns the list of supported AT commands. **
** **
** Inputs: buffer: Pointer to the buffer containing the **
** string representaton of the first AT com- **
** mand that is supported by the NAS sublayer **
** n_max: Maximum number of AT commands the buffer **
** may contain **
** Others: None **
** **
** Outputs: None **
** Return: The number of AT commands actually suppor- **
** ted by the NAS sublayer **
** Others: None **
** **
***************************************************************************/
int at_command_get_list(const char** buffer, int n_max);
#endif /* __AT_COMMAND_H__*/
@@ -0,0 +1,420 @@
/*****************************************************************************
Source at_error.c
Version 0.1
Date 2012/03/12
Product NAS stack
Subsystem Application Programming Interface
Author Frederic Maurel
Description Defines error codes returned when execution of AT command
failed.
*****************************************************************************/
#include "at_error.h"
#include "commonDef.h"
#include "nas_log.h"
#include <string.h> // strcpy
#include <stdio.h> // sprintf
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
/****************************************************************************/
extern int at_response_format_v1;
/*
* Result code suppression indicator (set by ATQ0 and ATQ1)
* -------------------------------------------------------
* FALSE - Result codes are transmitted to the user application
* TRUE - Result codes are suppressed and not transmitted
*/
int at_error_code_suppression_q1 = FALSE;
/*
* Verbose mode indicator (set by ATV0, ATV1 and AT+CMEE)
* ------------------------------------------------------
*/
at_error_format_t at_error_format = AT_ERROR_OFF;
/****************************************************************************/
/******************* L O C A L D E F I N I T I O N S *******************/
/****************************************************************************/
/*
* General errors
* --------------
*/
static const char * _at_error_str[] = {
"phone failure",
"no connection to phone",
"phone-adaptor link reserved",
"operation not allowed",
"operation not supported",
"PH-SIM PIN required",
"PH-FSIM PIN required",
"PH-FSIM PUK required",
NULL,
NULL,
"SIM not inserted",
"SIM PIN required",
"SIM PUK required",
"SIM failure",
"SIM busy",
"SIM wrong",
"incorrect password",
"SIM PIN2 required",
"SIM PUK2 required",
NULL,
"memory full",
"invalid index",
"not found",
"memory failure",
"text string too long",
"invalid characters in text string",
"dial string too long",
"invalid characters in dial string",
NULL,
NULL,
"no network service",
"network timeout",
"network not allowed - emergency calls only",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
"network personalization PIN required",
"network personalization PUK required",
"network subset personalization PIN required",
"network subset personalization PUK required",
"service provider personalization PIN required",
"service provider personalization PUK required",
"corporate personalization PIN required",
"corporate personalization PUK required",
"hidden key required",
"EAP method not supported",
"Incorrect parameters",
};
/*
* GPRS-related errors
* -------------------
*/
static const char* _at_error_gprs[] = {
"Illegal MS",
NULL,
NULL,
"Illegal ME",
"GPRS services not allowed",
NULL,
NULL,
NULL,
"PLMN not allowed",
"Location area not allowed",
"Roaming not allowed in this location area",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
"service option not supported",
"requested service option not subscribed",
"service option temporarily out of order",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
"unspecified GPRS error",
"PDP authentication failure",
"invalid mobile class",
"Last PDN disconnection not allowed",
};
/*
* VBS / VGCS and eMLPP -related errors
* ------------------------------------
*/
static const char* _at_error_vbs[] = {
/* 151 "VBS/VGCS not supported by the network" */
"No service subscription on SIM",
"No subscription for group ID",
"Group Id not activated on SIM",
"No matching notification",
"VBS/VGCS call already present",
"Congestion",
"Network failure",
"Uplink busy",
"No access rights for SIM file",
"No subscription for priority",
"operation not applicable or not possible",
"Group Id prefixes not supported",
"Group Id prefixes not usable for VBS",
"Group Id prefix value invalid",
};
/* Returns the verbose value of AT command error */
static const char* _at_error_to_string(int error);
static int _at_error_encode_ok(char* buffer);
static int _at_error_encode_ko(char* buffer, at_error_type_t type, int error);
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
/****************************************************************************
** **
** Name: at_error_set_format() **
** **
** Description: Sets the format of the error code **
** **
** Inputs: format: Format of the error code **
** Others: None **
** **
** Outputs: Return: None **
** Others: at_error_format **
** **
***************************************************************************/
void at_error_set_format(at_error_format_t format)
{
LOG_FUNC_IN;
at_error_format = format;
LOG_FUNC_OUT;
}
/****************************************************************************
** **
** Name: at_error_get_format() **
** **
** Description: Gets the format of the error code **
** **
** Inputs: format: Format of the error code **
** Others: None **
** **
** Outputs: Return: None **
** Others: at_error_format **
** **
***************************************************************************/
at_error_format_t at_error_get_format(void)
{
LOG_FUNC_IN;
LOG_FUNC_RETURN (at_error_format);
}
/****************************************************************************
** **
** Name: at_error_encode() **
** **
** Description: Encodes result code returned when AT command has been **
** processed. Result code can be OK or 0, if the command **
** succeed, ERROR or 4, if the command failed; depending of **
** the response format selected by the user. **
** **
** Inputs type: Type of the error code to encode **
** error: Error code to encode **
** Others: None **
** **
** Outputs: buffer: Pointer to the encoded data buffer **
** Return: The number of characters that have been **
** successfully encoded; **
** Others: None **
** **
***************************************************************************/
int at_error_encode(char* buffer, at_error_type_t type, int error)
{
LOG_FUNC_IN;
int bytes = 0;
/* Result code suppression (ATQ0, ATQ1) */
if (at_error_code_suppression_q1) {
LOG_FUNC_RETURN (0);
}
if (type == AT_ERROR_OK) {
/* Encode success return code */
bytes = _at_error_encode_ok(buffer);
}
else {
/* Encode failure return code */
bytes = _at_error_encode_ko(buffer, type, error);
}
LOG_FUNC_RETURN (bytes);
}
/****************************************************************************/
/********************* L O C A L F U N C T I O N S *********************/
/****************************************************************************/
/****************************************************************************
** **
** Name: _at_error_encode_ok() **
** **
** Description: Encodes AT command success result code message **
** **
** Inputs None **
** Others: None **
** **
** Outputs: buffer: Pointer to the encoded data buffer **
** Return: The number of characters that have been **
** successfully encoded; **
** Others: None **
** **
***************************************************************************/
static int _at_error_encode_ok(char* buffer)
{
LOG_FUNC_IN;
int offset = 0;
if (at_response_format_v1) {
offset += sprintf(buffer, "\r\n");
}
offset += sprintf(buffer + offset, "OK\r\n");
LOG_FUNC_RETURN (offset);
}
/****************************************************************************
** **
** Name: _at_error_encode_ko() **
** **
** Description: Encodes AT command error code message **
** **
** Inputs type: Type of the error code to encode **
** error: Error code to encode **
** Others: at_error_format **
** **
** Outputs: buffer: Pointer to the encoded data buffer **
** Return: The number of characters that have been **
** successfully encoded; **
** Others: None **
** **
***************************************************************************/
static int _at_error_encode_ko(char* buffer, at_error_type_t type, int error)
{
LOG_FUNC_IN;
int offset = 0;
if (at_response_format_v1) {
offset += sprintf(buffer, "\r\n");
}
/* Result code is disabled */
if (at_error_format == AT_ERROR_OFF) {
offset += sprintf(buffer + offset, "ERROR\r\n");
}
else
{
/* Error related to execution of AT command operation */
if (type == AT_ERROR_CME) {
offset += sprintf(buffer + offset, "+CME ERROR: ");
}
/* Result code is enabled for numeric values */
if (at_error_format == AT_ERROR_NUMERIC) {
offset += sprintf(buffer + offset, "%d\r\n", error);
}
/* Result code is enabled for verbose values */
else {
const char* error_str = _at_error_to_string(error);
if (error_str != NULL) {
offset += sprintf(buffer + offset, "%s\r\n", error_str);
}
else {
/* Error code is not valid */
offset += sprintf(buffer + offset, "invalid error code\r\n");
}
}
}
LOG_FUNC_RETURN (offset);
}
/****************************************************************************
** **
** Name: at_error_to_string() **
** **
** Description: Returns the verbose value of AT command error **
** **
** Inputs: error: AT command error identifier **
** Others: None **
** **
** Outputs: Return: The error's verbose value **
** NULL if the error code is not valid **
** Others: None **
** **
***************************************************************************/
static const char* _at_error_to_string(int error)
{
if (error < AT_ERROR_LAST_GENERAL_ERROR + 1)
{
/* General errors */
if (error > AT_ERROR_FIRST_GENERAL_ERROR - 1) {
return _at_error_str[error];
}
else {
return NULL;
}
}
else if (error < AT_ERROR_LAST_GPRS_RELATED_ERROR + 1)
{
/* GPRS-related errors */
if (error > AT_ERROR_FIRST_GPRS_RELATED_ERROR - 1) {
return _at_error_gprs[error - AT_ERROR_FIRST_GPRS_RELATED_ERROR];
}
else {
return NULL;
}
}
else if (error < AT_ERROR_LAST_VBS_RELATED_ERROR + 1)
{
/* VBS / VGCS and eMLPP -related errors */
if (error > AT_ERROR_FIRST_VBS_RELATED_ERROR - 1) {
return _at_error_vbs[error - AT_ERROR_FIRST_VBS_RELATED_ERROR];
}
else {
return NULL;
}
}
return NULL;
}
@@ -0,0 +1,173 @@
/*****************************************************************************
Source at_error.h
Version 0.1
Date 2012/03/12
Product NAS stack
Subsystem Application Programming Interface
Author Frederic Maurel
Description Defines error codes returned when execution of AT command
failed.
*****************************************************************************/
#ifndef __AT_ERROR_H__
#define __AT_ERROR_H__
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/*
* Cause code used to notify that the NAS procedure has been successfully
* processed
*/
#define AT_ERROR_SUCCESS (-1)
/*
* General errors
* --------------
*/
#define AT_ERROR_FIRST_GENERAL_ERROR AT_ERROR_PHONE_FAILURE
#define AT_ERROR_PHONE_FAILURE 0
#define AT_ERROR_NO_CONNECTION_TO_PHONE 1
#define AT_ERROR_PHONE_ADAPTOR_LINK_RESERVED 2
#define AT_ERROR_OPERATION_NOT_ALLOWED 3
#define AT_ERROR_OPERATION_NOT_SUPPORTED 4
#define AT_ERROR_PHSIM_PIN_REQUIRED 5
#define AT_ERROR_PHFSIM_PIN_REQUIRED 6
#define AT_ERROR_PHFSIM_PUK_REQUIRED 7
#define AT_ERROR_SIM_NOT_INSERTED 10
#define AT_ERROR_SIM_PIN_REQUIRED 11
#define AT_ERROR_SIM_PUK_REQUIRED 12
#define AT_ERROR_SIM_FAILURE 13
#define AT_ERROR_SIM_BUSY 14
#define AT_ERROR_SIM_WRONG 15
#define AT_ERROR_INCORRECT_PASSWD 16
#define AT_ERROR_SIM_PIN2_REQUIRED 17
#define AT_ERROR_SIM_PUK2_REQUIRED 18
#define AT_ERROR_MEMORY_FULL 20
#define AT_ERROR_INVALID_INDEX 21
#define AT_ERROR_NOT_FOUND 22
#define AT_ERROR_MEMORY_FAILURE 23
#define AT_ERROR_TEXT_STRING_TOO_LONG 24
#define AT_ERROR_TEXT_STRING_INVALID_CHAR 25
#define AT_ERROR_DIAL_STRING_TOO_LONG 26
#define AT_ERROR_DIAL_STRING_INVALID_CHAR 27
#define AT_ERROR_NO_NETWORK_SERVICE 30
#define AT_ERROR_TIMEOUT 31
#define AT_ERROR_NETWORK_NOT_ALLOWED 32
#define AT_ERROR_NETWORK_PERSO_PIN_REQUIRED 40
#define AT_ERROR_NETWORK_PERSO_PUK_REQUIRED 41
#define AT_ERROR_NETWORK_SUBNET_PERSO_PIN_REQUIRED 42
#define AT_ERROR_SUBNET_PERSO_PUK_REQUIRED 43
#define AT_ERROR_PROVIDER_PERSO_PIN_REQUIRED 44
#define AT_ERROR_PROVIDER_PERSO_PUK_REQUIRED 45
#define AT_ERROR_CORPORATE_PERSO_PIN_REQUIRED 46
#define AT_ERROR_CORPORATE_PERSO_PUK_REQUIRED 47
#define AT_ERROR_HIDDEN_KEY_REQUIRED 48
#define AT_ERROR_EAP_METHOD_NOT_SUPPORTED 49
#define AT_ERROR_INCORRECT_PARAMETERS 50
#define AT_ERROR_LAST_GENERAL_ERROR AT_ERROR_INCORRECT_PARAMETERS
#define AT_ERROR_UNKNOWN 100
/*
* GPRS-related errors
* -------------------
*/
/* Errors related to a failure to perform an attach */
#define AT_ERROR_FIRST_GPRS_RELATED_ERROR AT_ERROR_ILLEGAL_MS
#define AT_ERROR_ILLEGAL_MS 103
#define AT_ERROR_ILLEGAL_ME 106
#define AT_ERROR_GPRS_NOT_ALLOWED 107
#define AT_ERROR_PLMN_NOT_ALLOWED 111
#define AT_ERROR_LOCATION_AREA_NOT_ALLOWED 112
#define AT_ERROR_ROAMING_NOT_ALLOWED 113
/* Errors related to a failure to activate a context */
#define AT_ERROR_OPTION_NOT_SUPPORTED 132
#define AT_ERROR_OPTION_NOT_SUBSCRIBED 133
#define AT_ERROR_OPTION_TEMPORARILY_OUT_OF_ORDER 134
#define AT_ERROR_PDP_AUTHENTICATION_FAILURE 149
/* Errors related to a failure to disconnect a PDN */
#define AT_ERROR_LAST_PDP_DISCONNECT_NOT_ALLOWED 151
/* Other GPRS errors */
#define AT_ERROR_UNSPECIFIED_GPRS_ERROR 148
#define AT_ERROR_INVALID_MOBILE_CLASS 150
#define AT_ERROR_LAST_GPRS_RELATED_ERROR AT_ERROR_LAST_PDP_DISCONNECT_NOT_ALLOWED
/*
* VBS / VGCS and eMLPP -related errors
* ------------------------------------
*/
#define AT_ERROR_FIRST_VBS_RELATED_ERROR AT_ERROR_NO_SERVICE_SUBSCRIPTION_ON_SIM
/* AT_ERROR_VBS_VGCS_NOT_SUPPORTED=151,*/ /* !!! Conflict with AT_ERROR_LAST_PDP_DISCONNECT_NOT_ALLOWED !!! */
#define AT_ERROR_NO_SERVICE_SUBSCRIPTION_ON_SIM 152
#define AT_ERROR_NO_SUBSCRIPTION_FOR_GROUP_ID 153
#define AT_ERROR_GROUP_ID_NOT_ACTIVATED_ON_SIM 154
#define AT_ERROR_NO_MATCHING_NOTIFICATION 155
#define AT_ERROR_VBS_VGCS_CALL_ALREADY_PRESENT 156
#define AT_ERROR_CONGESTION 157
#define AT_ERROR_NETWORK_FAILURE 158
#define AT_ERROR_UPLINK_BUSY 159
#define AT_ERROR_NO_ACCESS_RIGHTS_FOR_SIM_FILE 160
#define AT_ERROR_NO_SUBSCRIPTION_FOR_PRIORITY 161
#define AT_ERROR_OPERATION_NOT_APPLICABLE_OR_NOT_POSSIBLE 162
#define AT_ERROR_GROUP_ID_PREFIXES_NOT_SUPPORTED 163
#define AT_ERROR_GROUP_ID_PREFIXES_NOT_USABLE_FOR_VBS 164
#define AT_ERROR_GROUP_ID_PREFIX_VALUE_INVALID 165
#define AT_ERROR_LAST_VBS_RELATED_ERROR AT_ERROR_GROUP_ID_PREFIX_VALUE_INVALID
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/*
* Error type identifiers
*/
typedef enum {
AT_ERROR_NONE, /* No error code displayed */
AT_ERROR_OK, /* AT command successfully processed */
AT_ERROR_SYNTAX, /* AT command syntax error */
AT_ERROR_CME, /* Error related to execution of AT command
* operation */
} at_error_type_t;
/*
* Error code format identifiers
*/
typedef enum {
AT_ERROR_OFF, /* disable result code and use ERROR instead */
AT_ERROR_NUMERIC, /* enable result code and use numeric error values */
AT_ERROR_VERBOSE, /* enable result code and use verbose error values */
} at_error_format_t;
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
void at_error_set_format(at_error_format_t format);
at_error_format_t at_error_get_format(void);
int at_error_encode(char* buffer, at_error_type_t type, int error);
#endif /* __AT_ERROR_H__*/
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,761 @@
/*****************************************************************************
Source at_response.h
Version 0.1
Date 2012/03/09
Product NAS stack
Subsystem Application Programming Interface
Author Frederic Maurel
Description Defines structure of the AT command response returned after
completion of AT command processing.
*****************************************************************************/
#ifndef __AT_RESPONSE_H__
#define __AT_RESPONSE_H__
#include "at_command.h"
#include "commonDef.h"
#include "networkDef.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/*
* Total number of characters, including line terminators, in information text
*/
#define AT_RESPONSE_INFO_TEXT_SIZE 2048
/*
* Value of the mask parameter for AT command reponses without any optional
* parameters
*/
#define AT_RESPONSE_NO_PARAM AT_COMMAND_PARAM0
/*
* Maximum value of an AT command response identifier
*/
#define AT_RESPONSE_ID_MAX AT_COMMAND_ID_MAX
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/*
* ================
* General commands
* ================
*/
/* CGSN: Request Product Serial Number identification (IMEI)
* ---------------------------------------------------------
* Returns information text intended to permit the user to identify the
* individual Mobile Equipment to which it is connected to.
* Action command:
* +CGSN returns <sn>
* <sn> information text containing the IMEI
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CGSN_MASK AT_RESPONSE_NO_PARAM
/* CGSN AT command response type */
typedef struct {
char sn[AT_RESPONSE_INFO_TEXT_SIZE+1];
} at_cgsn_resp_t;
/* CGMI: Request manufacturer identification
* -----------------------------------------
* Returns information text intended to permit the user to identify the
* manufacturer of the Mobile Equipment to which it is connected to.
* Action command:
* +CGMI returns <manufacturer>
* <manufacturer> information text containing the manufacturer id
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CGMI_MASK AT_RESPONSE_NO_PARAM
/* CGMI AT command response type */
typedef struct {
char manufacturer[AT_RESPONSE_INFO_TEXT_SIZE+1];
} at_cgmi_resp_t;
/* CGMM: Request model identification
* ----------------------------------
* Returns information text intended to permit the user to identify the
* specific model of the Mobile Equipment to which it is connected to.
* +CGMM returns <model>
* <model> information text containing the model id
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CGMM_MASK AT_RESPONSE_NO_PARAM
/* CGMM AT command response type */
typedef struct {
char model[AT_RESPONSE_INFO_TEXT_SIZE+1];
} at_cgmm_resp_t;
/* CGMR: Request revision identification
* -------------------------------------
* Returns information text intended to permit the user to identify the
* version, revision level or date, or other pertinent information of the
* Mobile Equipment to which it is connected to.
* +CGMR returns <revision>
* <revision> information text containing the revision of the firmware
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CGMR_MASK AT_RESPONSE_NO_PARAM
/* CGMR AT command response type */
typedef struct {
char revision[AT_RESPONSE_INFO_TEXT_SIZE+1];
} at_cgmr_resp_t;
/* CIMI: Request International Mobile Subscriber Identity
* ------------------------------------------------------
* Returns <IMSI>, which is intended to permit the user to identify the
* individual SIM card or active application in the UICC (GSM or USIM)
* which is attached to the Mobile Equipment to which it is connected to.
* Action command:
* +CIMI returns <IMSI>
* <IMSI> International Mobile Subscriber Identity (string without
* double quotes)
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CIMI_MASK AT_RESPONSE_NO_PARAM
/* CIMI AT command response type */
typedef struct {
char IMSI[AT_RESPONSE_INFO_TEXT_SIZE+1];
} at_cimi_resp_t;
/*
* ==============================================
* Mobile Termination control and status commands
* ==============================================
*/
/* CFUN: Set phone functionality
* -----------------------------
* Used to set the Mobile Equipment to different power consumption states
* Read parameter command:
* +CFUN? returns +CFUN: <fun>
* <fun> integer type - level of functionality
* Test parameter command:
* +CFUN=? returns +CFUN: (list of supported <fun>s),(list of supported <rst>s)
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CFUN_MASK AT_RESPONSE_NO_PARAM
/* CFUN AT command response type */
typedef struct {
int fun;
} at_cfun_resp_t;
/* CPIN: Enter PIN
* ---------------
* Used to enter MT passwords which are needed before any other
* functionality of the MT can be used
* Read parameter command:
* +CPIN? returns +CPIN: <code>
* <code> string - value may be: "READY", "SIM PIN"
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CPIN_MASK AT_RESPONSE_NO_PARAM
/* CPIN AT command response type */
typedef struct {
#define AT_CPIN_RESP_SIZE 16
char code[AT_CPIN_RESP_SIZE+1];
} at_cpin_resp_t;
/* CSQ: Signal quality
* -------------------
* Returns received signal strength indication and channel bit error rate
* from the Mobile Equipment
* Action command:
* +CSQ returns +CSQ: <rssi>, <ber>
* <rssi> integer type - received signal strength indication (in dBm)
* <ber> integer type - channel bit error rate (in percent)
*/
/* Received signal strength indicator */
#define AT_CSQ_RSSI_0 0 /* -113 dBm or less */
#define AT_CSQ_RSSI_31 31 /* -51 dBm or greater */
#define AT_CSQ_RSSI_UNKNOWN 99 /* not known or not detectable */
/* Channel bit error rate */
#define AT_CSQ_BER_0 0 /* BER < 0.2 % */
#define AT_CSQ_BER_1 1 /* 0.2 % < BER < 0.4 % */
#define AT_CSQ_BER_2 2 /* 0.4 % < BER < 0.8 % */
#define AT_CSQ_BER_3 3 /* 0.8 % < BER < 1.6 % */
#define AT_CSQ_BER_4 4 /* 1.6 % < BER < 3.2 % */
#define AT_CSQ_BER_5 5 /* 3.2 % < BER < 6.4 % */
#define AT_CSQ_BER_6 6 /* 6.4 % < BER < 12.8 % */
#define AT_CSQ_BER_7 7 /* 12.8 % < BER */
#define AT_CSQ_BER_UNKNOWN 99 /* not known or not detectable */
/* Optional parameter bitmask */
#define AT_RESPONSE_CSQ_MASK AT_RESPONSE_NO_PARAM
/* CSQ AT command response type */
typedef struct {
int rssi;
int ber;
} at_csq_resp_t;
/* CESQ: Extended signal quality
* -----------------------------
* Returns received signal quality parameters.
* Action command:
* +CESQ returns +CESQ: <rssi>,<ber>,<rscp>,<ecno>,<rsrq>,<rsrp>
* <rssi> integer type - received signal strength indication (in dBm)
* <ber> integer type - channel bit error rate (in percent)
* <rscp> integer type - received signal code power (in dBm)
* <ecno> integer type - ratio of the received energy per PN chip (in dBm)
* <rsrq> integer type - reference signal received quality (in dBm)
* <rsrp> integer type - reference signal received power (in dBm)
*/
/* Received signal strength indicator */
#define AT_CESQ_RSSI_0 0 /* -113 dBm or less */
#define AT_CESQ_RSSI_31 31 /* -51 dBm or greater */
#define AT_CESQ_RSSI_UNKNOWN 99 /* not known or not detectable */
/* Channel bit error rate */
#define AT_CESQ_BER_0 0 /* BER < 0.2 % */
#define AT_CESQ_BER_1 1 /* 0.2 % < BER < 0.4 % */
#define AT_CESQ_BER_2 2 /* 0.4 % < BER < 0.8 % */
#define AT_CESQ_BER_3 3 /* 0.8 % < BER < 1.6 % */
#define AT_CESQ_BER_4 4 /* 1.6 % < BER < 3.2 % */
#define AT_CESQ_BER_5 5 /* 3.2 % < BER < 6.4 % */
#define AT_CESQ_BER_6 6 /* 6.4 % < BER < 12.8 % */
#define AT_CESQ_BER_7 7 /* 12.8 % < BER */
#define AT_CESQ_BER_UNKNOWN 99 /* not known or not detectable */
/* Received signal code power */
#define AT_CESQ_RSCP_0 0 /* -120 dBm or less */
#define AT_CESQ_RSCP_96 96 /* -24 dBm or greater */
#define AT_CESQ_RSCP_UNKNOWN 255 /* not known or not detectable */
/* Ratio of the received energy per PN chip (Ec/No) */
#define AT_CESQ_ECNO_0 0 /* -24 dBm or less */
#define AT_CESQ_ECNO_49 49 /* 0,5 dBm or greater */
#define AT_CESQ_ECNO_UNKNOWN 255 /* not known or not detectable */
/* Reference signal received quality */
#define AT_CESQ_RSRQ_0 0 /* -19,5 dBm or less */
#define AT_CESQ_RSRQ_34 34 /* -2,5 dBm or greater */
#define AT_CESQ_RSRQ_UNKNOWN 255 /* not known or not detectable */
/* Reference signal received power */
#define AT_CESQ_RSRP_0 0 /* -140 dBm or less */
#define AT_CESQ_RSRP_97 97 /* -43 dBm or greater */
#define AT_CESQ_RSRP_UNKNOWN 255 /* not known or not detectable */
/* Optional parameter bitmask */
#define AT_RESPONSE_CESQ_MASK AT_RESPONSE_NO_PARAM
/* CSQ AT command response type */
typedef struct {
int rssi;
int ber;
int rscp;
int ecno;
int rsrq;
int rsrp;
} at_cesq_resp_t;
/* CLAC: List all available AT commands
* ------------------------------------
* Returns one or more lines of AT Commands that are available for the user.
* Action command:
* +CLAC returns +CLAC: <AT Command1>[<CR><LF><AT Command2>[...]]
* <AT Command> string - defines the AT command including the prefix AT
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CLAC_MASK AT_RESPONSE_NO_PARAM
/* CLAC AT command response type */
typedef struct {
int n_acs;
#define AT_CLAC_RESP_SIZE 100
const char* ac[AT_CLAC_RESP_SIZE];
} at_clac_resp_t;
/*
* =========================
* Mobile Termination errors
* =========================
*/
/*
* CMEE: Report mobile termination error
* -------------------------------------
* Disables or enables the use of final result code +CME ERROR: <err> as an
* indication of an error relating to the functionality of the MT.
* Read parameter command:
* +CMEE? returns +CMEE: <n>
* <n> numeric parameter
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CMEE_MASK AT_RESPONSE_NO_PARAM
/* CMEE AT command response type */
typedef at_cmee_t at_cmee_resp_t;
/*
* ================================
* Network service related commands
* ================================
*/
/* CNUM: Subscriber number
* -----------------------
* Returns the MSISDNs related to the subscriber.
* Action command:
* +CNUM returns +CNUM: <number1>,<type1>[<CR><LF>
* +CNUM: <number2>,<type2>[...]]
* <numberx> string type phone number of format specified by <typex>
* <typex> type of address octet in integer format
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CNUM_MASK AT_RESPONSE_NO_PARAM
/* CNUM AT command response type */
typedef struct {
#define AT_CNUM_NUMBER_SIZE MSISDN_DIGIT_SIZE
char number[AT_CNUM_NUMBER_SIZE];
int type;
} at_cnum_resp_t;
/* CLCK: Facility lock
* -------------------
* Used to lock, unlock or interrogate a MT or a network facility <fac>.
* When <mode>=2, returns +CLCK: <status>
* <status> state of the network service
*/
/* Network service status */
#define AT_CLCK_RESP_STATUS_NOT_ACTIVE 0
#define AT_CLCK_RESP_STATUS_ACTIVE 1
/* Optional parameter bitmask */
#define AT_RESPONSE_CLCK_MASK AT_RESPONSE_NO_PARAM
/* CLCK AT command response type */
typedef struct {
int status;
} at_clck_resp_t;
/* COPS: PLMN selection
* --------------------
* Forces an attempt to select and register the GSM/UMTS/EPS network operator
* using the SIM/USIM card installed in the currently selected card slot.
* Read parameter command:
* +COPS? returns +COPS:<mode>[,<format>,<oper>[,<AcT>]]
* <mode> operation mode of the network selection
* <format> representation format of the network operator
* <oper> APN operator identifier
* <AcT> access technology
* Test command returns a set of parameters, each representing an operator
* present in the network:
* +COPS=? returns +COPS: [list of supported (<stat>,long alphanumeric <oper>,
* short alphanumeric <oper>,numeric <oper>[,<AcT>])s][,,(list of supported
* <mode>s),(list of supported <format>s)]
* <stat> network operator availability
*/
/* Optional parameter bitmask */
#define AT_COPS_RESP_FORMAT_MASK AT_COMMAND_PARAM2
#define AT_COPS_RESP_OPER_MASK AT_COMMAND_PARAM3
#define AT_COPS_RESP_ACT_MASK AT_COMMAND_PARAM4
/* Structure of COPS AT test parameter command */
typedef struct {
const char* data; /* String representation of the list of operators */
int size; /* Size in byte of the data to be dislayed */
} at_cops_tst_t;
/* Structure of COPS AT read parameter command */
typedef at_cops_t at_cops_get_t;
/* COPS AT command response type */
typedef union {
at_cops_tst_t tst;
at_cops_get_t get;
} at_cops_resp_t;
/* CREG: network registration
* --------------------------
* When <n>=1, returns +CREG: <stat>, the Mobile Equipment's circuit mode
* network registration status in GERA/UTRA/E-UTRA Network.
* When <n>=2, returns +CREG: <stat>[,<lac>,<ci>[,<AcT>]], the Mobile
* Equipment's circuit mode network registration status and location information
* in GERA/UTRA/E-UTRA Network.
* Read parameter command:
* +CREG? returns +CREG:<n>,<stat>[,<lac>,<ci>[,<AcT>]]
* <n> numeric parameter
* <stat> numeric parameter that indicates the circuit mode registration
* status
* <lac> string type; two byte location area code in hexadecimal format
* <ci> string type; four byte GERAN/UTRAN/E-UTRAN cell ID in hexadeci-
* mal format
* <AcT> a numeric parameter that indicates the access technology of
* the serving cell
*/
/* Network registration status */
#define AT_CREG_RESP_REG_OFF NET_REG_STATE_OFF
#define AT_CREG_RESP_REG_HN NET_REG_STATE_HN
#define AT_CREG_RESP_REG_ON NET_REG_STATE_ON
#define AT_CREG_RESP_REG_DENIED NET_REG_STATE_DENIED
#define AT_CREG_RESP_REG_UNKNOWN NET_REG_STATE_UNKNOWN
#define AT_CREG_RESP_REG_SMS_HN NET_REG_STATE_SMS_HN
#define AT_CREG_RESP_REG_SMS_ROAMING NET_REG_STATE_SMS_ROAMING
#define AT_CREG_RESP_REG_ROAMING NET_REG_STATE_ROAMING
/* Access technology indicators */
#define AT_CREG_RESP_GSM NET_ACCESS_GSM /* GSM */
#define AT_CREG_RESP_COMPACT NET_ACCESS_COMPACT /* GSM Compact */
#define AT_CREG_RESP_UTRAN NET_ACCESS_UTRAN /* UTRAN */
#define AT_CREG_RESP_EGPRS NET_ACCESS_EGPRS /* GSM w/EGPRS */
#define AT_CREG_RESP_HSDPA NET_ACCESS_HSDPA /* UTRAN w/HSDPA */
#define AT_CREG_RESP_HSUPA NET_ACCESS_HSUPA /* UTRAN w/HSUPA */
#define AT_CREG_RESP_HSDUPA NET_ACCESS_HSDUPA /* w/HSDPA and HSUPA */
#define AT_CREG_RESP_EUTRAN NET_ACCESS_EUTRAN /* E-UTRAN */
/* Optional parameter bitmask */
//#define AT_CREG_RESP_N_MASK AT_COMMAND_PARAM1
#define AT_CREG_RESP_LAC_MASK AT_COMMAND_PARAM3
#define AT_CREG_RESP_CI_MASK AT_COMMAND_PARAM4
#define AT_CREG_RESP_ACT_MASK AT_COMMAND_PARAM5
/* CREG AT command response type */
typedef struct {
int n;
int stat;
#define AT_CREG_RESP_LAC_SIZE 4
char lac[AT_CREG_RESP_LAC_SIZE+1];
#define AT_CREG_RESP_CI_SIZE 8
char ci[AT_CREG_RESP_CI_SIZE+1];
int AcT;
} at_creg_resp_t;
/*
* ==========================
* Commands for Packet Domain
* ==========================
*/
/* CGATT: GPRS service attach/detach
* ---------------------------------
* Used to attach the MT to, or detach the MT from, the GPRS service.
* Read parameter command:
* +CGATT? returns CGATT: <state>
* <state> numeric parameter that indicates the state of GPRS attachment
* Test parameter command:
* +CGATT=? returns CGATT: (list of supported <state>s)
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CGATT_MASK AT_RESPONSE_NO_PARAM
/* CGATT AT command response type */
typedef struct {
int state;
} at_cgatt_resp_t;
/* CGREG: GPRS network registration status
* ---------------------------------------
* When <n>=1, returns +CGREG: <stat>, the Mobile Equipment's GPRS network
* registration status in GERA/UTRA Network.
* When <n>=2, returns +CGREG: <stat>[,<lac>,<ci>[,<AcT>,<rac>]], the Mobile
* Equipment's GPRS network registration status and location information in
* GERA/UTRA Network.
* Read parameter command:
* +CGREG? returns +CGREG:<n>,<stat>[,<lac>,<ci>[,<AcT>,<rac>]]
* <n> numeric parameter
* <stat> numeric parameter that indicates the GPRS registration status
* <lac> string type; two byte location area code in hexadecimal format
* <ci> string type; four byte GERAN/UTRAN cell ID in hexadecimal format
* <AcT> a numeric parameter that indicates the access technology of
* the serving cell
* <rac> string type; one byte routing area code in hexadecimal format
*/
/* Network registration status */
#define AT_CGREG_RESP_REG_OFF NET_REG_STATE_OFF
#define AT_CGREG_RESP_REG_HN NET_REG_STATE_HN
#define AT_CGREG_RESP_REG_ON NET_REG_STATE_ON
#define AT_CGREG_RESP_REG_DENIED NET_REG_STATE_DENIED
#define AT_CGREG_RESP_REG_UNKNOWN NET_REG_STATE_UNKNOWN
#define AT_CGREG_RESP_REG_ROAMING NET_REG_STATE_ROAMING
#define AT_CGREG_RESP_REG_EMERGENCY NET_REG_STATE_EMERGENCY
/* Access technology indicators */
#define AT_CGREG_RESP_GSM NET_ACCESS_GSM /* GSM */
#define AT_CGREG_RESP_COMPACT NET_ACCESS_COMPACT /* GSM Compact */
#define AT_CGREG_RESP_UTRAN NET_ACCESS_UTRAN /* UTRAN */
#define AT_CGREG_RESP_EGPRS NET_ACCESS_EGPRS /* GSM w/EGPRS */
#define AT_CGREG_RESP_HSDPA NET_ACCESS_HSDPA /* UTRAN w/HSDPA */
#define AT_CGREG_RESP_HSUPA NET_ACCESS_HSUPA /* UTRAN w/HSUPA */
#define AT_CGREG_RESP_HSDUPA NET_ACCESS_HSDUPA /* w/HSDPA and HSUPA */
/* Optional parameter bitmask */
//#define AT_CGREG_RESP_N_MASK AT_COMMAND_PARAM1
#define AT_CGREG_RESP_LAC_MASK AT_COMMAND_PARAM3
#define AT_CGREG_RESP_CI_MASK AT_COMMAND_PARAM4
#define AT_CGREG_RESP_ACT_MASK AT_COMMAND_PARAM5
#define AT_CGREG_RESP_RAC_MASK AT_COMMAND_PARAM6
/* CGREG AT command response type */
typedef struct {
int n;
int stat;
#define AT_CGREG_RESP_LAC_SIZE 4
char lac[AT_CGREG_RESP_LAC_SIZE+1];
#define AT_CGREG_RESP_CI_SIZE 8
char ci[AT_CGREG_RESP_CI_SIZE+1];
int AcT;
#define AT_CGREG_RESP_RAC_SIZE 2
char rac[AT_CGREG_RESP_RAC_SIZE+1];
} at_cgreg_resp_t;
/* CEREG: EPS network registration status
* --------------------------------------
* When <n>=1, returns +CEREG: <stat>, the Mobile Equipment's EPS services
* registration status in EUTRA Network.
* When <n>=2, returns +CEREG: <stat>[,<tac>,<ci>[,<AcT>]], the Mobile
* Equipment's EPS services registration status and location information in
* EUTRA Network.
* Read parameter command:
* +CEREG? returns +CEREG:<n>,<stat>[,<tac>,<ci>[,<AcT>]]
* <n> numeric parameter
* <stat> numeric parameter that indicates the EPS registration status
* <tac> string type; two byte tracking area code in hexadecimal format
* <ci> string type; four byte E-UTRAN cell ID in hexadecimal format
* <AcT> a numeric parameter that indicates the access technology of
* the serving cell
*/
/* Network registration status */
#define AT_CEREG_RESP_REG_OFF NET_REG_STATE_OFF
#define AT_CEREG_RESP_REG_HN NET_REG_STATE_HN
#define AT_CEREG_RESP_REG_ON NET_REG_STATE_ON
#define AT_CEREG_RESP_REG_DENIED NET_REG_STATE_DENIED
#define AT_CEREG_RESP_REG_UNKNOWN NET_REG_STATE_UNKNOWN
#define AT_CEREG_RESP_REG_ROAMING NET_REG_STATE_ROAMING
#define AT_CEREG_RESP_REG_EMERGENCY NET_REG_STATE_EMERGENCY
/* Access technology indicators */
#define AT_CEREG_RESP_EUTRAN NET_ACCESS_EUTRAN /* E-UTRAN */
/* Optional parameter bitmask */
//#define AT_CEREG_RESP_N_MASK AT_COMMAND_PARAM1
#define AT_CEREG_RESP_TAC_MASK AT_COMMAND_PARAM3
#define AT_CEREG_RESP_CI_MASK AT_COMMAND_PARAM4
#define AT_CEREG_RESP_ACT_MASK AT_COMMAND_PARAM5
/* CEREG AT command response type */
typedef struct {
int n;
int stat;
#define AT_CEREG_RESP_TAC_SIZE 4
char tac[AT_CEREG_RESP_TAC_SIZE+1];
#define AT_CEREG_RESP_CI_SIZE 8
char ci[AT_CEREG_RESP_CI_SIZE+1];
int AcT;
} at_cereg_resp_t;
/* CGDCONT: Define PDP Context
* ---------------------------
* Specifies PDP context parameter values for a PDP context identified by
* the (local) context identification parameter, <cid>.
* Read parameter command:
* +CGDCONT? returns +CGDCONT: <cid>,<PDP_type>,<APN>,<PDP_addr>,<d_comp>,
* <h_comp>[,<IPv4AddrAlloc>[,<emergency indication>[,<P-CSCF_
* discovery>[,<IM_CN_Signalling_Flag_Ind>]]]][<CR><LF>
* +CGDCONT: <cid>,<PDP_type>,<APN>,<PDP_addr>,<d_comp>,
* <h_comp>[,<IPv4AddrAlloc>[,<emergency indication>[,<P-CSCF_
* discovery>[,<IM_CN_Signalling_Flag_Ind>]]]]
* [...]]
* <cid> a numeric parameter which specifies a particular PDP
* context definition
* <PDP_type> type of packet data protocol ("IP", "IPV6", "IPV4V6")
* <APN> Access Point logical Name
* <PDP_addr> Mobile Equipment PDP address (not applicable to EPS)
* <d_comp> PDP data compression parameter
* <h_comp> PDP header compression parameter
* <IPv4AddrAlloc> IPv4 address allocation parameter
* <emergency indication> emergency bearer services support indication
* <P-CSCF_discovery> P-CSCF address discovery parameter
* <IM_CN_Signalling_Flag_Ind> IM CN subsystem-related signalling
* support indication
*/
/* Optional parameter bitmask */
#define AT_CGDCONT_RESP_IPV4ADDRALLOC_MASK AT_COMMAND_PARAM7
#define AT_CGDCONT_RESP_EMERGECY_INDICATION_MASK AT_COMMAND_PARAM8
#define AT_CGDCONT_RESP_P_CSCF_DISCOVERY_MASK AT_COMMAND_PARAM9
#define AT_CGDCONT_RESP_IM_CN_SIGNALLING_FLAG_IND_MASK AT_COMMAND_PARAM10
/* Structure of CGDCONT AT read parameter command */
typedef struct {
#define AT_CGDCONT_RESP_SIZE 8
int n_pdns; /* Number of defined PDN contexts in the lists */
int cid[AT_CGDCONT_RESP_SIZE]; /* List of PDN context identifiers */
int PDP_type[AT_CGDCONT_RESP_SIZE];
const char* APN[AT_CGDCONT_RESP_SIZE];
int d_comp[AT_CGDCONT_RESP_SIZE];
int h_comp[AT_CGDCONT_RESP_SIZE];
} at_cgdcont_get_t;
/* Structure of CGDCONT AT read parameter command */
typedef struct {
int n_cid; /* Range of supported PDN context identifiers */
} at_cgdcont_tst_t;
/* CGDCONT AT command response type */
typedef union {
at_cgdcont_tst_t tst;
at_cgdcont_get_t get;
} at_cgdcont_resp_t;
/* CGACT: PDP context activate or deactivate
* -----------------------------------------
* Read command returns the current activation states for all the defined
* PDP contexts.
* Read parameter command:
* +CGACT? returns +CGACT: <cid>,<state>[<CR><LF>+CGACT: <cid>,<state>[...]]
* <cid> a numeric parameter which specifies a particular PDP context
* definition
* <state> numeric parameter that indicates the state of PDP context
* activation
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CGACT_MASK AT_RESPONSE_NO_PARAM
/* CGACT AT command response type */
typedef struct {
#define AT_CGACT_RESP_SIZE AT_CGDCONT_RESP_SIZE
int n_pdns; /* Number of defined PDN contexts in the lists */
int cid[AT_CGACT_RESP_SIZE]; /* List of PDN context identifiers */
int state[AT_CGACT_RESP_SIZE]; /* List of PDN context states */
} at_cgact_resp_t;
/* CGPADDR: Show PDP address(es)
* -----------------------------
* Returns a list of PDP addresses for the specified context identifiers.
* +CGPADDR= returns +CGPADDR: <cid>[,PDP_addr_1[,PDP_addr_2]][<CR><LF>
* +CGPADDR: <cid>[,PDP_addr_1[,PDP_addr_2]][...]]
* <cid> a numeric parameter which specifies a particular PDP
* context definition
* <PDP_addr_x> string that identifies the MT in the address space
* applicable to the PDP
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CGPADDR_MASK AT_RESPONSE_NO_PARAM
/* CGPADDR AT command response type */
typedef struct {
#define AT_CGPADDR_RESP_SIZE AT_CGDCONT_RESP_SIZE
int n_pdns; /* Number of defined PDP addresses in the lists */
int cid[AT_CGPADDR_RESP_SIZE]; /* List of PDN context identifiers */
/* List of IPv4 addresses */
const char* PDP_addr_1[AT_CGPADDR_RESP_SIZE];
/* List of IPv6 addresses */
const char* PDP_addr_2[AT_CGPADDR_RESP_SIZE];
} at_cgpaddr_resp_t;
/* CGEV: Unsolicited result
* ------------------------
* Returns unsolicited result codes in case of certain events occurring
* in the Packet Domain MT or the network.
* +CGREV: <code> <cid>
* <code> unsolicited result code
* <cid> a numeric parameter which specifies a particular PDP
* context definition
*/
/* Optional parameter bitmask */
#define AT_RESPONSE_CGEV_MASK AT_RESPONSE_NO_PARAM
/* Unsolicited result codes */
#define AT_CGEV_RESP_NW_PDN_ACT (-1) /* Not applicable for LTE */
#define AT_CGEV_RESP_ME_PDN_ACT NET_PDN_MT_DEFAULT_ACT
#define AT_CGEV_RESP_NW_PDN_DEACT NET_PDN_NW_DEFAULT_DEACT
#define AT_CGEV_RESP_ME_PDN_DEACT NET_PDN_MT_DEFAULT_DEACT
#define AT_CGEV_RESP_NW_ACT NET_PDN_NW_DEDICATED_ACT
#define AT_CGEV_RESP_ME_ACT NET_PDN_MT_DEDICATED_ACT
#define AT_CGEV_RESP_NW_DEACT NET_PDN_NW_DEDICATED_DEACT
#define AT_CGEV_RESP_ME_DEACT NET_PDN_MT_DEDICATED_DEACT
/* CGEV unsolicited result type */
typedef struct {
int code;
int cid;
} at_cgev_resp_t;
/*
* ==========================================
* Global AT command response type definition
* ==========================================
*/
/* AT command response type */
typedef struct {
at_command_id_t id; /* AT command identifier */
at_command_type_t type; /* AT command type */
int mask; /* Optional parameter bitmask */
int cause_code; /* AT command error cause code */
union {
at_cgsn_resp_t cgsn;
at_cgmi_resp_t cgmi;
at_cgmm_resp_t cgmm;
at_cgmr_resp_t cgmr;
at_cimi_resp_t cimi;
at_cfun_resp_t cfun;
at_cpin_resp_t cpin;
at_csq_resp_t csq;
at_cesq_resp_t cesq;
at_clac_resp_t clac;
at_cmee_resp_t cmee;
at_cnum_resp_t cnum;
at_clck_resp_t clck;
at_cops_resp_t cops;
at_cgatt_resp_t cgatt;
at_creg_resp_t creg;
at_cgreg_resp_t cgreg;
at_cereg_resp_t cereg;
at_cgdcont_resp_t cgdcont;
at_cgact_resp_t cgact;
at_cgpaddr_resp_t cgpaddr;
at_cgev_resp_t cgev;
} response;
} at_response_t;
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
int at_response_encode(char* buffer, const at_response_t* at_response);
#endif /* __AT_RESPONSE_H__*/
@@ -0,0 +1,37 @@
ifndef PROJDIR
PROJDIR = $(PWD)/../../../..
endif
include $(PROJDIR)/Makerules
include $(PROJDIR)/Makefile.inc
LIBS = -lutil -lapi -lEMMmsg -lESMmsg -lies
INCLUDES = -I. -I$(INCDIR) -I$(UTILDIR) -I$(USERAPIDIR)
LIBSAPI = $(LIBDIR)/$(LIBAPI).a $(LIBDIR)/$(LIBAPI).so
TST_OBJ = at_parser.o
TST_TARGET = at_parser
TARGETS = $(TST_TARGET)
all: $(TARGETS)
%.o: %.c Makefile
$(CC) $(CFLAGS) -c $< -o $@
$(TST_TARGET): $(TST_OBJ)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
$(RM) $(OBJS) $(TARGETS) *.bak *~
depend:
makedepend -- ${CFLAGS} -- ${SRCS}
# DO NOT DELETE THIS LINE -- make depend depends on it.
at_parser.o: $(USERAPIDIR)/at_command.h
at_parser.o: $(INCDIR)/commonDef.h $(INCDIR)/userDef.h
at_parser.o: $(INCDIR)/networkDef.h $(UTILDIR)/log.h
@@ -0,0 +1,130 @@
/*****************************************************************************
Source main.c
Version 0.1
Date 01/04/2012
Product NAS stack
Subsystem Application Programming Interface
Author Baris Demiray
Description Interacts with AT parser for testing purposes
*****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "at_command.h"
#include "nas_log.h"
int main() {
const char * sample_at_commands[] = {
"AT+CGSN\r", "AT+CGSN=?\r", "AT+CGMI\r", "AT+CGMI=?\r", "AT+CGMM\r",
"AT+CGMM=?\r", "AT+CIMI\r", "AT+CIMI=?\r", "AT+CFUN=1,1\r",
"AT+CFUN=2\r", "AT+CFUN?\r", "AT+CFUN=?\r", "AT+CPIN=1234\r",
"AT+CPIN=1234,4321\r", "AT+CPIN?\r", "AT+CPIN=?\r", "AT+CSQ\r",
"AT+CSQ=?\r", "AT+COPS=1,1,EURECOM\r", "AT+COPS=2,3\r", "AT+COPS=5\r",
"AT+COPS?\r", "AT+COPS=?\r", "AT+CGREG=1\r", "AT+CGREG?\r",
"AT+CGREG=?\r", "AT+CGDCONT=1\r", "AT+CGDCONT?\r", "AT+CGDCONT=?\r",
"AT+CGACT=1\r", "AT+CGACT?\r", "AT+CGACT=?\r", "AT+CGMR\r",
"AT+CGMR=?\r", "AT+CESQ\r", "AT+CESQ=?\r", "AT+CMEE=2\r",
"AT+CMEE?\r", "AT+CMEE=?\r", "AT+CLCK=SC,2\r", "AT+CLCK=?\r",
"AT+CREG=1\r", "AT+CREG?\r", "AT+CREG=?\r",
"AT+CEREG=1\r", "AT+CEREG?\r", "AT+CEREG=?\r",
"AT+CGATT=1\r", "AT+CGATT?\r", "AT+CGATT=?\r",
"AT\r", "null"
};
const char * sample_faulty_at_commands[] = {
"AT+CGSN=3,4\r", "AT+CGSN=??\r", "AT+CGMI=1,b\r", "AT+CGMI==\r",
"AT+CGMM?\r", "AT+CGMM==n\r", "AT+CIMI=4\r", "AT+CIMI=?t\r",
"AT+CFUN=n1,1\r", "AT+CFUN??\r", "AT+CFUN=a?\r", "AT+CPIN=1fd4\r",
"AT+CPIN=1sd+,432\r", "AT+CPIN?4\r", "AT+CPIN=?,?\r", "AT+CSQ=AT\r",
"AT+CSQ=q\r",
"AT+COPS=123121123123123123,EURECOMEURECOMEURECOMEURECOM\r",
"AT+COPS=2asd3,33ads1\r", "AT+COPS.=5\r", "AT+COPS?/r\\r",
"AT+COPS=?\n\r\r", "AT+CGREG=da1243\42r", "AT+CGREG.?\r",
"AT+CGREG1=?\r", "AT+CGDCONT=d31\r", "AT+CGDCONTxc?\\crca",
"AT+CGDCONcTc=c?\r", "AT+CGA12C3T=11\123r", "AT+CGACT';;.,?\r",
"AT+CGACT=?]\\;e23\r", "\r\r\r", "AT+COP\r", "null"
};
at_command_t at_command;
unsigned int at_command_index;
//log_init(0x2f);
/* Parse valid AT commands */
at_command_index = 0;
while (strncmp(sample_at_commands[at_command_index], "null", 4) != 0) {
if (at_command_decode(sample_at_commands[at_command_index],
strlen(sample_at_commands[at_command_index]),
&at_command) > 0)
{
printf("INFO: Fine, parser interpreted valid command %s\n",
sample_at_commands[at_command_index]);
} else {
printf("ERROR: Parser rejected valid command %s\n",
sample_at_commands[at_command_index]);
}
at_command_index++;
}
/* Parse invalid AT commands */
at_command_index = 0;
while (strncmp(sample_faulty_at_commands[at_command_index], "null", 4) != 0)
{
if (at_command_decode(sample_faulty_at_commands[at_command_index],
strlen(sample_faulty_at_commands[at_command_index]),
&at_command) > 0)
{
printf("ERROR: Parser interpreted invalid command %s\n",
sample_faulty_at_commands[at_command_index]);
} else {
printf("INFO: Fine, parser rejected the command %s\n",
sample_faulty_at_commands[at_command_index]);
}
at_command_index++;
}
/*
* Provide a console to the user
*/
int bytes_read;
size_t input_size = 100;
char *input;
printf("Note 1: Carriage return will be appended to every command by default\n");
printf("Note 2: Enter 'quit' to exit\n");
printf("AT Command> ");
input = (char *)malloc(input_size + 1);
bytes_read = getline(&input, &input_size, stdin);
while (strncmp(input, "quit", 4) != 0)
{
if (bytes_read == -1) {
puts("Cannot read user input!\n");
}
else {
input[bytes_read - 1] = '\r';
if (at_command_decode(input, bytes_read, &at_command) > 0)
printf("INFO: Parser interpreted command %s\n", input);
else
printf("ERROR: Parser rejected command %s\n", input);
}
printf("\nAT Command> ");
memset(input, 0x00, input_size);
bytes_read = getline(&input, &input_size, stdin);
}
free(input);
printf("Exiting...\n");
return 0;
}
@@ -0,0 +1,2 @@
AT+COPS=3,0;+COPS?;+COPS=3,1;+COPS?;+COPS=3,2;+COPS?
quit
@@ -0,0 +1,59 @@
ATE0Q0V1
ATE0Q0V1
ATS0=0
AT+CMEE=1
AT+CREG=2
AT+CGREG=1
AT+CCWA=1
AT+CMOD=0
AT+CSSN=0,1
AT+COLP=0
AT+CSCS="HEX"
AT+CUSD=1
AT+CGEREP=1,0
AT+CMGF=0
AT+CFUN?
AT+CPIN?
AT+CSMS=1
AT+CNMI=1,2,2,1,0
AT+CFUN=0
AT+CFUN=1
AT+CPIN?
AT+CSMS=1
AT+CNMI=1,2,2,1,0
AT+CGSN
AT+COPS=3,0;+COPS?;+COPS=3,1;+COPS?;+COPS=3,2;+COPS?
AT+CGREG?
AT+CREG?
AT+COPS?
AT+CLCC
AT+COPS=3,0;+COPS?;+COPS=3,1;+COPS?;+COPS=3,2;+COPS?
AT+CGREG?
AT+CREG?
AT+COPS?
AT+COPS=0
AT+COPS=3,0;+COPS?;+COPS=3,1;+COPS?;+COPS=3,2;+COPS?
AT+CGREG?
AT+CREG?
AT+COPS?
AT+CIMI
AT+CRSM=192,12258,0,0,15
AT+CRSM=192,28480,0,0,15
AT+CRSM=192,28617,0,0,15
AT+CRSM=192,28589,0,0,15
AT+CRSM=192,28618,0,0,15
AT+CRSM=192,28433,0,0,15
AT+CRSM=192,28619,0,0,15
AT+CRSM=192,28435,0,0,15
AT+CRSM=192,28486,0,0,15
AT+CRSM=192,28621,0,0,15
AT+CRSM=192,28613,0,0,15
AT+CRSM=192,28472,0,0,15
AT+CRSM=192,28438,0,0,15
AT+CRSM=192,28437,0,0,15
AT+CPIN?
AT+CRSM=192,28439,0,0,15
AT+CRSM=192,28436,0,0,15
AT+CRSM=192,28440,0,0,15
AT+CSQ
quit
@@ -0,0 +1,90 @@
INFO: Fine, parser interpreted valid command AT+CGSN
INFO: Fine, parser interpreted valid command AT+CGSN=?
INFO: Fine, parser interpreted valid command AT+CGMI
INFO: Fine, parser interpreted valid command AT+CGMI=?
INFO: Fine, parser interpreted valid command AT+CGMM
INFO: Fine, parser interpreted valid command AT+CGMM=?
INFO: Fine, parser interpreted valid command AT+CIMI
INFO: Fine, parser interpreted valid command AT+CIMI=?
INFO: Fine, parser interpreted valid command AT+CFUN=1,1
INFO: Fine, parser interpreted valid command AT+CFUN=2
INFO: Fine, parser interpreted valid command AT+CFUN?
INFO: Fine, parser interpreted valid command AT+CFUN=?
INFO: Fine, parser interpreted valid command AT+CPIN=1234
INFO: Fine, parser interpreted valid command AT+CPIN=1234,4321
INFO: Fine, parser interpreted valid command AT+CPIN?
INFO: Fine, parser interpreted valid command AT+CPIN=?
INFO: Fine, parser interpreted valid command AT+CSQ
INFO: Fine, parser interpreted valid command AT+CSQ=?
INFO: Fine, parser interpreted valid command AT+COPS=1,1,EURECOM
INFO: Fine, parser interpreted valid command AT+COPS=2,3
INFO: Fine, parser interpreted valid command AT+COPS=5
INFO: Fine, parser interpreted valid command AT+COPS?
INFO: Fine, parser interpreted valid command AT+COPS=?
INFO: Fine, parser interpreted valid command AT+CGREG=1
INFO: Fine, parser interpreted valid command AT+CGREG?
INFO: Fine, parser interpreted valid command AT+CGREG=?
INFO: Fine, parser interpreted valid command AT+CGDCONT=1
INFO: Fine, parser interpreted valid command AT+CGDCONT?
INFO: Fine, parser interpreted valid command AT+CGDCONT=?
INFO: Fine, parser interpreted valid command AT+CGACT=1
INFO: Fine, parser interpreted valid command AT+CGACT?
INFO: Fine, parser interpreted valid command AT+CGACT=?
INFO: Fine, parser interpreted valid command AT+CGMR
INFO: Fine, parser interpreted valid command AT+CGMR=?
INFO: Fine, parser interpreted valid command AT+CESQ
INFO: Fine, parser interpreted valid command AT+CESQ=?
INFO: Fine, parser interpreted valid command AT+CMEE=2
INFO: Fine, parser interpreted valid command AT+CMEE?
INFO: Fine, parser interpreted valid command AT+CMEE=?
INFO: Fine, parser interpreted valid command AT+CLCK=SC,2
INFO: Fine, parser interpreted valid command AT+CLCK=?
INFO: Fine, parser interpreted valid command AT+CREG=1
INFO: Fine, parser interpreted valid command AT+CREG?
INFO: Fine, parser interpreted valid command AT+CREG=?
INFO: Fine, parser interpreted valid command AT+CEREG=1
INFO: Fine, parser interpreted valid command AT+CEREG?
INFO: Fine, parser interpreted valid command AT+CEREG=?
INFO: Fine, parser interpreted valid command AT+CGATT=1
INFO: Fine, parser interpreted valid command AT+CGATT?
INFO: Fine, parser interpreted valid command AT+CGATT=?
INFO: Fine, parser interpreted valid command AT
INFO: Fine, parser rejected the command AT+CGSN=3,4
INFO: Fine, parser rejected the command AT+CGSN=??
INFO: Fine, parser rejected the command AT+CGMI=1,b
INFO: Fine, parser rejected the command AT+CGMI==
INFO: Fine, parser rejected the command AT+CGMM?
INFO: Fine, parser rejected the command AT+CGMM==n
INFO: Fine, parser rejected the command AT+CIMI=4
INFO: Fine, parser rejected the command AT+CIMI=?t
INFO: Fine, parser rejected the command AT+CFUN=n1,1
INFO: Fine, parser rejected the command AT+CFUN??
INFO: Fine, parser rejected the command AT+CFUN=a?
INFO: Fine, parser rejected the command AT+CPIN=1fd4
INFO: Fine, parser rejected the command AT+CPIN=1sd+,432
INFO: Fine, parser rejected the command AT+CPIN?4
INFO: Fine, parser rejected the command AT+CPIN=?,?
INFO: Fine, parser rejected the command AT+CSQ=AT
INFO: Fine, parser rejected the command AT+CSQ=q
INFO: Fine, parser rejected the command AT+COPS=123121123123123123,EURECOMEURECOMEURECOMEURECOM
INFO: Fine, parser rejected the command AT+COPS=2asd3,33ads1
INFO: Fine, parser rejected the command AT+COPS.=5
INFO: Fine, parser rejected the command AT+COPS?/r\r
INFO: Fine, parser rejected the command AT+COPS=?
␍
INFO: Fine, parser rejected the command AT+CGREG=da1243"r
INFO: Fine, parser rejected the command AT+CGREG.?
INFO: Fine, parser rejected the command AT+CGREG1=?
INFO: Fine, parser rejected the command AT+CGDCONT=d31
INFO: Fine, parser rejected the command AT+CGDCONTxc?\crca
INFO: Fine, parser rejected the command AT+CGDCONcTc=c?
INFO: Fine, parser rejected the command AT+CGA12C3T=11Sr
INFO: Fine, parser rejected the command AT+CGACT';;.,?
INFO: Fine, parser rejected the command AT+CGACT=?]\;e23
INFO: Fine, parser rejected the command ␍␍
INFO: Fine, parser rejected the command AT+COP
Note 1: Carriage return will be appended to every command by default
Note 2: Enter 'quit' to exit
AT Command> INFO: Parser interpreted command AT+COPS=3,0;+COPS?;+COPS=3,1;+COPS?;+COPS=3,2;+COPS?
AT Command> Exiting...
@@ -0,0 +1,204 @@
INFO: Fine, parser interpreted valid command AT+CGSN
INFO: Fine, parser interpreted valid command AT+CGSN=?
INFO: Fine, parser interpreted valid command AT+CGMI
INFO: Fine, parser interpreted valid command AT+CGMI=?
INFO: Fine, parser interpreted valid command AT+CGMM
INFO: Fine, parser interpreted valid command AT+CGMM=?
INFO: Fine, parser interpreted valid command AT+CIMI
INFO: Fine, parser interpreted valid command AT+CIMI=?
INFO: Fine, parser interpreted valid command AT+CFUN=1,1
INFO: Fine, parser interpreted valid command AT+CFUN=2
INFO: Fine, parser interpreted valid command AT+CFUN?
INFO: Fine, parser interpreted valid command AT+CFUN=?
INFO: Fine, parser interpreted valid command AT+CPIN=1234
INFO: Fine, parser interpreted valid command AT+CPIN=1234,4321
INFO: Fine, parser interpreted valid command AT+CPIN?
INFO: Fine, parser interpreted valid command AT+CPIN=?
INFO: Fine, parser interpreted valid command AT+CSQ
INFO: Fine, parser interpreted valid command AT+CSQ=?
INFO: Fine, parser interpreted valid command AT+COPS=1,1,EURECOM
INFO: Fine, parser interpreted valid command AT+COPS=2,3
INFO: Fine, parser interpreted valid command AT+COPS=5
INFO: Fine, parser interpreted valid command AT+COPS?
INFO: Fine, parser interpreted valid command AT+COPS=?
INFO: Fine, parser interpreted valid command AT+CGREG=1
INFO: Fine, parser interpreted valid command AT+CGREG?
INFO: Fine, parser interpreted valid command AT+CGREG=?
INFO: Fine, parser interpreted valid command AT+CGDCONT=1
INFO: Fine, parser interpreted valid command AT+CGDCONT?
INFO: Fine, parser interpreted valid command AT+CGDCONT=?
INFO: Fine, parser interpreted valid command AT+CGACT=1
INFO: Fine, parser interpreted valid command AT+CGACT?
INFO: Fine, parser interpreted valid command AT+CGACT=?
INFO: Fine, parser interpreted valid command AT+CGMR
INFO: Fine, parser interpreted valid command AT+CGMR=?
INFO: Fine, parser interpreted valid command AT+CESQ
INFO: Fine, parser interpreted valid command AT+CESQ=?
INFO: Fine, parser interpreted valid command AT+CMEE=2
INFO: Fine, parser interpreted valid command AT+CMEE?
INFO: Fine, parser interpreted valid command AT+CMEE=?
INFO: Fine, parser interpreted valid command AT+CLCK=SC,2
INFO: Fine, parser interpreted valid command AT+CLCK=?
INFO: Fine, parser interpreted valid command AT+CREG=1
INFO: Fine, parser interpreted valid command AT+CREG?
INFO: Fine, parser interpreted valid command AT+CREG=?
INFO: Fine, parser interpreted valid command AT+CEREG=1
INFO: Fine, parser interpreted valid command AT+CEREG?
INFO: Fine, parser interpreted valid command AT+CEREG=?
INFO: Fine, parser interpreted valid command AT+CGATT=1
INFO: Fine, parser interpreted valid command AT+CGATT?
INFO: Fine, parser interpreted valid command AT+CGATT=?
INFO: Fine, parser interpreted valid command AT
INFO: Fine, parser rejected the command AT+CGSN=3,4
INFO: Fine, parser rejected the command AT+CGSN=??
INFO: Fine, parser rejected the command AT+CGMI=1,b
INFO: Fine, parser rejected the command AT+CGMI==
INFO: Fine, parser rejected the command AT+CGMM?
INFO: Fine, parser rejected the command AT+CGMM==n
INFO: Fine, parser rejected the command AT+CIMI=4
INFO: Fine, parser rejected the command AT+CIMI=?t
INFO: Fine, parser rejected the command AT+CFUN=n1,1
INFO: Fine, parser rejected the command AT+CFUN??
INFO: Fine, parser rejected the command AT+CFUN=a?
INFO: Fine, parser rejected the command AT+CPIN=1fd4
INFO: Fine, parser rejected the command AT+CPIN=1sd+,432
INFO: Fine, parser rejected the command AT+CPIN?4
INFO: Fine, parser rejected the command AT+CPIN=?,?
INFO: Fine, parser rejected the command AT+CSQ=AT
INFO: Fine, parser rejected the command AT+CSQ=q
INFO: Fine, parser rejected the command AT+COPS=123121123123123123,EURECOMEURECOMEURECOMEURECOM
INFO: Fine, parser rejected the command AT+COPS=2asd3,33ads1
INFO: Fine, parser rejected the command AT+COPS.=5
INFO: Fine, parser rejected the command AT+COPS?/r\r
INFO: Fine, parser rejected the command AT+COPS=?
␍
INFO: Fine, parser rejected the command AT+CGREG=da1243"r
INFO: Fine, parser rejected the command AT+CGREG.?
INFO: Fine, parser rejected the command AT+CGREG1=?
INFO: Fine, parser rejected the command AT+CGDCONT=d31
INFO: Fine, parser rejected the command AT+CGDCONTxc?\crca
INFO: Fine, parser rejected the command AT+CGDCONcTc=c?
INFO: Fine, parser rejected the command AT+CGA12C3T=11Sr
INFO: Fine, parser rejected the command AT+CGACT';;.,?
INFO: Fine, parser rejected the command AT+CGACT=?]\;e23
INFO: Fine, parser rejected the command ␍␍
INFO: Fine, parser rejected the command AT+COP
Note 1: Carriage return will be appended to every command by default
Note 2: Enter 'quit' to exit
AT Command> INFO: Parser interpreted command ATE0Q0V1
AT Command> INFO: Parser interpreted command ATE0Q0V1
AT Command> ERROR: Parser rejected command ATS0=0
AT Command> INFO: Parser interpreted command AT+CMEE=1
AT Command> INFO: Parser interpreted command AT+CREG=2
AT Command> INFO: Parser interpreted command AT+CGREG=1
AT Command> ERROR: Parser rejected command AT+CCWA=1
AT Command> ERROR: Parser rejected command AT+CMOD=0
AT Command> ERROR: Parser rejected command AT+CSSN=0,1
AT Command> ERROR: Parser rejected command AT+COLP=0
AT Command> ERROR: Parser rejected command AT+CSCS="HEX"
AT Command> ERROR: Parser rejected command AT+CUSD=1
AT Command> ERROR: Parser rejected command AT+CGEREP=1,0
AT Command> ERROR: Parser rejected command AT+CMGF=0
AT Command> INFO: Parser interpreted command AT+CFUN?
AT Command> INFO: Parser interpreted command AT+CPIN?
AT Command> ERROR: Parser rejected command AT+CSMS=1
AT Command> ERROR: Parser rejected command AT+CNMI=1,2,2,1,0
AT Command> INFO: Parser interpreted command AT+CFUN=0
AT Command> INFO: Parser interpreted command AT+CFUN=1
AT Command> INFO: Parser interpreted command AT+CPIN?
AT Command> ERROR: Parser rejected command AT+CSMS=1
AT Command> ERROR: Parser rejected command AT+CNMI=1,2,2,1,0
AT Command> INFO: Parser interpreted command AT+CGSN
AT Command> INFO: Parser interpreted command AT+COPS=3,0;+COPS?;+COPS=3,1;+COPS?;+COPS=3,2;+COPS?
AT Command> INFO: Parser interpreted command AT+CGREG?
AT Command> INFO: Parser interpreted command AT+CREG?
AT Command> INFO: Parser interpreted command AT+COPS?
AT Command> ERROR: Parser rejected command AT+CLCC
AT Command> INFO: Parser interpreted command AT+COPS=3,0;+COPS?;+COPS=3,1;+COPS?;+COPS=3,2;+COPS?
AT Command> INFO: Parser interpreted command AT+CGREG?
AT Command> INFO: Parser interpreted command AT+CREG?
AT Command> INFO: Parser interpreted command AT+COPS?
AT Command> INFO: Parser interpreted command AT+COPS=0
AT Command> INFO: Parser interpreted command AT+COPS=3,0;+COPS?;+COPS=3,1;+COPS?;+COPS=3,2;+COPS?
AT Command> INFO: Parser interpreted command AT+CGREG?
AT Command> INFO: Parser interpreted command AT+CREG?
AT Command> INFO: Parser interpreted command AT+COPS?
AT Command> INFO: Parser interpreted command AT+CIMI
AT Command> ERROR: Parser rejected command AT+CRSM=192,12258,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28480,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28617,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28589,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28618,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28433,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28619,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28435,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28486,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28621,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28613,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28472,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28438,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28437,0,0,15
AT Command> INFO: Parser interpreted command AT+CPIN?
AT Command> ERROR: Parser rejected command AT+CRSM=192,28439,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28436,0,0,15
AT Command> ERROR: Parser rejected command AT+CRSM=192,28440,0,0,15
AT Command> INFO: Parser interpreted command AT+CSQ
AT Command> Exiting...
@@ -0,0 +1,23 @@
Fully implemented:
AT Command> INFO: Parser interpreted command AT+CGSN
AT Command> INFO: Parser interpreted command AT+CGMM
AT Command> INFO: Parser interpreted command AT+CGMI
AT Command> INFO: Parser interpreted command AT+CPIN?
AT Command> INFO: Parser interpreted command ATE0Q0V1+CMEE=1
AT Command> INFO: Parser interpreted command AT+CFUN?
AT Command> INFO: Parser interpreted command AT+CFUN=1
AT Command> INFO: Parser interpreted command AT+CIMI
AT Command> INFO: Parser interpreted command AT+COPS?
AT Command> ERROR: Parser rejected command AT+CREG
AT Command> INFO: Parser interpreted command AT+CGACT=1,1
AT Command> INFO: Parser interpreted command AT+CGDCONT?
Not implemented:
AT Command> ERROR: Parser rejected command AT+CNUM
AT Command> ERROR: Parser rejected command AT+CRSM
AT Command> ERROR: Parser rejected command AT+CGMR
AT Command> ERROR: Parser rejected command AT+CESQ
AT Command> ERROR: Parser rejected command AT+CNTI
AT Command> ERROR: Parser rejected command AT!BAND?
AT Command> ERROR: Parser rejected command AT+PACSP?
@@ -0,0 +1,799 @@
/*****************************************************************************
Eurecom OpenAirInterface 3
Copyright(c) 2012 Eurecom
Source user_api.c
Version 0.1
Date 2012/02/28
Product NAS stack
Subsystem Application Programming Interface
Author Frederic Maurel
Description Implements the API used by the NAS layer running in the UE
to send/receive message to/from the user application layer
*****************************************************************************/
#ifdef NAS_UE
#include "user_api.h"
#include "nas_log.h"
#include "socket.h"
#include "device.h"
#include "at_command.h"
#include "at_response.h"
#include "at_error.h"
#include "user_indication.h"
#include <string.h> // strerror, memset
#include <netdb.h> // gai_strerror
#include <errno.h> // errno
#include <stdio.h> // sprintf
#include <unistd.h> // gethostname
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
/****************************************************************************/
/****************************************************************************/
/******************* L O C A L D E F I N I T I O N S *******************/
/****************************************************************************/
/*
* Asynchronous notification procedure handlers
*/
static int _user_api_registration_handler(unsigned char id, const void* data, size_t size);
static int _user_api_location_handler(unsigned char id, const void* data, size_t size);
static int _user_api_network_handler(unsigned char id, const void* data, size_t size);
static int _user_api_pdn_connection_handler(unsigned char id, const void* data, size_t size);
static int _user_api_send(at_response_t* data);
/* -------------------
* Connection endpoint
* -------------------
* The connection endpoint is used to send/receive data to/from the
* user application layer. Its definition depends on the underlaying
* mechanism chosen to communicate (network socket, I/O terminal device).
* A connection endpoint is handled using an identifier, and functions
* used to retreive the file descriptor actually allocated by the system,
* to receive data, to send data, and to perform clean up when connection
* is shut down.
* Only one single end to end connection with the user is managed at a
* time.
*/
static struct {
/* Connection endpoint reference */
void* endpoint;
/* Connection endpoint handlers */
void* (*open) (int, const char*, const char*);
int (*getfd)(const void*);
ssize_t (*recv) (void*, char*, size_t);
ssize_t (*send) (const void*, const char*, size_t);
void (*close)(void*);
} _user_api_id;
#define USER_API_OPEN(a, b, c) _user_api_id.open(a, b, c)
#define USER_API_GETFD() _user_api_id.getfd(_user_api_id.endpoint)
#define USER_API_RECV(a, b) _user_api_id.recv(_user_api_id.endpoint, a, b)
#define USER_API_SEND(a, b) _user_api_id.send(_user_api_id.endpoint, a, b)
#define USER_API_CLOSE() _user_api_id.close(_user_api_id.endpoint)
/*
* The buffer used to receive data from the user application layer
*/
#define USER_API_RECV_BUFFER_SIZE 4096
static char _user_api_recv_buffer[USER_API_RECV_BUFFER_SIZE];
/*
* The buffer used to send data to the user application layer
*/
#define USER_API_SEND_BUFFER_SIZE USER_API_RECV_BUFFER_SIZE
static char _user_api_send_buffer[USER_API_SEND_BUFFER_SIZE];
/*
* The decoded data received from the user application layer
*/
static struct {
int n_cmd; /* number of user data to be processed */
#define USER_DATA_MAX 10
at_command_t cmd[USER_DATA_MAX]; /* user data to be processed */
} _user_data = {};
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
/****************************************************************************
** **
** Name: user_api_initialize() **
** **
** Description: Initializes the user API from which the NAS layer **
** will send/receive messages to/from the user application **
** layer **
** **
** Inputs: host: The name of the host from which the user **
** application layer will connect **
** port: The local port number **
** Others: None **
** **
** Outputs: Return: RETURNerror, RETURNok **
** Others: _user_api_id **
** **
***************************************************************************/
int user_api_initialize(const char* host, const char* port,
const char* devname, const char* devparams)
{
LOG_FUNC_IN;
gethostname(_user_api_send_buffer, USER_API_SEND_BUFFER_SIZE);
if (devname != NULL) {
/* Initialize device handlers */
_user_api_id.open = device_open;
_user_api_id.getfd = device_get_fd;
_user_api_id.recv = device_read;
_user_api_id.send = device_write;
_user_api_id.close = device_close;
/* Initialize communication channel */
_user_api_id.endpoint = USER_API_OPEN(DEVICE, devname, devparams);
if (_user_api_id.endpoint == NULL) {
LOG_TRACE(ERROR, "USR-API - Failed to open connection endpoint, "
"%s", strerror(errno));
LOG_FUNC_RETURN (RETURNerror);
}
LOG_TRACE(INFO, "USR-API - User's communication device %d is OPENED "
"on %s/%s", user_api_get_fd(), _user_api_send_buffer, devname);
}
else {
/* Initialize network socket handlers */
_user_api_id.open = socket_udp_open;
_user_api_id.getfd = socket_get_fd;
_user_api_id.recv = socket_recv;
_user_api_id.send = socket_send;
_user_api_id.close = socket_close;
/* Initialize communication channel */
_user_api_id.endpoint = USER_API_OPEN(SOCKET_SERVER, host, port);
if (_user_api_id.endpoint == NULL) {
const char* error = ( (errno < 0) ?
gai_strerror(errno) : strerror(errno) );
LOG_TRACE(ERROR, "USR-API - Failed to open connection endpoint, "
"%s", error);
LOG_FUNC_RETURN (RETURNerror);
}
LOG_TRACE(INFO, "USR-API - User's UDP socket %d is BOUND to %s/%s",
user_api_get_fd(), _user_api_send_buffer, port);
}
/* Register the asynchronous notification handlers */
if (user_ind_register(USER_IND_REG, 0, _user_api_registration_handler) != RETURNok) {
LOG_TRACE(WARNING, "USR-API - "
"Failed to register registration notification");
}
else if (user_ind_register(USER_IND_LOC, 0, _user_api_location_handler) != RETURNok) {
LOG_TRACE(WARNING, "USR-API - "
"Failed to register location notification");
}
else if (user_ind_register(USER_IND_PLMN, 0, _user_api_network_handler) != RETURNok) {
LOG_TRACE(WARNING, "USR-API - "
"Failed to register network notification");
}
else if (user_ind_register(USER_IND_PLMN, 0, NULL) != RETURNok) {
LOG_TRACE(WARNING, "USR-API - Failed to enable network notification");
}
else if (user_ind_register(USER_IND_PDN, 0, _user_api_pdn_connection_handler) != RETURNok) {
LOG_TRACE(WARNING, "USR-API - "
"Failed to register PDN connection notification");
}
else if (user_ind_register(USER_IND_PDN, AT_CGACT, NULL) != RETURNok) {
LOG_TRACE(WARNING, "USR-API - "
"Failed to enable PDN connection notification");
}
else {
LOG_TRACE(INFO, "USR-API - "
"Notification handlers successfully registered");
}
LOG_FUNC_RETURN (RETURNok);
}
/****************************************************************************
** **
** Name: user_api_get_fd() **
** **
** Description: Get the file descriptor of the connection endpoint used **
** to send/receive messages to/from the user application **
** layer **
** **
** Inputs: None **
** Others: _user_api_id **
** **
** Outputs: Return: The file descriptor of the connection end- **
** point used by the user application layer **
** Others: None **
** **
***************************************************************************/
int user_api_get_fd(void)
{
LOG_FUNC_IN;
LOG_FUNC_RETURN (USER_API_GETFD());
}
/****************************************************************************
** **
** Name: user_api_get_data() **
** **
** Description: Get a generic pointer to the user data structure at the **
** given index. Casting to the proper type is necessary **
** before its usage. **
** **
** Inputs: index: Index of the user data structure to get **
** Others: _user_data **
** **
** Outputs: Return: A generic pointer to the user data **
** structure **
** Others: None **
** **
***************************************************************************/
const void* user_api_get_data(int index)
{
LOG_FUNC_IN;
if (index < _user_data.n_cmd) {
LOG_FUNC_RETURN ((void*)(&_user_data.cmd[index]));
}
LOG_FUNC_RETURN (NULL);
}
/****************************************************************************
** **
** Name: user_api_read_data() **
** **
** Description: Read data received from the user application layer **
** **
** Inputs: fd: File descriptor of the connection endpoint **
** from which data have been received **
** Others: _user_api_id **
** **
** Outputs: Return: The number of bytes read when success; **
** RETURNerror Otherwise **
** Others: _user_api_recv_buffer, _user_api_id **
** **
***************************************************************************/
int user_api_read_data(int fd)
{
LOG_FUNC_IN;
int rbytes;
/* Sanity check */
int sfd = user_api_get_fd();
if (fd != sfd) {
LOG_TRACE(ERROR, "USR-API - Endpoint %d is not the one created for communication with the user application layer (%d)", fd, sfd);
LOG_FUNC_RETURN (RETURNerror);
}
memset(_user_api_recv_buffer, 0, USER_API_RECV_BUFFER_SIZE);
/* Receive data from the user application layer */
rbytes = USER_API_RECV(_user_api_recv_buffer, USER_API_RECV_BUFFER_SIZE);
if (rbytes == RETURNerror) {
LOG_TRACE(ERROR, "USR-API - recv() failed, %s", strerror(errno));
LOG_FUNC_RETURN (RETURNerror);
}
else if (rbytes == 0) {
//LOG_TRACE(WARNING, "USR-API - A signal was caught");
}
else {
LOG_TRACE(INFO, "USR-API - %d bytes received "
"from the user application layer", rbytes);
LOG_DUMP(_user_api_recv_buffer, rbytes);
}
LOG_FUNC_RETURN (rbytes);
}
/****************************************************************************
** **
** Name: user_api_send_data() **
** **
** Description: Send data to the user application layer **
** **
** Inputs: fd: File descriptor of the connection endpoint **
** to which data have to be sent **
** length: Number of bytes to send **
** Others: _user_api_send_buffer, _user_api_id **
** **
** Outputs: Return: The number of bytes sent when success; **
** RETURNerror Otherwise **
** Others: None **
** **
***************************************************************************/
static int _user_api_send_data(int length)
{
int sbytes = USER_API_SEND(_user_api_send_buffer, length);
if (sbytes == RETURNerror) {
LOG_TRACE(ERROR, "USR-API - send() failed, %s", strerror(errno));
return RETURNerror;
}
else if (sbytes == 0) {
LOG_TRACE(WARNING, "USR-API - A signal was caught");
}
else {
LOG_TRACE(INFO, "USR-API - %d bytes sent "
"to the user application layer", sbytes);
LOG_DUMP(_user_api_send_buffer, sbytes);
}
return sbytes;
}
int user_api_send_data(int fd, int length)
{
LOG_FUNC_IN;
/* Sanity check */
int sfd = user_api_get_fd();
if (fd != sfd) {
LOG_TRACE(ERROR, "USR-API - Endpoint %d is not the one created for communication with the user application layer (%d)", fd, sfd);
LOG_FUNC_RETURN (RETURNerror);
}
/* Send data to the user application layer */
int sbytes = 0;
if (length > 0) {
sbytes = _user_api_send_data(length);
}
LOG_FUNC_RETURN (sbytes);
}
/****************************************************************************
** **
** Name: user_api_close() **
** **
** Description: Close the user API from which the NAS layer sent/received **
** messages to/from the user application layer **
** **
** Inputs: fd: File descriptor of the connection endpoint **
** allocated by the system to communicate **
** with the user application layer **
** Others: None **
** **
** Outputs: Return: None **
** Others: _user_api_id **
** **
***************************************************************************/
void user_api_close(int fd)
{
LOG_FUNC_IN;
/* Sanity check */
int sfd = user_api_get_fd();
if (fd != sfd) {
LOG_TRACE(ERROR, "USR-API - Endpoint %d is not the one created for communication with the user application layer (%d)", fd, sfd);
LOG_FUNC_OUT;
return;
}
/* Cleanup the connection endpoint */
USER_API_CLOSE();
_user_api_id.endpoint = NULL;
LOG_FUNC_OUT;
}
/****************************************************************************
** **
** Name: user_api_decode_data() **
** **
** Description: Parses the message received from the user application **
** (mainly AT commands) and fills the user data structure. **
** Returns an AT syntax error code to the user application **
** layer when the AT command failed to be decoded. **
** **
** Inputs: length: Number of bytes to decode **
** Others: _user_api_recv_buffer **
** **
** Outputs: Return: The number of AT commands succeessfully **
** decoded **
** Others: _user_api_send_buffer, _user_data **
** **
***************************************************************************/
int user_api_decode_data(int length)
{
LOG_FUNC_IN;
/* Parse the AT command line */
LOG_TRACE(INFO, "USR-API - Decode user data: %s", _user_api_recv_buffer);
_user_data.n_cmd = at_command_decode(_user_api_recv_buffer, length,
_user_data.cmd);
if (_user_data.n_cmd > 0) {
/* AT command data received from the user application layer
* has been successfully decoded */
LOG_TRACE(INFO, "USR-API - %d AT command%s ha%s been successfully "
"decoded", _user_data.n_cmd,
(_user_data.n_cmd > 1) ? "s" : "",
(_user_data.n_cmd > 1) ? "ve" : "s");
}
else
{
int bytes;
/* Failed to decode AT command data received from the user
* application layer; Return syntax error code message */
LOG_TRACE(ERROR, "USR-API - Syntax error: Failed to decode "
"AT command data %s", _user_api_recv_buffer);
/* Encode the syntax error code message */
bytes = at_error_encode(_user_api_send_buffer, AT_ERROR_SYNTAX,
AT_ERROR_OPERATION_NOT_SUPPORTED);
/* Send the syntax error code message */
(void) _user_api_send_data(bytes);
}
LOG_FUNC_RETURN (_user_data.n_cmd);
}
/****************************************************************************
** **
** Name: user_api_encode_data() **
** **
** Description: Encodes AT command response message **
** **
** Inputs data: Generic pointer to the data to encode **
** success_code: Indicates whether success code has to be **
** displayed or not (covers the case where **
** more than one AT command is executed in **
** the same user command line). **
** Others: None **
** **
** Outputs: Return: The number of characters that have been **
** successfully encoded; **
** RETURNerror otherwise. **
** Others: _user_api_send_buffer **
** **
***************************************************************************/
int user_api_encode_data(const void* data, int success_code)
{
LOG_FUNC_IN;
const at_response_t* user_data = (at_response_t*)(data);
int bytes;
/* Encode AT command error message */
if (user_data->cause_code != AT_ERROR_SUCCESS)
{
bytes = at_error_encode(_user_api_send_buffer, AT_ERROR_CME,
user_data->cause_code);
}
/* Encode AT command response message */
else
{
bytes = at_response_encode(_user_api_send_buffer, user_data);
/* Add success result code */
if ( (success_code) && (bytes != RETURNerror) ) {
bytes += at_error_encode(&_user_api_send_buffer[bytes],
AT_ERROR_OK, 0);
}
}
if (bytes != RETURNerror) {
LOG_TRACE(INFO, "USR-API - %d bytes encoded", bytes);
}
else {
LOG_TRACE(ERROR, "USR-API - Syntax error: Failed to encode AT "
"response data (%d)", user_data->id);
}
LOG_FUNC_RETURN (bytes);
}
/****************************************************************************
** **
** Name: user_api_callback() **
** **
** Description: Notifies the user application that asynchronous notifica- **
** tion has been received from the EPS Mobility Management **
** sublayer. **
** **
** Inputs: stat: Network registration status **
** tac: Location/Tracking Area Code **
** ci: Indentifier of the serving cell **
** AcT: Access Technology supported by the cell **
** data: Data string to display to the user **
** size: Size of the notification data (only used **
** to display string information to the user **
** application) **
** Others: None **
** **
** Outputs: None **
** Return: RETURNok, RETURNerror **
** Others: None **
** **
***************************************************************************/
int user_api_emm_callback(Stat_t stat, tac_t tac, ci_t ci, AcT_t AcT,
const char* data, size_t size)
{
LOG_FUNC_IN;
int rc = RETURNok;
if (size > 1) {
/*
* The list of available operators present in the network has to be
* displayed to the user application
*/
rc = user_ind_notify(USER_IND_PLMN, (void*)data, size);
}
else {
user_indication_t ind;
ind.notification.reg.status = stat;
if (size > 0) {
/* The UE's network registration status has changed */
rc = user_ind_notify(USER_IND_REG, (void*)&ind, 0);
}
if (rc != RETURNerror) {
/* The UE's location area has changed or,
* the UE's network registration status has changed and
* only location information notification is enabled */
ind.notification.loc.tac = tac;
ind.notification.loc.ci = ci;
ind.notification.loc.AcT = AcT;
rc = user_ind_notify(USER_IND_LOC, (void*)&ind, 0);
}
}
if (rc != RETURNerror) {
LOG_FUNC_RETURN (RETURNok);
}
LOG_FUNC_RETURN (rc);
}
/****************************************************************************
** **
** Name: user_api_esm_callback() **
** **
** Description: Notifies the user application that asynchronous notifica- **
** tion has been received from the EPS Session Management **
** sublayer. **
** **
** Inputs: cid: PDN connection identifier **
** state: PDN connection status **
** Others: None **
** **
** Outputs: None **
** Return: RETURNok, RETURNerror **
** Others: None **
** **
***************************************************************************/
int user_api_esm_callback(int cid, network_pdn_state_t state)
{
LOG_FUNC_IN;
int rc = RETURNok;
user_indication_t ind;
ind.notification.pdn.cid = cid;
ind.notification.pdn.status = state;
/* The status of the specified PDN connection has changed */
rc = user_ind_notify(USER_IND_PDN, (void*)&ind, 0);
LOG_FUNC_RETURN (rc);
}
/****************************************************************************/
/********************* L O C A L F U N C T I O N S *********************/
/****************************************************************************/
/****************************************************************************
** **
** Name: _user_api_send() **
** **
** Description: Encodes and sends data to the user application layer **
** **
** Inputs: data: The data to send **
** Others: _user_api_send_buffer, _user_api_id **
** **
** Outputs: Return: The number of bytes sent when success; **
** RETURNerror Otherwise **
** Others: None **
** **
***************************************************************************/
static int _user_api_send(at_response_t* data)
{
LOG_FUNC_IN;
/* Encode AT command response message */
int bytes = at_response_encode(_user_api_send_buffer, data);
/* Send the AT command response message to the user application */
if (bytes != RETURNerror) {
bytes = _user_api_send_data(bytes);
}
LOG_FUNC_RETURN (bytes);
}
/****************************************************************************
** **
** Name: _user_api_registration_handler() **
** **
** Description: Procedure executed upon receiving registration notifica- **
** tion whenever there is a change in the UE's network re- **
** gistration status in GERAN/UTRAN/E-UTRAN. **
** The network registration data are then displayed to the **
** user. **
** **
** Inputs: id: Network registration AT command identifier **
** data: Generic pointer to the registration data **
** size: Not used **
** Others: None **
** **
** Outputs: None **
** Return: The number of bytes actually sent to the **
** user application **
** Others: None **
** **
***************************************************************************/
static int _user_api_registration_handler(unsigned char id, const void* data,
size_t size)
{
LOG_FUNC_IN;
/* Get registration notification data */
user_ind_reg_t* reg = (user_ind_reg_t*)data;
/* Setup AT command response message for AT+CEREG? read command */
at_response_t at_response;
at_response.id = id; // may be +CREG, +CGREG, +CEREG
at_response.type = AT_COMMAND_GET;
at_response.mask = AT_RESPONSE_NO_PARAM;
at_response.response.cereg.n = AT_CEREG_ON;
at_response.response.cereg.stat = reg->status;
/* Encode and send the AT command response message to the user */
int bytes = _user_api_send(&at_response);
LOG_FUNC_RETURN (bytes);
}
/****************************************************************************
** **
** Name: _user_api_location_handler() **
** **
** Description: Procedure executed upon receiving location notification **
** whenever there is a change in the network serving cell **
** in GERAN/UTRAN/E-UTRAN. **
** The location data are then displayed to the user. **
** **
** Inputs: id: Network registration AT command identifier **
** data: Generic pointer to the registration data **
** size: Not used **
** Others: None **
** **
** Outputs: None **
** Return: The number of bytes actually sent to the **
** user application **
** Others: None **
** **
***************************************************************************/
static int _user_api_location_handler(unsigned char id, const void* data,
size_t size)
{
LOG_FUNC_IN;
/* Get location notification data */
user_ind_loc_t* loc = (user_ind_loc_t*)data;
/* Setup AT command response message for AT+CEREG? read command */
at_response_t at_response;
at_response.id = id; // may be +CREG, +CGREG, +CEREG
at_response.type = AT_COMMAND_GET;
at_response.mask = (AT_CEREG_RESP_TAC_MASK | AT_CEREG_RESP_CI_MASK);
at_response.response.cereg.n = AT_CEREG_BOTH;
at_response.response.cereg.stat = loc->status;
sprintf(at_response.response.cereg.tac, "%.4x", loc->tac); // two byte
sprintf(at_response.response.cereg.ci, "%.8x", loc->ci); // four byte
if (at_response.response.cereg.AcT != NET_ACCESS_UNAVAILABLE) {
at_response.response.cereg.AcT = loc->AcT;
at_response.mask |= AT_CEREG_RESP_ACT_MASK;
}
/* Encode and send the AT command response message to the user */
int bytes = _user_api_send(&at_response);
LOG_FUNC_RETURN (bytes);
}
/****************************************************************************
** **
** Name: _user_api_network_handler() **
** **
** Description: Procedure executed whenever the list of operators present **
** in the network has to be displayed to the user. **
** **
** Inputs: id: Not used **
** data: Generic pointer to the list of operators **
** size: The size of the data to display **
** Others: None **
** **
** Outputs: None **
** Return: The number of bytes actually sent to the **
** user application **
** Others: None **
** **
***************************************************************************/
static int _user_api_network_handler(unsigned char id, const void* data,
size_t size)
{
LOG_FUNC_IN;
/* Setup AT command response message for AT+COPS=? test command */
at_response_t at_response;
at_response.id = AT_COPS;
at_response.type = AT_COMMAND_TST;
at_response.response.cops.tst.data = (char*)data;
at_response.response.cops.tst.size = size;
/* Encode and send the AT command response message to the user */
int bytes = _user_api_send(&at_response);
LOG_FUNC_RETURN (bytes);
}
/****************************************************************************
** **
** Name: _user_api_pdn_connection_handler() **
** **
** Description: Procedure executed upon receiving PDN connection notifi- **
** cation whenever the user or the network has activated or **
** desactivated a PDN connection. **
** The PDN connection data are then displayed to the user. **
** **
** Inputs: id: Not used **
** data: Generic pointer to the PDN connection data **
** size: Not used **
** Others: None **
** **
** Outputs: None **
** Return: The number of bytes actually sent to the **
** user application **
** Others: None **
** **
***************************************************************************/
static int _user_api_pdn_connection_handler(unsigned char id, const void* data,
size_t size)
{
LOG_FUNC_IN;
/* Get PDN connection notification data */
user_ind_pdn_t* pdn = (user_ind_pdn_t*)data;
/* Setup AT command unsolicited result response message for +CGEV */
at_response_t at_response;
at_response.id = AT_CGEV;
at_response.type = AT_COMMAND_GET;
at_response.mask = AT_RESPONSE_CGEV_MASK;
at_response.response.cgev.cid = pdn->cid;
at_response.response.cgev.code = pdn->status;
/* Encode and send the AT command response message to the user */
int bytes = _user_api_send(&at_response);
LOG_FUNC_RETURN (bytes);
}
#endif // NAS_UE
@@ -0,0 +1,58 @@
/*****************************************************************************
Eurecom OpenAirInterface 3
Copyright(c) 2012 Eurecom
Source user_api.h
Version 0.1
Date 2012/02/28
Product NAS stack
Subsystem Application Programming Interface
Author Frederic Maurel
Description Implements the API used by the NAS layer running in the UE
to send/receive message to/from the user application layer
*****************************************************************************/
#ifndef __USER_API_H__
#define __USER_API_H__
#include "commonDef.h"
#include "networkDef.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
int user_api_initialize(const char* host, const char* port, const char* devname, const char* devparams);
int user_api_emm_callback(Stat_t stat, tac_t tac, ci_t ci, AcT_t AcT, const char* data, size_t size);
int user_api_esm_callback(int cid, network_pdn_state_t state);
int user_api_get_fd(void);
const void* user_api_get_data(int index);
int user_api_read_data(int fd);
int user_api_send_data(int fd, int length);
void user_api_close(int fd);
int user_api_decode_data(int length);
int user_api_encode_data(const void* data, int add_success_code);
#endif /* __USER_API_H__ */
@@ -0,0 +1,156 @@
/*****************************************************************************
Eurecom OpenAirInterface 3
Copyright(c) 2012 Eurecom
Source user_indication.c
Version 0.1
Date 2012/10/25
Product NAS stack
Subsystem Application Programming Interface
Author Frederic Maurel
Description Defines functions which allow the user application to register
procedures to be executed upon receiving asynchronous notifi-
cation.
*****************************************************************************/
#include "user_indication.h"
#include "nas_log.h"
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
/****************************************************************************/
/****************************************************************************/
/******************* L O C A L D E F I N I T I O N S *******************/
/****************************************************************************/
/* Notification handler */
static struct {
unsigned char id;
unsigned char mask;
user_ind_callback_t callback[USER_IND_MAX];
} _user_ind_handler = {};
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
/****************************************************************************
** **
** Name: user_ind_register() **
** **
** Description: Register the specified procedure to be executed upon **
** receiving the given asynchronous notification **
** **
** Inputs: ind: The notification type **
** id: The notification identifier **
** cb: The procedure to register **
** Others: None **
** **
** Outputs: None **
** Return: RETURNok, RETURNerror **
** Others: _user_ind_handler **
** **
***************************************************************************/
int user_ind_register(user_ind_t ind, unsigned char id, user_ind_callback_t cb)
{
LOG_FUNC_IN;
int rc = RETURNerror;
if (ind < USER_IND_MAX) {
/* Register the notification callback */
if (cb != NULL) {
_user_ind_handler.callback[ind] = cb;
}
else {
_user_ind_handler.id = id;
_user_ind_handler.mask |= (1 << ind);
}
rc = RETURNok;
}
LOG_FUNC_RETURN(rc);
}
/****************************************************************************
** **
** Name: user_ind_deregister() **
** **
** Description: Prevent a registered procedure from being executed upon **
** receiving the given asynchronous notification **
** **
** Inputs: ind: The notification identifier **
** Others: None **
** **
** Outputs: None **
** Return: RETURNok, RETURNerror **
** Others: _user_ind_handler **
** **
***************************************************************************/
int user_ind_deregister(user_ind_t ind)
{
LOG_FUNC_IN;
int rc = RETURNerror;
if (ind < USER_IND_MAX) {
_user_ind_handler.mask &= ~(1 << ind);
rc = RETURNok;
}
LOG_FUNC_RETURN(rc);
}
/****************************************************************************
** **
** Name: user_ind_notify() **
** **
** Description: Execute the procedure if registered for the received **
** notification identifier **
** **
** Inputs: ind: The notification identifier **
** data: Generic pointer to the notification data **
** size: The size parameter of the registered call- **
** back procedure to execute **
** Others: _user_ind_handler **
** **
** Outputs: None **
** Return: RETURNok, RETURNerror **
** Others: None **
** **
***************************************************************************/
int user_ind_notify(user_ind_t ind, const void* data, size_t size)
{
LOG_FUNC_IN;
int rc = RETURNerror;
if (ind < USER_IND_MAX) {
if (_user_ind_handler.mask & (1 << ind)) {
/* Execute the notification callback */
user_ind_callback_t notify = _user_ind_handler.callback[ind];
if (notify != NULL) {
rc = (*notify)(_user_ind_handler.id, data, size);
}
}
else {
/* Silently discard not registered notification */
rc = RETURNok;
}
}
LOG_FUNC_RETURN(rc);
}
/****************************************************************************/
/********************* L O C A L F U N C T I O N S *********************/
/****************************************************************************/
@@ -0,0 +1,103 @@
/*****************************************************************************
Eurecom OpenAirInterface 3
Copyright(c) 2012 Eurecom
Source user_indication.h
Version 0.1
Date 2012/10/25
Product NAS stack
Subsystem Application Programming Interface
Author Frederic Maurel
Description Defines functions which allow the user application to register
procedures to be executed upon receiving asynchronous notifi-
cation.
*****************************************************************************/
#ifndef __USER_IND_H__
#define __USER_IND_H__
#include "commonDef.h"
#include "networkDef.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/*
* Type of notification that may be asynchronously received by the user
*/
typedef enum {
USER_IND_REG = 0, /* Registration notification */
USER_IND_LOC, /* Location notification */
USER_IND_PLMN, /* Network notification */
USER_IND_PDN, /* PDN connection notification */
USER_IND_MAX
} user_ind_t;
/*
* Registration notification are received whenever there is a change in the
* UE's network registration status in GERAN/UTRAN/E-UTRAN
*/
typedef struct {
Stat_t status; /* network registration status */
} user_ind_reg_t;
/*
* Location notification are received whenever there is a change in the
* network serving cell in GERAN/UTRAN/E-UTRAN
*/
typedef struct {
Stat_t status; /* network registration status */
tac_t tac; /* Location/Tracking area code */
ci_t ci; /* GERAN/UTRAN/E-UTRAN cell ID */
AcT_t AcT; /* Supported Access Technology */
} user_ind_loc_t;
/*
* PDN connection notification are received whenever the user or the network
* has activated or desactivated a PDN connection
*/
typedef struct {
UInt8_t cid; /* PDN connection identifier */
network_pdn_state_t status; /* PDN connection status */
} user_ind_pdn_t;
/*
* Structure of asynchronous notification received by the user
*/
typedef struct {
union {
user_ind_reg_t reg; /* Registration notification */
user_ind_loc_t loc; /* Location notification */
user_ind_pdn_t pdn; /* PDN connection notification */
} notification;
} user_indication_t;
/*
* Type of procedure executed upon receiving registered notification
*/
typedef int (*user_ind_callback_t) (unsigned char, const void*, size_t);
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
int user_ind_register(user_ind_t ind, unsigned char id, user_ind_callback_t cb);
int user_ind_deregister(user_ind_t ind);
int user_ind_notify(user_ind_t ind, const void* data, size_t size);
#endif /* __USER_IND_H__*/