Functions to work with the FTP server. More...
Functions | |
netStatus | netFTPs_Start (void) |
Start FTP server. [thread-safe]. | |
netStatus | netFTPs_Stop (void) |
Stop FTP server. [thread-safe]. | |
bool | netFTPs_Running (void) |
Check if FTP server is running. [thread-safe]. | |
uint16_t | netFTPs_GetPort (void) |
Get port number of FTP server. [thread-safe]. | |
netStatus | netFTPs_SetPort (uint16_t port) |
Set port number of FTP server. [thread-safe]. | |
const char * | netFTPs_GetRootPath (void) |
Retrieve path to the root directory on FTP server. [thread-safe]. | |
netStatus | netFTPs_SetRootPath (const char *path) |
Set path to the root directory on FTP server. [thread-safe]. | |
const char * | netFTPs_GetUsername (void) |
Retrieve username of the built-in user account. [thread-safe]. | |
netStatus | netFTPs_SetUsername (const char *username) |
Set username of the built-in user account. [thread-safe]. | |
const char * | netFTPs_GetPassword (void) |
Retrieve password of the built-in user account. [thread-safe]. | |
netStatus | netFTPs_SetPassword (const char *password) |
Reset password of the built-in user account. [thread-safe]. | |
bool | netFTPs_LoginActive (void) |
Determine if FTP server authentication is enabled. [thread-safe]. | |
netStatus | netFTPs_LoginOnOff (bool login) |
Enable or disable FTP server authentication. [thread-safe]. | |
Functions to work with the FTP server.
Like all services, the FTP 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 FTP server needs to be started manually in the user application using netFTPs_Start. At runtime, it is always possible to stop the FTP server using the function netFTPs_Stop. The user application can check for a running server using the netFTPs_Running function.
To change the port of the FTP server at runtime, first call netFTPs_Stop (if the server is running) and then use the netFTPs_SetPort function. Afterwards, the FTP server needs to be (re-)started by the application calling netFTPs_Start.
Code Example
To change the path to a root folder of the FTP server at runtime, first call netFTPs_Stop (if the server is running) and then use the netFTPs_SetRootPath function. Afterwards, the FTP server needs to be (re-)started by the application calling netFTPs_Start.
The FTP server supports a built-in user account if the FTP_SERVER_AUTH_ADMIN
is set to 1. In this case, the user specified by FTP_SERVER_AUTH_USER
is created and the password FTP_SERVER_AUTH_PASS
is used for this user. The FTP server control interface provides functions to work with this built-in account. To retrieve the username in the application, use netFTPs_GetUsername. To change this username at runtime, use netFTPs_SetUsername. The same pair of functions is available for managing the password (netFTPs_GetPassword / netFTPs_SetPassword).
It is also possible to check if this login is active (netFTPs_LoginActive) and to enable or disable it at runtime using netFTPs_LoginOnOff. Please note that the function netFTPs_LoginOnOff is only available at runtime if the define FTP_SERVER_AUTH_ENABLE
is set to 1 in the Net_Config_FTP_Server.h file. Otherwise, this command will not be compiled into the project to save resources. For more complex account management, use the Access and Multi-User Interface.
const char * netFTPs_GetPassword | ( | void | ) |
Retrieve password of the built-in user account. [thread-safe].
The function netFTPs_GetPassword returns the password of the built-in user account if FTP_SERVER_AUTH_ADMIN
is set to 1 in the Net_Config_FTP.h file. If this define is set to 0, the function is not available at runtime and returns NULL.
Code Example (see netFTPs_LoginActive)
uint16_t netFTPs_GetPort | ( | void | ) |
Get port number of FTP server. [thread-safe].
The function netFTPs_GetPort returns the port of the FTP server.
Code Example
const char * netFTPs_GetRootPath | ( | void | ) |
Retrieve path to the root directory on FTP server. [thread-safe].
The function netFTPs_GetRootPath returns the path to the current root directory if FTP_SERVER_ROOT_ENABLE
is set to 1 in the Net_Config_FTP_Server.h file. If this define is set to 0, the function is not available at runtime and returns NULL.
Code Example
const char * netFTPs_GetUsername | ( | void | ) |
Retrieve username of the built-in user account. [thread-safe].
The function netFTPs_GetUsername returns the user name of the built-in user if FTP_SERVER_AUTH_ADMIN
is set to 1 in the Net_Config_FTP.h file. If this define is set to 0, the function is not available at runtime and returns NULL.
Code Example (see netFTPs_LoginActive)
bool netFTPs_LoginActive | ( | void | ) |
Determine if FTP server authentication is enabled. [thread-safe].
The function netFTPs_LoginActive checks if the FTP server is set up for user authentication.
Code Example
netStatus netFTPs_LoginOnOff | ( | bool | login | ) |
Enable or disable FTP server authentication. [thread-safe].
[in] | login | new authentication state:
|
The function netFTPs_LoginOnOff enables or disables the user authentication on the FTP server. If FTP_SERVER_AUTH_ENABLE
is set to 0 in the Net_Config_FTP.h file, the function is not available at runtime.
The argument login switches the log-in on (true) or off (false).
Possible netStatus return values:
Code Example
bool netFTPs_Running | ( | void | ) |
Check if FTP server is running. [thread-safe].
The function netFTPs_Running is used to check whether the FTP server is running. A return value of true shows a running FTP server.
Code Example (see netFTPs_SetPort)
netStatus netFTPs_SetPassword | ( | const char * | password | ) |
Reset password of the built-in user account. [thread-safe].
[in] | password | new password, a null-terminated string. |
The function netFTPs_SetPassword sets the password of the built-in user if FTP_SERVER_AUTH_ADMIN
is set to 1 in the Net_Config_FTP.h file. If this define is set to 0, the function is not available at runtime.
The argument password is a pointer to the password that is to be set, which is a null-terminated string. The function copies the content of the password to the password of the build-in user. The maximum length of the password string is limited to 15 characters.
Possible netStatus return values:
Code Example (see netFTPs_SetUsername)
netStatus netFTPs_SetPort | ( | uint16_t | port | ) |
Set port number of FTP server. [thread-safe].
[in] | port | port number. |
The function netFTPs_SetPort sets the port of the FTP server. The FTP server must not run while setting the port. If required, stop it first using netFTPs_Stop.
The argument port specifies the port number to be used.
Possible netStatus return values:
Code Example
netStatus netFTPs_SetRootPath | ( | const char * | path | ) |
Set path to the root directory on FTP server. [thread-safe].
[in] | path | new root path, a null-terminated string. |
The function netFTPs_SetRootPath sets the path to the root directory of FTP server if FTP_SERVER_ROOT_ENABLE
is set to 1 in the Net_Config_FTP_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. This path is common to all FTP server users.
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 FTP server. The maximum length of the path string is limited to 79 characters.
You can change the root path until the user logs on to the server. Once the user is authenticated, the root path can no longer be changed. This simple solution allows the root folder to be mapped to the user when logging on to the server. For example to access two drives, it is therefore necessary to create two user profiles, one has a root folder on the first drive (i.e "M:") and the other on the second drive (i.e. "F:"). The root path can be changed in the netFTPs_CheckUsername or in the netFTPs_CheckPassword function. To access another drive, the user must log out and then log on with other credentials.
Possible netStatus return values:
Code Example
netStatus netFTPs_SetUsername | ( | const char * | username | ) |
Set username of the built-in user account. [thread-safe].
[in] | username | new username, a null-terminated string. |
The function netFTPs_SetUsername sets the user name of the built-in user if FTP_SERVER_AUTH_ADMIN
is set to 1 in the Net_Config_FTP.h file. If this define is set to 0, the function is not available at runtime.
The argument username is a pointer to the user name to be set, which is a null-terminated string. The function copies the content of the username to the user name of the built-in user. The maximum length of the username string is limited to 15 characters.
Possible netStatus return values:
Code Example
netStatus netFTPs_Start | ( | void | ) |
Start FTP server. [thread-safe].
The function netFTPs_Start is used to start the FTP server at runtime.
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 FTP server previously using netFTPs_Stop or have set NET_START_SERVICE
to 0.Code Example (see netFTPs_SetPort)
netStatus netFTPs_Stop | ( | void | ) |
Stop FTP server. [thread-safe].
The function netFTPs_Stop is used to stop the FTP server at runtime. To re-start the FTP server, use netFTPs_Start.
Possible netStatus return values:
Code Example (see netFTPs_SetPort)