Hello.
I have q2686. I write application which sends some data to server every 5 minutes, but for some reason connection was broken by mobile operator every ~8 hours. I cannot reconnect to GPRS. I spent 2 days and I cant figure it out…
Here is my code: (I delete http procedures)
#include "adl_global.h"
#include "wip.h"
s8 global_event;
/* bearer handle */
wip_bearer_t myBearer;
/* bearer events handler */
void myHandler( wip_bearer_t br, s8 event, void *context)
{
global_event = event;
switch( event) {
case WIP_BEV_IP_CONNECTED:
/*IP connectivity we can start IP application from here*/
adl_atSendResponse ( ADL_AT_UNS, "\r\nGPRS on.\r\n" );
break;
case WIP_BEV_STOPPED:
/*IP connectivity we can start IP application from here*/
adl_atSendResponse ( ADL_AT_UNS, "\r\n bev stopped.\r\n" );
wip_bearerClose( myBearer);
break;
case WIP_BEV_IP_DISCONNECTED:
/*stop IP application*/
adl_atSendResponse ( ADL_AT_UNS, "\r\nGPRS stop.\r\n" );
wip_bearerStop(myBearer);
break;
/* other events: */
adl_atSendResponse ( ADL_AT_UNS, "\r\nOther.\r\n" );
default:
/*cannot start bearer: report error to higher levels*/
adl_atSendResponse ( ADL_AT_UNS, "\r\nCannot start bearer.\r\n" );
break;
}
}
/* initialize and start GPRS bearer */
bool myConnectToGPRS( void)
{
if(wip_netInit() < 0)
{
adl_atSendResponse ( ADL_AT_UNS, "\r\nCannot net init.\r\n" );
return FALSE;
}
adl_atSendResponse ( ADL_AT_UNS, "\r\nConnecting....\r\n" );
/* open bearer and install our event handler */
if( wip_bearerOpen( &myBearer, "GPRS", myHandler, NULL) != 0) {
/* cannot open bearer */
adl_atSendResponse ( ADL_AT_UNS, "\r\nCannot open bearer.1\r\n" );
return FALSE;
}
/* configure GPRS interface */
if( wip_bearerSetOpts ( myBearer,
WIP_BOPT_GPRS_APN, "internet",
WIP_BOPT_LOGIN, "mobitel",
WIP_BOPT_PASSWORD, "internet",
WIP_BOPT_END) != 0) {
/* cannot configure bearer */
adl_atSendResponse ( ADL_AT_UNS, "\r\nCannot configure bearer.\r\n" );
return FALSE;
}
/* start connection */
if( wip_bearerStart( myBearer) != 0) {
/* cannot start bearer */
adl_atSendResponse ( ADL_AT_UNS, "\r\nCannot start bearer.1\r\n" );
return FALSE;
}
/* connection status will be reported to the event handler */
return TRUE;
}
//gprs
void GPRSHandler( u8 ID )
{
if (global_event != WIP_BEV_IP_CONNECTED) {
myConnectToGPRS();
}
}
/***************************************************************************/
/* Function : adl_main */
/*-------------------------------------------------------------------------*/
/* Object : Customer application initialisation */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilisation */
/*--------------------+---+---+---+----------------------------------------*/
/* InitType | | | | Application start mode reason */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void adl_main ( adl_InitType_e InitType )
{
TRACE (( 1, "Embedded : Appli Init" ));
global_event = WIP_BEV_IP_DISCONNECTED;
/* Set 1s cyclic timer */
adl_tmrSubscribe ( TRUE, 200, ADL_TMR_TYPE_100MS, GPRSHandler );
}
and here is resposne:
+WIND: 13
Connecting....
Cannot start bearer.1 (I do not know why... caused by wip_netInit() )
GPRS on.
GPRS stop.
bev stopped.
Cannot net init.
Cannot net init.
So… How to reconnect to GPRS. Reset module is not right answer (but works).
I simulate problem which appears every ~8 hours with reconnecting SIM card.
Thanks for answers