Hi there,
i got a strange problem trying to download a file from FTP.
After connecting to GPRS, connecting to FTP and trying to download a file I receive a WIP_CERR_CSTATE error.
This sees strange to me, because i am waiting for all appropriate events.
Here’s my code:
After being connectd to GPRS (WIP_BEV_IP_CONNECTED), open FTP communication channel:
void SOCK_FTP_hdl_c(wip_event_t *event, void *context)
{
ftp_channel_c = event->channel;
switch(event->kind)
{
case WIP_CEV_OPEN:
TRACE((TL_SOCK, "SOCK_FTP_hdl_c(): WIP_CEV_OPEN"));
wip_getFileSize(ftp_channel_c, "test.php");
break;
case WIP_CEV_DONE:
TRACE((TL_SOCK, "SOCK_FTP_hdl_c(): WIP_CEV_DONE"));
//START DOWNLOADING HERE
break;
//....
Now wip_getFile:
ftp_channel_d = wip_getFile(ftp_channel_c, "test.php", FTP_hdl_d, "");
Now in the handler for this channel (FTP_hdl_d):
void DOTA_FTP_hdl_d(wip_event_t *event, void *context)
{
ftp_channel_d = event->channel;
switch(event->kind)
{
case WIP_CEV_OPEN:
TRACE((TL_DOTA, "DOTA_FTP_hdl_d(): WIP_CEV_OPEN"));
break;
case WIP_CEV_WRITE:
TRACE((TL_DOTA, "DOTA_FTP_hdl_d(): WIP_CEV_WRITE"));
break;
case WIP_CEV_READ:
TRACE((TL_DOTA, "DOTA_FTP_hdl_d() %d bytes readable", event->content.read.readable));
//read file
u32 nread;
u8 buf[256];
while ( (nread = wip_read(ftp_channel_d,buffer, sizeof(buffer)-1)) > 0)
//...
So in my Trace, everything is normal, until the data channel for FTP is opened. Then I receive the WIP_CEV_OPEN, the WIP_CEV_WRITE and after this i get error -999 (WIP_CERR_CSTATE).
Strange: If I remove the while statement around the wip_read function, the error does not happen…
Any ideas?