rsi_ftp_connect

Prototype int32_t rsi_ftp_connect(uint16_t flags, int8_t *server_ip, int8_t *username, int8_t *password, uint32_t server_port)
Input Arguments uint16_t flags : Network flags.Each bit in the flag is is own significance

BIT(0) – RSI_IPV6

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

BIT(1) to BIT(15) are reserved for future use

int8_t *server_ip : FTP server IP address to connect

int8_t *username: username for server Authentication

int8_t *password: password for server Authentication

uint32_t server_port: port number of FTP server

Note : FTP server port is configurable on non standard port also

Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015
  • Please referError Codes for description of above error codes.
Description This API is used to create FTP objects and connect to the FTP server on the given server port.This should be the first command for accessing FTP server.
Example Usage rsi_ftp_connect(4,(uint8_t*)&server_ip,”test”,”test123”,21);

rsi_ftp_disconnect

Prototype int32_t rsi_ftp_disconnect(void)
Input Arguments Void : None
Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015
  • Please refer Error Codes for description of above error codes.
Description This function is used to disconnect from the FTP server and destroy the FTP objects.Once FTP objects are destroyed,FTP server cannot be accessed.For the further accessing,FTP objects should be created again
Example Usage rsi_ftp_disconnect();

rsi_ftp_file_write

Prototype int32_t rsi_ftp_file_write(int8_t *file_name)
Input Arguments int8_t *file_name: File name or filename including path can be given.

e.g “example.txt”

or “/test/ftp/example.txt”

Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015
  • Please refer Error Codesfor description of above error codes.
Description This function is used to open a file in the specified path on the FTP server.
Example Usage rsi_ftp_file_write(“write.txt”);

rsi_ftp_file_write_content

Prototype int32_t rsi_ftp_file_write_content(uint16_t flags, int8_t *file_content,int16_t content_length,uint8_t end_of_file)
Input Arguments uint16_t flags: Network flags.Each bit in the flag is is own significance

BIT(0) – RSI_IPV6

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

BIT(1) to BIT(15) are reserved for future use

int8_t *file_content: Data stream to be written into the file

int16_tcontent_length: file content length

uint8_t end_of_file: This flag indicates the end of file

1 – This chunk is end of content to write into the file

0 – more data is pending to write into the file

Note : This API can be called multiple times to append data  into the same file and at the last chunk ,this flag should be 1

Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015
  • Please refer Error Codes for description of above error codes.
Description This function is used to write the content into the file opened using rsi_ftp_file_write() API
Example Usage rsi_ftp_file_write_content(0,&file_data_read,file_data_length,1);

 

Note: file content length should not exceed 1344 bytes in case of IPV4 and 1324 bytes in case of IPV6.If exceeds, this API will breaks the file content and send it in multiple packets.

rsi_ftp_file_read_aysnc

Prototype int32_t rsi_ftp_file_read_aysnc(int8_t *file_name, void (*call_back_handler_ptr)(uint16_t status, int8_t *file_content, uint16_t content_length, uint8_t end_of_file))
Input Arguments int8_t *file_name: File name or filename including path can be given.

e.g “example.txt”

or “/test/ftp/example.txt”

void (*call_back_handler_ptr): callback when asynchronous response comes for the file read request

parameters:status , file_content, content_length, end_of_file

status: status code.Other parameters are valid only if status is 0

file_content: file content

content_length:length of file content

end_of_file: indicates end of file

if 1 – No more data

0 – more data present

Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015
  • Please refer Error Codesfor description of above error codes.
Description This function is used to read the content from the file content from the specified file on the FTP server
Example Usage rsi_ftp_file_read_aysnc(“raed.txt”,rsi_file_read_cb;

rsi_ftp_file_delete

Prototype int32_t rsi_ftp_file_delete(int8_t *file_name)
Input Arguments File name or filename including path can be given to delete

e.g “example.txt”

or “/test/ftp/example.txt”

Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015
  • Please refer Error Codesfor description of above error codes.
Description This API is used to delete the file which is present in the specified path on the FTP server.
Example Usage rsi_ftp_file_delete(“read.txt”);

rsi_ftp_file_rename

Prototype int32_t rsi_ftp_file_rename(int8_t *old_file_name, int8_t *new_file_name)
Input Arguments int8_t *old_file_name:filename/file name which has to be renamed

int8_t *new_file_name: new file name

Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015
  • Please refer Error Codes for description of above error codes.
Description This API is used to rename the file with the new name on the FTP server
Example Usage rsi_ftp_file_rename(“old.txt”,”new.txt”);

rsi_ftp_directory_create

Prototype int32_t rsi_ftp_directory_create(int8_t *directory_name)
Input Arguments int8_t *directory_name: directory name(with path if required) to create

e.g “example”

or “/test/ftp/example”

Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015
  • Please refer Error Codes for description of above error codes.
Description This API is used to create a directory on the FTP server
Example Usage rsi_ftp_directory_create(“test”);

rsi_ftp_directory_delete

Prototype int32_t rsi_ftp_directory_delete(int8_t *directory_name)
Input Arguments int8_t *directory_name: directory name(with path if required) to delete

e.g “example”

or “/test/ftp/example”

Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015
  • Please refer Error Codes for description of above error codes.
Description This API is used to delete a directory on the FTP server
Example Usage rsi_ftp_directory_delete(“test”);

rsi_ftp_directory_set

Prototype int32_t rsi_ftp_directory_set(int8_t *directory_path)
Input Arguments int8_t *directory_name: directory name(with path if required) to set

e.g “example”

or “/test/ftp/example”

Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015
  • Please refer Error Codes for description of above error codes.
Description This API is used to set a directory on the FTP server
Example Usage rsi_ftp_directory_set(“C:\example”);

rsi_ftp_directory_list_async

Prototype int32_t rsi_ftp_directory_list_async(int8_t *directory_path,void (*call_back_handler_ptr)(uint16_t  status, int8_t *directory_list, uint16_t length , uint8_t end_of_list))
Input Arguments int8_t *directory_path: File name or filename including path can be given.

e.g “example.txt”

or “/test/ftp/example.txt”

void (*call_back_handler_ptr): callback when asynchronous response comes for the directory list request

parameters:status , directory_list, length, end_of_list

status: status code.Other parameters are valid only if status is 0

directory_list: Stream of data with directory list as content

length: length of content

end_of_list: indicates end of list

if 1 – No more data

0 – more data present

Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -2 : Invalid parameter,expects call back handler
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015
  • Please refer Error Codes for description of above error codes.
Description This function is used to get the list of directories present in the specified directory on the FTP server
Example Usage rsi_ftp_directory_list_async(“example.txt”,

list_resp_cb);