In the project folder there are a file with the extension *.scs open this file and add this line to the WMNew script additional options:
-otherlib /TCPIP
this will link the compiler to the ed_Lib Libraries
Find below an example on how to connect to GPRS ussing ed_Lib
#include "adl_global.h"
#include "ed_common.h"
#include "ed_dialup.h"
#include "ed_ftp.h"
#include "ed_gprs.h"
#include "ed_socket.h"
#include "ed_msgcodes.h"
/***************************************************************************/
/* Mandatory variables */
/*-------------------------------------------------------------------------*/
/* wm_apmCustomStack */
/* wm_apmCustomStackSize */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
u32 wm_apmCustomStack [ 4000 ];
const u16 wm_apmCustomStackSize = sizeof ( wm_apmCustomStack );
/***************************************************************************/
/* Local variables */
/***************************************************************************/
ed_FTPSetupParams_t FTPParams;
ed_gprsSetupParams_t APNParams;
ed_FTPGetFileParams_t FTPGetFileParameters;
s32 Cell_Handle;
s32 S32Return;
/***************************************************************************/
/* Local functions */
/***************************************************************************/
void adl_main ( adl_InitType_e InitType );
void My_App_Normal_Init (void);
void SimEventHandler(u8 Event);
void SetupHandler(u8 ID);
bool AttRspHandler(adl_atResponse_t *params);
void GPRSWait( u8 ID);
void GPRSTimer(u8 ID);
void dialupHandler( s32 responseCode , TeDHandle id);
void dotted_notation(unsigned long int hex_ip);
/***************************************************************************/
/* Function : adl_main */
/*-------------------------------------------------------------------------*/
/* Object : Customer application initialization */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilization */
/*--------------------+---+---+---+----------------------------------------*/
/* InitType | | | | Application start mode reason */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void adl_main ( adl_InitType_e InitType )
{
s8 result;
TRACE (( 2, "Application Start with Init Type:%s",InitType ));
result = ed_Init();
TRACE (( 2, "Ed Library Initialized - %d" , result));
switch(InitType)
{
case ADL_INIT_POWER_ON: // Normal power on
TRACE (( 2, "ADL_INIT_POWER_ON (Normal Start)" ));
adl_atSendResponse( ADL_AT_UNS, "\r\nSMSParam Application Starting Normally\r\n" );
My_App_Normal_Init();
break;
case ADL_INIT_REBOOT_FROM_EXCEPTION: // Reboot after an embedded application exception
TRACE (( 2, "ADL_INIT_REBOOT_FROM_EXCEPTION" ));
break;
case ADL_INIT_DOWNLOAD_SUCCESS: // Reboot after a successfully downloaded process
TRACE (( 2, "ADL_INIT_DOWNLOAD_SUCCESS" ));
break;
case ADL_INIT_DOWNLOAD_ERROR: // Reboot after a unsuccessful downloaded process
TRACE (( 2, "ADL_INIT_DOWNLOAD_ERROR" ));
break;
}
}
void My_App_Normal_Init()
{
TRACE (( 2, "My_App_Normal_Init"));
adl_atCmdCreate("AT+CGCLASS=\"B\"",FALSE,NULL,NULL);
adl_simSubscribe(SimEventHandler,NULL);
//adl_tmrSubscribe(FALSE, 10, ADL_TMR_TYPE_100MS, SetupHandler); /*Only for Dev comment out for real app*/
}
void SimEventHandler(u8 Event)
{
TRACE (( 2, "SimEventHandler"));
switch(Event)
{
case ADL_SIM_EVENT_REMOVED:
break;
case ADL_SIM_EVENT_INSERTED:
break;
case ADL_SIM_EVENT_FULL_INIT:
TRACE ((2,"ADL_SIM_EVENT_FULL_INIT"));
adl_tmrSubscribe(FALSE, 10, ADL_TMR_TYPE_100MS, SetupHandler); //To Start The App Only After 1 Second To Allow Init
break;
case ADL_SIM_EVENT_PIN_ERROR:
break;
case ADL_SIM_EVENT_PIN_OK:
break;
case ADL_SIM_EVENT_PIN_WAIT:
break;
case ADL_SIM_EVENT_PIN_NO_ATTEMPT:
break;
}
}
void SetupHandler(u8 ID)
{
TRACE( ( 2, "Inside SetupHandler" ) );
adl_atCmdCreate("AT+CGATT=1",FALSE,AttRspHandler,"*",NULL);
}
bool AttRspHandler(adl_atResponse_t *params)
{
TRACE( ( 2, "Inside AttRspHandler" ) );
//if an OK is received as response to AT+CGATT=1 command then set GPRS settings.
if( !wm_strncmp( params->StrData, "\r\nOK", 4 ) )
{
//Ready
TRACE( ( 2, "Received OK" ) );
adl_tmrSubscribe(FALSE,2,ADL_TMR_TYPE_100MS,GPRSWait);//Give modem time to process CGATT=1
}
//if an OK is not received then create AT+CGATT=1 again.
else
{
adl_atCmdCreate( "AT+CGATT=1", FALSE, AttRspHandler, "*", NULL );
}
return FALSE;
}
void GPRSWait( u8 ID)
{
s8 returnCode;
TRACE( ( 2, "Inside GPRSWait" ) );
APNParams.Cid=1;
APNParams.Mode=1;
wm_strcpy( APNParams.ApnUn,"");
wm_strcpy( APNParams.ApnPw,"");
wm_strcpy( APNParams.ApnServ,"internet");
returnCode = ed_GprsSetConfig( &APNParams );
if (returnCode == 0)
{
adl_tmrSubscribe(FALSE, 10, ADL_TMR_TYPE_100MS,GPRSTimer);
}
else
{
TRACE((2,"ed_GprsSetConfig failed returnCode = %d",returnCode));
}
}
void GPRSTimer(u8 ID)
{
s8 returnCode;
TRACE( ( 2, "Inside timerHandler" ) );
returnCode = ed_DialupConnectionStart(dialupHandler );
if(returnCode == 0)
{
TRACE((2,"ed_DialupConnectionStart success returnCode = %d",returnCode));
adl_atSendResponse(ADL_AT_RSP,"\r\nTrying to retrieve ip information.Please wait until local ip is received...\r\n");
}
else
{
adl_atSendResponse( ADL_AT_RSP, "\r\ned_DialupConnectionStart failed\r\n" );
TRACE((2,"ed_DialupConnectionStart failed returnCode = %d",returnCode));
}
}
void dialupHandler( s32 responseCode , TeDHandle id)
{
// s8 RetS8;
// ascii Temp[255];
ed_dialupIPInfos_t ip_info;
TRACE( ( 2, "Inside dialupHandler" ) );
switch ( responseCode )
{
case ED_OK_GPRS_SESSION_SET://GPRS session is set.
TRACE( ( 2, "Inside ED_OK_GPRS_SESSION_SET" ) );
ed_DialupGetIpInformations(&ip_info); //retrieve ip informations (retrieved as u32).
adl_atSendResponse(ADL_AT_RSP,"\r\nLocal ip is \r\n");
dotted_notation(ip_info.LocalIP);//Print the ip information in dotted format
adl_atSendResponse(ADL_AT_RSP,"\r\n");
break;
case ED_INFO_CONNECT:
TRACE( ( 2, "Inside ED_INFO_CONNECT" ) );
break;
case ED_OK_PPP:
TRACE( ( 2, "Inside ED_OK_PPP" ) );
ed_DialupGetIpInformations(&ip_info);
adl_atSendResponse(ADL_AT_RSP,"\r\nLocal ip is\r\n");
dotted_notation(ip_info.LocalIP);
break;
case ED_OK_ON_HOOK:
TRACE( ( 2, "Dial up connection closed" ) );
adl_atSendResponse( ADL_AT_RSP, "\r\nDial up connection closed" );
break;
case ED_ERR_GPRS_ABORTED:
TRACE((2,"ED_ERR_GPRS_ABORTED"));
adl_atSendResponse(ADL_AT_RSP,"\r\nInternal GPRS error.Please check your APN parameters");
break;
default:
TRACE((2,"default or error received in gprsHandler: responseCode - %d", responseCode));
adl_atSendResponse( ADL_AT_RSP, "\r\nerror received in dial up connection start" );
break;
}
}
void dotted_notation(unsigned long int hex_ip)
{
ascii array[30];
TRACE( ( 2, "Inside dotted_Notation %d",hex_ip ) );
if (hex_ip > 16777215)//to detect the least significant byte (not to put dot behind)
{
dotted_notation(hex_ip>>8 );
sprintf(array,"%d",hex_ip & 0xFF);
adl_atSendResponse(ADL_AT_RSP,array);
}
else
{
if (hex_ip==0x00000000)
return;
else
{
dotted_notation(hex_ip>>8 );
sprintf(array,"%d.",hex_ip & 0xFF);
adl_atSendResponse(ADL_AT_RSP,array);
}
}
}