nRF5 IoT SDK
v0.9.0
|
The TFTP client module provides the functionality for both sending and retrieving files from the file server using Trivial File Transfer Protocol which uses UDP as a transport layer. The module sends requests to the server and manages file transfers using File abstraction.
This module supports several extensions like negotiating connection parameters, informing about file size, and setting a retransmission interval. These features enable files to be downloaded/uploaded in blocks with negotiated size and to control transmission speed.
For more information see the References section.
The following sections describe TFTP transactions and show how to use this module.
Figure 1 shows the negotiation procedure between the TFTP client and TFTP server.
The client sends a read or write request (RRQ/WRQ) to the server. If the client supports some of the TFTP extensions, it appends parameter names and its values to the packet.
The following piece of code will initialize the TFTP client and send a request to the server:
Figure 2 shows the file transfer from the server.
File transfers in TFTP are controlled by ACK packets. Each data chunk has to be acknowledged by the other side. The first data packet, which is smaller, marks the end of a file transfer. If the file size is a multiple of a block size, the last data packet contains the block ID and a zero-length payload.
To provide better control over the transmission speed, the server will always wait for ACK or next DATA packet. The following figure shows the flow inside the application.
The TFTP module calls the user callback only on events like error or transfer complete, but if it sees that the passed file instance has assigned a callback, it holds transmission on every packet. By doing that, the application can release the transfer by calling iot_tftp_resume()
or wait to slow the transmission. It also allows data transfer onto devices with longer access time.
The following code presents the easiest, fast release policy:
Connections finish when one side sends an error packet or if the last data packet was received. To stop transfer, send an error packet and drop into idle state. The TFTP module provides the iot_tftp_abort() function and the iot_tftp_uninit call to close the connection and release UDP sockets.
The following configuration parameters should be defined in sdk_config.h
.
Disables debug tracing in the module. To enable tracing, this flag must be set to 0 and ENABLE_DEBUG_LOG_SUPPORT must be set to 1.
Description | Value |
---|---|
Enable debug trace | 0 |
Disable debug trace | 1 |
Dependencies | ENABLE_DEBUG_LOG_SUPPORT |
Disables API parameter checks in the module. Set this define to 1 to disable checks on API parameters in the module.
API parameter checks are added to ensure that the correct parameters are passed to the module. These checks are useful during development phase, but they might be redundant when the application is finalized. Disabling these checks might improve performance.
Description | Value |
---|---|
Enable API parameters check | 0 |
Disable API parameters check | 1 |
Dependencies | None |
Maximum number of retransmitted packets.
Restriction | Value |
---|---|
Minimum value | 0 |
Maximum value | 255 |
Recommended value | 3 |
Dependencies | None |
Maximum number of TFTP client instances.
Restriction | Value |
---|---|
Minimum value | 1 |
Maximum value | 255 |
Dependencies | None |
The following sections describe the specifics and limitations to the current implementation.