About Sending data to a FTP server

Hi everybody and fanfan1110,

Mr. fanfan1110 i have read your mails of forum. You are able to send data to a FTP server. But I am not able to send data to server. I dounloaded the code from the reply of your query.

Every function executes successfully but file did not get upload in server. :cry:

:arrow_right: I want to know about DOTA feature. But the problem is this, that I am not having any document or sample program to study how it works.

:frowning: So please any one help me about both FTP and DOTA.

Hello Mr Repal

I want to send some php page in web by ftp protocol
In this particular application I have GPRS sesion wich the module sends strings to the server by TCP/IP prptocol. In this case I set the module with IP number an PORT number. Its works 100%

I need to do the same action to send same string which in some VARIABLE to send by FTP instead TCP/IP

I see in the forum a sample code for that But I don’t know where exactly I need to insert writgh codes to cause the module will works in FTP mode

This codes I finded in this forum.
The server side its works 100% also. When I put the string

http://www.roro.co.il/test/g24_cc/report.php?IMEI=004400009817014&MSISDN=0546306299&CurrentRead=200

on address text box of the IE and pressing its works

/*************************************************************************** 
PI Componentes - Gustavo M. Nunes 

Objetivo:  Enviar um arquivo texto para um servidor FTP 

Descricao: 
         1) Criar um comando "at+ftp" que inicia a trasnferencia FTP 

Upgrades:  --//-- 

Data Criacao:      22-Fev-2006 
Ultima Atualizacao: 22-Fev-2006 
/***************************************************************************/ 

#include "adl_global.h" 

#include "ed_gprs.h" 
#include "ed_dialup.h" 

#include "ed_ftp.h" 
#include "ed_msgcodes.h" 

/*************************************************************************** 
   Mandatory variables 
---------------------------------------------------------------------------- 
   wm_apmCustomStack 
   wm_apmCustomStackSize 
---------------------------------------------------------------------------- 
****************************************************************************/ 

u32 wm_apmCustomStack [ 256 ]; 
const u16 wm_apmCustomStackSize = sizeof ( wm_apmCustomStack ); 

ed_gprsSetupParams_t   ParamsGPRS;    
ed_FTPSetupParams_t      ParamsFTP; 
ed_FTPPutFileParams_t   ParamsFile; 

/*************************************************************************** 
   Function   : Config 
---------------------------------------------------------------------------- 
   Description: Setup every information for parameters 
---------------------------------------------------------------------------- 
   Variable Name     |IN |OUT|GLB|  Utilisation 
----------------------+---+---+---+----------------------------------------- 
                    |   |   |   | 
----------------------+---+---+---+----------------------------------------- 
****************************************************************************/ 
void Config ()
{ 

   //Configuracao da conexao GPRS com o operadora 

   ParamsGPRS.Cid = 1; //Configura canal 1 de conexao (4 canais estao disponiveis) 
   ParamsGPRS.Mode = 1; //Configura o modem para conexao GPRS 

   wm_strcpy(ParamsGPRS.ApnServ,"tim.br");  //APN da servidora TIM 

   wm_strcpy(ParamsGPRS.ApnUn,"tim"); 
   wm_strcpy(ParamsGPRS.ApnPw,"tim"); 

   //FTP configuration 

   ParamsFTP.FtpPort = 21; 
   ParamsFTP.FtpType = 'A'; 
   wm_strcpy(ParamsFTP.FtpServ,"200.162.41.205"); 
   wm_strcpy(ParamsFTP.FtpUn,"xx"); 
   wm_strcpy(ParamsFTP.FtpPw,"xx"); 

   wm_strcpy(ParamsFile.FtpPutFilename,"testeftp01.txt"); 
   wm_strcpy(ParamsFile.FtpPutPath,"."); 

} 

