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

Connection Problems to a TCP Server

Hi, 

I have a nRF9160DK with a Sim Card from a local provider, that supports NB-IoT.

I modified the example program  in \ncs\zephyr\samples\net\sockets\echo and wanted to set up a connection from the nRF9160 to my TCP Server. That didn't work and then I tried to connect it to the Google DNS server as a test. That didn't work either and I am out of ideas now on what could be the problem. This is the error message I get from the LTE Monitor:

The LTE Monitor log file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2019-11-02T07:24:26.836Z INFO Application data folder: C:\Users\Benjamin Bergmann\AppData\Roaming\nrfconnect\pc-nrfconnect-linkmonitor
2019-11-02T07:24:26.910Z DEBUG App pc-nrfconnect-linkmonitor v1.1.1 official
2019-11-02T07:24:26.910Z DEBUG App path: C:\Users\Benjamin Bergmann\.nrfconnect-apps\node_modules\pc-nrfconnect-linkmonitor
2019-11-02T07:24:26.910Z DEBUG nRFConnect 3.2.0 is supported by the app (^3.2.0)
2019-11-02T07:24:26.910Z DEBUG nRFConnect path: C:\Users\Benjamin Bergmann\AppData\Local\Programs\nrfconnect\resources\app.asar
2019-11-02T07:24:26.910Z DEBUG HomeDir: C:\Users\Benjamin Bergmann
2019-11-02T07:24:26.910Z DEBUG TmpDir: C:\Users\BENJAM~1\AppData\Local\Temp
2019-11-02T07:24:28.628Z INFO Modem port is opened
2019-11-02T07:24:28.634Z DEBUG modem >> AT+CFUN?\x0D\x0A
2019-11-02T07:24:28.650Z DEBUG modem << +CFUN: 1\x0D\x0A
2019-11-02T07:24:28.652Z DEBUG modem << OK\x0D\x0A\x00
2019-11-02T07:24:28.669Z DEBUG modem >> AT+CGSN=1\x0D\x0A
2019-11-02T07:24:28.675Z DEBUG modem << +CGSN: "352656100037459"\x0D\x0A
2019-11-02T07:24:28.677Z DEBUG modem << OK\x0D\x0A
2019-11-02T07:24:28.680Z DEBUG modem >> AT+CGMI\x0D\x0A
2019-11-02T07:24:28.686Z DEBUG modem << Nordic Semiconductor ASA\x0D\x0A
2019-11-02T07:24:28.687Z DEBUG modem << OK\x0D\x0A\x00
2019-11-02T07:24:28.693Z DEBUG modem >> AT+CGMM\x0D\x0A
2019-11-02T07:24:28.700Z DEBUG modem << nRF9160-SICA\x0D\x0A
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

My code (c file):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <errno.h>
#include <stdio.h>
#include <net/bsdlib.h>
#include <kernel.h>
#include <net/socket.h>
#include <at_cmd.h>
#include <lte_lc.h>
#define PORT 22
#define IPADDR "8.8.8.8"
#include <logging/log.h>
/* Initialize module-specific magic state (once per module name): */
LOG_MODULE_REGISTER();
int clientInit()
{
int fd, ret;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

My prj.conf file:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#
# General config
CONFIG_ASSERT=y
CONFIG_TEST_RANDOM_GENERATOR=y
# Network
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
# BSD library
CONFIG_BSD_LIBRARY=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Do you have any idea what could cause the error? Is the structure of the c file correct, or do you set up the connection with other commands?

Thanks for your help and your answers!