Datasheet

Flyport Wi-Fi and Ethernet Programmer's guide framework 2.3 (rev 1.0) www.openpicus.com
NOTE: both the functions take a command socket and open the data socket, write the data on file
and close the socket. To keep the data socket opened and write data multiple times without
reopening it, use the stream functions instead.
Parameters:
*cmdSock: The command socket previously connected to the server.
fileName: A string with the file name to read the size.
appStr/stoStr: the string to append/store on to the file.
Returns:
int variable containing the number of bytes written, an error code if the operation failed.
File stream write mode
When a file writing must be repeated multiple times in a small time interval (ten of seconds or
minutes), instead of using the FTPAppend() or FTPStore() function, it's more convenient to open a
"stream" and keep it opened to write the data you need. For example, data can be read from a
memory card in chunks and written directly on FTP server.
Attention must be kept on server timeouts! If you open the stream and don't write any data within
the server timeout (each server has different values), your connection is directly closed by the server,
so you'll have to open it again. Server timeouts usually goes from 30 secs to some minutes, but it's a
very variable value, so you first should check your server settings. Once the server disconnect the
Flyport, the stream must be closed using the FTPStreamClose() function and reopened.
Opening the stream in write mode FTPStreamOpen(TCP_SOCKET cmdSock,
char fileName[], char mode[]);
Using stream in writing mode, it's possible to specify APPEND or STORE mode.
Parameters:
*cmdSock: The command socket previously connected to the server.
fileName: A string with the file name to open in stream mode.
mode: The mode of the stream: APPE or STOR to write the data on the file. APPE will open in append
mode, STOR in store mode, so it will overwrite the file if it exist.
Returns:
int var containing the report for the operation: FTP_CONNECTED if succeeded, otherwise an error
code will be reported.
Write data on stream FTPStreamWrite(char strWrite[],
long toWrite);
Writes data on the stream.
Parameters:
strWrite The char array to write
toWrite The length of the char array to write
NOTE: since the length of the data to write is specified as parameter, there is no need to terminate it
with a null char. A string is not needed, a char array is sufficient. In this way it's possible to send "raw
data" also containing null chars.
Returns:
long int containing the data written on the stream. If the data written is different from the toWrite
parameter, some error occurred during writing.
File stream read mode
To read a file from an FTP server, can be used a stream of data in reading mode. Since Flyport's RAM
is not sufficient to contain large files, in this way it's possible to read parts of the file, store it, for
52