I am using OPEN CPU API RIL_QSSL_CERTIFICATE_WRITE_FILE() to write a certificate. however the problem i am facing is it randomly stucks the M66 though i have watchdog in place it wont reset until i do apower reset. Following is the implementation of the API.
s32 RIL_SSL_QSSLCERTIFICATE_WRITE(u8 timeout)
{
s32 ret = RIL_AT_SUCCESS;
s32 errCode = RIL_AT_FAILED;
char strAT[200];
Ql_memset(strAT, 0, sizeof(strAT));
write_flag= 1;
Ql_sprintf(strAT, "AT+QSECWRITE=\"NVRAM:CA0\",%d,%d\n",CA_CERT_LEN,timeout);
ret = Ql_RIL_SendATCmd(strAT,Ql_strlen(strAT),ATResponse_SSL_handler_CERTIFICATE_WRITE,&errCode,0);
APP_DEBUG("<-- Send AT:%s, ret = %d -->\r\n",strAT, ret);
if (ret != RIL_AT_SUCCESS)
{
if (RIL_AT_FAILED == errCode)
{
return ret;
}
else
{
return errCode;
}
}
Ql_memset(strAT, 0, sizeof(strAT));
write_flag= 2;
Ql_sprintf(strAT, "AT+QSECWRITE=\"NVRAM:CC0\",%d,%d\n",CL_CERT_LEN,timeout);
ret = Ql_RIL_SendATCmd(strAT,Ql_strlen(strAT),ATResponse_SSL_handler_CERTIFICATE_WRITE,&errCode,0);
APP_DEBUG("<-- Send AT:%s, ret = %d -->\r\n",strAT, ret);
if (ret != RIL_AT_SUCCESS)
{
if (RIL_AT_FAILED == errCode)
{
return ret;
}
else
{
return errCode;
}
}
Ql_memset(strAT, 0, sizeof(strAT));
write_flag= 3;
Ql_sprintf(strAT, "AT+QSECWRITE=\"NVRAM:CK0\",%d,%d\n",CK_CERT_LEN,timeout);
ret =Ql_RIL_SendATCmd(strAT,Ql_strlen(strAT),ATResponse_SSL_handler_CERTIFICATE_WRITE,&errCode,0);
APP_DEBUG("<-- Send AT:%s, ret = %d -->\r\n",strAT, ret);
if (ret != RIL_AT_SUCCESS)
{
if (RIL_AT_FAILED == errCode)
{
return ret;
}
else
{
return errCode;
}
}
return RIL_AT_SUCCESS;
}
static s32 ATResponse_SSL_handler_CERTIFICATE_WRITE(char* line, u32 len, void* userdata)
{
char* pHead = NULL;
pHead = Ql_RIL_FindString(line, len, “CONNECT”);
if (pHead)
{
Ql_Sleep(1000);//Do not move
Ql_RIL_WriteDataToCore((u8*)cert, Ql_strlen(cert));
if (write_flag == 1)
{
Ql_RIL_WriteDataToCore((u8*)CA_CERT, CA_CERT_LEN);
}
else if (write_flag == 2)
{
Ql_RIL_WriteDataToCore((u8*)CL_CERT, CL_CERT_LEN);
}
else if (write_flag == 3)
{
Ql_RIL_WriteDataToCore((u8*)CK_CERT, CK_CERT_LEN);
}
return RIL_ATRSP_CONTINUE; // wait for OK
}
pHead = Ql_RIL_FindString(line, len, “OK”);
if (pHead)
{
return RIL_ATRSP_SUCCESS;
}
pHead = Ql_RIL_FindString(line, len, "ERROR");
if (pHead)
{
if (userdata != NULL)
{
*((s32*)userdata) = RIL_AT_FAILED;
}
return RIL_ATRSP_FAILED;
}
pHead = Ql_RIL_FindString(line, len, "+CME ERROR:");
if (pHead)
{
if (userdata != NULL)
{
Ql_sscanf(line, "%*[^: ]: %d[^\r\n]", (s32*)userdata);
}
return RIL_ATRSP_FAILED;
}
return RIL_ATRSP_CONTINUE; // Just wait for the specified results above
}
My observation is it never returns after sending ret=Ql_RIL_SendATCmd(strAT,Ql_strlen(strAT),ATResponse_SSL_handler_CERTIFICATE_WRITE,&errCode,0);
The reason i am suspecting this beacause APP_DEBUG("<-- Send AT:%s, ret = %d -->\r\n",strAT, ret); is never printed on QCOMM. Just before it stucks somewhere. Ideally watchdog should reset the module