/*===========================================================================
FILE: 
   QmiNASAPI.h

DESCRIPTION:
   Gobi Network Access Service APIs

Copyright (C) 2015 Sierra Wireless Incorporated. All rights reserved.
                   Sierra Wireless Proprietary/GTDR
==========================================================================*/

#ifndef __GOBI_NAS_API_H__
#define __GOBI_NAS_API_H__
/*=========================================================================*/
// Definitions
/*=========================================================================*/

/** 
* \defgroup GroupNAS Network Access Service
*/
/*@{*/

/*=========================================================================*/
// Structs
/*=========================================================================*/
#ifdef __cplusplus
	extern "C" {
#endif

#ifdef __cplusplus
	};
#endif

/*=========================================================================*/
// Prototypes
/*=========================================================================*/

//TLV 0x01 of QMI_NAS_SERVING_SYSTEM_IND 0x0024
IMPORTGOBI ULONG GOBICMAPI SetServingSystemCallback( 
	tFNServingSystem	pCallback );

//QMI_NAS_SERVING_SYSTEM_IND 0x0024
//Serving system info callback function (struct containing serving system, current plmn data capability and romaing indicator)
IMPORTGOBI ULONG GOBICMAPI SwiSetServingSystemInfoCallback( 
	tFNSwiServingSystemInfo pCallback );

//TLV 0x12 of QMI_NAS_SERVING_SYSTEM_IND 0x0024
IMPORTGOBI ULONG GOBICMAPI SetCurrentPlmnCallback( 
	tFNCurrentPlmn	pCallback );

//QMI_NAS_SET_3GPP2_SUBSCRIPTION_INFO 0x003F
IMPORTGOBI ULONG GOBICMAPI Set3Gpp2SubscriptionInfo( 
	BYTE*				pNamId,
	MinBasedImsi*		pMinBasedImsi,
	TrueImsi*			pTrueImsi,
	BYTE*				pMdnLen,
	BYTE*				pMdn
);

//QMI_NAS_GET_3GPP2_SUBSCRIPTION_INFO 0x003E
IMPORTGOBI ULONG GOBICMAPI Get3Gpp2SubscriptionInfo( 
	BYTE*				pNamId,
	MinBasedImsi*		pMinBasedImsi,
	TrueImsi*			pTrueImsi,
	BYTE*				pMdnLen,
	BYTE*				pMdn
);

//QMI_NAS_SET_DDTM_PREFERENCE 0x0037
IMPORTGOBI ULONG GOBICMAPI SetDdtmPreference( 
	BYTE		ddtmPref,
	WORD		ddtmAction,
	BYTE		soListAction,		//string array with fixed size of 16
	BYTE		numSoInstances,	//also as input buffer size
	WORD*		pArrServiceOption
);

//QMI_NAS_GET_SYS_INFO 0x004D
IMPORTGOBI ULONG GOBICMAPI GetSysInfo(
	CdmaSystemInfo*		pCdmaSystemInfo,
	HdrSystemInfo*		pHdrSystemInfo,
	GsmSystemInfo*		pGsmSystemInfo,
	WcdmaSystemInfo*	pWcdmaSystemInfo,
	LteSystemInfo*		pLteSystemInfo,
	TdscdmaSystemInfo*	pTdscdmaSystemInfo); 

//QMI_NAS_GET_ERR_RATE 0x0052	
IMPORTGOBI ULONG GOBICMAPI GetErrRate( 
	WORD*			pCdmaFrameErrorRate,
	WORD*			pHdrPacketErrorRate,
	BYTE*			pGsmBitErrorRate,
	BYTE*			pWcdmaBlockErrorRate,
	BYTE*			pTdscdmaBlockErrorRate
);	


//QMI_NAS_GET_HDR_COLOR_CODE 0x0057
IMPORTGOBI ULONG GOBICMAPI GetHdrColorCode( 
	BYTE*			pColorCode
);

//QMI_NAS_GET_TX_RX_INFO 0x005A
IMPORTGOBI ULONG GOBICMAPI GetTxRxInfo( 
	BYTE 	  	radioIf,
	RxInfo*		pRxInfoCh0,
	RxInfo*		pRxInfoCh1,
	TxInfo*		pTxInfo
);

