Please help, DOTA downloading?

Good morning everyone!
The fisrt, i want saying thanks you to everyone reading my Topic and try to help me. Thanks you very much.
Now i’ve problem with DOTA. This is My Sample code :

#include "adl_global.h"
    #include "wip.h"

    const u16 wm_apmCustomStackSize = 4096;

    /* Variables */
    u8 ftp_State = 0;
    u8 GPRS_State = 0;
    s32 DOTA_Cell_Handle = 0;
    s32 ADEventHandle = 0;
    ascii SimPin[4];
    static wip_bearer_t gprs_bearer = NULL;
    wip_channel_t ftp_WipHandle, ftp_Data_Channel;
    ascii dotafile[64];
    wip_bearer_t myBearer;
    //TRACE LEVELS
    #define lvl_Common   9
    #define lvl_Sim      10
    #define lvl_WIP      11
    #define lvl_AD      12

    // Destination address
    #define STR_SIZE        64   // Common string size
    #define STR_SIZE_SRV    128  // Server parameters string size
    struct
    {
      u16 Port; // FTP server port
      u8 Mode; // FTP server mode (active/passive)
      ascii Type; // FTP server type (binary/ascii)
      ascii Server[STR_SIZE_SRV]; // FTP server address
      ascii Login[STR_SIZE]; // FTP account login
      ascii Password[STR_SIZE]; // FTP account password
      ascii FileName1[STR_SIZE_SRV]; // FTP server file name
      ascii FileName2[STR_SIZE_SRV]; // FTP server file name
    } ftp_DestAddr;

    struct
    {
      ascii APN_Name[STR_SIZE];
      ascii Username[STR_SIZE];
      ascii Password[STR_SIZE];
    } APN_Details;

    void adl_main(adl_InitType_e InitType);
    void initvariables();
    void Sim_Handler(u8 Event);
    void GPRS_Attach(wip_bearer_t *wb);
    static void gprs_bearer_handler(wip_bearer_t br, s8 event, void *ctx);
    void ConnectFTP();
    void ftp_SessionHandler(wip_event_t *ev, void *ctx);
    void ftp_DataHandler(wip_event_t *ev, void *ctx);
    //void ftp_Write(void);
    void ftp_Read(void);
    //void FTPGetMyFile(wip_event_t *ev, void *ctx);
    void ADEvHandler(adl_adEvent_e Event, u32 Progress);
    void DotaCellHandleReturnValue();
    void CmdDOTAHandler1(adl_atCmdPreParser_t *params);
    void CmdDOTAHandler2(adl_atCmdPreParser_t *params);
    void CmdFORMATHandler(adl_atCmdPreParser_t *params);
    void CmdINSTALLHandler(adl_atCmdPreParser_t *params);
    void CmdCOMPACTHandler(adl_atCmdPreParser_t *params);
    /***************************************************************************/
    /*  Local functions                                                        */
    /***************************************************************************/
    char ErrMsg[256];
    void mlog(ascii *msg)
    {
    	adl_atSendResponse(ADL_AT_PORT_TYPE(ADL_PORT_UART1,ADL_AT_RSP), msg);
    }

    char InfoMsg[256];
    void Info(ascii *msg)
    {
    	adl_atSendResponse(ADL_AT_PORT_TYPE(ADL_PORT_UART1,ADL_AT_RSP), msg);
    }

    void adl_main(adl_InitType_e InitType)
    {
      s8 S8RetVal = 0;
      s32 s32RetVal = 0;
      wm_sprintf(InfoMsg, "adl_main :Start InitType: %d\r\n", InitType);
      Info(InfoMsg);
      GPRS_State = 0;
      //This Check is only for RTE because it does not always return the correct InitType
      if (InitType < 0)
      {
        InitType = 0;
      }
      // Initialize TCP/IP stack
      S8RetVal = wip_netInit();
      wm_sprintf(InfoMsg, "wip_netInit Ret= %d\r\n", S8RetVal);
      Info(InfoMsg);
      // Initialize My Variables
      initvariables();
      //Subscribe To Sim card For Notifications
      s32RetVal = adl_simSubscribe(Sim_Handler, SimPin);
      wm_sprintf(InfoMsg, "adl_simSubscribe Ret= %d\r\n", s32RetVal);
      Info(InfoMsg);
      ADEventHandle = adl_adEventSubscribe(ADEvHandler);
      wm_sprintf(InfoMsg, "adl_adEventSubscribe Ret= %d\r\n", ADEventHandle);
      Info(InfoMsg);

      adl_atCmdSubscribe("AT+DOTA1", CmdDOTAHandler1, ADL_CMD_TYPE_ACT);
      adl_atCmdSubscribe("AT+DOTA2", CmdDOTAHandler2, ADL_CMD_TYPE_ACT);
      adl_atCmdSubscribe("AT+FORMAT", CmdFORMATHandler, ADL_CMD_TYPE_ACT);
      adl_atCmdSubscribe("AT+INSTALL", CmdINSTALLHandler, ADL_CMD_TYPE_ACT);
      adl_atCmdSubscribe("AT+COMPACT", CmdCOMPACTHandler, ADL_CMD_TYPE_ACT);

      wm_sprintf(InfoMsg, "App Version : 2\r\n");
      Info(InfoMsg);
      switch (InitType)
      {
        case ADL_INIT_POWER_ON:
          // Normal power on
          wm_sprintf(InfoMsg, "ADL_INIT_POWER_ON\r\n" );
          Info(InfoMsg);
          wm_sprintf(InfoMsg, "app start normallY\r\n" );
          Info(InfoMsg);
          wm_sprintf(InfoMsg, "Please wait for Sim to Init...\r\n" );
          Info(InfoMsg);
          //Create a Cell For The Dota File
          DOTA_Cell_Handle = adl_adSubscribe(0, ADL_AD_SIZE_UNDEF);
          wm_sprintf(InfoMsg, "DOTA_Cell_Subscribe Ret= %d\r\n", DOTA_Cell_Handle);
          Info(InfoMsg);

          if (DOTA_Cell_Handle < 0)
          {
            //If Cell Is Not Subscribed WHY???
            DotaCellHandleReturnValue();
          }
          break;
        case ADL_INIT_REBOOT_FROM_EXCEPTION:
          // Reboot after an embedded application exception
        	wm_sprintf(InfoMsg, "ADL_INIT_REBOOT_FROM_EXCEPTION\r\n" );
        	Info(InfoMsg);
        	wm_sprintf(InfoMsg, "Modem Start After Exception\r\n" );
        	Info(InfoMsg);
          break;
        case ADL_INIT_DOWNLOAD_SUCCESS:
          // Reboot after a successful download process
        	wm_sprintf(InfoMsg, "ADL_INIT_DOWNLOAD SUCCESS\r\n" );
        	Info(InfoMsg);
        	wm_sprintf(InfoMsg, "MODEM START AFTER DOTA OK\r\n" );
        	Info(InfoMsg);
          //Format A&amp;D to clear Dota File
          s32RetVal = adl_adFormat(ADEventHandle);
          wm_sprintf(InfoMsg, "adl_adFormat Ret= %d\r\n", s32RetVal);
          Info(InfoMsg);
          break;
        case ADL_INIT_DOWNLOAD_ERROR:
          // Reboot after a Failed download process
        	wm_sprintf(InfoMsg, "ADL_INIT_DOWNLOAD_ERROR\r\n" );
        	Info(InfoMsg);
        	wm_sprintf(InfoMsg, "MODEM START AFTER DOTA OK\r\n" );
        	Info(InfoMsg);
          //Format A&amp;D to clear Dota File
          ////s32RetVal = adl_adFormat(ADEventHandle);
          ////TRACE((lvl_AD, "adl_adFormat Ret= %d", s32RetVal));
          break;
      }
  	wm_sprintf(InfoMsg, "EXIT MAIN.\r\n" );
  	Info(InfoMsg);
    }

    void DotaCellHandleReturnValue()
    {
      //TODO: Handle Cell Subscribe Failures
    	wm_sprintf(InfoMsg, "DotaCellHandleReturnValue :Start\r\n" );
    	Info(InfoMsg);
      switch (DOTA_Cell_Handle)
      {
        case ADL_RET_ERR_ALREADY_SUBSCRIBED:
        	wm_sprintf(InfoMsg, "ADL_RET_ERR_ALREADY_SUBSCRIBED\r\n" );
        	Info(InfoMsg);
          //if the cell is already subscribed
          break;
        case ADL_RET_ERR_PARAM:
          //on parameter error
        	wm_sprintf(InfoMsg, "ADL_RET_ERR_PARAM\r\n" );
        	Info(InfoMsg);
          break;
        case ADL_RET_ERR_BAD_STATE:
          //if an undefined size cell is already subscribed and not finalized
        	wm_sprintf(InfoMsg, "ADL_RET_ERR_BAD_STATE\r\n" );
        	Info(InfoMsg);
          break;
        case ADL_AD_RET_ERR_NOT_AVAILABLE:
          //if A&amp;D space is not available
        	wm_sprintf(InfoMsg, "ADL_AD_RET_ERR_NOT_AVAILABLE\r\n" );
        	Info(InfoMsg);
          break;
        case ADL_AD_RET_ERR_OVERFLOW:
          //if there is not enough space for allocation
        	wm_sprintf(InfoMsg, "ADL_AD_RET_ERR_OVERFLOW\r\n" );
        	Info(InfoMsg);
          break;
        case ADL_RET_ERR_SERVICE_LOCKED:
          //if called from a low level interruption handler
        	wm_sprintf(InfoMsg, "ADL_RET_ERR_SERVICE_LOCKED\r\n" );
        	Info(InfoMsg);
          break;
      }
  	wm_sprintf(InfoMsg, "DotaCellHandleReturnValue :Exit\r\n" );
  	Info(InfoMsg);
    }

    void ADEvHandler(adl_adEvent_e Event, u32 Progress)
    {
			wm_sprintf(InfoMsg, "ADEvHandler :Start Event: %d\r\n",Event );
			Info(InfoMsg);
		  switch (Event)
		  {
			case ADL_AD_EVENT_FORMAT_INIT:
			  // Format process initialization
				wm_sprintf(InfoMsg, "ADL_AD_EVENT_FORMAT_INIT.....\r\n" );
				Info(InfoMsg);
			  break;
			case ADL_AD_EVENT_FORMAT_PROGRESS:
			  // Format process progress
				wm_sprintf(InfoMsg, "ADL_AD_EVENT_FORMAT_PROGRESS\r\n" );
				Info(InfoMsg);
			  break;
			case ADL_AD_EVENT_FORMAT_DONE:
			  // Format process Done
				wm_sprintf(InfoMsg, "ADL_AD_EVENT_FORMAT_DONE...FORMAT COMPLETED\r\n" );
				Info(InfoMsg);
			  //A&D Is Empty Create your A&D objects
			  //NOTE! if you create undefined size then you can only create one
				DOTA_Cell_Handle = adl_adSubscribe(0, ADL_AD_SIZE_UNDEF);
				wm_sprintf(InfoMsg, "DOTA CELL HANDLE =: %d\r\n",DOTA_Cell_Handle );
				Info(InfoMsg);
			  if (DOTA_Cell_Handle < 0)
			  {
				//If Cell Is Not Subscribed WHY???
				DotaCellHandleReturnValue();
			  }
			  break;
			case ADL_AD_EVENT_RECOMPACT_INIT:
			  // Re-compaction process initialization
				wm_sprintf(InfoMsg, "ADL_AD_EVENT_RECOMPACT_INIT\r\n" );
				Info(InfoMsg);
				wm_sprintf(InfoMsg, "Recompact Starting...\r\n" );
				Info(InfoMsg);
			  break;
			case ADL_AD_EVENT_RECOMPACT_PROGRESS:
			  // Re-compaction process progress
				wm_sprintf(InfoMsg, "ADL_AD_EVENT_RECOMPACT_PROGRESS\r\n" );
				Info(InfoMsg);
			  break;
			case ADL_AD_EVENT_RECOMPACT_DONE:
			  // Re-compaction process Done
				wm_sprintf(InfoMsg,"ADL_AD_EVENT_RECOMPACT_DONE \r\n" );
				Info(InfoMsg);
				wm_sprintf(InfoMsg,"Recompact Completed\r\n");
				Info(InfoMsg);
				DOTA_Cell_Handle = adl_adSubscribe(0, ADL_AD_SIZE_UNDEF);

				wm_sprintf(InfoMsg, "DOTA_Cell_Handle=%d\r\n", DOTA_Cell_Handle );
				Info(InfoMsg);

			  if (DOTA_Cell_Handle <0)
			  {
				//If Cell Is Not Subscribed WHY???
				DotaCellHandleReturnValue();
			  }
			  break;
			case ADL_AD_EVENT_INSTALL:
				wm_sprintf(InfoMsg,"ADL_AD_EVENT_INSTALL \r\n" );
				Info(InfoMsg);
			  break;
		  }
		wm_sprintf(InfoMsg,"ADEvHandler :Exit \r\n" );
		Info(InfoMsg);
    }

    void Sim_Handler(u8 Event)
    {
    	wm_sprintf(InfoMsg, "Sim_Handler :Start with Event: %d\r\n", Event );
    	Info(InfoMsg);
      switch (Event)
      {
        case ADL_SIM_EVENT_FULL_INIT:
          //When Sim is fully Init then Continue
        	wm_sprintf(InfoMsg,"Sim Init Complete \r\n" );
        	Info(InfoMsg);
          GPRS_Attach(&myBearer);
          break;
        case ADL_SIM_EVENT_PIN_WAIT:
        	wm_sprintf(InfoMsg, "ADL_SIM_EVENT_PIN_WAIT\r\n" );
        	Info(InfoMsg);
          break;
        case ADL_SIM_EVENT_PIN_OK:
        	wm_sprintf(InfoMsg, "ADL_SIM_EVENT_PIN_OK\r\n" );
        	Info(InfoMsg);
          break;
        case ADL_SIM_EVENT_INSERTED:
        	wm_sprintf(InfoMsg,"ADL_SIM_EVENT_INSERTED \r\n" );
        	Info(InfoMsg);
          break;
        case ADL_SIM_EVENT_REMOVED:
        	wm_sprintf(InfoMsg, "ADL_SIM_EVENT_REMOVED\r\n" );
        	Info(InfoMsg);
          break;
        case ADL_SIM_EVENT_PIN_ERROR:
        	wm_sprintf(InfoMsg,"ADL_SIM_EVENT_PIN_ERROR \r\n" );
        	Info(InfoMsg);
          break;
        case ADL_SIM_EVENT_PIN_NO_ATTEMPT:
        	wm_sprintf(InfoMsg, "ADL_SIM_EVENT_PIN_NO_ATTEMPT\r\n" );
        	Info(InfoMsg);
          break;
        case ADL_SIM_EVENT_LAST:
        	wm_sprintf(InfoMsg, "ADL_SIM_EVENT_LAST \r\n" );
        	Info(InfoMsg);
          break;
      }
  	wm_sprintf(InfoMsg,"Sim_Handler :Exit \r\n" );
  	Info(InfoMsg);
    }

    void GPRS_Attach(wip_bearer_t *wb)
    {
    	s8 ercode;
    	s8 s8RetVal;
		wm_sprintf(InfoMsg, "GPRS_Attach :Start\r\n" );
		Info(InfoMsg);
    	wm_sprintf(InfoMsg,"Connecting To GPRS... \r\n" );
    	Info(InfoMsg);
      //Create a Bearer e.g GPRS,CSD Call,UART


    	s8RetVal = wip_bearerOpen(&gprs_bearer, "GPRS", gprs_bearer_handler, NULL);
    	wm_sprintf(InfoMsg,"wip_bearerOpen Retval: %d \r\n", s8RetVal );
    	Info(InfoMsg);
      //Provide GPRS(in this case)Login Details
    	s8RetVal = wip_bearerSetOpts(gprs_bearer, WIP_BOPT_GPRS_APN,
        APN_Details.APN_Name, WIP_BOPT_LOGIN, APN_Details.Username,
        WIP_BOPT_PASSWORD, APN_Details.Password, WIP_BOPT_END);

    	wm_sprintf(InfoMsg,"wip_bearerSetOpts Retval: %d \r\n", s8RetVal );
    	Info(InfoMsg);
      //Connect the Bearer(GPRS Attach)
    	s8RetVal = wip_bearerStart(gprs_bearer);


    	wm_sprintf(InfoMsg, "wip_bearerStart Retval: %d\r\n", s8RetVal );
    	Info(InfoMsg);
    	wm_sprintf(InfoMsg,"GPRS_Attach :Exit \r\n" );
    	Info(InfoMsg);
    }

    static void gprs_bearer_handler(wip_bearer_t br, s8 event, void *ctx)
    {
      ascii RspStr[128];
      ascii ipStr[16], dns1Str[16], dns2Str[16];
      wip_in_addr_t ip, dns1, dns2;
    	wm_sprintf(InfoMsg,"gprs_bearer_handler :Start with Event: %d\r\n", event );
    	Info(InfoMsg);
      //Make Sure Correct Bearer is connecting
      if (br != gprs_bearer)
    	  return ;
      switch (event)
      {
        case WIP_BEV_IP_CONNECTED:
          //Get Bearer Info
			wm_sprintf(InfoMsg, "WIP_BEV_IP_CONNECTED\r\n" );
			Info(InfoMsg);
			wip_bearerGetOpts(br, WIP_BOPT_IP_ADDR,&ip, WIP_BOPT_IP_DNS1, &dns1,
			WIP_BOPT_IP_DNS2,&dns2, WIP_BOPT_END);
			wip_inet_ntoa(ip, ipStr, sizeof(ipStr));
			wip_inet_ntoa(dns1, dns1Str, sizeof(dns1Str));
			wip_inet_ntoa(dns2, dns2Str, sizeof(dns2Str));
			wm_sprintf(InfoMsg, "GPRS: CONNECTED IP=%s DNS1=%s DNS2=%s\r\n", ipStr,dns1Str, dns2Str );
			Info(InfoMsg);
			wm_sprintf(InfoMsg, "%d\r\n" ,RspStr);
			Info(InfoMsg);
        	wm_sprintf(InfoMsg, "GPRS Connect Ready For DOTA\r\n" );
        	Info(InfoMsg);
			GPRS_State = 1;

          break;
        case WIP_BEV_IP_DISCONNECTED:
        	wm_sprintf(InfoMsg, "WIP_BEV_IP_DISCONNECTED\r\n" );
        	Info(InfoMsg);
          	wm_sprintf(InfoMsg,"WIPSTART: DISCONNECTED \r\n" );
          	Info(InfoMsg);
          	GPRS_State = 0;
          //ReAttach
          GPRS_Attach(&myBearer);
          break;
        case WIP_BEV_STOPPED:
        	wm_sprintf(InfoMsg,"WIP_BEV_STOPPED \r\n" );
        	Info(InfoMsg);
        	wip_bearerClose(br);
          GPRS_State = 0;
          gprs_bearer = NULL;
          //ReAttach
          GPRS_Attach(&myBearer);
          break;
        case WIP_BEV_CONN_FAILED:
        	wm_sprintf(InfoMsg, "WIP_BEV_CONN_FAILED\r\n" );
        	Info(InfoMsg);
          	wm_sprintf(InfoMsg,"WIPSTART: FAILED \r\n" );
          	Info(InfoMsg);
          	wip_bearerClose(br);
		  gprs_bearer = NULL;
		  //ReAttach
		  GPRS_State = 0;
		  GPRS_Attach(&myBearer);
		  break;
      }
    	wm_sprintf(InfoMsg,"gprs_bearer_handler :Exit \r\n" );
    	Info(InfoMsg);
    }

    void ConnectFTP()
    {
    	wm_sprintf(InfoMsg, "ConnectFTP :Start\r\n" );
    	Info(InfoMsg);
    	// Check for current state
    	if (!ftp_State)
    	{
        // Get parameters
        //ftp_Mode = FTP_MODE_GET;
        //      adl_atSendResponse( ADL_AT_RSP,"\r\nEnter ConnectFTP\r\n");
    		wm_sprintf(InfoMsg, "ConnectFTP :Start-> !ftp_State\r\n" );
    		Info(InfoMsg);
    		ftp_WipHandle = wip_FTPCreateOpts(ftp_DestAddr.Server, ftp_SessionHandler,
    				NULL, WIP_COPT_USER, ftp_DestAddr.Login, WIP_COPT_PASSWORD,
    				ftp_DestAddr.Password, WIP_COPT_PASSIVE, ftp_DestAddr.Mode, WIP_COPT_TYPE,
    				ftp_DestAddr.Type, WIP_COPT_PEER_PORT, ftp_DestAddr.Port, WIP_COPT_END);
			if (ftp_WipHandle == NULL)
			{
				  // FTP error
				  wm_sprintf(InfoMsg, "FTP Has Not Started\r\n" );
				  Info(InfoMsg);
				  adl_atSendStdResponseExt(ADL_AT_RSP, ADL_STR_CME_ERROR, 3);
				  ftp_State = 0;
			}
			else
			{
			  // FTP started
				  wm_sprintf(InfoMsg, "FTP Has Started Ok%\r\n" );
				  Info(InfoMsg);
				  wm_sprintf(InfoMsg, "FTP STARTED OK\r\n" );
				  Info(InfoMsg);
				  ftp_State = 1;
			}
      }
      else
      {
        // Already running
        adl_atSendStdResponseExt(ADL_AT_RSP, ADL_STR_CME_ERROR, 515);
      }
      wm_sprintf(InfoMsg, "ConnectFTP :Exit\r\n" );
	  Info(InfoMsg);
	 }

    void ftp_SessionHandler(wip_event_t *ev, void *ctx)
    {
      wm_sprintf(InfoMsg, "ftp_SessionHandler :Start with Event %d\r\n", ev->kind );
	  Info(InfoMsg);
      switch (ev->kind)
      {
        case WIP_CEV_OPEN:
          //Download The Dota File
          //TODO Make sure Cell is empty first
          wm_sprintf(InfoMsg, "WIP_CEV_OPEN\r\n" );
		  Info(InfoMsg);
          wm_sprintf(InfoMsg, "DOWNLOADING NEW APP\r\n" );
		  Info(InfoMsg);
          ftp_Data_Channel = wip_getFile(ftp_WipHandle, dotafile, ftp_DataHandler,NULL);
          break;
        case WIP_CEV_DONE:
          //Called if you close the Connection
          wm_sprintf(InfoMsg, "WIP_CEV_DONE\r\n" );
		  Info(InfoMsg);
          wm_sprintf(InfoMsg, "FTP CONNECTION CLOSED BY APP\r\n" );
		  Info(InfoMsg);
          break;
        case WIP_CEV_PEER_CLOSE:
          //Called if Remote Connection Closes the Connection
          wm_sprintf(InfoMsg, "WIP_CEV_PEER_CLOSE\r\n" );
		  Info(InfoMsg);
          wm_sprintf(InfoMsg, "FTP Connection Closed by PEER\r\n" );
		  Info(InfoMsg);
        case WIP_CEV_ERROR:
          // End of transfer
          wm_sprintf(InfoMsg, "WIP_CEV_ERROR\r\n" );
		  Info(InfoMsg);
          wm_sprintf(InfoMsg, "FTP CONNECTION CLOSED\r\n" );
		  Info(InfoMsg);
          ftp_State = 0;
          //Close the FTP Connection
          wip_close(ftp_WipHandle);
          ftp_WipHandle = NULL;
          break;
      }
      wm_sprintf(InfoMsg, "ftp_SessionHandler :Exit\r\n" );
	  Info(InfoMsg);
    }

    void ftp_DataHandler(wip_event_t *ev, void *ctx)
    {
      s32 s32RetVal = 0;
      wm_sprintf(InfoMsg, "ftp_DataHandler :Start with Event %d\r\n", ev->kind );
	  Info(InfoMsg);
      wip_debug("FTP data event: %d\n", ev->kind);
      switch (ev->kind)
      {
        case WIP_CEV_OPEN:
          wm_sprintf(InfoMsg, "WIP_CEV_OPEN\r\n" );
		  Info(InfoMsg);
          break;
        case WIP_CEV_READ:
          wm_sprintf(InfoMsg, "WIP_CEV_READ\r\n" );
		  Info(InfoMsg);
          // Read FTP data
          wm_sprintf(InfoMsg, "$\r\n" );
		  Info(InfoMsg);
          ftp_Read();
          break;
        case WIP_CEV_WRITE:
          wm_sprintf(InfoMsg, "WIP_CEV_WRITE\r\n" );
		  Info(InfoMsg);
          // Write FTP Data
          break;
        case WIP_CEV_PEER_CLOSE:
          wm_sprintf(InfoMsg, "WIP_CEV_PEER_CLOSE\r\n" );
		  Info(InfoMsg);
          //all Data Downloaded
          wm_sprintf(InfoMsg, "FTP Download Completed\r\n" );
		  Info(InfoMsg);
          //Finalize Cell with Undefined Size before you can use it
          s32RetVal = adl_adFinalise(DOTA_Cell_Handle);

          wm_sprintf(InfoMsg,"adl_adFinalise return Code %d\r\n", s32RetVal );
		  Info(InfoMsg);

        case WIP_CEV_ERROR:
          wm_sprintf(InfoMsg, "WIP_CEV_ERROR\r\n" );
		  Info(InfoMsg);
          // Close data channel
          wip_close(ftp_Data_Channel);
          // Close session channel
          wm_sprintf(InfoMsg, "ErrorNumber: %d\r\n", ev->content.error.errnum );
		  Info(InfoMsg);
          if (ev->content.error.errnum == WIP_CERR_ABORTED)
          {
        	  wm_sprintf(InfoMsg, "ftp download aborted\r\n" );
        	  Info(InfoMsg);
          }
          if (ftp_WipHandle != NULL)
          {
            wip_close(ftp_WipHandle);
            ftp_WipHandle = NULL;
          }
          break;
      }
      wm_sprintf(InfoMsg, "ftp_DataHandler :Exit\r\n" );
	  Info(InfoMsg);
    }

    void ftp_Read(void)
    {
      int len = 0x00;
      u8 buf[256] =
      {
        NULL
      };
      s32 RetVal32 = 0x00;
      wm_sprintf(InfoMsg, "ftp_Read :Start\r\n" );
	  Info(InfoMsg);
      wm_sprintf(InfoMsg, "Read Data From FTP\r\n" );
	  Info(InfoMsg);
      //Keep reading until you read 0
      while ((len = wip_read(ftp_Data_Channel, buf, sizeof(buf))) > 0)
      {
        //Write Data To A&D
        wm_sprintf(InfoMsg, "Bytes Read:%d\r\n", len );
		  Info(InfoMsg);
        //New Data is added to end of Current data in Cell
        RetVal32 = adl_adWrite(DOTA_Cell_Handle, len, (void*)buf);
        wm_sprintf(InfoMsg, "adl_adWrite RetCode:%d\r\n", RetVal32 );
		  Info(InfoMsg);
        if (RetVal32 != 0)
        {
			wm_sprintf(InfoMsg, "Something is wrong with A&amp;D Space,\r\nPlease format and Retry\r\n" );
			Info(InfoMsg);
			wip_close(ftp_WipHandle);
        }
      }
      wm_sprintf(InfoMsg, "ftp_Read :Exit\r\n" );
	  Info(InfoMsg);
    }

    void CmdDOTAHandler1(adl_atCmdPreParser_t *params)
    {
      wm_sprintf(InfoMsg, "CmdDOTAHandler1 :Start With Event %d\r\n", params->Type );
	  Info(InfoMsg);
      if (GPRS_State == 1)
      {
        //Connect To FTP To Download New Application

        wm_sprintf(dotafile, ftp_DestAddr.FileName1);
        wm_sprintf(InfoMsg, "%s -> OK\r\n",dotafile );
        Info(InfoMsg);
        ConnectFTP();
      }
      else
      {
        //Connect To GPRS First
        wm_sprintf(InfoMsg, "First Connecting to GPRS\r\n" );
		  Info(InfoMsg);
        wm_sprintf(InfoMsg, "Please Wait Before Retry\r\n" );
		  Info(InfoMsg);
        wm_sprintf(InfoMsg, "Error\r\n" );
		  Info(InfoMsg);
        GPRS_Attach(&myBearer);
      }
      wm_sprintf(InfoMsg, "CmdDOTAHandler1 :Exit\r\n" );
	  Info(InfoMsg);
    }

    void CmdDOTAHandler2(adl_atCmdPreParser_t *params)
    {
      wm_sprintf(InfoMsg, "CmdDOTAHandler2 :Start With Event %d\r\n" , params->Type);
	  Info(InfoMsg);
      if (GPRS_State == 1)
      {
        //Connect To FTP To Download New Application
        wm_sprintf(dotafile, ftp_DestAddr.FileName2);
        wm_sprintf(InfoMsg, "OK\r\n" );
		  Info(InfoMsg);
        ConnectFTP();
      }
      else
      {
        //Connect To GPRS First
        wm_sprintf(InfoMsg, "First Connecting to GPRS\r\n" );
		  Info(InfoMsg);
        wm_sprintf(InfoMsg, "Please Wait Before Retry\r\n" );
		  Info(InfoMsg);
        wm_sprintf(InfoMsg, "ERROR\r\n" );
		  Info(InfoMsg);
        GPRS_Attach(&myBearer);
      }
      wm_sprintf(InfoMsg, "CmdDOTAHandler2 :Exit\r\n" );
	  Info(InfoMsg);
    }

    void CmdFORMATHandler(adl_atCmdPreParser_t *params)
    {
      s32 s32RetVal;
      wm_sprintf(InfoMsg, "CmdFORMATHandler :Start With Event %d\r\n", params->Type );
	  Info(InfoMsg);
      //Format A&D to clear Dota File
      adl_adFinalise(DOTA_Cell_Handle);
      adl_adUnsubscribe(DOTA_Cell_Handle);
      s32RetVal = adl_adFormat(ADEventHandle);
      wm_sprintf(InfoMsg, "adl_adFormat Ret= %d\r\n", s32RetVal );
	  Info(InfoMsg);
      if (s32RetVal == 0)
      {
        wm_sprintf(InfoMsg, "OK\r\n" );
		  Info(InfoMsg);
      }
      else
      {
        wm_sprintf(InfoMsg, "ERROR\r\n" );
		  Info(InfoMsg);
      }
      //  OK                                             */
      //ADL_RET_ERR_UNKNOWN_HDL //if the handle is unknown           */
      //ADL_RET_ERR_NOT_SUBSCRIBED //if the service is not subscribed*/
      //ADL_AD_RET_ERR_NOT_AVAILABLE //if A&amp;D space is not available */
      //ADL_RET_ERR_BAD_STATE //if there is at least one currently   */
      //subscribed cell or if a recompact/format process is running */
      //ADL_RET_ERR_SERVICE_LOCKED //if called from a low level
      wm_sprintf(InfoMsg, "CmdFORMATHandler :Exit\r\n" );
	  Info(InfoMsg);
    }

    void CmdINSTALLHandler(adl_atCmdPreParser_t *params)
    {
      s32 s32RetVal;
      wm_sprintf(InfoMsg, "CmdINSTALLHandler :Start With Event %d\r\n" , params->Type);
	  Info(InfoMsg);
      //Install The New Application
      s32RetVal = adl_adInstall(DOTA_Cell_Handle);
      if (s32RetVal != OK)
      {
        wm_sprintf(InfoMsg, "ERROR\r\n" );
		  Info(InfoMsg);
      }
      else
      {
        wm_sprintf(InfoMsg, "OK\r\n" );
		  Info(InfoMsg);
      }
      wm_sprintf(InfoMsg, "CmdINSTALLHandler :Exit\r\n" );
	  Info(InfoMsg);
    }

    void CmdCOMPACTHandler(adl_atCmdPreParser_t *params)
    {
      s32 s32RetVal;
      wm_sprintf(InfoMsg, "CmdCOMPACTHandler :Start With Event %d\r\n", params->Type );
	  Info(InfoMsg);
      adl_adFinalise(DOTA_Cell_Handle);
      adl_adUnsubscribe(DOTA_Cell_Handle);
      s32RetVal = adl_adRecompact(ADEventHandle);
      wm_sprintf(InfoMsg, "adl_adRecompact Ret= %d\r\n", s32RetVal );
	  Info(InfoMsg);
      if (s32RetVal == 0)
      {
        wm_sprintf(InfoMsg, "OK\r\n" );
		  Info(InfoMsg);
      }
      else
      {
        wm_sprintf(InfoMsg, "ERROR\r\n" );
		  Info(InfoMsg);
      }
      wm_sprintf(InfoMsg, "CmdCOMPACTHandler :Exit\r\n" );
	  Info(InfoMsg);
    }

    void initvariables()
    {
      wm_sprintf(InfoMsg, "initvariables :Start\r\n" );
	  Info(InfoMsg);
      ftp_DestAddr.Port = 21;
      ftp_DestAddr.Mode = 1;
      ftp_DestAddr.Type = 'A';
      wm_sprintf(ftp_DestAddr.Server, "abc.aac.ds.aad");
      wm_sprintf(ftp_DestAddr.Login, "waveccom");
      wm_sprintf(ftp_DestAddr.Password, "MyPass");
      wm_sprintf(ftp_DestAddr.FileName1, "hello.dwl");
      wm_sprintf(ftp_DestAddr.FileName2, "file2.dwl");
      wm_sprintf(APN_Details.APN_Name, "m3-world");
      wm_sprintf(APN_Details.Username, "mms");
      wm_sprintf(APN_Details.Password, "mms");
      wm_sprintf(InfoMsg, "initvariables :Exit\r\n" );
	  Info(InfoMsg);
    }

