At_Parser stops working after undetermined amount of time

So right off the bat, I’m aware that calling the At_Parser function in code is probably not advised for various reasons. Having said that I thought I would ask for help anyway.

I have modified the downlink callback to call the At_Parser function if an AT command is send as a downlink (I can send the series of characters “AT+CLASS=?” for example and it will run that AT command).

/**
 * @brief Handler for downlink AT commands
 *
 * @param data
 */
void handleDownlinkATCommand(const SERVICE_LORA_RECEIVE_T *data)
{
	if (strstr((char *)data->Buffer, "ATZ") != NULL)
	{
		api.system.reboot();
	}
	else if (strstr((char *)data->Buffer, "AT+") != NULL || strstr((char *)data->Buffer, "ATC+") != NULL)
	{
		uint8_t nRet = At_Parser(SERIAL_UART1, (char *)data->Buffer, data->BufferSize);
		CHARBUFFERLOG("AT", data->Buffer, data->BufferSize);
		MYLOG("AT", "Buffer Size: %d, nRet: %d", data->BufferSize, nRet);
	}
}

For the first ~30min after the device is turned on this works fine, but after that I get an AT_PARAM_ERROR no matter the command. If I run AT commands locally (over serial) I do not have an issue. I know that the command and command length I am inputting into the function are correct.

I have tried to look through function code and believe it is occurring at a number of places where the nRet value is set to AT_PARAM_ERROR, however I’m unsure why the exact same commands work over serial.

Any insight?

AT Parser is not for API call. No guarantee that it works like you use it. It should only be invoked when data is coming in on the serial port.

Why do you need to do it like this? For every AT command you have corresponding API calls. Instead of sending AT commands in your downlinks, it would be better to send (shorter) byte buffers with a marker for the command and then the data you want to set with that command.

I agree that is the better way to handle it. I was attempting this method as with the method you suggested, you would have to write a case for every single AT and ATC command and its corresponding API call. Considering this functionality was designed to be used sparingly and as a ‘just in case’, I figured I would try the path of least resistance.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.