Functions to work with the TFTP server. More...
Functions | |
netStatus | netTFTPs_Start (void) |
Start the TFTP server. [thread-safe]. | |
netStatus | netTFTPs_Stop (void) |
Stop the TFTP server. [thread-safe]. | |
bool | netTFTPs_Running (void) |
Check if the TFTP server is running. [thread-safe]. | |
uint16_t | netTFTPs_GetPort (void) |
Get port number of the TFTP server. [thread-safe]. | |
netStatus | netTFTPs_SetPort (uint16_t port) |
Set port number of the TFTP server. [thread-safe]. | |
const char * | netTFTPs_GetRootPath (void) |
Retrieve path to the root directory on TFTP server. [thread-safe]. | |
netStatus | netTFTPs_SetRootPath (const char *path) |
Set path to the root directory on TFTP server. [thread-safe]. | |
Functions to work with the TFTP server.
Like all services, the TFTP server is normally started automatically if NET_START_SERVICE
is set to 1 in the Net_Config.h configuration file. If it is disabled, the TFTP server needs to be started manually in the user application using netTFTPs_Start. At runtime, it is always possible to stop the TFTP server using the function netTFTPs_Stop. The user application can check for a running server using the netTFTPs_Running function.
To change the port of the TFTP server at runtime, first call netTFTPs_Stop (if the server is running) and then use the netTFTPs_SetPort function. Afterwards, the TFTP server needs to be (re-)started by the application calling netTFTPs_Start.
Code Example
To change the path to a root folder of the TFTP server at runtime, first call netTFTPs_Stop (if the server is running) and then use the netTFTPs_SetRootPath function. Afterwards, the TFTP server needs to be (re-)started by the application calling netTFTPs_Start.
uint16_t netTFTPs_GetPort | ( | void | ) |
Get port number of the TFTP server. [thread-safe].
The function netTFTPs_GetPort returns the port that is used for the TFTP server.
Code Example
const char * netTFTPs_GetRootPath | ( | void | ) |
Retrieve path to the root directory on TFTP server. [thread-safe].
The function netTFTPs_GetRootPath returns the path to the current root directory if TFTP_SERVER_ROOT_ENABLE
is set to 1 in the Net_Config_TFTP_Server.h file. If this define is set to 0, the function is not available at runtime and returns NULL.
Code Example
bool netTFTPs_Running | ( | void | ) |
Check if the TFTP server is running. [thread-safe].
The function netTFTPs_Running checks whether the TFTP server is running. It returns true if the server is up and running.
Code Example (see netTFTPs_SetPort)
netStatus netTFTPs_SetPort | ( | uint16_t | port | ) |
Set port number of the TFTP server. [thread-safe].
[in] | port | port number. |
The function netTFTPs_SetPort sets the port that is to be used for the TFTP server. The TFTP server must not run while setting the port. If required, stop it first using netTFTPs_Stop.
The argument port specifies the port number to be used.
Possible netStatus return values:
Code Example
netStatus netTFTPs_SetRootPath | ( | const char * | path | ) |
Set path to the root directory on TFTP server. [thread-safe].
[in] | path | new root path, a null-terminated string. |
The function netTFTPs_SetRootPath sets the path to the root directory of TFTP server if TFTP_SERVER_ROOT_ENABLE
is set to 1 in the Net_Config_TFTP_Server.h file. If this define is set to 0, the function is not available at runtime. Root directory specifies a path on a storage device, where the user files are stored.
The argument path is a pointer to the new root path to be set, which is a null-terminated string. The function copies the content of the path to the root path of the TFTP server. The maximum length of the path string is limited to 79 characters.
Possible netStatus return values:
Code Example
netStatus netTFTPs_Start | ( | void | ) |
Start the TFTP server. [thread-safe].
The function netTFTPs_Start starts the TFTP server at runtime. It can be stopped again using netTFTPs_Stop.
Possible netStatus return values:
NET_START_SERVICE
to 1 in Net_Config.h, all selected services will be started automatically. Thus, you only need to call this function, if you have either stopped the TFTP server previously using netTFTPs_Stop or have set NET_START_SERVICE
to 0.Code Example (see netTFTPs_SetPort)
netStatus netTFTPs_Stop | ( | void | ) |
Stop the TFTP server. [thread-safe].
The function netTFTPs_Stop stops the TFTP server at runtime. It can be restarted using netTFTPs_Start.
Possible netStatus return values:
Code Example (see netTFTPs_SetPort)