and here are Remote Shell Target :

adl_main tart InitType: -858993460
wip_netInit Ret= 0
initvariables tart
initvariables :Exit
adl_simSubscribe Ret= 0
adl_adEventSubscribe Ret= 0
App Version : 2
EXIT MAIN.
Sim_Handler tart with Event: 5
ADL_SIM_EVENT_PIN_OK
Sim_Handler :Exit
+WIND: 16
Sim_Handler tart with Event: 3
Sim Init Complete
GPRS_Attach tart
Connecting To GPRS…
wip_bearerOpen Retval: 0
wip_bearerSetOpts Retval: 0
wip_bearerStart Retval: -27
GPRS_Attach :Exit
Sim_Handler :Exit
+WIND: 4
+WIND: 10,“SM”,0,“FD”,0,“ON”,0,“EN”,0
+WIND: 11,“867EED28439F42574F680B55B7B933B2”,
gprs_bearer_handler tart with Event: 2
WIP_BEV_IP_CONNECTED
GPRS: CONNECTED IP=10.1.115.123 DNS1=10.1.10.11 DNS2=10.1.10.11
60751368
GPRS Connect Ready For DOTA
gprs_bearer_handler :Exit

CmdDOTAHandler1 tart With Event 2048
hello.dwl -> OK
ConnectFTP tart
ConnectFTP tart-> !ftp_State
FTP Has Started Ok
FTP STARTED OK
ConnectFTP :Exit
CmdDOTAHandler1 :Exit
ftp_SessionHandler tart with Event 2
WIP_CEV_OPEN
DOWNLOADING NEW APP
ftp_SessionHandler :Exit
ftp_DataHandler tart with Event 2
WIP_CEV_OPEN
ftp_DataHandler :Exit
ftp_DataHandler tart with Event 6
WIP_CEV_WRITE
ftp_DataHandler :Exit
ftp_SessionHandler tart with Event 1
WIP_CEV_ERROR
FTP CONNECTION CLOSED
ftp_SessionHandler :Exit
ftp_DataHandler tart with Event 1
WIP_CEV_ERROR
ErrorNumber: 550
ftp_DataHandler :Exit

