Serial LTE Modem TCP/IP Example

I have programmed the NRF9160 with the Serial LTE Modem example and am following along with the example here - Testing scenarios — nRF Connect SDK 2.0.99 documentation (nordicsemi.com)

First thing I notice is AT#XSLMVER returns 2.0.2 instead of 1.5 in the example. 

When I try AT#XSOCKET=1,1,0 it returns XSOCKET: 0,1,6 instead of 1,1,0,6 in the example. 

AT#XSSOCKET? returns 0,1,0 instead of 1,6,0.

I do get the expected OK response from AT#XSOCKETOPT=1,20,60

The rest of the example trying to connect to port 80 of google.com does not seem to work. 

Any ideas, or perhaps I've done something wrong?


Thank you! 

  • Hi Eric,

    I suggest you use the latest release version like the current Welcome to the nRF Connect SDK! — nRF Connect SDK 2.0.2 documentation (nordicsemi.com) instead of 2.0.99, which is the main branch still under development and maybe not very stale until it is well tested before formal release.

    First thing I notice is AT#XSLMVER returns 2.0.2 instead of 1.5 in the example. 

    It is just a demonstration to show how this command will work. You can find its implementation in nrf\applications\serial_lte_modem\src\slm_at_commands.c. It will actually use the NCS version, which is the latest released NCS v2.0.2 in your case.

    sprintf(rsp_buf, "\r\n#XSLMVER: %s\r\n",
    	STRINGIFY(NCS_VERSION_STRING));

    When I try AT#XSOCKET=1,1,0 it returns XSOCKET: 0,1,6 instead of 1,1,0,6 in the example. 

    AT#XSSOCKET? returns 0,1,0 instead of 1,6,0.

    I agree with you it is a bit misleading. I will inquire with the developer if they forget to update it or due to something else. You can refer directly to Socket AT commands — nRF Connect SDK 2.0.2 documentation (nordicsemi.com) and the replies you got look well.

    I do get the expected OK response from AT#XSOCKETOPT=1,20,60

    The rest of the example trying to connect to port 80 of google.com does not seem to work. 

    Can you descript how did you do your test? is there any information returned back?
    I did a quick test based on the SLM application NCS2.0.0(NCS2.0.2 has no update on this sample according to the release note) and everything seems fine. Please see the log file from my LTE Link Monitor.

    2022-08-31T11:00:05.792Z DEBUG Application data folder: C:\Users\chs1\AppData\Roaming\nrfconnect\pc-nrfconnect-linkmonitor
    2022-08-31T11:00:05.852Z INFO Using nrf-device-lib-js version: 0.4.11
    2022-08-31T11:00:05.852Z INFO Using nrf-device-lib version: 0.11.8
    2022-08-31T11:00:05.852Z INFO Using nrfjprog DLL version: 10.15.4
    2022-08-31T11:00:05.852Z INFO Using JLink version: JLink_V7.58b
    2022-08-31T11:00:05.859Z DEBUG App pc-nrfconnect-linkmonitor v2.0.1 official
    2022-08-31T11:00:05.860Z DEBUG App path: C:\Users\chs1\.nrfconnect-apps\node_modules\pc-nrfconnect-linkmonitor
    2022-08-31T11:00:05.860Z DEBUG nRFConnect 3.11.1, required by the app is (^3.8.0)
    2022-08-31T11:00:05.860Z DEBUG nRFConnect path: C:\Users\chs1\AppData\Local\Programs\nrfconnect\resources\app.asar
    2022-08-31T11:00:05.860Z DEBUG HomeDir: C:\Users\chs1
    2022-08-31T11:00:05.860Z DEBUG TmpDir: C:\Users\chs1\AppData\Local\Temp
    2022-08-31T11:00:29.204Z INFO Modem port is opened
    2022-08-31T11:00:29.213Z DEBUG modem >> AT+CFUN?
    2022-08-31T11:00:29.258Z DEBUG modem << +CFUN: 0
    2022-08-31T11:00:29.260Z DEBUG modem << OK
    2022-08-31T11:00:40.032Z DEBUG modem >> AT+CFUN=1
    2022-08-31T11:00:40.079Z DEBUG modem << OK
    2022-08-31T11:00:41.718Z DEBUG modem >> AT+CFUN?
    2022-08-31T11:00:41.727Z DEBUG modem << +CFUN: 1
    2022-08-31T11:00:41.740Z DEBUG modem << OK
    2022-08-31T11:00:56.758Z DEBUG modem >> AT#XSOCKET=?
    2022-08-31T11:00:56.769Z DEBUG modem << #XSOCKET: (0,1,2),(1,2,3),(0,1)
    2022-08-31T11:00:56.770Z DEBUG modem << OK
    2022-08-31T11:01:07.485Z DEBUG modem >> AT#XSOCKET=1,1,0
    2022-08-31T11:01:07.504Z DEBUG modem << #XSOCKET: 0,1,6
    2022-08-31T11:01:07.509Z DEBUG modem << OK
    2022-08-31T11:01:16.445Z DEBUG modem >> AT#XSOCKETOPT=1,20,30
    2022-08-31T11:01:16.453Z DEBUG modem << OK
    2022-08-31T11:01:37.756Z DEBUG modem >> AT#XCONNECT="google.com",80
    2022-08-31T11:01:38.533Z DEBUG modem << #XCONNECT: 1
    2022-08-31T11:01:38.535Z DEBUG modem << OK
    2022-08-31T11:02:46.892Z DEBUG modem >> AT#XSEND="Test TCP"
    2022-08-31T11:02:46.943Z DEBUG modem << OK
    2022-08-31T11:03:08.542Z DEBUG modem >> AT#XRECV=0
    2022-08-31T11:03:08.550Z DEBUG modem << #XRECV: 1240
    2022-08-31T11:03:08.552Z DEBUG modem << HTTP/1.0 400 Bad Request
    2022-08-31T11:03:08.555Z DEBUG modem << Content-Type: text/html; charset=UTF-8
    2022-08-31T11:03:08.558Z DEBUG modem << Referrer-Policy: no-referrer
    2022-08-31T11:03:08.564Z DEBUG modem << Content-Length: 1555
    2022-08-31T11:03:08.565Z DEBUG modem << Date: Wed, 31 Aug 2022 11:02:21 GMT
    2022-08-31T11:03:08.567Z DEBUG modem << <!DOCTYPE html>
    2022-08-31T11:03:08.567Z DEBUG modem << <html lang=en>
    2022-08-31T11:03:08.568Z DEBUG modem <<   <meta charset=utf-8>
    2022-08-31T11:03:08.576Z DEBUG modem <<   <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
    2022-08-31T11:03:08.581Z DEBUG modem <<   <title>Error 400 (Bad Request)!!1</title>
    2022-08-31T11:03:08.582Z DEBUG modem <<   <style>
    2022-08-31T11:03:08.658Z DEBUG modem <<     *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media
    2022-08-31T11:03:08.659Z DEBUG modem << OK

    Best regards,

    Charlie

  • Thank you for the reply.

    My local FAE suggested I try using a standard terminal program instead of LTE Link Monitor to send the AT Commands, and this worked. Link Monitor would get hung up after I would send AT#XSEND, and the +++ command could not get it out of of data mode. 

    Now that it is functioning properly, does Nordic have a TCP server that echos data sent to it, or is there a public one that you know of?

    Thanks!

  • Hi Eric,

    Thanks for the update. I tested data mode and it seems work on LTE Link Monitor. Just ignore the timed-out reminder since it does not give a response on data mode before end with +++

    2022-09-01T08:26:41.488Z DEBUG modem >> AT#XSOCKET=1,1,0
    2022-09-01T08:26:41.506Z DEBUG modem << #XSOCKET: 0,1,6
    2022-09-01T08:26:41.507Z DEBUG modem << OK
    2022-09-01T08:26:49.579Z DEBUG modem >> AT#XSOCKETOPT=1,20,30
    2022-09-01T08:26:49.588Z DEBUG modem << OK
    2022-09-01T08:26:56.219Z DEBUG modem >> AT#XCONNECT="google.com",80
    2022-09-01T08:26:56.956Z DEBUG modem << #XCONNECT: 1
    2022-09-01T08:26:56.957Z DEBUG modem << OK
    2022-09-01T08:26:56.961Z DEBUG modem << %CESQ: 49,2,17,2
    2022-09-01T08:27:04.954Z DEBUG modem >> AT#XCONNECT="google.com",80
    2022-09-01T08:27:04.972Z DEBUG modem << ERROR
    2022-09-01T08:27:04.973Z ERROR Error: AT#XCONNECT="google.com",80
     failed
    2022-09-01T08:27:23.565Z DEBUG modem << %CESQ: 255,0,255,0
    2022-09-01T08:27:25.172Z DEBUG modem >> AT#XSEND
    2022-09-01T08:27:26.173Z ERROR Error: 'AT#XSEND
    ' timed out
    2022-09-01T08:27:28.828Z DEBUG modem >> xdasfa
    2022-09-01T08:27:29.841Z ERROR Error: 'xdasfa
    ' timed out
    2022-09-01T08:27:34.515Z DEBUG modem >> xdasfafdafdsaf+++
    2022-09-01T08:27:34.566Z DEBUG modem << OK

    We do not provide such a server for test. You need to build your own with python or other script languages. There are also TCP server apps that can directly run on your PC. You need to make sure the server is exposed to the internet with a Public IP and stop the server when you do not use it for security reasons.

    Best regards,

    Charlie

Related