/*************************************************************************** 
   Function   : FtpPutHandler 
---------------------------------------------------------------------------- 
   Description: Callback dos eventos da conexao FTP 
---------------------------------------------------------------------------- 
   Variable Name     |IN |OUT|GLB|  Utilisation 
----------------------+---+---+---+----------------------------------------- 
   ResponseCode      |   |   |   |  Report FTP status 
----------------------+---+---+---+----------------------------------------- 
   id                |   |   |   |  Sempre retorna ED_ID_FTP_PUT 
----------------------+---+---+---+----------------------------------------- 
****************************************************************************/ 
void FtpPutHandler(s32 ResponseCode,TeDHandle id){ 

   char msg[20]; 

   sprintf(msg,"Put Handler: %d\n\r",ResponseCode); 

   adl_atSendResponse ( ADL_AT_UNS, msg); 

} 

/*************************************************************************** 
   Function   : FtpPutData 
---------------------------------------------------------------------------- 
   Description: Essa funcao ? chamada quando o servidor FTP esta apto a 
             receber arquivos 
---------------------------------------------------------------------------- 
   Variable Name     |IN |OUT|GLB|  Utilisation 
----------------------+---+---+---+----------------------------------------- 
   MaxLen            |   |   |   |  Numero maximo de bytes que podem ser 
                 |   |   |   |  enviados no momento 
----------------------+---+---+---+----------------------------------------- 
   id                |   |   |   |  Sempre retorna ED_ID_FTP_PUT 
----------------------+---+---+---+----------------------------------------- 
****************************************************************************/ 
void FtpPutData(u16 MaxLen,TeDHandle id){ 

   ascii teste[100]="Exemplo FTP - PI Componentes"; 

   u8   * ptr = NULL; 

   ptr = teste; 

   adl_atSendResponse ( ADL_AT_UNS, "FTP Put Data Event\n\r"); 

   ed_SendData(ptr,strlen(teste),TRUE); 

} 

/*************************************************************************** 
   Function   : ConexaoFTP 
---------------------------------------------------------------------------- 
   Description: Inicia conexao com o FTP e trasmissao do arquivo 
---------------------------------------------------------------------------- 
****************************************************************************/ 
void ConexaoFTP () 
{ 

   //Variaveis 
   char msg[20]; 
   s8 sreturnCode; 

   sreturnCode = ed_FTPSetConfig(&ParamsFTP); 

   if(sreturnCode==0) 
   { 

      //FTP configuration ok 

      adl_atSendResponse ( ADL_AT_UNS, "FTP configurado com sucesso\n\r"); 

      sreturnCode = ed_FTPPutFileSetConfig(&ParamsFile); 

      if(sreturnCode==0){ 

         //Paramentros do arquivo configurado com sucesso 
         adl_atSendResponse ( ADL_AT_UNS, "Arquivo FTP configurado com sucesso\n\r"); 
             
         //Iniciar transferencia FTP 
         ed_FTPPut(FtpPutHandler,FtpPutData); 

      }else{ 

         //Falha na configuracao do arquivo 
         adl_atSendResponse ( ADL_AT_UNS, "Erro na configuracao do arquivo FTP\n\r"); 

      } 

   }else{ 

      //FTP configuration failed 

      adl_atSendResponse ( ADL_AT_UNS, "Erro nos parametros FTP\n\r"); 

      sprintf(msg,"+Erro: %d\n\r",sreturnCode); 

      adl_atSendResponse ( ADL_AT_UNS, msg); 

   } 
} 

/*************************************************************************** 
   Function   : DialupHandler 
---------------------------------------------------------------------------- 
   Description: ed_DialupConnectionStart Handler 
---------------------------------------------------------------------------- 
   Variable Name     |IN |OUT|GLB|  Utilisation 
----------------------+---+---+---+----------------------------------------- 
   ResponseCode      |   |   |   |  Report Dialup status 
----------------------+---+---+---+----------------------------------------- 
****************************************************************************/ 
void DialupHandler(s32 ResponseCode){ 

   char msg[20]; 
   s8 sreturnCode; 

   switch (ResponseCode){ 

   case ED_OK_GPRS_SESSION_SET:  // GPRS online 


      adl_atSendResponse ( ADL_AT_UNS, "GPRS conectado\n\r"); 

      //Inicia conexao FTP 
      ConexaoFTP(); 

      break; 
   default: 

      //Erro na conexao GPRS 
      adl_atSendResponse ( ADL_AT_UNS, "Erro na conexao GPRS\n\r"); 

      break; 
   } 
} 

