diff --git a/README.md b/README.md index 24cc70c..58bee9d 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ A FTP-Client for the ESP32 ## TODO - [ ] List Dir contents test with different serves; +- [ ] Implement `FEAT` in order to choose which mode to list dir... - [ ] Implement download; * For the uploading example we will use the GitHub Octocat, which binary file is [here](./src/octocat.h): diff --git a/examples/upload_image/upload_image.ino b/examples/upload_image/upload_image.ino index 0f77ff9..08d3deb 100644 --- a/examples/upload_image/upload_image.ino +++ b/examples/upload_image/upload_image.ino @@ -17,7 +17,7 @@ Distributed as-is; no warranty is given. #define WIFI_SSID "" #define WIFI_PASS "" -char ftp_server[] = "ftp.drivehq.com"; +char ftp_server[] = ""; char ftp_user[] = ""; char ftp_pass[] = ""; @@ -40,26 +40,28 @@ void setup() ftp.OpenConnection(); - // Get directory contentx + // Get directory content ftp.InitFile("Type A"); - char list[256]; - ftp.ContentList("/My Pictures/", list); + String list[128]; + ftp.ChangeWorkDir("/public_html/zyro/gallery_gen/"); + ftp.ContentList("", list); Serial.print("\nDirectory info: "); - Serial.println(list); + Serial.println(list[2]); ftp.CloseFile(); + // Make a new directory ftp.InitFile("Type A"); - ftp.MakeDir("/jagua"); + ftp.MakeDir("/my_new_dir"); ftp.CloseFile(); // Create the new file and send the image - ftp.InitFile("Type A"); - ftp.ChangeWorkDir("/wwwhome/images"); - ftp.NewFile("octocat.png"); + ftp.InitFile("Type I"); + ftp.ChangeWorkDir("/my_new_dir"); + ftp.NewFile("octocat.jpg"); ftp.WriteData( octocat_pic, sizeof(octocat_pic) ); ftp.CloseFile(); - + // Create the file new and write a string into it ftp.InitFile("Type A"); ftp.NewFile("hello_world.txt"); diff --git a/library.json b/library.json index 30dc3cc..1abceba 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "esp32_ftpclient", - "version": "0.0.1", + "version": "0.0.2", "description": "A FTP-Client for the ESP32", "keywords": "sensors, low power, mobile, ftp, web, cloud, iot, esp32, espressif", "authors": diff --git a/library.properties b/library.properties new file mode 100644 index 0000000..25f0e64 --- /dev/null +++ b/library.properties @@ -0,0 +1,10 @@ +name=esp32_ftpclient +version=0.0.2 +author=Leonardo Bispo +license=MIT +maintainer=Leonardo Bispo +sentence=An FTP-Client for the ESP32. +paragraph=An FTP-Client for the ESP32. +category=Communication +url=https://github.com/ldab/ESP32_FTPClient +architectures=esp32 \ No newline at end of file diff --git a/src/ESP32_FTPClient.cpp b/src/ESP32_FTPClient.cpp index 3f3ce5b..3e9a871 100644 --- a/src/ESP32_FTPClient.cpp +++ b/src/ESP32_FTPClient.cpp @@ -36,33 +36,25 @@ void ESP32_FTPClient::WriteClientBuffered(WiFiClient* cli, unsigned char * data, } void ESP32_FTPClient::GetFTPAnswer (char* result, int offsetStart) { - //byte thisByte; + char thisByte; outCount = 0; - - String response; - while (!client.available()) delay(1); while (client.available()) { - //thisByte = client.read(); - response = client.readString(); - response.toCharArray(outBuf, sizeof(outBuf)); - /*if ( outCount < sizeof(outBuf) ) { + thisByte = client.read(); + if (outCount < sizeof(outBuf)) { outBuf[outCount] = thisByte; outCount++; outBuf[outCount] = 0; - }*/ + } } - if(result != NULL) - { - for(int i = offsetStart; i