ZX FTP client
version: 0.7
autohor: Hood
release: 20.10.2022
download: version 0.7
video: here





FOREWORD
Dear ZX users, and especially fans of wireless data transfer. I am really very proud to present to the ZX world a software, that I dreamt of for years- FTP client for ZX Spectrum, which will make users relieve of endless removing memory cards up and down from their ZX. When I say FTP client, I mean true FTP client. Not a special solution, not a tiny ftp, but a true one. That should enable you to connect to any ftp server on the world. Both, in internet or a local one.

My previous work, HTML up/downloader which we did together with Lanex, was a very good piece of work. It had a slightly higher download speed than ZX FTP client, but it was a special solution with PHP need on PC side. So it required quite sophisticated tweaking on PC side. ZX FTP client is true client which complies with FTP standart so no additional setting and tools are required to make it work.

Shame I am not the first one, since guys on ZX UNO clone have already an ftp client for years (see:https://github.com/yomboprime/FTP_Uno). And not to forget, my biggest inspiration was of course very old but not finished FTP client for SIF hardware by Pavel Urbancik, see it in the action here. Nevertheless, I am more than happy even with the first release version 0.7.

I have been coding it on very regular base, with small steps. Small steps, but almost every day.

The client file contains wifi bios 1.8, a handy bios by Busy and me for low level wifi routines and speed management 2.0 routine by me, that carry out automatic speed and module settings. Both can be used in other wifi applications independently.

Terminology: in the text below "host" and "ftp server" can be understood interchangeably. "The client" stand for ZX FTP client.



REQUIREMENTS
- MB03+ interface fitted with Wifi module ESP-01
- BSDOS disk operating system



WHAT IT CANNOT DO
In the very beginning, I need to say version 0.7 cannot do:
- load and save of files does not work in any DOS except for BS-DOS only (on MB03+, or MB-02+)
- cannot display directory structure or file list

Both major drawbacks will be solved right away in next versions.





BUGS
Although tested, I did not have a chance to test all servers and its specialities. So I expect some bugs may occur in version 0.7. They should be neither fatal, nor should they corrupt data on your disk. If you encounter problems and do not know the solution, simply write down the error code if any, and report the problem to me. I am available on Telegram, Whatsup, Messenger, Facebook. And reset the computer and start again.



WHAT CAN IT DO
Version 0.7. can:
- connect to any ftp server
- download a single file from server to ZX
- upload a single file from ZX to server

Ideal usage: for copying files from your PC to ZX and vice versa without need of manipulating your memory card. Disk operating system- BSDOS only for the moment.

Version 0.7 supports 10 commands: USER, PASS, PASV, QUIT, STOR, RETR, SIZE, ABOR, APPE, NOOP. For download it is using passive transfer mode.



PRACTICALLY
In real ZX life of a true ZX user, version 0.7 can be seriously used only on BSDOS for copying files from and to your PC. On other platforms you can only try out logging in and off.



DESCRIPTION OF THE SCREEN
- line 1, 2: headline
- line 4: Speed: here you will see number 16. Meaning the module communication speed is set to 3.456.000 Bauds. Speed 16 is maximum speed on which the module is able to communicate. Setting other speeds is possible, but the user cannot do it by themselves. Practically, other speeds are of no use, since we need fast transfers of data. For your complete info, here is the list of speeds in Bauds as reffered in Wifi bios 1.8.:
- line 5: Host: here you will see either X meaning you are not connected to any host, or you will see host name you are connected to.
- line 6, 7, 8: reports returned by ftp server, they are server reactions to your/ZX client requests. They can slightly guide you throughout your work
- line 18: File: variable file name, that the user can change. Start: variable start address for downloaded file, that the user can change
- line 19: Host: variable host name, that the user can change. User: user name for login. Pass: password for login
- line 20,21: menu texts
- line 23: info line guiding the user throughout their action
- line 24: input line





CONTROL KEYS
Your control possibilities are displayed on lines 20, 21:

- F- file enter file name
- T- start enter start address of the file to be downloaded
- A- switch between manual and automatic login. If YES, automatic login will be carried out upon client start
- H- host enter host name
- R- usr enter user name
- P- pass enter password
- ss+P hide/disclose password on the screen
- U- upl upload file from your curent BS-DOS path
- S- size serves mainly testing purposes, it returns to the user size of the file he inputted
- Q- quit quits the client
- W- wifi switch between ON/ OFF. It determines the state in which wifi module should be upon client quit
- L- login manual login to the host. Host name is taken from host variable name. User and password are entered manually
- ss+L automatic login. Host, user and password are taken from 3 variables Host, User and Pass.
- O- logoff logoff from host. Connection to host remains.
- V- save app saves client to your current path with all its settings
- D- dwnld download a file from ftp server. Enter its name manually.
- ss+D autodwnl-download a file from ftp server. Its name and start address are taken from variables File and Start

In the middle of your work, if available, use B key to abort action.




INPUT LINE FEATURES
Throughout your work input prompt line apperas on the screen. The input line uses these keys:
- left/right- for moving your cursor
- TRUE VIDEO- for input abort
- DELETE
- GRAPH- for backspace
- SS+Q- for jump on line start



SETUP
There is no setup or configuration file for the moment. ZX FTP client works as a single file. The reason is, that on BS-DOS you will be able to run it from a remote path (using eg. NEW#3,25 command, meaning "run file number 25 from disk 3). More info how to handle setup, see below.



SOME USAGE DESCRIPTION/ FAQ/ TROUBLESHOOTING/ TIPS
The ZX FTP client is self contained as far as basic wifi connection and setting is concerned. Upon its start, the client will automatically login to prefered ftp server, if selection A is switched to yes. If not, it will let you login manually. You do not have to do any wifi module setting prior to running the client. The only thing that is required for automatic login is, that your module should have enabled auto AP, ie. should automatically connect to AP (acces point). If it cannot connect automatically to an AP, you will have to do it either manually in the terminal or you can use my utility Wifi Setup.. From that time, no other action concerning wifi module settings will be required from you.

Status 5. If your status remains 5, than your module is not connected to an AP, so most probably it has not set automatic connection to an AP. You will have to solve it outside ZX, in the terminal
terminal or Wifi Setup..

Try version 0.7. on Esxdos in MB03+. It will work, except for file upload/ download which both require special BS-DOS disk operations.

A tip for quick download of a file: I use this feature especially when I am coding a project on a PC and the file to be downloaded has the same name (and start address). Set your client to autologin. And after it has logged in, press ss+D to download automatically your file from File and Start variable. Very easy, very convenient to work with.

Setup: use V to save your whole client with its setup. It will be saved to your disk as a new file. In the setup you may change: file name, start address, host, user, pasword, autologin to ftp server upon start or during your work, wifi module on/ off on the client's quit, hide/disclose password. Simply, the state your saved your client will reapear on your next client's run.

Autologin: how does it work? The client on its start will carry out automatic login to the host if autologin is set to yes. It can be also used during work with the client. Press ss+L and autologin will be made automatically for you.

A tip: if you want to use the client permanently during your current work on ZX, switch your wifi module to ON with a key W. Then you can leave the client with QUIT only. This means you remained logged in to ftp server. Then you can do your other work on ZX. If you set your ftp server to no kick off, your ftp session will remain untouched, and you will enter it upon next run of the client.





LOCAL FTP SERVER
It is advisible to install your local server to be able to copy files from your ZX to PC and vice versa. In the package you will find FileZilla server and its interface which I find both, small and easy to install and set. Since there is no directory listing in ver 0.7. you have to know file names, and the easiest way is to have your PC screen with files open (together with the running client on ZX), and read file names you want to work with. In the server interface, you need to add a new user and password, assign a path to your drive on PC that the client will work with and enable work with files (delete, append, etc.) see the picture below. I found the latest versions incovenient to set, so I use this old version instead. But practically, you can use any local ftp server of your wish.





IDDLE TIME
The client sends a NOOP command roughly every 1 minute to keep your connection alive and to prevent being kicked off by the server for inactivity.



DATA FLOW SPEEDS
Download: on a standart ZX machine with 3,5 Mhz CPU, version 0.7 manage speed of 16 kb/ sec including saving to disk. Yet I believe this could be increased a bit. For upload it manages mere 3,3 kb/ sec including load from disk. I doubt if it can be increased. The limit size our ESP-01 module can send in one go is 2048 bytes. So, paradoxically, ZX Spectrum is waiting for module here.

However, version 0.7 changes CPU speed during download, if your ZX machine is
eLeMeNt ZX, so with 20 Mhz CPU speed the download speed including save to disk is 60 kb/sec. For upload, I did not manage to make it work with 20 Mhz, or even with 7 Mhz. Hopefully, this can be solved and improved in next versions.



ERROR CODES
Not all of the following error have to appear on your screen:
;Error reports
;1=sending string error (cipsend_request routine) ...OK
;2=error sending CWMODE AT commad ...OK
;3=error sending CIPMUX AT command ...OK
;7=error sending CIPCLOSE AT command (ftp upload) ...OK

;8= module did not return SEND OK after data block sending (ftp_upl_send)..OK
;9= error in entering passive mode (enter_passive_mode) ...OK
;14=file not exist ...OK
;15=disk error ...OK
;25= module not connected to AP, the user has to set his module externally.OK

;ftp
;4= check_module_answer routine did not found the answer from DE ...OK
;5= uploaded data not sent correctly (ftp_upl_send) ...OK
;6= cipsend_lod routine error. Module not ready to send data for upload ...OK
;10= error in connecting to ftp server (ftp_login)(probably wrong URL) ...OK
;11= error in receiving ftp answer (receive_ftp_answer) ...OK
;12= "+IPD," string not found in the incoming bytes (look_for_ipd) ...OK
;13= FTP server did not confirm answer 225 on download attempt (ftp_download_file...OK
;16= ABOR command not successful ...OK
;17= upload: connection not accepted (code 150 not received) ...OK
;18= upload: transfer not ok (code 226 not accepted) ...OK
;19= initial check. Connected to server, not good answer to NOOP cmnd ...OK
;20= ABOR command initiated by the user ...OK
;21= download: files does not exist ...OK
;22= file does not exist on ftp server ...OK
;23= download: block of data receive error ...OK
;24= server did not respond with "226 Transfer OK" ...OK
;25= command sent ok, but return code other than expected ...OK

;28=speed management: AT command not accepted ... present in the code but not used
;29=speed management: all speeds tested, timeout, fix it in terminal-add it in the next ver... present in the code but not used
;30=speed management: failed, probably Wifi module wrongly set,fix in terminal-add it in the next ver... present in the code but not used
;31=user defined speed_ AT+UART_CUR command not sent ...???
;32=user defined routine_ speed in UART not set ...???
;33=user defined speed_ you try to set nonsence speed (ie. > 23) ...???





TO DO LIST
top priority:
- enable work with server directory list and files
- enable disk operations for Esxdos

lower priority:
- higher CPU during upload



ACKNOWLEDGEMENTS
Primarily: Busy for his couple of handful routines and advices
LMN, Lanex, SCJoe- for inspiration and knowledge
Shrek, Ped7g, Nihirash- their valuable knowledge