TFTP
Zephyr provides a simple TFTP client library that can enabled with
CONFIG_MQTT_SN_LIB Kconfig option.
See TFTP client sample application for more information about the library usage.
API Reference
- group tftp_client
- TFTP client error codes. - 
TFTPC_SUCCESS
- Success. 
 - 
TFTPC_DUPLICATE_DATA
- Duplicate data received. 
 - 
TFTPC_BUFFER_OVERFLOW
- User buffer is too small. 
 - 
TFTPC_UNKNOWN_FAILURE
- Unknown failure. 
 - 
TFTPC_REMOTE_ERROR
- Remote server error. 
 - 
TFTPC_RETRIES_EXHAUSTED
- Retries exhausted. 
 - Defines - 
TFTP_BLOCK_SIZE
- RFC1350: the file is sent in fixed length blocks of 512 bytes. - Each data packet contains one block of data, and must be acknowledged by an acknowledgment packet before the next packet can be sent. A data packet of less than 512 bytes signals termination of a transfer. 
 - 
TFTP_HEADER_SIZE
- RFC1350: For non-request TFTP message, the header contains 2-byte operation code plus 2-byte block number or error code. 
 - 
TFTPC_MAX_BUF_SIZE
- Maximum amount of data that can be sent or received. 
 - Typedefs - Enums - 
enum tftp_evt_type
- TFTP Asynchronous Events notified to the application from the module through the callback registered by the application. - Values: - 
enumerator TFTP_EVT_DATA
- DATA event when data is received from remote server. - Note - DATA event structure contains payload data and size. 
 - 
enumerator TFTP_EVT_ERROR
- ERROR event when error is received from remote server. - Note - ERROR event structure contains error code and message. 
 
- 
enumerator TFTP_EVT_DATA
 - Functions - 
int tftp_get(struct tftpc *client, const char *remote_file, const char *mode)
- This function gets data from a “file” on the remote server. - Note - This function blocks until the transfer is completed or network error happens. The integrity of the - clientstructure must be ensured until the function returns.- Parameters:
- client – Client information of type tftpc. 
- remote_file – Name of the remote file to get. 
- mode – TFTP Client “mode” setting. 
 
- Return values:
- The – size of data being received if the operation completed successfully. 
- TFTPC_BUFFER_OVERFLOW – if the file is larger than the user buffer. 
- TFTPC_REMOTE_ERROR – if the server failed to process our request. 
- TFTPC_RETRIES_EXHAUSTED – if the client timed out waiting for server. 
- -EINVAL – if - clientis NULL.
 
 
 - 
int tftp_put(struct tftpc *client, const char *remote_file, const char *mode, const uint8_t *user_buf, uint32_t user_buf_size)
- This function puts data to a “file” on the remote server. - Note - This function blocks until the transfer is completed or network error happens. The integrity of the - clientstructure must be ensured until the function returns.- Parameters:
- client – Client information of type tftpc. 
- remote_file – Name of the remote file to put. 
- mode – TFTP Client “mode” setting. 
- user_buf – Data buffer containing the data to put. 
- user_buf_size – Length of the data to put. 
 
- Return values:
- The – size of data being sent if the operation completed successfully. 
- TFTPC_REMOTE_ERROR – if the server failed to process our request. 
- TFTPC_RETRIES_EXHAUSTED – if the client timed out waiting for server. 
- -EINVAL – if - clientor- user_bufis NULL or if- user_buf_sizeis zero.
 
 
 - 
struct tftp_data_param
- #include <tftp.h>Parameters for data event. 
 - 
struct tftp_error_param
- #include <tftp.h>Parameters for error event. 
 - 
union tftp_evt_param
- #include <tftp.h>Defines event parameters notified along with asynchronous events to the application. Public Members - 
struct tftp_data_param data
- Parameters accompanying TFTP_EVT_DATA event. 
 - 
struct tftp_error_param error
- Parameters accompanying TFTP_EVT_ERROR event. 
 
- 
struct tftp_data_param data
 - 
struct tftp_evt
- #include <tftp.h>Defines TFTP asynchronous event notified to the application. Public Members - 
enum tftp_evt_type type
- Identifies the event. 
 - 
union tftp_evt_param param
- Contains parameters (if any) accompanying the event. 
 
- 
enum tftp_evt_type type
 - 
struct tftpc
- #include <tftp.h>TFTP client definition to maintain information relevant to the client. Note Application must initialize serverandcallbackbefore calling GET or PUT API with thetftpcstructure.Public Members - 
tftp_callback_t callback
- Event notification callback. - No notification if NULL 
 - 
uint8_t tftp_buf[(512 + 4)]
- Buffer for internal usage. 
 
- 
tftp_callback_t callback
 
- 
TFTPC_SUCCESS