Hi i am trying to use dota but i have a problem for me it seems that dota starts, i mean the reading of data from the ftp file starts but then it restarts over and over in a infinite loop, because i keep getting wip_cev_read event, if a put a boolean flag so that only once the read to start then reading of data freezes. Could someone help me out? Here is my code
void dota_read_upgrade(void){
s32 len;
u8 buf[1500];
s32 RetVal32 = 0x00;
//Keep reading until you read 0
while ((len = wip_read(dataChannel, buf, sizeof(buf))) > 0)
{
//New Data is added to end of Current data in Cell
RetVal32 = adl_adWrite(DOTA_Cell_Handle, len, (void*)buf);
if (RetVal32 != 0)
{
TRACE(TRACE_LEVEL_FTP,"Something is wrong with A&D Space,Please format and Retry");
wip_close(controlChannel);
}
}
}
//*********************************************************************************************************
// Handler for the events related to the data channel
//*********************************************************************************************************
static void dota_ftpUpgradedataChannelHandler(wip_event_t * event, void * context) {
ascii buff[4];
ascii buffer[30];
s32 s32RetVal;
wm_sprintf(buff,"%d",event->kind);
dbg_writeToConsole(TRACE_LEVEL_FTP,"dota_ftpUpgradedataChannelHandler event");
dbg_writeToConsole(TRACE_LEVEL_FTP,buff);
switch (event->kind) {
case WIP_CEV_OPEN: break;
case WIP_CEV_READ:
dbg_writeToConsole(TRACE_LEVEL_FTP, "Start read");
dota_read_upgrade();
break;
case WIP_CEV_PEER_CLOSE:
dbg_writeToConsole(TRACE_LEVEL_FTP, "WIP_CEV_PEER_CLOSE");
//all Data Downloaded
dbg_writeToConsole(TRACE_LEVEL_FTP, "FTP Download Completed");
//Finalize Cell with Undefined Size before you can use it
s32RetVal = adl_adFinalise(DOTA_Cell_Handle);
//Install The New Application
s32RetVal = adl_adInstall(DOTA_Cell_Handle);
break;
case WIP_CEV_ERROR:
wip_debug( "Error %i on channel 0x%x\n", event->content.error.errnum,event->channel);
// if (dataChannel) {
wip_close( dataChannel);
dataChannel = (wip_channel_t)NULL;
// }
if( controlChannel) {
wip_close( controlChannel);
controlChannel = (wip_channel_t)NULL;
}
LOG_ERR(E_FTP_NOT_ABLE_TO_SEND);
break;
default : dbg_writeToConsole(TRACE_LEVEL_FTP,"ftp_dataChannelHandler default event");
//LOG_ERR(E_FTP_NOT_ABLE_TO_SEND);
break;
}
}
//*********************************************************************************************************
// Handler for the events related to the ftp channel
//*********************************************************************************************************
static void dota_ftpUpgradeControlChannelHandler(wip_event_t *event,void *context){
ascii buff[4];
ascii buffer[30];
wm_sprintf(buff,"%d",event->kind);
dbg_writeToConsole(TRACE_LEVEL_FTP,"dota_ftpUpgradeControlChannelHandler event");
dbg_writeToConsole(TRACE_LEVEL_FTP,buff);
switch( event->kind) {
case WIP_CEV_DONE:
dbg_writeToConsole(TRACE_LEVEL_FTP,"WIP_CEV_DONE");
//wip_getFileSize(controlChannel,ftpFile);
break;
case WIP_CEV_OPEN:
dataChannel = wip_getFile( controlChannel, ftpFile, dota_ftpUpgradedataChannelHandler, NULL);
if( ! dataChannel) {
wip_debug( "Can't create data channel");
LOG_ERR(E_FTP_NOT_ABLE_TO_CONNECT);
return;
}
break;
case WIP_CEV_ERROR:
wip_debug( "Error %i on cx channel\n", event->content.error.errnum);
// fall through
case WIP_CEV_PEER_CLOSE:
wip_debug( "Closing everything\n");
if( dataChannel) {
wip_close( dataChannel);
dataChannel = (wip_channel_t)NULL;
}
wip_close( controlChannel);
controlChannel = (wip_channel_t)NULL;
LOG_ERR(E_FTP_NOT_ABLE_TO_CONNECT);
break;
default :
LOG_ERR(E_FTP_NOT_ABLE_TO_CONNECT);
dbg_writeToConsole(TRACE_LEVEL_FTP,"Default for ftp_controlChannelHandler");
break;
}
}
void upgradeApp(ascii * fileName){
dbg_writeToConsole(TRACE_LEVEL_FTP,"Starting update of project");
dbg_writeToConsole(TRACE_LEVEL_FTP,fileName);
ftpFile=fileName;
controlChannel = wip_FTPCreateOpts (dota_ftp_settings->ftpServerName, dota_ftpUpgradeControlChannelHandler, NULL,
WIP_COPT_USER, dota_ftp_settings->ftpUserName, WIP_COPT_PASSWORD, dota_ftp_settings->ftpPassword, WIP_COPT_PASSIVE,
TRUE, WIP_COPT_END);
}