I try too pass this Error but i can’t find any way. Please help me!

For a start, have you looked-up the meaning of error number 550 :question:

Thanks Awneil !
I’ve found this error. it is difference Filename. Hello.dwl <> hello.dwl.

Hi Awneil!
Now i’m using a GPRS service but the signal is not good, When i connect my Model to GPRS, I spend alot of time for reply. Some time i can’t connet to GPRS.
Yesterday afternoon i was downloading a file from my FPT server. the file only 48kB but it can’t download complete. I do not know what happen with me: I’ve aproblem with my code or My network is bad. I don’t what happen.
Today i want trying and using other GPRS service but i have a problem with this GPRS.
The older GPRS Service:

  • Bearer: GPRS
  • Username: mms
  • Password: mms
  • APN/GPRS access point: m3-world

so i can’t setup My GPRS by function:

  wm_sprintf(APN_Details.APN_Name, "m3-world");
  wm_sprintf(APN_Details.Username, "mms");
  wm_sprintf(APN_Details.Password, "mms");
	s8RetVal = wip_bearerSetOpts(gprs_bearer, WIP_BOPT_GPRS_APN,
    APN_Details.APN_Name, WIP_BOPT_LOGIN, APN_Details.Username,
    WIP_BOPT_PASSWORD, APN_Details.Password, WIP_BOPT_END);

