Skip to content

ftpserver

Boris Lovosevic edited this page Apr 15, 2018 · 3 revisions

Ftp server

Ftp server is implemented as ESP32 task and runs in background (when started).

Method Notes
network.ftp.start([user="micro", password="python", buffsize=1024, timeout=300]) Start FTP server.
All arguments are optional, if not set the dafaults are used.
Buffsize sets the transfer buffer size, larger buffer enables faster transfers, but uses more memory.
network.ftp.pause() Pause Ftp server. Only when no client is connected.
network.ftp.resume() Resume Ftp server. Only when no client is connected.
network.ftp.stop() Stop Ftp server. Only when no client is connected.
The ESP32 task is terminated, all memory is freed.
network.ftp.status() Get the current Ftp server status.
The status is returned as 5-item tuple of numeric value and string description of Command and Data channels and listening IP(s) tuple.
(status, data_chan_status, status_str, data_chan_status_str, (listen_IPs))
network.ftp.stack() Get the maximum amount of stack used by the Ftp task.
The stack size is set at compile time and can be changed in mpthreadport.h

Notes

  • Only one connection to FTP server at the time can be used
  • Passive transfer mode must be used
  • Only one data connection can be used, make shure your FTP client does not try to establish multiple data connections
  • No encription is allowed, configure your client to use plain FTP (insecure). That shouldn't be an issue, you will mostly use FTP server in local network.

Example of FileZilla settings:


# connect to a WIFI AP, sync time and start telnet and FTP server
# Paste it in the Python command line (REPL)
# Then you can connect to the IP of your ESP32 in FTP (passive mode) or in telnet !

wifi_ssid = "my_home_ssid"
wifi_passwd = "my_wifi_password"
my_timezone = "CET-1CEST" # found in second field, text before the coma, in https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/blob/master/MicroPython_BUILD/components/micropython/docs/zones.csv

import network
import machine
import time

sta_if = network.WLAN(network.STA_IF); sta_if.active(True)
sta_if.connect(wifi_ssid, wifi_passwd)

time.sleep(6)
sta_if.ifconfig()

rtc = machine.RTC()
rtc.init((2018, 01, 01, 12, 12, 12))
rtc.ntp_sync(server= "", tz=my_timezone, update_period=3600)
network.ftp.start(user="micro", password="python", buffsize=1024, timeout=300)
network.telnet.start(user="micro", password="python", timeout=300)
print("IP of this ESP32 is : " + sta_if.ifconfig()[0])
Clone this wiki locally