This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FTP support for nrf9160

i want to start evaluating FTP client in nrf9160 SoC.  Can you provide an example code for FTP client mode. 

Parents
  • Hi Praveen,

    There is now a pull request open for the fixes: 

    https://github.com/nrfconnect/sdk-nrf/pull/2547

    "Decouple Data and Control channel in FTP client for LIST and RETR
    commands, leave the synchronization to SLM FTP code. This removes
    the infinite wait as stated in problem 1.

    No need of update for problem 2.

    (the size of message is decided by FTP Server)"


    NOTE-1: List a Get will now get Control message first, then Data message, then OK

    NOTE-2: Data message by Get could be encoded as hexadecimal but there will be no indication of data type

    Sample scenario:

    Ready
    --> AT+CFUN=1
    OK
    --> AT+CEREG?
    +CEREG: 5,1,"76C1","014ACE00",7,,,"11100000","00001111"
    OK
    --> AT#XFTP="open",,,"speedtest.tele2.net"
    220 (vsFTPd 3.0.3)
    200 Always in UTF8 mode.
    331 Please specify the password.
    230 Login successful.
    OK
    --> AT#XFTP="ls"
    227 Entering Passive Mode (90,130,70,73,96,156).
    150 Here comes the directory listing.
    226 Directory send OK.
    1000GB.zip
    100GB.zip
    100KB.zip
    100MB.zip
    10GB.zip
    10MB.zip
    1GB.zip
    1KB.zip
    1MB.zip
    200MB.zip
    20MB.zip
    2MB.zip
    3MB.zip
    500MB.zip
    50GB.zip
    50MB.zip
    512KB.zip
    5MB.zip
    upload
    
    OK
    --> AT#XFTP="ls","-l"
    227 Entering Passive Mode (90,130,70,73,110,27).
    150 Here comes the directory listing.
    226 Directory send OK.
    -rw-r--r--    1 0        0        1073741824000 Feb 19  2016 1000GB.zip
    -rw-r--r--    1 0        0        107374182400 Feb 19  2016 100GB.zip
    -rw-r--r--    1 0        0          102400 Feb 19  2016 100KB.zip
    -rw-r--r--    1 0        0        104857600 Feb 19  2016 100MB.zip
    -rw-r--r--    1 0        0        10737418240 Feb 19  2016 10GB.zip
    -rw-r--r--    1 0        0        10485760 Feb 19  2016 10MB.zip
    -rw-r--r--    1 0        0        1073741824 Feb 19  2016 1GB.zip
    -rw-r--r--    1 0        0            1024 Feb 19  2016 1KB.zip
    -rw-r--r--    1 0        0         1048576 Feb 19  2016 1MB.zip
    -rw-r--r--    1 0        0        209715200 Feb 19  2016 200MB.zip
    -rw-r--r--    1 0        0        20971520 Feb 19  2016 20MB.zip
    -rw-r--r--    1 0        0         2097152 Feb 19  2016 2MB.zip
    -rw-r--r--    1 0        0         3145728 Feb 19  2016 3MB.zip
    -rw-r--r--    1 0        0        524288000 Feb 19  2016 500MB.zip
    -rw-r--r--    1 0        0        53687091200 Jul 24  2014 50GB.zip
    -rw-r--r--    1 0        0        52428800 Feb 19  2016 50MB.zip
    -rw-r--r--    1 0        0          524288 Feb 19  2016 512KB.zip
    -rw-r--r--    1 0        0         5242880 Feb 19  2016 5MB.zip
    drwxr-xr-x    2 106      109         69632 Jul 02 09:22 upload
    
    OK
    --> AT#XFTP="binary"
    200 Switching to Binary mode.
    OK
    --> AT#XFTP="ls","-l 1KB.zip"
    227 Entering Passive Mode (90,130,70,73,93,53).
    150 Here comes the directory listing.
    226 Directory send OK.
    -rw-r--r--    1 0        0            1024 Feb 19  2016 1KB.zip
    
    OK
    --> AT#XFTP="get","1KB.zip"
    227 Entering Passive Mode (90,130,70,73,109,182).
    226 Transfer complete.
    data connection for 1KB.zip (1024 bytes).
    000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    OK
    --> AT#XFTP="ls","-l 2KB.zip"
    227 Entering Passive Mode (90,130,70,73,108,231).
    150 Here comes the directory listing.
    226 Directory send OK.
    OK
    --> AT#XFTP="get","2KB.zip"
    227 Entering Passive Mode (90,130,70,73,108,196).
    ERROR
    

    Here is the precompiled .hex with the fixes --> slm_ftp_02_07.hex

    Best regards,
    martin L.

