serial_lte_modem AT#XFTP="put" SLM data mode and escaping data?

So I have to upload a bunch of files, some contain arbitrary data that might contain +,\r,\n,\ ext

So there are two different ways of using the FTP put command, one is in SLM data mode, the other is inline in quotes and I am having huge issues with both

**inline Mode?**
AT#XFTP="open","******username********","*******password*****","*******domain*******"
AT#XFTP="verbose","on"
AT#XFTP="binary"
AT#XFTP="put","test.txt","this is test content"
AT#XFTP="close"


**SLM Data Mode**
AT#XFTP="open","******username********","*******password*****","*******domain*******"
AT#XFTP="verbose","on"
AT#XFTP="binary"
AT#XFTP="put","test.txt"
this is test content
AT#XFTP="close"

We can talk about these two options:

Option1 is what I call inline mode:

if I try to include a  \" inside the first option, or a \r\n in the next the modem will just lock up for a long time. Is there any way to send a bunch of arbitrary binary data as long as I escape it somehow? since backslash doesn't seem to be working

Example that will fail:

AT#XFTP="open","******username********","*******password*****","*******domain*******"
AT#XFTP="verbose","on"
AT#XFTP="binary"
AT#XFTP="put","test.txt","this is\" test content"
AT#XFTP="close"

Option2: Is what you guys call SLM data mode:

According to the documentation and from what I can see in the code, the only way the modem should exit SLM data mode is after a timeout, or by sending +++

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/serial_lte_modem/doc/slm_data_mode.html

But this doesn't happen, it only seems to exit SLM mode when I send a \r\n but there appears to be no way of escaping this?

Another problem is if I just pretend the first issue isnt a thing and remove all new lines from my data(which I really can't do, this is just for exploring the other problem I am having) and send +++ it shows up in the file that is uploaded to the server?

Example that will write part of a file and then get an error because it drops out of SLM too soon:

AT#XFTP="open","******username********","*******password*****","*******domain*******"
AT#XFTP="verbose","on"
AT#XFTP="binary"
AT#XFTP="put","test.txt"
this is \r\ntest content+++
AT#XFTP="close"

If I try to use the +++ as intended from the documentation:

AT#XFTP="open","******username********","*******password*****","*******domain*******"
AT#XFTP="verbose","on"
AT#XFTP="binary"
AT#XFTP="put","test.txt"
this is test content+++
AT#XFTP="close"

I end up with a file on the server including the +++:

this is test content+++

This example will also fail if you do not send a \r\n at the end of the test content line even though the +++ is supposed to terminate it.

Few quite baffling things that do not follow normal conventions or even the documentation?

  • I desperately need to get this working tonight and load our 50 sample boards, so I will be up for a while here

  • Charlie,

    Did you hear back from the dev team about this issue?

    Thanks,

    Kyle

  • Another odd thing, is even though the buffer is 4096 in the nRF9160, but it seems to be limited to 256 bytes in SLM mode?

  • Hi Kyle,

    I did some further investigation and found all your requests can be satisfied with current FTP commands.

    1. It is your serial terminal that decides how your input is parsed into hex format. I test with CoolTerm, its Connection->Send String has the option to send ASCII and edit hex format at the same, you can add special charactors for example 0D 0A(\r\n) in the content. The FTP command will just transfer the hex data as it receives.

    2. QUOTATION MARK(") is a special character for SLM to parser parameters. If your content what to have, you have to use data mode. Document Running in data mode mentioned "FTP unique or single put operations are completed." will trigger data mode exists, so make sure you have all your content at one put action. In data mode, QUOTATION MARK can be at anywhere of you sending string.

    Best regards,

    Charlie

  • I am sending the data to the modem with a ESP32 which supports sending escaped char, but every time I send a new line the modem exists SLM mode

    After connecting I send exactly:

    Serial.println((char*)"AT#XFTP=\"put\",\"test.txt\"\0"); //mirror data to Debug serial
    nRF9160_serial->println((char*)"AT#XFTP=\"put\",\"test.txt\"\0");
    
    
    Serial.println((char*)"this is some test+++\r\n content with some \"odd' data to test things+++\0"); //mirror data to Debug serial
    nRF9160_serial->println((char*)"this is some test+++\r\n content with some \"odd' data to test things+++\0");

    And then I get this on the server:

    this is some test+++
     content with some "odd' data to test things+++

    Seems like +++ does nothing, but waiting ~1000ms just lets it auto terminate it, not ideal though.

    Another odd thing is the put command kinda works fine, but only accepts 256bytes before having issues. So I was using mput to continue to append to the files, but it is not ever exiting SLM mode for some reason.

    Even after the signal booster, both the ftp and http connect functions seem to only sometimes connect at all

    When the FTP connects now HEX encoding works, still a little unstable but uploading via SLM is still broken

    When HTTP finally connects I can't post any data without the modem closing the connection and returning 0 bytes

Related