I’m trying to set up a GPRS connection so I can make HTTP requests. I’m using WIP 5.42, FW 7.46 and Dev Studio 2.1.1
The bearer isn’t started until now
Here is a snippet of my code:
void BearHandler(wip_bearer_t Br_Id, s8 Event, void *context) {
s8 close;
switch(Event){
case WIP_BEV_CONN_FAILED:
TRACE((1,"Bear conn failed"));
break;
case WIP_BEV_IP_DISCONNECTED:
TRACE((1,"IP communication terminated"));
break;
case WIP_BEV_IP_CONNECTED:
TRACE((1,"Bear ip connected"));
break;
case WIP_BEV_STOPPED:
TRACE((1,"Bear close, stopped"));
close = wip_bearerClose (Br_Id);
switch(close){
case WIP_BERR_BAD_STATE:
TRACE((1,"Bad state"));
break;
case WIP_BERR_BAD_HDL:
TRACE((1,"bad handle"));
break;
}
break;
case WIP_BERR_GPRS_FAILED:
TRACE((1,"GPRS failed"));
break;
case WIP_BERR_PIN_NOT_READY:
TRACE((1,"Pin error"));
break;
default:
TRACE((1,"Default: error: %d", Event));
break;
}
}
static void open_and_start_bearer(void) {
wip_bearer_t Br_ID;
TRACE((1, "wip_bearerOpen()"));
if(wip_bearerOpen( &Br_ID, "GPRS", BearHandler, NULL) != 0) TRACE((1, "wip_bearerOpen() : Fail"));
else{
TRACE((1, "wip_bearerSetOpts()"));
if(wip_bearerSetOpts( Br_ID, WIP_BOPT_GPRS_APN, GPRS_APN,
WIP_BOPT_LOGIN, GPRS_USER,
WIP_BOPT_PASSWORD, GPRS_PASSWORD,
WIP_BOPT_END) != 0) {
TRACE((1, "wip_bearerSetOpts : Fail"));
wip_bearerClose(Br_ID);
}
else{
if(wip_bearerStart(Br_ID) != 0){
TRACE((1, "wip_bearerStart : Fail"));
TRACE((1, "ERROR CODE: %d", wip_bearerStart(Br_ID)));
}
}
}
}
static void wip_init( void) {
u8 wRet;
wip_logEvents = TRUE;
wRet = wip_netInitOpts(WIP_NET_OPT_IP_FORWARD,FALSE,WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_TRACE,WIP_NET_OPT_END);
if(wRet != 0){
TRACE (( 1, "wip_netInit error" ));
}
else{
TRACE (( 1, "wip_netInit :)" ));
adl_atSendResponse ( ADL_AT_UNS, "wip_eventInit :)\r\n");
open_and_start_bearer();
}
}
This is the feedback from the traces
2012/02/29;14:26:30:842;001;ADL;1;GPRS_Handler
2012/02/29;14:26:30:846;001;ADL;1;GPRS ME Attached
2012/02/29;14:26:32:007;001;ATI;1;<CR><LF>OK<CR><LF>
2012/02/29;14:26:32:009;001;ATI;1;0d 0a 4f 4b 0d 0a
2012/02/29;14:26:32:012;001;ATI;1;AT+CGPADDR=1<CR>
2012/02/29;14:26:32:015;001;ATI;1;41 54 2b 43 47 50 41 44 44 52 3d 31 1a
2012/02/29;14:26:32:018;001;ATI;1;<CR><LF>+CGPADDR: 1,"62.133.83.36"<CR><LF>
2012/02/29;14:26:32:021;001;ATI;1;0d 0a 2b 43 47 50 41 44 44 52 3a 20 31 2c 22 36 32 2e 31 33 33 2e 38 33 2e 33 36 22 0d 0a
2012/02/29;14:26:32:028;001;ATI;1;<CR><LF>OK<CR><LF>
2012/02/29;14:26:32:030;001;ATI;1;0d 0a 4f 4b 0d 0a
2012/02/29;14:26:32:035;001;ADL;1;GPRS_Handler
2012/02/29;14:26:32:038;001;ADL;1;GPRS Event activated
2012/02/29;14:26:32:044;001;ADL;20;[ADL] tmr subs ; id 1 ; hdlr 0026A86D ; val 5 ; cycl 2
2012/02/29;14:26:32:047;001;ADL;1;wip_netInit :)
2012/02/29;14:26:32:050;001;ADL;1;wip_bearerOpen()
2012/02/29;14:26:32:054;001;ADL;1;[GPRS]: open: -> DISCONNECTED
2012/02/29;14:26:32:060;001;ADL;1;wip_bearerSetOpts()
2012/02/29;14:26:32:064;001;ADL;31;[ADL] Gprs subs 0026C869 : 0
2012/02/29;14:26:32:068;001;ADL;16;[ADL port] IsAvailable(80) : 1
2012/02/29;14:26:32:073;001;ATI;1;AT+CGDCONT=1,"IP","m2mc.webtrial",,0,0<CR>
2012/02/29;14:26:32:080;001;ATI;1;41 54 2b 43 47 44 43 4f 4e 54 3d 31 2c 22 49 50 22 2c 22 6d 32 6d 63 2e 77 65 62 74 72 69 61 6c 22 2c 2c 30 2c 30 1a
2012/02/29;14:26:32:087;001;ATI;1;<CR><LF>OK<CR><LF>
2012/02/29;14:26:32:089;001;ATI;1;0d 0a 4f 4b 0d 0a
2012/02/29;14:26:32:095;001;ADL;31;[ADL] Gprs setup 1 : 0
2012/02/29;14:26:32:099;001;ADL;1;[GPRS]: start: -> CONNECTING
2012/02/29;14:26:32:103;001;ADL;1;wip_bearerStart : Fail
2012/02/29;14:26:32:108;001;ADL;1;ERROR CODE: -28
2012/02/29;14:26:32:115;001;ADL;1;[GPRS]: GPRS CTX (cid=1) found
2012/02/29;14:26:32:120;001;ADL;1;[GPRS]: GPRS EVENT ACTIVATE OK (cid=1)
2012/02/29;14:26:32:129;001;ADL;1;[GPRS]: cannot get GPRS information: GPRS deactivate
2012/02/29;14:26:32:134;001;ADL;16;[ADL port] IsAvailable(80) : 1
2012/02/29;14:26:32:138;001;ADL;1;GPRS_Handler
2012/02/29;14:26:32:142;001;ADL;1;GPRS Setup error 26
2012/02/29;14:26:32:146;001;ADL;16;[ADL port] IsAvailable(80) : 1
2012/02/29;14:26:32:148;001;ATI;1;AT+CGACT=1,1<CR>
2012/02/29;14:26:32:151;001;ATI;1;41 54 2b 43 47 41 43 54 3d 31 2c 31 1a
2012/02/29;14:26:32:157;001;ATI;1;<CR><LF>OK<CR><LF>
2012/02/29;14:26:32:159;001;ATI;1;0d 0a 4f 4b 0d 0a
2012/02/29;14:26:32:166;001;ADL;1;[GPRS]: GPRS CTX (cid=1) found
2012/02/29;14:26:32:172;001;ADL;1;[GPRS]: GPRS EVENT SETUP/ACTIVATE KO (cid=1): -> DISCONNECTED
2012/02/29;14:26:32:178;001;ADL;1;[WIP] No more ctx, call adl_gprsUnsubscribe()
2012/02/29;14:26:32:182;001;ADL;31;[ADL] GPRS unsubs 0026C869 : 0
2012/02/29;14:26:32:186;001;ADL;1;Bear conn failed
2012/02/29;14:26:32:188;001;ATI;1;AT+CGPADDR=1<CR>
2012/02/29;14:26:32:191;001;ATI;1;41 54 2b 43 47 50 41 44 44 52 3d 31 1a
2012/02/29;14:26:32:194;001;ATI;1;<CR><LF>+CGPADDR: 1,<CR><LF>
2012/02/29;14:26:32:196;001;ATI;1;0d 0a 2b 43 47 50 41 44 44 52 3a 20 31 2c 0d 0a
2012/02/29;14:26:32:202;001;ATI;1;<CR><LF>OK<CR><LF>
2012/02/29;14:26:32:205;001;ATI;1;0d 0a 4f 4b 0d 0a
2012/02/29;14:26:32:211;001;ADL;1;GPRS_Handler
Is it a problem with the settings for the connection?
I get error -28 which seems weird because the bearer never started.
Also after the connection failed it calls the GPRS handler again with ADL_GPRS_EVENT_ACTIVATE_OK.