C/C++ Question simpleFTP working with arduino but not working in a library for B4R

candide

Active Member
Licensed User
because i wanted to use SPIFFS and a simple way for me to transfert files is by FTP
i tested simpleFTP for esp8266 in arduino and it is working well.
Next step was to create a simple library to do exactly what is done in ino file but included to B4R.
Library is created, compilation of project is OK, when FTP client try to connect to esp, it is not rejected but we don't have event in esp8266ftpserver to manage this connection.
first i tested creation of wifi in B4R side, but after in wrapper also but without positive result.
Loop in esp8266ftpserver is running, but we don't have event coming from WIFIserver.

why we have event in ino project and not in case of B4R compilation ? i don't understand. i did mutiple traces at different levels but without result.
I suppose we have conflict at wifi level between arduino version and B4R version, but i didn't find where and what to do.

who can help ? code of arduino version and B4R version are in zip file.
 

Attachments

  • rESP8266FTPServer.zip
    31.8 KB · Views: 356
Last edited:

Laurent95

Active Member
Licensed User
Longtime User
Hi,

3 points:
- You don't masked your WIFI credentials, it's not really safe :( ;
- In your wrapper you don't implement any event so it's normal you have nothing returned ;
- You just wrapped only the initializing nothing else, the handle can't return anything outside of Arduino code.
You must wrapping also all the properties and events you need to work with inside B4R wrapper.

I think you must study more this thread : Tutorial BAR libraries
Or without wrapper youn can try this one : Inline C/C++ code in B4R tutorial but it's more tricky.
I guess that was the same problem when you tried to trace Wifi connexion, fortunately B4R libray is already wrapped ;)

Best regards
 
Last edited:

candide

Active Member
Licensed User
Thanks Laurent for your feedback, now credentials are removed

in my wrapper we don't have event because this library is not managed by event:
- at low level we have WIFIserveur receiving external requests at FTPclient connection and only some parameters and status are updated.
- after, in esp8266FTPserver library (arduino) we have a task running in loop (handleFTP()) and looking at aprameters from WIFIserver and managing answer to FTPclient and actions requested
- after, interrogation/modification of SPIFFS are done in this library. It is totally out of B4R project.
in B4R we have just to launch FTPserveur.begin to initialise FTPserver, and after to put FTPserveur.handleFTP() in a loop, nothing else.

my problem is at WIFIserver level, this one don't detect connection of a FTPClient when compilation is done with B4R
 

Laurent95

Active Member
Licensed User
Longtime User
Ok maybe i didn't detailled enough my response, but at least you can search a bit also.
Take a look better at your Arduino library code (ESP8266FtpServer.cpp)
Where is the implementation of "FtpServer::clientConnected()"
Where is the implementation of "FtpServer::processCommand()"
etc.
See below :
C++:
void FtpServer::handleFTP()        // <- it's what you wrapped, no ?
{
  if((int32_t) ( millisDelay - millis() ) > 0 )        // <- 1st problem, maybe return all time millis() is unkow by B4R ! And probably millisDealy too
    return;

// And all under are not wrapped, what happend under B4R, nothing happen too...
  if (ftpServer.hasClient()) {
      client.stop();
      client = ftpServer.available();
  }
  if( cmdStatus == 0 )
  {
    if( client.connected())            // <- What happen here, it's your B4R code who manage that ?
                                                   //      No it's returned to Arduino library code, but how the compiler could do the trick ?
      disconnectClient();
    cmdStatus = 1;
  }
  .../...
  else if( cmdStatus > 2 && ! ((int32_t) ( millisEndConnection - millis() ) > 0 ))       // <- Again a test on an internal Arduino timer
  {
    client.println("530 Timeout");
    millisDelay = millis() + 200;    // delay of 200 ms
    cmdStatus = 0;
  }
}

B4R is not magic and can't wrap the things for you.
It's why i told you study a bit more the tutorials, nothing else.
And to be honest i fear that to implemente a void "sub" who contains an "if" on an "Arduino internal timer (millis())" wont be working properly under B4R
So a best way is to implement all that is needed.

But if you know better than others it's ok.
EDIT :
in B4R we have just to launch FTPserveur.begin to initialise FTPserver, and after to put FTPserveur.handleFTP() in a loop, nothing else.
it's why i say that above !
But i'm quite sure you prepare yourself to big surprises.
For my part i leave this thread, not too much time to catch your eyes where it's easy to find why that'll don't work.
 
Top