Hi all,
First of all, I must say that I am newbie on Open AT and embedded modules. Please accept my apologies if I ask stupid questions.
I am using Q2687H embedded modules and developing an application to connect remote server. I have some troubles with GPRS connection part of my code. All the settings are OK for APN and the other initial procedures (I think so ). When I download the app to the module to test if it works I got a problem. It gives me WIP_BEV_CONN_FAILED error first but when I remove and insert again the sim card it connects to GPRS.
You can see the related code snippets below:
Main:
void adl_main(adl_InitType_e InitType)
{
switch (InitType)
{
case ADL_INIT_POWER_ON:
break;
case ADL_INIT_REBOOT_FROM_EXCEPTION:
ATRSP("\r\nModem Start After Exception\r\n");
break;
case ADL_INIT_DOWNLOAD_SUCCESS:
ATRSP("\r\nModem Start After DOTA OK\r\n");
break;
case ADL_INIT_DOWNLOAD_ERROR:
ATRSP("\r\nModem Start After DOTA ERROR\r\n");
break;
case ADL_INIT_RTC:
ATRSP("\r\nModem Start After RTC\r\n");
break;
}
UART2_Enable();
GPIO_Enable();
adl_simSubscribe(Sim_Handler, (ascii *) SimPin);
}
Sim_Handler:
void Sim_Handler(u8 Event)
{
switch (Event)
{
case ADL_SIM_EVENT_FULL_INIT:
TRACE((1, "ADL_SIM_EVENT_FULL_INIT"));
GPRS_Enable();
break;
case ADL_SIM_EVENT_PIN_WAIT:
TRACE((1, "ADL_SIM_EVENT_PIN_WAIT"));
break;
case ADL_SIM_EVENT_PIN_OK:
TRACE((1, "ADL_SIM_EVENT_PIN_OK"));
break;
case ADL_SIM_EVENT_INSERTED:
TRACE((1, "ADL_SIM_EVENT_INSERTED"));
break;
case ADL_SIM_EVENT_REMOVED:
TRACE((1, "ADL_SIM_EVENT_REMOVED"));
break;
case ADL_SIM_EVENT_PIN_ERROR:
TRACE((1, "ADL_SIM_EVENT_PIN_ERROR"));
break;
case ADL_SIM_EVENT_PUK_WAIT:
TRACE((1, "ADL_SIM_EVENT_PUK_WAIT"));
break;
case ADL_SIM_EVENT_PUK_ERROR:
TRACE((1, "ADL_SIM_EVENT_PUK_ERROR"));
break;
case ADL_SIM_EVENT_FAILURE:
TRACE((1, "ADL_SIM_EVENT_FAILURE"));
break;
case ADL_SIM_EVENT_NET_LOCK:
TRACE((1, "ADL_SIM_EVENT_NET_LOCK"));
break;
case ADL_SIM_EVENT_LAST:
TRACE((1, "ADL_SIM_EVENT_LAST"));
break;
default:
TRACE((1, "default..."));
break;
}
}
GPRS_Enable:
void GPRS_Enable(void)
{
TRACE (( 1, "GPRS_Enable" ));
gprsIsValid = FALSE;
gprsLed(FALSE);
if (adl_gprsSubscribe(gprs_Handler) == OK)
{
s8RetVal = wip_bearerClose(gprs_bearer);
s8RetVal = wip_netInit();
if (s8RetVal < 0)
TRACE((10, "ADL_SIM_EVENT_FULL_INIT : Bearer Close %d", s8RetVal));
else
TRACE((10, "ADL_SIM_EVENT_FULL_INIT : Bearer Closed"));
s8RetVal = wip_bearerOpen(&gprs_bearer, "GPRS", gprsBearerHandler, NULL);
if (s8RetVal < 0 && s8RetVal != -27)
TRACE((10, "ADL_SIM_EVENT_FULL_INIT : Bearer Open %d", s8RetVal));
else
s8RetVal = wip_bearerSetOpts(gprs_bearer, WIP_BOPT_GPRS_CID, 1, WIP_BOPT_GPRS_APN, APN_Name, WIP_BOPT_LOGIN, APN_Username, WIP_BOPT_PASSWORD, APN_Password, WIP_BOPT_END);
if (s8RetVal < 0)
TRACE((10, "ADL_SIM_EVENT_FULL_INIT : Bearer SetOpts %d", s8RetVal));
else
s8RetVal = wip_bearerStart(gprs_bearer);
if (s8RetVal < 0)
TRACE((10, "ADL_SIM_EVENT_FULL_INIT : Bearer Start %d", s8RetVal));
else
TRACE((10, "ADL_SIM_EVENT_FULL_INIT : Bearer Started %d", s8RetVal));
wm_sprintf(rsp, "status:%d\r\n", s8RetVal);
ATRSP(rsp);
}
else
{
ATRSP("\r\nInit error\r\n");
TRACE((1, "GPRS init error"));
}
}
gprsBearerHandler:
void gprsBearerHandler(wip_bearer_t br, s8 event, void *ctx)
{
ascii RspStr[128];
ascii dns1Str[16], dns2Str[16];
wip_in_addr_t ip, dns1, dns2;
s8 errcode = 0;
u8 gprsCID;
if (br != gprs_bearer)
return;
switch (event)
{
case WIP_BEV_IP_CONNECTED:
TRACE((10, "gprs_bearer: WIP_BEV_IP_CONNECTED"));
//Get Bearer Info
s8RetVal = wip_bearerGetOpts(br, WIP_BOPT_IP_ADDR, &ip, WIP_BOPT_IP_DNS1, &dns1, WIP_BOPT_IP_DNS2, &dns2, WIP_BOPT_END);
if (s8RetVal < 0)
TRACE((10, "WIP_BEV_IP_CONNECTED : GetOpts %d", s8RetVal));
wip_inet_ntoa(ip, ipStr, sizeof(ipStr));
wip_inet_ntoa(dns1, dns1Str, sizeof(dns1Str));
wip_inet_ntoa(dns2, dns2Str, sizeof(dns2Str));
wm_sprintf(RspStr, "\r\nGPRS: CONNECTED IP=%s DNS1=%s DNS2=%s\r\n",ipStr, dns1Str, dns2Str);
gprsIsValid = TRUE;
gprsLed(TRUE);
TRACE((10, "WIP_BEV_IP_CONNECTED"));
ATRSP(RspStr);
break;
case WIP_BEV_IP_DISCONNECTED:
TRACE((10, "gprs_bearer: WIP_BEV_IP_DISCONNECTED"));
gprsIsValid = FALSE;
break;
case WIP_BEV_STOPPED:
TRACE((10, "gprs_bearer: WIP_BEV_STOPPED"));
s8RetVal = wip_bearerClose(br);
if (s8RetVal < 0)
TRACE((12, "WIP_BEV_STOPPED : Stop %d", s8RetVal));
gprsIsValid = FALSE;
gprs_bearer = NULL;
break;
case WIP_BEV_CONN_FAILED:
TRACE((10, "gprs_bearer: WIP_BEV_CONN_FAILED"));
ATRSP("\r\n+WIPSTART: FAILED\r\n");
s8RetVal = wip_bearerGetOpts(br, WIP_BOPT_GPRS_CID, &gprsCID, WIP_BOPT_ERROR, &errcode, WIP_BOPT_END);
if (s8RetVal < 0)
TRACE((10, "WIP_BEV_CONN_FAILED : GetOpts %d", s8RetVal));
wm_sprintf(RspStr, "CID:%d\r\n", gprsCID);
ATRSP(RspStr);
wm_sprintf(RspStr, "Error Code:%d\r\n", errcode);
ATRSP(RspStr);
TRACE((10, "gprs_bearer: CID: %d Error Code: %d", gprsCID, errcode));
wip_bearerClose(br);
if (s8RetVal < 0)
TRACE((10, "WIP_BEV_CONN_FAILED : Close %d", s8RetVal));
gprsIsValid = FALSE;
gprs_bearer = NULL;
break;
default:
TRACE((10, "gprs_bearer: DEFAULT"));
wm_sprintf(RspStr, "wip_bearer Code: %d\r\n", event);
ATRSP(RspStr);
break;
}
}
Edit: Iâve added the Trace logs as following;
Timestamp | Id | Level | Message | |
---|---|---|---|---|
2019/01/15;14:15:59:111 - 001 | ADL | 1 | Binary header at 00260000 | |
2019/01/15;14:15:59:111 - 002 | ADL | 1 | Letâs Begin | |
2019/01/15;14:15:59:111 - 003 | ADL | 13 | UART2 FCM Available | |
2019/01/15;14:15:59:127 - 001 | ADL | 13 | FCM2 HANDLE RESULT: 0 | |
2019/01/15;14:15:59:127 - 002 | ADL | 1 | LED GPIO Subscribe OK | |
2019/01/15;14:15:59:127 - 003 | ADL | 1 | GPIO OK | |
2019/01/15;14:15:59:127 - 004 | ADL | 1 | ADL_SIM_EVENT_INSERTED | |
2019/01/15;14:15:59:127 - 005 | ADL | 13 | UART2 is in DATA mode | |
2019/01/15;14:15:59:860 - 001 | ADL | 1 | ADL_SIM_EVENT_PIN_OK | |
2019/01/15;14:16:04:291 - 001 | ADL | 1 | ADL_SIM_EVENT_FULL_INIT | |
2019/01/15;14:16:04:291 - 002 | ADL | 1 | GPRS_Enable | |
2019/01/15;14:16:04:291 - 003 | ADL | 10 | ADL_SIM_EVENT_FULL_INIT : Bearer Closed | |
2019/01/15;14:16:04:291 - 004 | ADL | 10 | ADL_SIM_EVENT_FULL_INIT : Bearer Start -27 | |
2019/01/15;14:16:04:291 - 005 | ADL | 12 | gprs_handler: Embedded : Event receive 25 CID: 1 | |
2019/01/15;14:16:04:306 - 001 | ADL | 12 | gprs_handler: ADL_GPRS_EVENT_SETUP_OK | |
2019/01/15;14:16:04:306 - 002 | ADL | 12 | gprs_handler: Embedded : Event receive 25 CID: 1 | |
2019/01/15;14:16:04:306 - 004 | ADL | 12 | gprs_handler: Embedded : Event receive 23 CID: 1 | |
2019/01/15;14:16:04:306 - 005 | ADL | 12 | gprs_handler: ADL_GPRS_EVENT_ACTIVATE_KO : CID 1 | |
2019/01/15;14:16:04:337 - 001 | ADL | 10 | gprs_bearer: WIP_BEV_CONN_FAILED | |
2019/01/15;14:16:04:337 - 002 | ADL | 10 | gprs_bearer: CID: 1 Error Code: -36 | |
2019/01/15;14:16:18:268 - 001 | ADL | 1 | ADL_SIM_EVENT_REMOVED | |
2019/01/15;14:16:19:750 - 001 | ADL | 1 | ADL_SIM_EVENT_INSERTED | |
2019/01/15;14:16:20:655 - 001 | ADL | 1 | ADL_SIM_EVENT_PIN_OK | |
2019/01/15;14:16:25:257 - 001 | ADL | 1 | ADL_SIM_EVENT_FULL_INIT | |
2019/01/15;14:16:25:273 - 001 | ADL | 1 | GPRS_Enable | |
2019/01/15;14:16:25:273 - 002 | ADL | 10 | ADL_SIM_EVENT_FULL_INIT : Bearer Closed | |
2019/01/15;14:16:25:273 - 003 | ADL | 10 | ADL_SIM_EVENT_FULL_INIT : Bearer Start -27 | |
2019/01/15;14:16:25:273 - 004 | ADL | 12 | gprs_handler: Embedded : Event receive 25 CID: 1 | |
2019/01/15;14:16:25:273 - 005 | ADL | 12 | gprs_handler: ADL_GPRS_EVENT_SETUP_OK | |
2019/01/15;14:16:25:288 - 001 | ADL | 12 | gprs_handler: Embedded : Event receive 25 CID: 1 | |
2019/01/15;14:16:25:288 - 002 | ADL | 12 | gprs_handler: ADL_GPRS_EVENT_SETUP_OK | |
2019/01/15;14:16:26:255 - 001 | ADL | 12 | gprs_handler: Embedded : Event receive 27 CID: 1 | |
2019/01/15;14:16:26:255 - 002 | ADL | 12 | gprs_handler: ADL_GPRS_EVENT_ME_ATTACH | |
2019/01/15;14:16:26:271 - 001 | ADL | 12 | gprs_handler: Embedded : Event receive 27 CID: 1 | |
2019/01/15;14:16:26:271 - 002 | ADL | 12 | gprs_handler: ADL_GPRS_EVENT_ME_ATTACH | |
2019/01/15;14:16:27:737 - 001 | ADL | 12 | gprs_handler: Embedded : Event receive 16 CID: 1 | |
2019/01/15;14:16:27:737 - 002 | ADL | 12 | gprs_handler: ADL_GPRS_EVENT_ANSWER_OK_FROM_EXT | |
2019/01/15;14:16:27:753 - 001 | ADL | 12 | gprs_handler: Embedded : Event receive 16 CID: 1 | |
2019/01/15;14:16:27:753 - 002 | ADL | 12 | gprs_handler: ADL_GPRS_EVENT_ANSWER_OK_FROM_EXT | |
2019/01/15;14:16:27:769 - 001 | ADL | 12 | gprs_handler: Embedded : Event receive 16 CID: 1 | |
2019/01/15;14:16:27:769 - 002 | ADL | 12 | gprs_handler: ADL_GPRS_EVENT_ANSWER_OK_FROM_EXT | |
2019/01/15;14:16:27:769 - 003 | ADL | 10 | gprs_bearer: WIP_BEV_IP_CONNECTED | |
2019/01/15;14:16:27:769 - 004 | ADL | 10 | WIP_BEV_IP_CONNECTED |
Could anyone give me a suggestion about the problem?
Note: ATRSP is a simple function to send string to TMConsole.
Thanks in advance.
Best regards
MĂ.