/*************************************************************************** 
   Function   : TimerHandler 
---------------------------------------------------------------------------- 
   Description: adl_tmrSubscribe Handler 
---------------------------------------------------------------------------- 
   Variable Name     |IN |OUT|GLB|  Utilisation 
----------------------+---+---+---+----------------------------------------- 
   tmerId            |   |   |   |  Say which time Id is running at the 
                 |   |   |   |    moment 
----------------------+---+---+---+----------------------------------------- 
****************************************************************************/ 
void TimerHandler(u8 timerId){ 

   char msg[20]; 
   s8   sreturnCode; 

   sreturnCode = ed_DialupConnectionStart(DialupHandler); 

   if(sreturnCode == 0){ 

      //GPRS Conectado 

      adl_atSendResponse ( ADL_AT_UNS, "Diaul up Ok\n\r"); 

   }else{ 

      //Verifica se GPRS ja nao esta conectado 
      if(sreturnCode == ED_ERR_MODEM_RUNNING) 
      { 
         adl_atSendResponse ( ADL_AT_UNS, "GPRS ja conectado\n\r"); 

         ConexaoFTP (); 

      }else{ 

         //Falha na conexao GPRS 

         adl_atSendResponse ( ADL_AT_UNS, "Falha no Dial Up\n\r"); 

         sprintf(msg,"+Erro: %d\n\r",sreturnCode); 

         adl_atSendResponse ( ADL_AT_UNS, msg); 
      } 

   } 
} 

/*************************************************************************** 
   Function   : GPRSHandler 
---------------------------------------------------------------------------- 
   Description: Callback do comando "at+cgatt=1" que ? enviado pela funcao 
             GPRSConnection 
---------------------------------------------------------------------------- 
   Variable Name     |IN |OUT|GLB|  Utilisation 
----------------------+---+---+---+----------------------------------------- 
   paras             |   |   |   |  CmdCreate answer 
----------------------+---+---+---+----------------------------------------- 
****************************************************************************/ 
bool GPRSHandler(adl_atResponse_t *paras){ 

   s8      sreturnCode = ERROR; 
   char   msg[20]; 

   if( !wm_strncmp(paras->StrData,"\r\nOK",4)){ 

      //Comando AT+CGATT executado com sucesso 

      sreturnCode = ed_GprsSetConfig(&ParamsGPRS); 

      if (sreturnCode == 0){ 

         //Parametros OK 
         adl_atSendResponse ( ADL_AT_UNS, "Parametros Ok\n\r"); 

         adl_tmrSubscribe(FALSE,10,ADL_TMR_TYPE_100MS,TimerHandler); 
          
      }else{ 

         //Parametros com erro 
         adl_atSendResponse ( ADL_AT_UNS, "Erro nos parametros GPRS\n\r"); 

         sprintf(msg,"+Erro: %d\n\r",sreturnCode); 

         adl_atSendResponse ( ADL_AT_UNS, msg); 
      } 
   }else{ 

      //Erro ao tentar usar o comando AT+CGATT 
      adl_atSendResponse ( ADL_AT_UNS, "Falha na conexao GPRS\n\r"); 
   }    

   return TRUE; 
} 

/*************************************************************************** 
   Function   : GPRSConnection 
---------------------------------------------------------------------------- 
   Description: Inicia conexao GPRS 
---------------------------------------------------------------------------- 
****************************************************************************/ 
void GPRSConnection (){ 

   adl_atSendResponse ( ADL_AT_UNS, "Abrindo conexao GPRS...\n\r"); 

   adl_atCmdCreate("AT+CGATT=1",TRUE,GPRSHandler,"*",NULL); 
} 