//QMI_NAS_SWI_GET_HRPD_STATS 0x5561
IMPORTGOBI ULONG GOBICMAPI SwiGetHrpdStats( 
	BYTE*			pDrcValue,
	BYTE*			pDrcCover,
	BYTE*			pArrUati,		//string array with fixed size of 16
	BYTE*			pNumOfPilot,	//also as input buffer size
	HrpdPilot*		pHrpdPilot
);


//QMI_NAS_SWI_GET_CDMA_DOMINANT_PN 0x7560
IMPORTGOBI ULONG GOBICMAPI SwiGetCdmaDominantPn( 
	WORD*		p1xDominantPn,
	WORD*		pDoDominantPn
);

//////////////////////////////////////////////////////////////////////////////
///
/// This function enables/disables the PLMN mode callback function
/// QMI_NAS_GET_CSP_PLMN_MODE_BIT_IND 0x003C
///
/// \param	pCallback   [ I ] - Callback function
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI SetPLMNModeCallback( tFNPLMNMode pCallback );

//////////////////////////////////////////////////////////////////////////////
///
/// This function enables/disables the signal strength callback function with
/// QMI_NAS_SET_EVENT_REPORT 0x0002 TLV 0x10
///
/// \param	pCallback      [ I ] - Callback function (0 = disable)
/// \param	thresholdsSize [ I ] - Number of elements the threshold array contain
///                       (a maximum of 5 thresholds is supported), must
///                       be 0 when disabling the callback
/// \param	pThresholds    [ I ] - Signal threshold array (each entry in dBm),
///                       must be 0 when disabling the callback
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI SetSignalStrengthCallback( 
   tFNSignalStrength          pCallback,
   BYTE                       thresholdsSize,
   INT8 *                     pThresholds );

//////////////////////////////////////////////////////////////////////////////
///
/// This function enables/disables the LU reject callback function with
/// QMI_NAS_SET_EVENT_REPORT 0x0002 TLV 0x12
/// \param	pCallback   [ I ] - Callback function (0 = disable)
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI SetLURejectCallback( tFNLUReject pCallback );

//////////////////////////////////////////////////////////////////////////////
///
/// This function enables/disables the RF information callback function with
/// QMI_NAS_SET_EVENT_REPORT 0x0002 TLV 0x11
/// 
/// \param	pCallback   [ I ] - Callback function (0 = disable)
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI SetRFInfoCallback( tFNRFInfo pCallback );

//////////////////////////////////////////////////////////////////////////////
///
/// This function enables/disables the roaming indicator callback function
/// QMI_NAS_GET_SERVING_SYSTEM 0x0024
/// QMI_NAS_SERVING_SYSTEM_IND 0x0024 TLV Roaming Indicator Value 0x10
/// 
/// \param	pCallback   [ I ] - Callback function (0 = disable)
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI SetRoamingIndicatorCallback( 
   tFNRoamingIndicator        pCallback );
   
//////////////////////////////////////////////////////////////////////////////
///
/// This function enables/disables the serving system data capabilities 
/// callback function
/// QMI_NAS_GET_SERVING_SYSTEM_IND 0x0024 TLV Data Service Capability 0x11
/// 
/// \param	pCallback   [ I ] - Callback function (0 = disable)
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI SetDataCapabilitiesCallback( 
   tFNDataCapabilities        pCallback );

   
//////////////////////////////////////////////////////////////////////////////
///
/// This function retrieves information about the home network of the device
/// QMI_NAS_GET_HOME_NETWORK_MSG =                    0x0025
/// 
/// \param	pMCC        [ O ] - Mobile country code
/// \param	pMNC        [ O ] - Mobile network code
/// \param	nameSize    [ I ] - The maximum number of characters (including NULL 
///                    terminator) that the network name array can contain
/// \param	 pName       [ O ] - The network name or description represented as a NULL 
///                    terminated string (empty string returned when unknown)
/// \param	pSID        [ O ] - Home network system ID (0xFFFF - Unknown)
/// \param	pNID        [ O ] - Home network ID (0xFFFF - Unknown)
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI GetHomeNetwork( 
   WORD *                     pMCC, 
   WORD *                     pMNC, 
   BYTE                       nameSize, 
   CHAR *                     pName, 
   WORD *                     pSID, 
   WORD *                     pNID );