Reply
  • Hi Praveen,

    There is now a pull request open for the fixes: 

    https://github.com/nrfconnect/sdk-nrf/pull/2547

    "Decouple Data and Control channel in FTP client for LIST and RETR
    commands, leave the synchronization to SLM FTP code. This removes
    the infinite wait as stated in problem 1.

    No need of update for problem 2.

    (the size of message is decided by FTP Server)"


    NOTE-1: List a Get will now get Control message first, then Data message, then OK

    NOTE-2: Data message by Get could be encoded as hexadecimal but there will be no indication of data type

    Sample scenario:

    Ready
    --> AT+CFUN=1
    OK
    --> AT+CEREG?
    +CEREG: 5,1,"76C1","014ACE00",7,,,"11100000","00001111"
    OK
    --> AT#XFTP="open",,,"speedtest.tele2.net"
    220 (vsFTPd 3.0.3)
    200 Always in UTF8 mode.
    331 Please specify the password.
    230 Login successful.
    OK
    --> AT#XFTP="ls"
    227 Entering Passive Mode (90,130,70,73,96,156).
    150 Here comes the directory listing.
    226 Directory send OK.
    1000GB.zip
    100GB.zip
    100KB.zip
    100MB.zip
    10GB.zip
    10MB.zip
    1GB.zip
    1KB.zip
    1MB.zip
    200MB.zip
    20MB.zip
    2MB.zip
    3MB.zip
    500MB.zip
    50GB.zip
    50MB.zip
    512KB.zip
    5MB.zip
    upload
    
    OK
    --> AT#XFTP="ls","-l"
    227 Entering Passive Mode (90,130,70,73,110,27).
    150 Here comes the directory listing.
    226 Directory send OK.
    -rw-r--r--    1 0        0        1073741824000 Feb 19  2016 1000GB.zip
    -rw-r--r--    1 0        0        107374182400 Feb 19  2016 100GB.zip
    -rw-r--r--    1 0        0          102400 Feb 19  2016 100KB.zip
    -rw-r--r--    1 0        0        104857600 Feb 19  2016 100MB.zip
    -rw-r--r--    1 0        0        10737418240 Feb 19  2016 10GB.zip
    -rw-r--r--    1 0        0        10485760 Feb 19  2016 10MB.zip
    -rw-r--r--    1 0        0        1073741824 Feb 19  2016 1GB.zip
    -rw-r--r--    1 0        0            1024 Feb 19  2016 1KB.zip
    -rw-r--r--    1 0        0         1048576 Feb 19  2016 1MB.zip
    -rw-r--r--    1 0        0        209715200 Feb 19  2016 200MB.zip
    -rw-r--r--    1 0        0        20971520 Feb 19  2016 20MB.zip
    -rw-r--r--    1 0        0         2097152 Feb 19  2016 2MB.zip
    -rw-r--r--    1 0        0         3145728 Feb 19  2016 3MB.zip
    -rw-r--r--    1 0        0        524288000 Feb 19  2016 500MB.zip
    -rw-r--r--    1 0        0        53687091200 Jul 24  2014 50GB.zip
    -rw-r--r--    1 0        0        52428800 Feb 19  2016 50MB.zip
    -rw-r--r--    1 0        0          524288 Feb 19  2016 512KB.zip
    -rw-r--r--    1 0        0         5242880 Feb 19  2016 5MB.zip
    drwxr-xr-x    2 106      109         69632 Jul 02 09:22 upload
    
    OK
    --> AT#XFTP="binary"
    200 Switching to Binary mode.
    OK
    --> AT#XFTP="ls","-l 1KB.zip"
    227 Entering Passive Mode (90,130,70,73,93,53).
    150 Here comes the directory listing.
    226 Directory send OK.
    -rw-r--r--    1 0        0            1024 Feb 19  2016 1KB.zip
    
    OK
    --> AT#XFTP="get","1KB.zip"
    227 Entering Passive Mode (90,130,70,73,109,182).
    226 Transfer complete.
    data connection for 1KB.zip (1024 bytes).
    000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    OK
    --> AT#XFTP="ls","-l 2KB.zip"
    227 Entering Passive Mode (90,130,70,73,108,231).
    150 Here comes the directory listing.
    226 Directory send OK.
    OK
    --> AT#XFTP="get","2KB.zip"
    227 Entering Passive Mode (90,130,70,73,108,196).
    ERROR
    

    Here is the precompiled .hex with the fixes --> slm_ftp_02_07.hex

    Best regards,
    martin L.

