Datasheet

Flyport Wi-Fi and Ethernet Programmer's guide framework 2.3 (rev 1.0) www.openpicus.com
example in an sd card, and retrieve the data later.
Opening the stream in read mode FTPStreamOpen(TCP_SOCKET cmdSock,
char fileName[], char mode[]);
To open the file stream in read mode, the function FTPStreamOpen() must be used specifying the
mode RETR.
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: RETR to read the data from the file.
Returns:
int var containing the report for the operation: FTP_CONNECTED if succeeded, otherwise an error
code will be reported.
Read data from stream FTPStreamRead(char dest[],
int len, BYTE timeout);
Allows to specify the destination and the length of the data to read.
Parameters:
dest The destination char array for the data.
len The length of the data to read.
timeout The max time (expressed in seconds) to wait for the data.
Returns:
long int length of the data read from the file, otherwise an error code will be reported.
IMPORTANT: the reading operation should be performed as fast as possible, since the server could
disconnect Flyport or data loss may be experienced. Don't use delays or perform any other operation
if you want to download a file. In particular the last "chunk" of the file could be loss if the interval
between reading is long. This may happen because when the server has sent the last byte, it
disconnects the client. When the Flyport is disconnected from the server, the data is flushed in a max
timeout of 50msecs. So if data is not read within that interval, it is lost.
To know if the end of file is reached, it's possible to read the status of the stream using the function
FTPStreamStat().
Close the stream FTPStreamClose();
Each time the stream must be reinitialized, or the server disconnected the Flyport, FTPStreamClose()
must be called before FTPStreamOpen().
Parameters:
None
Returns:
Nothing
The stream status FTPStreamStat();
returns the status of the stream.
Parameters:
None
Returns:
A BYTE with the status of the stream. The possible values are the following:
FTP_STREAM_NOT_CONN - Stream not connected yet.
FTP_STREAM_READING - Stream in reading mode.
FTP_STREAM_EOF - Stream in reading mode has reached the end of file.
FTP_STREAM_WRITING - Stream in writing mode.
53