//////////////////////////////////////////////////////////////////////////////
///
/// This function sets the network registration preference
/// QMI_NAS_SET_TECHNOLOGY_PREFERENCE_MSG =           0x002A
///
/// \param	technologyPref [ I ] - Technology preference bitmap
/// \param	duration       [ I ] - Duration of active preference
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI SetNetworkPreference( 
   ULONG                      technologyPref, 
   ULONG                      duration );

//////////////////////////////////////////////////////////////////////////////
///
/// This function returns the network registration preference
/// QMI_NAS_GET_TECHNOLOGY_PREFERENCE_MSG =           0x002B
/// 
///
/// \param	pTechnologyPref            [ O ] - Technology preference bitmap
/// \param	pDuration                  [ O ] - Duration of active preference
/// \param	pPersistentTechnologyPref  [ O ] - Persistent technology preference bitmap 
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI GetNetworkPreference( 
   ULONG *                    pTechnologyPref, 
   ULONG *                    pDuration, 
   ULONG *                    pPersistentTechnologyPref );

//////////////////////////////////////////////////////////////////////////////
///
/// This function sets the desired CDMA network parameters
/// QMI_NAS_SET_DEVICE_CONFIG =                       0x0030
///
/// \param	[ I ] - Six digit service programming code
/// \param	pForceRev0     [ I ] - (Optional) Force CDMA 1x-EV-DO Rev. 0 mode?
/// \param	pCustomSCP     [ I ] - (Optional) Use a custom config for CDMA 1x-EV-DO SCP?
/// \param	pProtocol      [ I ] - (Optional) Protocol mask for custom SCP config
/// \param	pBroadcast     [ I ] - (Optional) Broadcast mask for custom SCP config
/// \param	pApplication   [ I ] - (Optional) Application mask for custom SCP config
/// \param	pRoaming       [ I ] - (Optional) Roaming preference
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI SetCDMANetworkParameters( 
   CHAR *                     pSPC,
   BYTE *                     pForceRev0,
   BYTE *                     pCustomSCP,
   ULONG *                    pProtocol,
   ULONG *                    pBroadcast,
   ULONG *                    pApplication,
   ULONG *                    pRoaming );

//////////////////////////////////////////////////////////////////////////////
///
/// This function gets the current CDMA network parameters
/// QMI_NAS_GET_DEVICE_CONFIG =                       0x002F
/// 
/// \param	pSCI           [ O ] - Slot cycle index
/// \param	pSCM           [ O ] - Station class mark
/// \param	pRegHomeSID    [ O ] - Register on home SID?
/// \param	pRegForeignSID [ O ] - Register on foreign SID?
/// \param	pRegForeignNID [ O ] - Register on foreign NID?
/// \param	pForceRev0     [ O ] - Force CDMA 1x-EV-DO Rev. 0 mode?
/// \param	pCustomSCP     [ O ] - Use a custom config for CDMA 1x-EV-DO SCP?
/// \param	pProtocol      [ O ] - Protocol mask for custom SCP config
/// \param	pBroadcast     [ O ] - Broadcast mask for custom SCP config
/// \param	pApplication   [ O ] - Application mask for custom SCP config
/// \param	pRoaming       [ O ] - Roaming preference
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI GetCDMANetworkParameters( 
   BYTE *                     pSCI,
   BYTE *                     pSCM,
   BYTE *                     pRegHomeSID,
   BYTE *                     pRegForeignSID,
   BYTE *                     pRegForeignNID,
   BYTE *                     pForceRev0,
   BYTE *                     pCustomSCP,
   ULONG *                    pProtocol,
   ULONG *                    pBroadcast,
   ULONG *                    pApplication,
   ULONG *                    pRoaming );

//////////////////////////////////////////////////////////////////////////////
///
/// This function returns the Access Overload Class (ACCOLC) of the device
/// QMI_NAS_GET_ACCOLC_MSG =                          0x002C
/// 
/// \param	pACCOLC     [ O ] - The ACCOLC
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI GetACCOLC( BYTE * pACCOLC );

