Particle Electron FTP upload

Hello,
is there a easy way to connect to a FTP Server with the Electron? I tried the ParticleFTPClient, but it dosen’t connect to the server. If I try it with AT Commands (u-blox at command examples) Cellular.command returns always -1 but it dosen’t connect.
Or ist there a possibility for debuging to ger directly access to the Sara Module without using the MCU and Cellular.command?
I tried to connect also with an Arduino and SIM800 module and this works. I really near to put the electron in a corner and go back to Arduino and SIM800.
PS. I use a 3th party sin card

The code I tested with is:

/*  FTP
AT+CGDCONT? 
AT+UFTP?
AT+UFTP=1,"ftp.u-blox.com" 
AT+UFTP=2,"anonymous" 
AT+UFTP=3,"user@somedomain.com" 
AT+UFTP=6,1                                         //FTP Mode 0=Active 1=Passive
AT+UFTPC=1                                          //FTP Login
AT+UFTPC=14,"downloads"                             //List the files in the directory
AT+UFTPER                                           
AT+UFTPC=13                                         //Information of a file in a directory
AT+UFTPC=13,"downloads" 
AT+UFTPER 
AT+UFTPC=8,"downloads"                              //Change the working directory
AT+UFTPC=4,"downloads/100Kb.bin","download.bin"     //Recive the File from the FTP server
AT+ULSTFILE 
AT+UFTPC=0                                          //FTP Logout
*/


//SYSTEM_MODE(MANUAL);

//#include "cellular_hal.h"
STARTUP(cellular_credentials_set("gprs.swisscom.ch", "", "", NULL));

int AT_TIMEOUT = 1000;

void setup() {
    Serial.begin(9600);
    Serial.println("Cellular started. Ready to receive AT commands.");
}

void loop() {
    if (Serial.available() > 0) {
        String input = Serial.readString();
        Serial.println("Received input: "+input);
        Serial.println("--BEGIN RESPONSE--");
        int point;
        int i = Cellular.command(parseResponse, &point, AT_TIMEOUT, input+"\r\n");
        Serial.println(i);
        Serial.println("--END RESPONSE--");
    }
}

int parseResponse(int type, const char* buf, int len, int* point) {
    char line[1024+64];
    strncpy(line, buf, len);
    line[len] = '\0';
    String line_as_string = String(line);
    Serial.println(line_as_string.trim());
    if (type == TYPE_ABORTED) {
        return RESP_ABORTED;
    }
    else if (type == TYPE_PROMPT) {
        return RESP_PROMPT;
    }
    else if (type == TYPE_ERROR) {
        return RESP_ERROR;
    }
    else if (type == TYPE_OK) {
        return RESP_OK;
    }
    else {
        return WAIT;
    }
}

Even if you got that to work, there’s another problem I think you’re going to run into. It’s not possible to read or write the u-blox flash file system without modifying system firmware, because the accessor functions are not exported. So even if you could download or upload by FTP, there wouldn’t be a way to access the data.

It is possible to use FTP from user firmware, however. This is upload. Download by FTP doesn’t really make sense; HTTP would be a much better choice for download.

1 Like

thx for your help
this works fine for my.
the only thing i will is upload a file to an ftp server.
I used your code ant it’s look like it works fine.
I’ll now to try to understand your code fo that i can implement it to my project.
It’s looks like it’s not so easy the switch from arduino to the electron as i thought.

Isnagut