Dear Team,
I have written the below code to get time from the network. but I am not getting any value from the module please validate my code and tell me what mistake I did.
/******************************************************************************
- Function: ATResponse_CLK_Handler
- Description:
-
This function is used to deal with the response of the AT+CSQ command.
- Parameters:
-
line:
-
[in]The address of the string.
-
len:
-
[in]The length of the string.
-
userdata:
-
[out]Used to transfer the customer's parameter.
- Return:
-
RIL_ATRSP_SUCCESS, indicates AT executed successfully..
-
RIL_ATRSP_FAILED, indicates AT executed failed.
-
RIL_ATRSP_CONTINUE,indicates continue to wait for the response
-
of the AT command.
- Notes:
-
1.Can't send any new AT commands in this function.
-
2.RIL handle the AT response line by line, so this function may
-
be called multiple times.
****************************************************************************/
static s32 ATResponse_CCLK_Handler(char line, u32 len, void userdata)
{
ST_CCLK_Reponse CCLK_Reponse = (ST_CCLK_Reponse)userdata;
char *head = Ql_RIL_FindString(line, len, "+CCLK:"); //continue wait
if(head)
{
Ql_sscanf(head,"%*[^ ]%s,%s,%[^\r\n]",&CCLK_Reponse->Date,&CCLK_Reponse->Time);
return RIL_ATRSP_CONTINUE;
}
head = Ql_RIL_FindLine(line, len, "OK"); // find <CR><LF>OK<CR><LF>, <CR>OK<CR>£¬<LF>OK<LF>
if(head)
{
return RIL_ATRSP_SUCCESS;
}
head = Ql_RIL_FindLine(line, len, "ERROR");// find <CR><LF>ERROR<CR><LF>, <CR>ERROR<CR>£¬<LF>ERROR<LF>
if(head)
{
return RIL_ATRSP_FAILED;
}
head = Ql_RIL_FindString(line, len, "+CME ERROR:");//fail
if(head)
{
return RIL_ATRSP_FAILED;
}
return RIL_ATRSP_CONTINUE; //continue wait
}
/******************************************************************************
- Function: RIL_NW_GetNetworkTime
- Description:
-
This function gets the network time form the GSM.
- Parameters:
-
Date:
-
[out] output buffer for the Date.
-
Time:
-
[out] output buffer for the Time.
- Return:
-
RIL_AT_SUCCESS,send AT successfully.
-
RIL_AT_FAILED, send AT failed.
-
RIL_AT_TIMEOUT,send AT timeout.
-
RIL_AT_BUSY, sending AT.
-
RIL_AT_INVALID_PARAM, invalid input parameter.
-
RIL_AT_UNINITIALIZED, RIL is not ready, need to wait for MSG_ID_RIL_READY
-
and then call Ql_RIL_Initialize to initialize RIL.
***************************************************************************/
s32 RIL_NW_GetNetworkTime(char Date, char Time)
{
s32 retRes = 0;
char strAT[] = “AT+CCLK?\0”;
ST_CCLK_Reponse pCCLK_Reponse;
Ql_memset(&pCCLK_Reponse,0, sizeof(pCCLK_Reponse));
retRes = Ql_RIL_SendATCmd(strAT,Ql_strlen(strAT), ATResponse_CCLK_Handler,(void)&pCCLK_Reponse,0);
if(RIL_AT_SUCCESS == retRes)
{
strcpy(Date , pCCLK_Reponse.Date);
strcpy(Time , pCCLK_Reponse.Time);
//*Date = pCCLK_Reponse.Date;
//*Time = pCCLK_Reponse.Time;
}
return retRes;
}