/*************************************************************************** 
   Function   : AtFTP 
---------------------------------------------------------------------------- 
   Description: Callback do comando "at+ftp" 
---------------------------------------------------------------------------- 
   Variable Name     |IN |OUT|GLB|  Utilisation 
----------------------+---+---+---+----------------------------------------- 
   paras             |   |   |   | Parametros do comando 
----------------------+---+---+---+----------------------------------------- 
****************************************************************************/ 
void AtFTP(adl_atCmdPreParser_t * paras) 
{ 
   //Inicia conexao GPRS 
   GPRSConnection(); 

   //Mensagem de retorno do comando AT 
   adl_atSendResponse ( ADL_AT_RSP, "OK\n\r"); 
} 

/*************************************************************************** 
   Function   : SimCard 
---------------------------------------------------------------------------- 
   Description: Display the SimCard Events 
---------------------------------------------------------------------------- 
   Variable Name     |IN |OUT|GLB|  Utilisation 
----------------------+---+---+---+----------------------------------------- 
   Event             |   |   |   | Sim Card Events 
----------------------+---+---+---+----------------------------------------- 
****************************************************************************/ 
void SimCard (u8 Event){ 

   switch(Event){ 

   //Normal Events 
   case ADL_SIM_EVENT_PIN_OK: 
         adl_atSendResponse ( ADL_AT_UNS, "PIN Code Ok\n\rConectando...\n\r"); 
   break; 
   case ADL_SIM_EVENT_REMOVED: 
         adl_atSendResponse ( ADL_AT_UNS, "SimCard Removido\n\r"); 
   break; 
   case ADL_SIM_EVENT_INSERTED: 
         adl_atSendResponse ( ADL_AT_UNS, "SimCard Inserido\n\r"); 
   break; 
   case ADL_SIM_EVENT_FULL_INIT: 
         adl_atSendResponse ( ADL_AT_UNS, "Conectado !\n\r"); 

         //Cria comando para conectar no servidor FTP 
         adl_atCmdSubscribe("at+ftp",AtFTP,ADL_CMD_TYPE_ACT); 
   break; 

   //Error Events 
   case ADL_SIM_EVENT_PIN_ERROR: 
         adl_atSendResponse ( ADL_AT_UNS, "PIN Code Incorreto\n\r"); 
   break; 

   /*Erro quando se e necessario inserir o PIN Code. 
     Por comandos AT, insera o PIN Code usando 
     AT+CPIN="xxxx", onde xxxx e o codigo de 4 digitos*/ 
   case ADL_SIM_EVENT_PIN_WAIT: 
         adl_atSendResponse ( ADL_AT_UNS, "Entre com o PIN Code\n\r"); 
   break; 
   } 
} 

/*************************************************************************** 
   Function   : adl_main 
---------------------------------------------------------------------------- 
   Description: Main function 
---------------------------------------------------------------------------- 
   Variable Name     |IN |OUT|GLB|  Utilisation 
----------------------+---+---+---+----------------------------------------- 
   InitType          |   |   |   | Application start mode reason 
----------------------+---+---+---+----------------------------------------- 
****************************************************************************/ 
void adl_main ( adl_InitType_e InitType ) 
{ 
   //Inicio da aplicacao 
   adl_atSendResponse(ADL_AT_UNS, "\n\rInicio da aplicacao\n\r"); 

   //Executa a funcao SimCard a cada evento que ocorrer 
   adl_simSubscribe(SimCard,NULL); 

   //Inicializa?ao das bibliotecas IP 
   ed_Init(); 

   //Configura parametros diversos 
   Config(); 
    
}

I tried to copy and pasted but its missing some links Its not works

Thanks again
[/code]