1.参数判定及处理
2.stAT_Tcpip_Paras *tcpipParas = &(g_uCipContexts.nTcpipParas[uMuxIndex]);//获取链接的信息
3. if (AT_CMD_LINE_BUFF_LEN < uLength || tcpipParas->uState != CIP_CONNECTED)//如果长度超过或者状态没连接好,则返回
4. if (!pParam->iExDataLen)判断外部数据长度,首次长度为0,执行at_CmdRespOutputPrompt(pParam->engine);,设置成 > 提示输入,设置成CMD_PARSE_MODE_FIXED,搜索CMD_PARSE_MODE_FIXED,在at_CmdPushData中调用,->at_CmdPushInRawMode等待提供符合长度的数据,UART等待输入。得到符合长度的数据,会将数据添加到cache,调用at_CmdRawFinished,设置成CMD_PARSE_MODE_LINE模式->at_ModuleRunCommandExtra 回到AT_TCPIP_CmdFunc_CIPSEND(???)->
if (uLength == 0)//如果 不带设定的长度,即AT+CIPSEND
{
if (pParam->pExData[pParam->iExDataLen - 1] == 27)
{//输入的是ESC,则取消发送
AT_TC(g_sw_TCPIP, "end with esc, cancel send");
AT_CMD_RETURN(at_CmdRespOK(pParam->engine));
}
else if ((pParam->pExData[pParam->iExDataLen - 1] != 26 || pParam->iExDataLen <= 1) && (!cipATS_setTimer))
{//非正常结束
AT_TC(g_sw_TCPIP, "not end with ctl+z, err happen");
AT_CMD_RETURN(at_CmdRespCmeError(pParam->engine, ERR_AT_CMS_INVALID_LEN));
}
}
else if (uLength != 0 && uLength != pParam->iExDataLen)(????)
{
AT_TC(g_sw_TCPIP, "pParam->iExDataLen=%d,uLength=%d", pParam->iExDataLen, uLength);
AT_CMD_RETURN(at_CmdRespCmeError(pParam->engine, ERR_AT_CMS_INVALID_LEN));
}
if (tcpipParas->uProtocol != CFW_TCPIP_IPPROTO_UDP)
{//如果不是UDP传输,进行send data,UDP传输会调用CFW_TcpipSocketSendto发送数据。
iResult = CFW_TcpipSocketSend(tcpipParas->uSocket, (UINT8 *)pParam->pExData, (UINT16)pParam->iExDataLen - ((uLength == 0) && (pParam->pExData[pParam->iExDataLen - 1] == 26)), 0);
if (iResult == SOCKET_ERROR)
{
AT_TC(g_sw_TCPIP, "TCPIP send socket data error");
}
}
if (cipATS_setTimer)(????)
{
at_TCPIPBufDestroy(g_bypass_buf);
g_bypass_buf = NULL;
}
AT_SetAsyncTimerMux(pParam->engine, 120);(异步timer作用????)
当受到主机端发回的ack包的时候,lwip层会发送EV_CFW_TCPIP_SOCKET_SEND_RSP的 response,tcpip_rsp回复 SEND OK