AT+CIPSEND unexpected response



Hello all,
it has been a few months I’m working with SIM800L attached to my microprocessor, an MSP430F5529. I’ve managed to implement those (let me say) awful AT commands by using a simple logic: when I execute a command I always wait a response and check whether the response is valid or not (using a strcmp).
The code I made is simple and works well: I reset the modem, establish a TCP connection to a remote MQTT broker, send an MQTT CONNECT, PUBLISH and DISCONNECT packets, and close the TCP connection. I do this every 5 seconds and I’m able to listen packets coming from the broker.

However there’s an issue I can’t understand: after a few cycles the AT+CIPSEND command, that I use to send TCP data, stops giving me the response “SEND OK” and just give me “OK”. This way my firmware interprets the string as an unexpected response and halts the execution.

For debug purposes I created a string made of the latest AT commands executed and related responses and I print it when an error occurs. In this case that string has the value:


Is there a reason why am I receiving that “OK” instead of “SEND OK”? What’s the best way to implement AT commands on a microprocessor?