FTP Client#

Functions#

int32_t
rsi_ftp_connect(uint16_t flags, int8_t *server_ip, int8_t *username, int8_t *password, uint32_t server_port)

Create FTP objects and connect to the FTP server on the given server port. This should be the first command for accessing FTP server. This is a blocking API.

int32_t

Disconnect from the FTP server and destroy the FTP objects. Once the FTP objects are destroyed, FTP server cannot be accessed. For further accessing, FTP objects should be created again. This is a blocking API.

int32_t
rsi_ftp_file_write(int8_t *file_name)

Open a file in the specified path on the FTP server. This is a blocking API.

int32_t
rsi_ftp_file_write_content(uint16_t flags, int8_t *file_content, int16_t content_length, uint8_t end_of_file)

Write the content into the file that was opened using rsi_ftp_file_write() API. This is a blocking API.

int32_t
rsi_ftp_file_read_aysnc(int8_t *file_name, void(*call_back_handler_ptr)(uint16_t status, uint8_t *file_content, uint16_t content_length, uint8_t end_of_file))

Read the content from the specified file on the FTP server. This is a non-blocking API.

int32_t
rsi_ftp_file_delete(int8_t *file_name)

Delete the file that is present in the specified path on the FTP server. This is a blocking API.

int32_t
rsi_ftp_file_rename(int8_t *old_file_name, int8_t *new_file_name)

Rename the file with a new name on the FTP server. This is a blocking API.

int32_t
rsi_ftp_directory_create(int8_t *directory_name)

Create a directory on the FTP server. This is a blocking API.

int32_t
rsi_ftp_directory_delete(int8_t *directory_name)

Delete the directory on the FTP server. This is a blocking API.

int32_t
rsi_ftp_directory_set(int8_t *directory_path)

Change the current working directory to the specified directory path on the FTP server. This is a blocking API.

int32_t
rsi_ftp_directory_list_async(int8_t *directory_path, void(*call_back_handler_ptr)(uint16_t status, uint8_t *directory_list, uint16_t length, uint8_t end_of_list))

Get the list of directories present in the specified directory on the FTP server. This is a non-blocking API.

int32_t
rsi_ftp_mode_set(uint8_t mode)

Set the FTP client mode - either in Passive mode or Active Mode. In active mode, FTP client establishes the command channel, and the server establishes the data channel. In passive mode, both the command channel and the data channel are established by the client. This is a blocking API.

int32_t
rsi_ftp_file_size_set(uint32_t file_size)

Set the file size.

Function Documentation#

rsi_ftp_connect#

int32_t rsi_ftp_connect (uint16_t flags, int8_t * server_ip, int8_t * username, int8_t * password, uint32_t server_port)

Create FTP objects and connect to the FTP server on the given server port. This should be the first command for accessing FTP server. This is a blocking API.

Parameters
[in]flags

- Network flags. Each bit in the flag has its own significance

Flags

Description

BIT(0) - RSI_IPV6

Set this bit to enable IPv6. By default, it is configured to IPv4

BIT(1) to BIT(15)

Reserved for future use

[in]server_ip

- FTP server IP address to connect

[in]username

- Username for server authentication

[in]password

- Password for server authentication

[in]server_port

- Port number of FTP server

Returns

  • 0 - Success

  • Non Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0x0021, 0x002C, 0x0015)

Note

  • Precondition - rsi_config_ipaddress() API needs to be called before this API.

  • FTP server port is also configurable on a non-standard port

  • Refer to Error Codes for the description of above error codes.


Definition at line 45 of file network/protocols/rsi_ftp.c

rsi_ftp_disconnect#

int32_t rsi_ftp_disconnect (void )

Disconnect from the FTP server and destroy the FTP objects. Once the FTP objects are destroyed, FTP server cannot be accessed. For further accessing, FTP objects should be created again. This is a blocking API.

Parameters
N/A

Returns

  • 0 - Success

  • Non Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0x0021, 0x002C, 0x0015)

Note


Definition at line 197 of file network/protocols/rsi_ftp.c

rsi_ftp_file_write#

int32_t rsi_ftp_file_write (int8_t * file_name)

Open a file in the specified path on the FTP server. This is a blocking API.

Parameters
[in]file_name

- Filename or filename with the path

Returns

  • 0 - Success

  • Non Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0x0021, 0x002C, 0x0015)

Note


Definition at line 319 of file network/protocols/rsi_ftp.c

rsi_ftp_file_write_content#

int32_t rsi_ftp_file_write_content (uint16_t flags, int8_t * file_content, int16_t content_length, uint8_t end_of_file)

Write the content into the file that was opened using rsi_ftp_file_write() API. This is a blocking API.

Parameters
[in]flags

- Network flags.

Flags

Description

BIT(0) - RSI_IPV6

Set this bit to enable IPv6. By default, it is configured to IPv4

BIT(1) to BIT(15)

Reserved for future use

[in]file_content

- Data stream to be written into the file

[in]content_length

- File content length

[in]end_of_file

- Flag that indicates the end of file. 1 – Represent the end of content to be written into the file, 0 – Extra data that is pending to write into the file

Returns

  • 0 - Success

  • Non Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0x0021, 0x002C, 0x0015)

