Got my Airlift Featherwing last Thursday. After connecting it to a T4.1 I was able to successfully run all of the example sketches I tried. Downloaded SimpleFTPServer from here:
https://github.com/xreef/SimpleFTPServer
This library has an amazing amount of defines it FtpServerKey.h and FtpServer.h. One device I noticed was SAMD that was using WiFiNINA. I created defines for Teensy based on the defines for SAMD board.
In FtpServerKey.h I added:
Code:
// Teensy T4.x with TEENSYDUINO
#ifndef DEFAULT_FTP_SERVER_NETWORK_TYPE_TEENSY
// Teensy T4.x
#define DEFAULT_FTP_SERVER_NETWORK_TYPE_TEENSY NETWORK_WiFiNINA
#define DEFAULT_STORAGE_TYPE_TEENSY STORAGE_SD
#endif
And in FTPServer.h I added:
Code:
#elif defined(TEENSYDUINO)
#define FTP_SERVER_NETWORK_TYPE DEFAULT_FTP_SERVER_NETWORK_TYPE_TEENSY
#define STORAGE_TYPE DEFAULT_STORAGE_TYPE_TEENSY
This is the sketch I am using for testing:
Code:
/*
* FtpServer Adafruit Airlift Featherwing with SD
*
* AUTHOR: Renzo Mischianti
*
* https://www.mischianti.org/2020/02/08/ftp-server-on-esp8266-and-esp32
*
* Modified for use with Adafruit Airlift Featherwing and Teensy 4.x
* 04-30-2022
* By: Warren Watson.
*/
#include "SD.h"
#include <SimpleFTPServer.h>
#define SPIWIFI SPI // The SPI port
#define SPIWIFI_SS 5 // Chip select pin
#define ESP32_RESETN 6 // Reset pin
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
#define ESP32_GPIO0 -1
#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
FtpServer ftpSrv; //set #define FTP_DEBUG in ESP8266FtpServer.h to see ftp verbose on serial
void _callback(FtpOperation ftpOperation, unsigned int freeSpace, unsigned int totalSpace){
Serial.print(">>>>>>>>>>>>>>> _callback " );
Serial.print(ftpOperation);
/* FTP_CONNECT,
* FTP_DISCONNECT,
* FTP_FREE_SPACE_CHANGE
*/
Serial.print(" ");
Serial.print(freeSpace);
Serial.print(" ");
Serial.println(totalSpace);
// freeSpace : totalSpace = x : 360
if (ftpOperation == FTP_CONNECT) Serial.println(F("CONNECTED"));
if (ftpOperation == FTP_DISCONNECT) Serial.println(F("DISCONNECTED"));
};
void _transferCallback(FtpTransferOperation ftpOperation, const char* name, unsigned int transferredSize){
Serial.print(">>>>>>>>>>>>>>> _transferCallback " );
Serial.print(ftpOperation);
/* FTP_UPLOAD_START = 0,
* FTP_UPLOAD = 1,
*
* FTP_DOWNLOAD_START = 2,
* FTP_DOWNLOAD = 3,
*
* FTP_TRANSFER_STOP = 4,
* FTP_DOWNLOAD_STOP = 4,
* FTP_UPLOAD_STOP = 4,
*
* FTP_TRANSFER_ERROR = 5,
* FTP_DOWNLOAD_ERROR = 5,
* FTP_UPLOAD_ERROR = 5
*/
Serial.print(" ");
Serial.print(name);
Serial.print(" ");
Serial.println(transferredSize);
};
void setup(void){
Serial.begin(115200);
// check for the WiFi module:
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true);
}
WiFi.begin(ssid, pass);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
if (SD.begin(BUILTIN_SDCARD)) {
Serial.println("SD opened!");
ftpSrv.setCallback(_callback);
ftpSrv.setTransferCallback(_transferCallback);
ftpSrv.begin("esp8266","esp8266"); //username, password for ftp. (default 21, 50009 for PASV)
}
}
void loop(void){
ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!!
// server.handleClient(); //example if running a webserver you still need to call .handleClient();
}
Note: I added arduino_secrets.h file to the sketch folder which looks like this:
Code:
#define SECRET_SSID "your SSID"
#define SECRET_PASS "your password"
At this point Filezilla will connect with this message:
Code:
Status: Connecting to 192.168.0.113:21...
Status: Connection established, waiting for welcome message...
Error: Connection timed out after 20 seconds of inactivity
Error: Could not connect to server
The connection is made but there does not seem to be communication between the server and client. It goes into an endless loop in ftpSrv.handleFTP();.
This section shows status always returning 0:
Code:
#if (FTP_SERVER_NETWORK_TYPE == NETWORK_WiFiNINA)
// if (client && !client.connected()) {
// client.stop();
// DEBUG_PRINTLN(F("CLIENT STOP!!"));
// }
byte status;
client = ftpServer.available(&status);
/*
* CLOSED = 0,
LISTEN = 1,
SYN_SENT = 2,
SYN_RCVD = 3,
ESTABLISHED = 4,
FIN_WAIT_1 = 5,
FIN_WAIT_2 = 6,
CLOSE_WAIT = 7,
CLOSING = 8,
LAST_ACK = 9,
TIME_WAIT = 10
*
*/
// DEBUG_PRINTLN(status);
More debugging needed