TCP Data portion of the driver doesn't work

Oct 9, 2012 at 3:45 PM
I have found a bug in the Cellular Radio Module driver for TCP
this code will never send the data portion

public ReturnedState SendTcpData(string data)
        {
            SendATCommand("AT+CIPSEND");
            Thread.Sleep(1000);
            return SendATCommand(data + (char)26);
 
        }

because
public ReturnedState SendATCommand(string atCommand)
        {
            // Check if module is busy
            if (isModuleBusy) return ReturnedState.ModuleBusy;
 
            // Append carriage return
            if (atCommand.IndexOf("\r") < 0) atCommand += "\r";
 
            // Check if string is an AT command
            if (atCommand.IndexOf("AT") < 0) return ReturnedState.InvalidCommand;
 
            // Check if module is on
            if (!isPowerOn) return ReturnedState.ModuleIsOff;
 
            // Check if serial line is open
            if (serialLine.IsOpen) serialLine.Write(atCommand);
            else return ReturnedState.Error;
            Thread.Sleep(100);
            DebugPrint("SENT: " + atCommand);
            return ReturnedState.OK;
        }
will generate an error because it is not an AT command and will not send the data.
To fix this i changed the SendTcpData to
public ReturnedState SendTcpData(string data)
        {
            SendATCommand("AT+CIPSEND");
            Thread.Sleep(1000);
            if (serialLine.IsOpen) serialLine.Write(data + (char)26);
            else return ReturnedState.Error;
            Thread.Sleep(3000);
            DebugPrint("SENT: " + data);
            return ReturnedState.OK;
        }

It works with this.

it would be better to split the AT command and the data so the data chunks could be written directly to the module and not the whole data set as this can result im memory errors.