//////////////////////////////////////////////////////////////////////////////
///
/// This function sets the Access Overload Class (ACCOLC) of the device
/// QMI_NAS_SET_ACCOLC_MSG =                          0x002D
/// 
/// 
/// \param	pSPC        [ I ] - NULL terminated string representing the six digit 
///                    service programming code
/// \param	accolc      [ I ] - The ACCOLC
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI SetACCOLC( 
   CHAR *                     pSPC,
   BYTE                       accolc );

//////////////////////////////////////////////////////////////////////////////
///
/// This function returns the PLMN mode from the CSP
/// QMI_NAS_GET_CSP_PLMN_MODE_BIT_IND =               0x003B
/// 
/// \param	pMode       [ O ] - PLMN mode
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI GetPLMNMode( ULONG * pMode );

//////////////////////////////////////////////////////////////////////////////
///
/// This function returns PLMN name information for the given MCC/MNC
/// QMI_NAS_GET_PLMN_NAME_MSG =                       0x0044
/// 
/// \param	mcc         [ I ] - Mobile country code
/// \param	mnc         [ I ] - Mobile network code
/// \param	pNamesSize  [I/O] - Upon input the size in BYTEs of the name structure 
///                    array.  Upon success the actual number of BYTEs 
///                    copied to the name structure array
/// \param	pNames      [ O ] - The name structure array
/// 
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI GetPLMNName(
   USHORT                     mcc,
   USHORT                     mnc,
   ULONG *                    pNamesSize, 
   BYTE *                     pNames );

//////////////////////////////////////////////////////////////////////////////
///
/// This function gets the current RF information
/// QMI_NAS_GET_RF_BAND_INFO =                        0x0031
/// 
/// \param	pInstanceSize  [I/O] - Upon input the maximum number of elements that the 
///                       RF info instance array can contain.  Upon success
///                       the actual number of elements in the RF info 
///                       instance array
/// \param	pInstances     [ O ] - The RF info instance array 
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI GetRFInfo( 
   BYTE *                     pInstanceSize, 
   BYTE *                     pInstances );

//////////////////////////////////////////////////////////////////////////////
///
/// This function performs a scan for available networks
/// 
/// \param	pInstanceSize  [I/O] - Upon input the maximum number of elements that the 
///                       network info instance array can contain.  Upon 
///                       success the actual number of elements in the
///                       network info instance array
/// \param	pInstances     [ O ] - The network info instance array 
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI PerformNetworkScan( 
   BYTE *                     pInstanceSize, 
   BYTE *                     pInstances );

//////////////////////////////////////////////////////////////////////////////
///
/// This function performs a scan for available networks (includes RAT)
/// QMI_NAS_PERFORM_NETWORK_SCAN_MSG =                0x0021
///
/// \param	pInstanceSize  [I/O] - Upon input the maximum number of elements that the 
///                       network info instance array can contain.  Upon 
///                       success the actual number of elements in the
///                       network info instance array
/// \param	pInstances     [ O ] - The network info instance array 
/// \param	pRATSize       [I/O] - Upon input the maximum number of elements that the 
///                       RAT info instance array can contain.  Upon success 
///                       the actual number of elements in the RAT info 
///                       instance array
/// \param	pRATInstances  [ O ] - The RAT info instance array
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI PerformNetworkRATScan( 
   BYTE *                     pInstanceSize, 
   BYTE *                     pInstances,
   BYTE *                     pRATSize, 
   BYTE *                     pRATInstances );

//////////////////////////////////////////////////////////////////////////////
///
/// This function initiates a network registration
/// QMI_NAS_INITIATE_NETWORK_REGISTER =                     0x0022
///
/// \param	regType     [ I ] - Registration type 
/// \param	mcc         [ I ] - Mobile country code (ignored for auto registration)
/// \param	mnc         [ I ] - Mobile network code (ignored for auto registration)
/// \param	rat         [ I ] - Radio access type (ignored for auto registration)
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI InitiateNetworkRegistration( 
   ULONG                      regType,
   WORD                       mcc, 
   WORD                       mnc, 
   ULONG                      rat );

