I also have the same problem when I trying to connecting to non-existing server.
I set in wip_TCPClientCreate my IP and that Port on which not exist my server application.
From some time (10-20 minute) i have ARM Exception 1
This is my code.
#include "adl_global.h"
#include "wip.h"
_ext_ wip_bearer_t Bearer;
_ext_ wip_channel_t TCPChanel;
void SimHandler(u8 Event);
bool CGATTHandler(adl_atResponse_t *Response);
void TCPwipHandler( wip_event_t *ev, void *context);
void TCPWIPTimerHandler(u8 ID);
void GPRSHandler(wip_bearer_t br,s8 event,void *context);
u32 wm_apmCustomStack [ 4096 ];
const u16 wm_apmCustomStackSize = sizeof ( wm_apmCustomStack );
void adl_main ( adl_InitType_e InitType )
{
TRACE((1,"[ENTER] adl_main"));
adl_simSubscribe(SimHandler,"0000");
TRACE((1,"[EXIT] adl_main"));
return;
}
void SimHandler(u8 Event)
{
s8 sResult;
TRACE((1,"[INFO] SimHandler"));
if(Event == ADL_SIM_EVENT_FULL_INIT)
{
TRACE((1,"SimHandler = ADL_SIM_EVENT_FULL_INIT"));
adl_atCmdCreate("AT+CGATT=1",TRUE,CGATTHandler,"*",NULL);
TRACE (( 1, "adl_atCmdCreate = AT+CGATT=1" ));
break;
}
TRACE((1,"[EXIT] SimHandler"));
return;
}
bool CGATTHandler(adl_atResponse_t *Response)
{
s8 sResult;
TRACE((1,"[INFO] CGATTHandler"));
if(Response->RspID != ADL_STR_OK)
{
adl_atCmdCreate("AT+CGATT=1",TRUE,CGATTHandler,"*",NULL);
TRACE (( 1, "adl_atCmdCreate = AT+CGATT=1" ));
TRACE((1,"[EXIT] CGATTHandler"));
return FALSE;
}
sResult = wip_netInitOpts(WIP_NET_OPT_DEBUG_PORT,WIP_NET_DEBUG_PORT_TRACE,
WIP_NET_OPT_SOCK_MAX,1,
WIP_NET_OPT_BUF_MAX,4,
WIP_NET_OPT_END);
switch(sResult)
{
case 0:
TRACE (( 1, "wip_netInit = SUCCESS" ));
sResult = wip_bearerOpen(&Bearer,"GPRS",GPRSHandler,NULL);
switch(sResult)
{
case 0:
TRACE (( 1, "wip_bearerOpen = SUCCESS" ));
sResult = wip_bearerSetOpts(Bearer,
WIP_BOPT_GPRS_CID,1,
WIP_BOPT_GPRS_DATACOMP,FALSE,
WIP_BOPT_GPRS_HEADERCOMP,FALSE,
WIP_BOPT_LOGIN,"apnus",
WIP_BOPT_PASSWORD,"apnpassword",
WIP_BOPT_GPRS_APN,"apn",
WIP_BOPT_END);
switch(sResult)
{
case 0:
TRACE (( 1, "wip_bearerSetOpts = SUCCESS" ));
sResult = wip_bearerStart(Bearer);
switch(sResult)
{
case 0:
TRACE (( 1, "wip_bearerStart = SUCCESS" ));
break;
case WIP_BERR_OK_INPROGRESS:
TRACE (( 1, "wip_bearerStart = WIP_BERR_OK_INPROGRESS" ));
break;
case WIP_BERR_BAD_HDL:
TRACE (( 1, "wip_bearerStart = WIP_BERR_BAD_HDL" ));
break;
case WIP_BERR_BAD_STATE:
TRACE (( 1, "wip_bearerStart = WIP_BERR_BAD_STATE" ));
break;
case WIP_BERR_DEV:
TRACE (( 1, "wip_bearerStart = WIP_BERR_DEV" ));
break;
default:
TRACE (( 1, "wip_bearerStart = UNDEFINED %d",sResult ));
break;
}
break;
case WIP_BERR_BAD_HDL:
TRACE (( 1, "wip_bearerSetOpts = WIP_BERR_BAD_HDL" ));
break;
case WIP_BERR_OPTION:
TRACE (( 1, "wip_bearerSetOpts = WIP_BERR_OPTION" ));
break;
case WIP_BERR_PARAM:
TRACE (( 1, "wip_bearerSetOpts = WIP_BERR_PARAM" ));
break;
default:
TRACE (( 1, "wip_bearerSetOpts = UNDEFINED %d",sResult ));
break;
}
break;
case WIP_BERR_NO_DEV:
TRACE (( 1, "wip_bearerOpen = WIP_BERR_NO_DEV" ));
break;
case WIP_BERR_ALREADY:
TRACE (( 1, "wip_bearerOpen = WIP_BERR_ALREADY" ));
break;
case WIP_BERR_NO_IF:
TRACE (( 1, "wip_bearerOpen = WIP_BERR_NO_IF" ));
break;
case WIP_BERR_NO_HDL:
TRACE (( 1, "wip_bearerOpen = WIP_BERR_NO_HDL" ));
break;
default:
TRACE (( 1, "wip_bearerOpen = UNDEFINED %d",sResult ));
break;
}
break;
case WIP_NET_ERR_PARAM:
TRACE (( 1, "wip_netInit = WIP_NET_ERR_PARAM" ));
break;
case WIP_NET_ERR_NO_MEM:
TRACE (( 1, "wip_netInit = WIP_NET_ERR_NO_MEM" ));
break;
default:
TRACE (( 1, "wip_netInit = ERROR %d", sResult));
break;
}
TRACE((1,"[EXIT] CGATTHandler"));
return FALSE;
}
void GPRSHandler(wip_bearer_t br,s8 event,void *context)
{
s8 sResult;
TRACE((1,"[INFO] GPRSHandler"));
switch(event)
{
case WIP_BEV_CONN_FAILED:
TRACE (( 1, "GPRSHandler WIP_BEV_CONN_FAILED"));
sResult = wip_bearerStart(Bearer);
switch(sResult)
{
case 0:
TRACE (( 1, "wip_bearerStart = SUCCESS" ));
break;
case WIP_BERR_OK_INPROGRESS:
TRACE (( 1, "wip_bearerStart = WIP_BERR_OK_INPROGRESS" ));
break;
case WIP_BERR_BAD_HDL:
TRACE (( 1, "wip_bearerStart = WIP_BERR_BAD_HDL" ));
break;
case WIP_BERR_BAD_STATE:
TRACE (( 1, "wip_bearerStart = WIP_BERR_BAD_STATE" ));
break;
case WIP_BERR_DEV:
TRACE (( 1, "wip_bearerStart = WIP_BERR_DEV" ));
break;
default:
TRACE (( 1, "wip_bearerStart = UNDEFINED %d",sResult ));
break;
}
break;
case WIP_BEV_IP_CONNECTED:
TRACE (( 1, "GPRSHandler WIP_BEV_IP_CONNECTED"));
TCPChanel = wip_TCPClientCreate(
"IP",
Port,
TCPwipHandler,
NULL);
if(TCPChanel == NULL)
{
TRACE((1,"wip_TCPClientCreateOpts = ERROR"));
}
else
{
TRACE((1,"wip_TCPClientCreateOpts = SUCCESS"));
}
break;
case WIP_BEV_IP_DISCONNECTED:
TRACE (( 1, "GPRSHandler WIP_BEV_IP_DISCONNECTED"));
wip_close(TCPChanel);
sResult = wip_bearerStart(Bearer);
switch(sResult)
{
case 0:
TRACE (( 1, "wip_bearerStart = SUCCESS" ));
break;
case WIP_BERR_OK_INPROGRESS:
TRACE (( 1, "wip_bearerStart = WIP_BERR_OK_INPROGRESS" ));
break;
case WIP_BERR_BAD_HDL:
TRACE (( 1, "wip_bearerStart = WIP_BERR_BAD_HDL" ));
break;
case WIP_BERR_BAD_STATE:
TRACE (( 1, "wip_bearerStart = WIP_BERR_BAD_STATE" ));
wip_bearerStop(Bearer);
break;
case WIP_BERR_DEV:
TRACE (( 1, "wip_bearerStart = WIP_BERR_DEV" ));
break;
default:
TRACE (( 1, "wip_bearerStart = UNDEFINED %d",sResult ));
break;
}
break;
case WIP_BEV_STOPPED:
TRACE (( 1, "GPRSHandler WIP_BEV_STOPPED"));
wip_bearerClose(Bearer);
sResult = wip_bearerStart(Bearer);
switch(sResult)
{
case 0:
TRACE (( 1, "wip_bearerStart = SUCCESS" ));
break;
case WIP_BERR_OK_INPROGRESS:
TRACE (( 1, "wip_bearerStart = WIP_BERR_OK_INPROGRESS" ));
break;
case WIP_BERR_BAD_HDL:
TRACE (( 1, "wip_bearerStart = WIP_BERR_BAD_HDL" ));
break;
case WIP_BERR_BAD_STATE:
TRACE (( 1, "wip_bearerStart = WIP_BERR_BAD_STATE" ));
wip_bearerStop(Bearer);
break;
case WIP_BERR_DEV:
TRACE (( 1, "wip_bearerStart = WIP_BERR_DEV" ));
break;
default:
TRACE (( 1, "wip_bearerStart = UNDEFINED %d",sResult ));
break;
}
break;
default:
TRACE (( 1, "GPRSHandler = UNDEFINED %d",event));
break;
}
TRACE((1,"[EXIT] GPRSHandler"));
return;
}
void TCPwipHandler( wip_event_t *ev, void *context)
{
u16 i;
s32 sResult;
u32 a1,a2;
switch(ev->kind)
{
case WIP_CEV_ERROR:
TRACE (( 1, "TCPwipHandler WIP_CEV_ERROR = %d",ev->content.error.errnum));
wip_close(TCPChanel);
TCPChanel = wip_TCPClientCreate(
"IP",
Port,
TCPwipHandler,
NULL);
if(TCPChanel == NULL)
{
TRACE((1,"wip_TCPClientCreateOpts = ERROR"));
}
else
{
TRACE((1,"wip_TCPClientCreateOpts = SUCCESS"));
}
break;
case WIP_CEV_OPEN:
TRACE (( 1, "TCPwipHandler WIP_CEV_OPEN"));
break;
case WIP_CEV_PEER_CLOSE:
TRACE (( 1, "TCPwipHandler WIP_CEV_PEER_CLOSE"));
wip_close(TCPChanel);
TCPChanel = wip_TCPClientCreate(
"IP",
Port,
TCPwipHandler,
NULL);
if(TCPChanel == NULL)
{
TRACE((1,"wip_TCPClientCreateOpts = ERROR"));
}
else
{
TRACE((1,"wip_TCPClientCreateOpts = SUCCESS"));
}
break;
case WIP_CEV_READ:
TRACE (( 1, "[SOCKET] WIP_CEV_READ = %d",ev->content.read.readable));
break;
case WIP_CEV_WRITE:
TRACE (( 1, "[SOCKET] WIP_CEV_WRITE = %d",ev->content.write.writable));
break;
case WIP_CEV_DONE:
TRACE (( 1, "[SOCKET] WIP_CEV_DONE = %d",ev->content.done.result));
break;
default:
TRACE (( 1, "[SOCKET] UNDEFINED_CEV"));
break;
}
return;
}