When sending "AT+COPS=?" via Ql_RIL_SendATCmd() the response callback seems to not be called

I am trying to send the command AT+COPS=? using the Ql_RIL_SendATCmd().

Here is a snippet:

void getCopsInformation(void)
{
    static char cmd[] = "AT+COPS=?";
   debugPrint("%s:%d\r\n", __func__, __LINE__);  // <<== my own debug that prints on serial
    Ql_RIL_SendATCmd(cmd, strlen(cmd), atCopsResponseHandler, NULL, 1000*60*6);
   debugPrint("%s:%d\r\n", __func__, __LINE__);  // <<== my own debug that prints on serial
}

And the registered callback atCopsResponseHandler just prints on the serial that it has reached that point, and the response.

The command is taking about 3 minutes to be executed, and I am getting a response:

getCOPSInformation:144
+COPS: (2,"","","72404",9),(0,"","","72499",9),(0,"","","72406",9),,(0-4),(0-2)

OK
getCOPSInformation:146

But, as you can see, it is printing my debug messages only around the AT command, but not in the response callback.

If I change the command to be like AT+COPS? then the callback prints fine, and the command executes very fast:

getCOPSInformation:144

atCopsResponseHandler:123

atCopsResponseHandler:127

atCopsResponseHandler:132, line=[+COPS: 0,2,"72404",9

OK
]

atCopsCollectNeighbors:55

atCopsCollectNeighbors:58

atCopsResponseHandler:134

Any idea why in the first command the response callback is not being called?

Update 1: I printed the return code from the Ql_RIL_SendAtCmd() and it is returning -6:

+COPS: (2,"","","72404",9),(0,"","","72499",9),(0,"","","72406",9),,(0-4),(0-2)

OK
getCOPSInformation:145, RETURN=-6

And checking at the header file, the function Ql_RIL_SendAtCmd() has this documentation:

/*
* Return:                                                                                                                                                                                                   
*                RIL_AT_SUCCESS,succeed in executing AT command, and the response is OK.                                                                                                                    
*                RIL_AT_FAILED, fail to execute AT command, or the response is ERROR.                                                                                                                       
*                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.
*/  

Checking these error codes:

RIL_AT_FAILED=-1,
RIL_AT_TIMEOUT=-2,
RIL_AT_BUSY=-3,
RIL_AT_INVALID_PARAM=-4,
RIL_AT_UNINITIALIZED=-5

So, there is no -6 at the documented return codes.

However, checking it at the SDK, there is two definitions of error to be == -6:

QL_RET_ERR_BUSY = -6
RIL_AT_RSPNULL = -6

Update 2: The first time AT+COPS=? is executed, the module takes about 3 ~ 4 minutes to return the response.

After that, the next execution takes less time, maybe from 20 secs ~ 1 minute, and yes, the same issue happens:

getCOPSInformation:142

+COPS: (2,"","","72404",9),(0,"","","72499",9),(0,"","","72406",9),,(0-4),(0-2)

OK
getCOPSInformation:145, RETURN=-6

radioControlDebugEnable:450

hi, cassianocampes
Are there any problems in the above debugging process? Do you need our help or solution?

Hello @herbert.pan-Q ,

I did more tests and up to now, it is still an open issue as I described above.

But, we decided to not use AT+COPS=? command anyway, because it takes time and it could slow down our Application if this command is issued many times in a row.

So, we decided to use the AT+COPS? which provides the current connected Provider/MNO which will be enough for our debugging purposes.

But yet, would be nice if you can take a look at this issue and have a possible solution :slight_smile:

BTW: I am using a BC660K

COPS is not important in our application, if you need to fix PLMN, you can execute the Command