i’t can work but not very well.
The New GPRS Service :

  • Bearer: GPRS
  • Username:
  • Password:
  • APN/GPRS access point: v-internet

When i connect GPRS , i do:
wm_sprintf(APN_Details.APN_Name, “v-internet”);
wm_sprintf(APN_Details.Username, “’”); // or wm_sprintf(APN_Details.Username, "’ ");
wm_sprintf(APN_Details.Password, “”); // or wm_sprintf(APN_Details.Password, " ");
s8RetVal = wip_bearerSetOpts(gprs_bearer, WIP_BOPT_GPRS_APN,
APN_Details.APN_Name, WIP_BOPT_LOGIN, APN_Details.Username,
WIP_BOPT_PASSWORD, APN_Details.Password, WIP_BOPT_END);

it not Run. i can’t connect to GPRS Service.
I don’t know why?
Please Awneil give me advice to help me pass this mistake! Please give me a advice about Mycode.
Thanks you very much!

Hi Everyone and Awneil!
Today, i have a problem with DOTA. when i run my APP with my code. it can download complete but report some error:

ftp_DataHandler tart with Event 3
WIP_CEV_PEER_CLOSE
FTP Download Completed
adl_adFinalise return Code 0
WIP_CEV_ERROR
ErrorNumber: 0
ftp_DataHandler :Exit

ErrorNumber:0 What does it mean? I’m trying and downloading again but this ErrorNumber:0 always appear.
Everyone can help me please! I’m focusing and making a report about this project for my project manager.Thank for help

Thanks you everyone. I complete my project successful.

So, for the benefit of others who read this with similar problems, would you care to share what exactly was going wrong, and how you fixed it :question:

In fact, when the FS was downloaded. I do the Finalise and Install step. it install successful and auto reset FS. My New APP run OK.
Do you think it true? Can you give me some advice about My code?

Yes, that is the correct procedure!

Yes, that is the way it works.

I thought you said it was working now? :confused:

Yes of course, Now my FS can run well. But i’m not sure it works well for along time.
This the first time i use FS and write some code with OPEN AT. So i need you help me.
i’m not worry about The Hardware. But i’m worry my code. Because the first i use and code with OPEN AT.
Please help. Do you think my code is ok?