Note

  • Precondition - rsi_config_ipaddress() API needs to be called before this API.

  • This API can be called multiple times to append data into the same file.

  • File content length should not exceed 1344 bytes in case of IPV4 and 1324 bytes in case of IPV6. If exceeded, this API will break the file content and send it in multiple packets.

  • Refer to Error Codes for the description of above error codes.


Definition at line 422 of file network/protocols/rsi_ftp.c

rsi_ftp_file_read_aysnc#

int32_t rsi_ftp_file_read_aysnc (int8_t * file_name, void(*)(uint16_t status, uint8_t *file_content, uint16_t content_length, uint8_t end_of_file) call_back_handler_ptr, status, file_content, content_length, end_of_file)

Read the content from the specified file on the FTP server. This is a non-blocking API.

Parameters
[in]file_name

- Filename or filename with path

[in]call_back_handler_ptr

- Called when asynchronous response is received from module for file read request

[out]status

- Status code

[out]file_content

- File content

[out]content_length

- Length of file content

[out]end_of_file

- Indicate the end of file. 1 – No more data, 0 – More data present

Returns

  • 0 - Success

  • Non Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0x0021, 0x002C, 0x0015)

Note


Definition at line 585 of file network/protocols/rsi_ftp.c

rsi_ftp_file_delete#

int32_t rsi_ftp_file_delete (int8_t * file_name)

Delete the file that is present in the specified path on the FTP server. This is a blocking API.

Parameters
[in]file_name

- Filename or filename with path to delete

Returns

  • 0 - Success

  • Non Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0x0021, 0x002C, 0x0015)

Note


Definition at line 677 of file network/protocols/rsi_ftp.c

rsi_ftp_file_rename#

int32_t rsi_ftp_file_rename (int8_t * old_file_name, int8_t * new_file_name)

Rename the file with a new name on the FTP server. This is a blocking API.

Parameters
[in]old_file_name

- Filename or filename with path to rename

[in]new_file_name

- New filename

Returns

  • 0 - Success

  • Non Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0x0021, 0x002C, 0x0015)

Note


Definition at line 767 of file network/protocols/rsi_ftp.c

rsi_ftp_directory_create#

int32_t rsi_ftp_directory_create (int8_t * directory_name)

Create a directory on the FTP server. This is a blocking API.

Parameters
[in]directory_name

- Directory name (with path if required) to create

Returns

  • 0 - Success

  • Non Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0x0021, 0x002C, 0x0015)

Note


Definition at line 859 of file network/protocols/rsi_ftp.c

rsi_ftp_directory_delete#

int32_t rsi_ftp_directory_delete (int8_t * directory_name)

Delete the directory on the FTP server. This is a blocking API.

Parameters
[in]directory_name

- Directory name (with path if required) to delete

Returns

  • 0 - Success

  • Non Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0x0021, 0x002C, 0x0015)

Note


Definition at line 948 of file network/protocols/rsi_ftp.c

rsi_ftp_directory_set#

int32_t rsi_ftp_directory_set (int8_t * directory_path)

Change the current working directory to the specified directory path on the FTP server. This is a blocking API.

Parameters
[in]directory_path

- Directory name (with path if required) to create

Returns

  • 0 - Success

  • Non Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0x0021, 0x002C, 0x0015)

Note


Definition at line 1036 of file network/protocols/rsi_ftp.c

rsi_ftp_directory_list_async#

int32_t rsi_ftp_directory_list_async (int8_t * directory_path, void(*)(uint16_t status, uint8_t *directory_list, uint16_t length, uint8_t end_of_list) call_back_handler_ptr, status, directory_list, length, end_of_list)

Get the list of directories present in the specified directory on the FTP server. This is a non-blocking API.

Parameters
[in]directory_path

- Directory path(with path if required) to list

[in]call_back_handler_ptr

- Called when asynchronous response is received from module for directory list request

[out]status

- Status code

[out]directory_list

- Stream of data with directory list as content

[out]length

- Length of content

[out]end_of_list

- Indicate end of list. 1 – No more data, 0 – More data present

Returns

  • 0 - Success

  • Non Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0x0021, 0x002C, 0x0015)

Note


Definition at line 1132 of file network/protocols/rsi_ftp.c

rsi_ftp_mode_set#

int32_t rsi_ftp_mode_set (uint8_t mode)

Set the FTP client mode - either in Passive mode or Active Mode. In active mode, FTP client establishes the command channel, and the server establishes the data channel. In passive mode, both the command channel and the data channel are established by the client. This is a blocking API.

Parameters
[in]mode

- Used to select the mode of FTP client if FTP is enabled. BIT(0) refers FTP client mode and BIT(1) refers FTP transfer mode. BIT(0) - 0 then active mode is enabled, BIT(0) - 1 then passive mode is enabled, BIT(1) - 0 then stream transfer mode is enabled, BIT(1) - 1 then block transfer mode is enabled

Returns

  • 0 - Success

  • Non Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0x0021, 0x002C, 0x0015)

Note


Definition at line 1233 of file network/protocols/rsi_ftp.c

rsi_ftp_file_size_set#

int32_t rsi_ftp_file_size_set (uint32_t file_size)

Set the file size.

Parameters
[in]file_size

- represents the size of the file in bytes that is to be transferred.

Returns

  • 0 - Success

  • Non Zero Value - Failure (Possible Error Codes - 0xfffffffd, 0xfffffffc, 0x0021, 0x002C, 0x0015)

Note


Definition at line 1321 of file network/protocols/rsi_ftp.c