This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

receiving 'OK' after CR_LF in datamode

I'm currently trying to send a HTTP body payload that includes "\r\n" in the data payload.   I'm getting an "OK" response before I have sent the complete payload. 

The problem occurs when sending the HTTP request (#XHTTPREQ).  After sending the initial AT message including headers

[00:00:35.041,000] <info> MODEM_NRF9160: tx:AT
[00:00:35.041,000] <info> MODEM_NRF9160: tx:#XHTTPCREQ
[00:00:35.041,000] <info> MODEM_NRF9160: tx:=
[00:00:35.041,000] <info> MODEM_NRF9160: tx:"POST","/device/api/v0/station/powerontest","User-Agent: SLM/1.2.0
Accept: application/json
Content-Type: application/octet-stream
x-boundary: ----B0uNd4Ry2018
Content-Length: 1026

",1026
 The AT host is in datamode, so the actual data patterns should be ignored.
I'm sending this payload with \r\n on the first line to datamode:
"------B0uNd4Ry2018\r\n\
Content-Disposition: form-data; name=\"log_data\"\n\
Content-Type: application/json\n\
{\n\
\"source\": \"Basestation 2.14.0\",\n\
\"stationMAC\":\"DA1111111111\",\n\
\"serialNum\":\"B00000\",\n\
\"deviceMAC\":\"DA1111111111\",\n\
\"logType\": \"Station\",\n\
\"fwVersion\": \"2.14.0\",\n\
\"sdVersion\": \"09-89-168\",\n\
\"blVersion\": 8,\n\
\"command\":\"selfTest\",\n\
\"rtc\": {\n\
    \"epochTime\": 1631050498,\n\
    \"batterySwitchOverFlag\": 1,\n\
    \"batteryLowFlag\": 0\n\
  },\n\
\"modem\": {\n\
    \"fwVersion\":\"L0.0.00.00.05.08 [Apr 17 2019 19:34:02]\",\n\
    \"model\":\"SARA-R410M-02B\",\n\
    \"ICCID\":\"89011703278453956677\",\n\
    \"CSQ\":\"+CSQ: 21,99\",\n\
    \"CESQ\":\"+CESQ: 99,99,255,255,14,38\",\n\
    \"IMEI\":\"352753097871972\"\n\
  },\n\
\"createdAt\": \"2021-09-07T21:34:58Z\",\n\
\"epochTime\": 1631050498,\n\
\"localEpochTime\": 13143,\n\
\"tzOffset\":-14400,\n\
\"inventory\":\n\
{\n\
  \"productName\" : \"Trio_Station\",\n\
  \"subsystems\" : [\n\
    { \"id\" : 0, \"name\" : \"NRF_00\", \"version\" : \"2.14.0\" },\n\
    { \"id\" : 1, \"name\" : \"MODEM_00\", \"version\" : \"L0.0.00.00.05.08 [Apr 17 2019 19:34:02]\" }\n\
  ]\n\
}\n\
,\n\
\"last_key\":0\n\
}\n\
\n\
------B0uNd4Ry2018--"
The SLM AT host works as expected if I remove the '\r' character on the first line of the payload.
Any ideas why datamode is terminated when it receives the termination character sequence?  Seems like the command mode is still scanning the data.
  • Some additional information:

    Testing with Release 1.5.1.  Using SLM over UART, only modification is to switch UART port to UART2.

  • Hello Anthony,

    I will come back to you tomorrow.

    Regards,

    Markus

  • Hello Anthony,

    The Serial LTE modem application has no datamode available in NCS v1.5.1. So the “\r\n” in line:

    "------B0uNd4Ry2018\r\n\

    will basically terminate the command.

    Additionally, characters like “\"” could cause trouble as they might be interpreted differently in command mode, which makes it difficult the send data in .json format as body.

    Hence, I strongly recommend you update to at least NCS v1.6.0, where datamode was added to the Serial LTE modem application. The command you would like to send could look something like this then:

    [00:00:35.041,000] <info> MODEM_NRF9160: tx:"POST","/device/api/v0/station/powerontest","User-Agent: SLM/1.2.0
    Accept: application/json
    Content-Type: application/ json
    Content-Disposition: form-data; name=\"log_data\"
    Content-Length: XXXX
    ",XXXX

    Followed by URC:

    #XHTTPCREQ: 1

    which makes the Serial LTE modem application entering datamode.

    {
    "source": "Basestation 2.14.0",
    "stationMAC": "DA1111111111",
    "serialNum": "B00000\",
    "deviceMAC": "DA1111111111",
    "logType": "Station",
    "fwVersion": "2.14.0\",
    "sdVersion": "09-89-168",
    "blVersion": 8,
    "command": "selfTest",
    "rtc": {
        "epochTime": 1631050498,
        "batterySwitchOverFlag": 1,
        "batteryLowFlag": 0
      },
    "modem": {
        "fwVersion\": "L0.0.00.00.05.08 [Apr 17 2019 19:34:02]",
        "model": "SARA-R410M-02B",
        "ICCID": "89011703278453956677",
        "CSQ": "+CSQ: 21,99",
        "CESQ": "+CESQ: 99,99,255,255,14,38",
        "IMEI": "352753097871972"
      },
    "createdAt": "2021-09-07T21:34:58Z",
    "epochTime": 1631050498,
    "localEpochTime": 13143,
    "tzOffset":-14400,
    “inventory":
    {
     productName : "Trio_Station",
     subsystems : [
        { "id" : 0, "name" : "NRF_00", "version" : "2.14.0" },
        { "id" : 1, "name" : "MODEM_00", "version" : "L0.0.00.00.05.08 [Apr 17 2019 19:34:02]" }
      ]
    }
    ,
    "last_key":0
    }

    Datamode is able to send the original .json text without shift or newline chars, etc.

    When total XXXX bytes has been sent, SLM HTTP client quits datamode automatically followed by:

    #XHTTPCREQ: 0

    I hope this will solve your issue!

    Regards,

  • The documentation for 1.5.1 indicates it has the concept of datamode, nonetheless it seems the code does not work as described.  I have updated to 1.6.1 now, so I will close this ticket. 

Related