Children
  • Hi Martin,

    I have tested the build shared "slm_ftp_02_07.hex" and found that now if file name is given wrong its not waiting  for infinite time and returning error as shown below.

     

    AT#XFTP="get","testtp.txt"
    
    
    227 Entering Passive Mode (192,168,1,21,229,252).
    
    
    ERROR

    But if I read FTP status using AT command AT#XFTP="status" after getting response and then If I give any FTP command like to read a file from ftp server or given "ls" command or file name is given wrong, then again its going into infinite loop and not getting any response.


    AT#XFTP="open","Administrator","Password1","192.168.1.21"


    220 Microsoft FTP Service


    200 OPTS UTF8 command successful - UTF8 encoding now ON.


    331 Password required


    230 User logged in.


    OK


    AT#XFTP="ls"


    227 Entering Passive Mode (192,168,1,21,230,20).

    150 Opening ASCII mode data connection.


    226 Transfer complete.


    testftp.txt


    OK


    AT#XFTP="get","testftp.txt"


    227 Entering Passive Mode (192,168,1,21,230,26).


    226 Transfer complete.


    ata connection.


    30,26).


    ow ON.


    Hello


    OK


    AT#XFTP="status"


    215 Windows_NT


    211-Microsoft FTP Service status:


         Logged in user: Administrator


         TYPE: ASCII; FORM: NONPRINT; STRUcture: FILE; transfer MODE: STREAM


         Data connection: none


    211 End of status.


    OK


    AT#XFTP="get","testftp.txt"


    227 Entering Passive Mode (192,168,1,21,230,36).

    "Got into infinite loop"

    Can we minimize the extra messages for example came for connecting to FTP server using

    AT#XFTP="open","Administrator","Password1","192.168.1.2

    220 Microsoft FTP Service


    200 OPTS UTF8 command successful - UTF8 encoding now ON.


    331 Password required


    230 User logged in.

    Similar messages are also coming for other FTP commands- get,Ls, status

    With regards,

    Praveen P

  • Hi Praveen,

    Sorry for the delay I have been out of office.
    It looks like this has been addressed in the this PR:https://github.com/nrfconnect/sdk-nrf/commit/ffc175f41f0e4a731eae5496373d4a931146ffe0

    It is merged with the master branch so if you update NCS and rebuild the application you should have the latest updates.

    7652.slm_ftp_28_07.hex

    This version also includes the support to change UART baudrate: https://github.com/nrfconnect/sdk-nrf/pull/2571


    Best regards,
    Martin L.

Related