@peekay123 Clarification question, if you have time. Is Passive FTP going to be able to return the contents of my directory with a command like LIST?
Currently i’m just trying to get the contents to print out in the serial monitor (just to make sure i’m sending the command correctly) then i’ll try putting it in a local array of strings for downloading with something like client.write(etc)…client.read(etc). The server just returns 150: Connection accepted, additionally I have tried dir and referencing the directory path.
byte directoryPrint()
{
// if (client.connect(server,21)) { // port number is 21 for driveHQ
if (client.connect(server, 21)){
Serial.println("Command connected");
}
else {
Serial.println("Command connection failed");
return 0;
}
// For remote FTP server replace particle with username and photon with password, ftp.drivehq.com/drivehqshare/clabadmin/dev1-2
// unsure about the format for the rest but PASV is likely passive TCP
if(!eRcv()) return 0;
client.println("USER ...");
if(!eRcv()) return 0;
client.println("PASS ...");
if(!eRcv()) return 0;
client.println("CWD /drivehqshare/...");
if(!eRcv()) return 0;
client.println("SYST");
if(!eRcv()) return 0;
client.println("Type ascii");
if(!eRcv()) return 0;
client.println("PASV");
if(!eRcv()) return 0;
char *tStr = strtok(outBuf,"(,");
int array_pasv[6];
for ( int i = 0; i < 6; i++) {
tStr = strtok(NULL,"(,");
array_pasv[i] = atoi(tStr);
if(tStr == NULL)
{
Serial.println("Bad PASV Answer");
}
}
unsigned int hiPort,loPort;
hiPort = array_pasv[4] << 8;
loPort = array_pasv[5] & 255;
Serial.print("Data port: ");
hiPort = hiPort | loPort;
Serial.println(hiPort);
if (dclient.connect(server,hiPort)) {
Serial.println("Data connected");
}
else {
Serial.println("Data connection failed");
client.stop();
return 0;
}
Serial.println("Testing List Command");
client.println("LIST");
if(!eRcv()) return 0;
Serial.println("List Command Has been Issued");
if(!eRcv())
{
dclient.stop();
return 0;
}
dclient.stop();
Serial.println("Data disconnected");
if(!eRcv()) return 0;
client.println("QUIT");
if(!eRcv()) return 0;
client.stop();
Serial.println("Command disconnected");
return 1;
}