//////////////////////////////////////////////////////////////////////////////
///
/// This function initiates a domain attach (or detach)
/// QMI_NAS_INITIATE_ATTACH_MSG =                     0x0023 (deprecated)
/// QMI_NAS_SET_SYSTEM_SELECTION_PREFERENCE = 0x0033 (new)
///
/// \param	action      [ I ] - PS attach action (attach or detach)
///\li • 0x01 – PS_ACTION_ATTACH – Initiates an immediate packet domain attach action
///\li • 0x02 – PS_ACTION_DETACH – Initiates an immediate packet domain detach action
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI InitiateDomainAttach( ULONG action );

//////////////////////////////////////////////////////////////////////////////
///
/// Gets information regarding the system that currently provides service 
/// to the device
/// QMI_NAS_GET_SERVING_SYSTEM_MSG =                  0x0024
/// 
/// \param	pRegistrationState   [ O ] - Registration state
/// \param	pCSDomain            [ O ] - Circuit switch domain status
/// \param	pPSDomain            [ O ] - Packet switch domain status 
/// \param	pRAN                 [ O ] - Radio access network 
/// \param	pRadioIfacesSize     [I/O] - Upon input the maximum number of elements 
///                             that the radio interfaces can contain.  Upon 
///                             successful output the actual number of elements 
///                             in the radio interface array
/// \param	pRadioIfaces         [ O ] - The radio interface array 
/// \param	pRoaming             [ O ] - Roaming indicator (0xFFFFFFFF - Unknown)
/// \param	pMCC                 [ O ] - Mobile country code (0xFFFF - Unknown)
/// \param	pMNC                 [ O ] - Mobile network code (0xFFFF - Unknown)
/// \param	nameSize             [ I ] - The maximum number of characters (including 
///                             NULL terminator) that the network name array 
///                             can contain
/// \param	pName                [ O ] - The network name or description represented 
///                             as a NULL terminated string (empty string 
///                             returned when unknown)
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI GetServingNetwork( 
   ULONG *                    pRegistrationState, 
   ULONG *                    pCSDomain, 
   ULONG *                    pPSDomain, 
   ULONG *                    pRAN, 
   BYTE *                     pRadioIfacesSize, 
   BYTE *                     pRadioIfaces, 
   ULONG *                    pRoaming, 
   WORD *                     pMCC, 
   WORD *                     pMNC, 
   BYTE                       nameSize, 
   CHAR *                     pName );

//////////////////////////////////////////////////////////////////////////////
///
/// Gets information regarding the data capabilities of the system that 
/// currently provides service to the device
/// QMI_NAS_GET_SERVING_SYSTEM_MSG =                  0x0024
///
/// \param	pDataCapsSize  [I/O] - Upon input the maximum number of elements that the 
///                       data capabilities array can contain.  Upon success
///                       the actual number of elements in the data 
///                       capabilities array
/// \param	pDataCaps      [ O ] - The data capabilities array 
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI GetServingNetworkCapabilities( 
   BYTE *                     pDataCapsSize, 
   BYTE *                     pDataCaps );

//////////////////////////////////////////////////////////////////////////////
///
/// This function gets the AN-AAA authentication status
/// QMI_NAS_GET_AN_AAA_STATUS_MSG =					0x0032
/// 
/// \param	pStatus     [ O ] - AN-AAA authentication status
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI GetANAAAAuthenticationStatus( ULONG * pStatus );

//////////////////////////////////////////////////////////////////////////////
///
/// This function gets the current available signal strengths (in dBm) 
/// as measured by the device
/// QMI_NAS_GET_SIGNAL_STRENGTH_MSG =                 0x0020
/// 
/// \param	pArraySizes       [I/O] - Upon input the maximum number of elements 
///                          that each array can contain can contain.  
///                          Upon successful output the actual number 
///                          of elements in each array
/// \param	pSignalStrengths  [ O ] - Received signal strength array (dBm)
/// \param	pRadioInterfaces  [ O ] - Radio interface technology array 
///
/// \return See GobiErrorCodes.h
///
///////////////////////////////////////////////////////////////////////////////
IMPORTGOBI ULONG GOBICMAPI GetSignalStrengths( 
   ULONG *                    pArraySizes, 
   INT8 *                     pSignalStrengths, 
   ULONG *                    pRadioInterfaces );
   
/*@}*/ // End of NAS group
#endif