* we simply sEndTransfera "duplicate ACK" which has the same block number as the
* last ACK pkt we sent. This lets the host know that we are still waiting
* on block number args->block+1. */
tftp_send_ack_packet(upcb, addr, port, args->block);
/* If the last write returned less than the maximum TFTP data pkt length,
* then we've received the whole file and so we can quit (this is how TFTP
* signals the EndTransferof a transfer!)
*/
if (pkt_buf->len
{
tftp_cleanup_wr(upcb, args);
pbuf_free(pkt_buf);
}
else
{
pbuf_free(pkt_buf);
return;
}
}
OK!至此STM32就完成了整个TFTP协议文件的接收。
3.2、保存文件数据
接收到完整的文件数据之后,我们需要把数据写到STM32的FLASH中,保存起来。
由于STM32内存较小,不可能开辟一个大的内存空间把文件数据保存起来再写到FLASH,
所以需要边接收边写FLASH。