<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>LTE TCP socket stability testing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/45311/lte-tcp-socket-stability-testing</link><description>I am trying to design some test cases to check the LTE stability and performance. 
 I avoid to use the existing Nordic samples to do this as they are too complicate for the testing purposes. 
 
 Here is a test case I&amp;#39;ve made to test the LTE TCP communication</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 30 Mar 2019 04:21:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/45311/lte-tcp-socket-stability-testing" /><item><title>RE: LTE TCP socket stability testing</title><link>https://devzone.nordicsemi.com/thread/179324?ContentTypeID=1</link><pubDate>Sat, 30 Mar 2019 04:21:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2e5899d-a69b-47e0-aa7f-604f1c3e11dd</guid><dc:creator>Kai</dc:creator><description>&lt;p&gt;Hi Sigurd&lt;/p&gt;
&lt;p&gt;The problem has been identified. The Verizon SIM card seems to not have been activated. When using an activated iBasis card, the problem is gone.&lt;/p&gt;
&lt;p&gt;Best,&lt;/p&gt;
&lt;p&gt;Kai&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LTE TCP socket stability testing</title><link>https://devzone.nordicsemi.com/thread/179259?ContentTypeID=1</link><pubDate>Fri, 29 Mar 2019 13:59:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3fc66c7-d2cf-4b7f-b6d3-235cf459c53d</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;You should also try to apply this errata workaround:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.nordicsemi.com/DocLib/Content/Errata/nRF9160_EngA/latest/ERR/nRF9160/EngineeringA/latest/anomaly_160_17"&gt;https://www.nordicsemi.com/DocLib/Content/Errata/nRF9160_EngA/latest/ERR/nRF9160/EngineeringA/latest/anomaly_160_17&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LTE TCP socket stability testing</title><link>https://devzone.nordicsemi.com/thread/179160?ContentTypeID=1</link><pubDate>Fri, 29 Mar 2019 09:15:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d4ca3ae-cb59-44cf-939d-05bda5a2c40f</guid><dc:creator>Sigurd</dc:creator><description>[quote userid="73977" url="~/f/nordic-q-a/45311/lte-tcp-socket-stability-testing/179100"]I&amp;#39;ve added the above code in main.c. The error behavior has changed a bit. When the error occurs, instead of being hung there, it resets the whole board. -- what does this behavior change mean?[/quote]
&lt;p&gt;Please try to add &amp;quot;&lt;em&gt;CONFIG_DEBUG&lt;/em&gt;&lt;span&gt;=y&amp;quot; in the&amp;nbsp;prj.conf, and see if that stops the reboot.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LTE TCP socket stability testing</title><link>https://devzone.nordicsemi.com/thread/179100?ContentTypeID=1</link><pubDate>Fri, 29 Mar 2019 05:15:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc5e4884-bd84-46f7-b6ff-2c07dc54b524</guid><dc:creator>Kai</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;enum error_type {
	ERROR_BSD_RECOVERABLE,
	ERROR_BSD_IRRECOVERABLE
};

static void error_handler(enum error_type err_type, int err)
{
	while (1) 
	{
		switch (err_type) {
		case ERROR_BSD_RECOVERABLE:
			printk(&amp;quot;BSD ERROR: RECOVERABLE: %d\n&amp;quot;, err);
			break;
		case ERROR_BSD_IRRECOVERABLE:
			printk(&amp;quot;BSD ERROR: IRRECOVERABLE: %d\n&amp;quot;, err);
			break;
		default:
			break;
		}
		k_busy_wait(1000000*2);		// 2s
	}
}

void bsd_recoverable_error_handler(uint32_t err)
{
	error_handler(ERROR_BSD_RECOVERABLE, (int)err);
}

void bsd_irrecoverable_error_handler(uint32_t err)
{
	error_handler(ERROR_BSD_IRRECOVERABLE, (int)err);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;hi,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve added the above code in main.c. The error behavior has changed a bit. When the error occurs, instead of being hung there, it resets the whole board. -- what does this behavior change mean?&lt;/p&gt;
&lt;p&gt;My card is a Verizon SIM coming with older board (v.0.7.0). No sure if it has been activated or not.&lt;/p&gt;
&lt;p&gt;Best,&lt;/p&gt;
&lt;p&gt;Kai&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LTE TCP socket stability testing</title><link>https://devzone.nordicsemi.com/thread/178803?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2019 23:44:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b37773f-32e8-483a-9826-b377be1bf4d0</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Are you testing with the iBasis sim card? If yes, did you register them at nrfcloud.com ?&lt;/p&gt;
&lt;p&gt;It could be that you are getting a error returned from the bsdlib. Please add the error-handlers and printing of error codes to your main.c file. You can do it like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;gps.h&amp;gt;
#include &amp;lt;sensor.h&amp;gt;
#include &amp;lt;console.h&amp;gt;
#include &amp;lt;nrf_cloud.h&amp;gt;
#include &amp;lt;dk_buttons_and_leds.h&amp;gt;
#include &amp;lt;lte_lc.h&amp;gt;
#include &amp;lt;misc/reboot.h&amp;gt;
#include &amp;lt;bsd.h&amp;gt;
#include &amp;quot;nrf_socket.h&amp;quot;
#include &amp;quot;orientation_detector.h&amp;quot;
#include &amp;lt;net/socket.h&amp;gt;
#include &amp;lt;sys/time.h&amp;gt;


#define TCP_HOST &amp;quot;45.33.53.75&amp;quot;
#define TCP_PORT 9090


#define LC_MAX_READ_LENGTH1 128
#define AT_CMD_SIZE1(x) (sizeof(x) - 1)

static const char subscribe[] = &amp;quot;AT+CEREG=2&amp;quot;;
static const char psm_disable[] = &amp;quot;AT+CPSMS=0&amp;quot;;
static const char normal[] = &amp;quot;AT+CFUN=1&amp;quot;;
static const char success[] = &amp;quot;OK&amp;quot;;
static const char status1[] = &amp;quot;+CEREG: 1&amp;quot;;
static const char status2[] = &amp;quot;+CEREG:1&amp;quot;;
static const char status3[] = &amp;quot;+CEREG: 5&amp;quot;;
static const char status4[] = &amp;quot;+CEREG:5&amp;quot;;

/* Interval in microseconds between each time LEDs are updated when indicating
 * that an error has occurred.
 */
#define LEDS_ERROR_UPDATE_INTERVAL      250000


enum error_type {
	ERROR_NRF_CLOUD,
	ERROR_BSD_RECOVERABLE,
	ERROR_BSD_IRRECOVERABLE,
	ERROR_LTE_LC
};



static int at_cmd1(int fd, const char *cmd, size_t size)
{
	int len;
	u8_t buffer[LC_MAX_READ_LENGTH1];

	printk(&amp;quot;====AT send (%d bytes): %s\n&amp;quot;, strlen(cmd), cmd);
	len = send(fd, cmd, size, 0);
	if (len != size) {
		printk(&amp;quot;***ERROR: AT send: failed, ret=%d.\n&amp;quot;, len);
		return -1;
	}

	for (int i=0; i&amp;lt;50; i++)		// wait for 5s
	{
		len = recv(fd, buffer, LC_MAX_READ_LENGTH1, MSG_DONTWAIT);
		if (len &amp;gt; 0)
		{
			printk(&amp;quot;====AT receive (%d bytes): %s&amp;quot;, strlen(buffer), buffer);
			return 0;
		} 
		k_sleep(K_MSEC(100));
	}
	printk(&amp;quot;**********AT receive ERROR.\n&amp;quot;);
	return -1;
}

/**@brief error handler. */
void error_handler(enum error_type err_type, int err_code)
{


//#if !defined(CONFIG_DEBUG)
//	sys_reboot(SYS_REBOOT_COLD);
//#else
	u8_t led_pattern;

	switch (err_type) {
	case ERROR_NRF_CLOUD:
		/* Blinking all LEDs ON/OFF in pairs (1 and 4, 2 and 3)
		 * if there is an application error.
		 */
		led_pattern = DK_LED1_MSK | DK_LED4_MSK;
		printk(&amp;quot;Error of type ERROR_NRF_CLOUD: %d\n&amp;quot;, err_code);
	break;
	case ERROR_BSD_RECOVERABLE:
		/* Blinking all LEDs ON/OFF in pairs (1 and 3, 2 and 4)
		 * if there is a recoverable error.
		 */
		led_pattern = DK_LED1_MSK | DK_LED3_MSK;
		printk(&amp;quot;Error of type ERROR_BSD_RECOVERABLE: %d\n&amp;quot;, err_code);
	break;
	case ERROR_BSD_IRRECOVERABLE:
		/* Blinking all LEDs ON/OFF if there is an
		 * irrecoverable error.
		 */
		led_pattern = DK_ALL_LEDS_MSK;
		printk(&amp;quot;Error of type ERROR_BSD_IRRECOVERABLE: %d\n&amp;quot;,
								err_code);
								EINVAL;

	break;
	default:
		/* Blinking all LEDs ON/OFF in pairs (1 and 2, 3 and 4)
		 * undefined error.
		 */
		led_pattern = DK_LED1_MSK | DK_LED2_MSK;
		printk(&amp;quot;Unknown error type: %d err_code: %d\n&amp;quot;,
			err_type, err_code);
	break;
	}

	while (true) {
		dk_set_leds(led_pattern &amp;amp; 0x0f);
		k_busy_wait(LEDS_ERROR_UPDATE_INTERVAL);
		dk_set_leds(~led_pattern &amp;amp; 0x0f);
		k_busy_wait(LEDS_ERROR_UPDATE_INTERVAL);
	}
//#endif /* CONFIG_DEBUG */
}


/**@brief Recoverable BSD library error. */
void bsd_recoverable_error_handler(uint32_t err)
{
	error_handler(ERROR_BSD_RECOVERABLE, (int)err);
}

/**@brief Irrecoverable BSD library error. */
void bsd_irrecoverable_error_handler(uint32_t err)
{
	error_handler(ERROR_BSD_IRRECOVERABLE, (int)err);
}



void main(void)
{
	printk(&amp;quot;Application started\n&amp;quot;);

	int err;
	int at_socket_fd;
	u8_t buffer[LC_MAX_READ_LENGTH1];


	// create AT socket
	at_socket_fd = socket(AF_LTE, 0, NPROTO_AT);

	// start modem
	at_cmd1(at_socket_fd, subscribe, AT_CMD_SIZE1(subscribe));
	at_cmd1(at_socket_fd, psm_disable, AT_CMD_SIZE1(psm_disable));
	at_cmd1(at_socket_fd, normal, AT_CMD_SIZE1(normal));

	// wait for LET connection ready
	printk(&amp;quot;LTE connecting ...\n&amp;quot;);
	while (true) {
		int bytes;
		bytes = recv(at_socket_fd, buffer, LC_MAX_READ_LENGTH1, 0);
		if (bytes) {
			buffer[bytes] = 0;
			printk(&amp;quot;====AT receive (%d bytes): %s&amp;quot;, bytes, buffer);
			if (!memcmp(status1, buffer, AT_CMD_SIZE1(status1)) ||
			    !memcmp(status2, buffer, AT_CMD_SIZE1(status2)) ||
			    !memcmp(status3, buffer, AT_CMD_SIZE1(status3)) ||
			    !memcmp(status4, buffer, AT_CMD_SIZE1(status4))) {
				break;
			}
		}
	}
	printk(&amp;quot;\nLTE connected\n\n&amp;quot;);


	// get server IP address
	struct addrinfo * server_addr;
	err = getaddrinfo(TCP_HOST, NULL, NULL, &amp;amp;server_addr);
	if (err != 0)
	{
		printk(&amp;quot;***ERROR: failed to get server IP address\n&amp;quot;);
		return 0;
	}

	// print server IP address
	{
		u8_t * p2 = &amp;amp;(((struct sockaddr_in *)server_addr-&amp;gt;ai_addr)-&amp;gt;sin_addr.s_addr);
		printk(&amp;quot;server IP addr=%d.%d.%d.%d\n&amp;quot;, p2[0], p2[1], p2[2], p2[3]);
	}

	// set server TCP listening port
	((struct sockaddr_in *)server_addr-&amp;gt;ai_addr)-&amp;gt;sin_port = htons(TCP_PORT);

	// create &amp;amp; bind TCP socket
	int tcp_socket_fd;
	{
		tcp_socket_fd = socket(AF_INET, SOCK_STREAM, 0);

		struct sockaddr_in local_addr;
		local_addr.sin_family = AF_INET;
		local_addr.sin_port = htons(0);
		local_addr.sin_addr.s_addr = 0;
		err = bind(tcp_socket_fd, (struct sockaddr *)&amp;amp;local_addr, sizeof(local_addr));
		if (err != 0)
		{
			printk(&amp;quot;TCP sokcet bind err: %d\n\r&amp;quot;, err);
			return;
		}
	}

	// connect to server
	while(1) 
	{
		printk(&amp;quot;\nTCP connect()...\n&amp;quot;);
		err = connect(tcp_socket_fd, (struct sockaddr *)server_addr-&amp;gt;ai_addr, sizeof(struct sockaddr_in));
		if (err == 0)
		{
			printk(&amp;quot;TCP connect() succeeded\n\n&amp;quot;);
			break;
		}
		k_sleep(K_MSEC(1000));	// delay 1s
	} 

	// check modem status; send TCP data to server

	int loop = 1;
	while(1) 
	{
		// read AT socket to see if there is any data; with non-block mode read
		while (true) 
		{
			int bytes;
			bytes = recv(at_socket_fd, buffer, LC_MAX_READ_LENGTH1, MSG_DONTWAIT );
			if (bytes &amp;lt;= 0) 
				break;
			buffer[bytes] = 0;
			printk(&amp;quot;====AT receive (%d bytes): %s&amp;quot;, bytes, buffer);
		}

		printk(&amp;quot;---------------------------------------- %d\n&amp;quot;, loop++);

		// send AT command to check modem status
//		at_cmd1(at_socket_fd, &amp;quot;AT%XCBAND&amp;quot;, AT_CMD_SIZE1(&amp;quot;AT%XCBAND&amp;quot;));
		at_cmd1(at_socket_fd, &amp;quot;AT+CESQ&amp;quot;, AT_CMD_SIZE1(&amp;quot;AT+CESQ&amp;quot;));
		at_cmd1(at_socket_fd, &amp;quot;AT+CEREG?&amp;quot;, AT_CMD_SIZE1(&amp;quot;AT+CEREG?&amp;quot;));
		at_cmd1(at_socket_fd, &amp;quot;AT+CGDCONT?&amp;quot;, AT_CMD_SIZE1(&amp;quot;AT+CGDCONT?&amp;quot;));

		// send TCP data to server
#if 1
		static char buf[] = {&amp;quot;a&amp;quot;};
		static int len = sizeof(buf);
		err = send(tcp_socket_fd, buf, len, 0);
		if (err != len)
			printk(&amp;quot;**********TCP send: error=%d.\n&amp;quot;, err);
		else
			printk(&amp;quot;====TCP send (%d bytes)\n&amp;quot;, len);
#endif

		// sleep 10s
		k_sleep(K_MSEC(10000));
	}

	close(at_socket_fd);
	return 0;
}

&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LTE TCP socket stability testing</title><link>https://devzone.nordicsemi.com/thread/178476?ContentTypeID=1</link><pubDate>Tue, 26 Mar 2019 16:14:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61375b8d-5723-4952-8adb-cb61b8f5c49c</guid><dc:creator>Kai</dc:creator><description>&lt;p&gt;hi Sigurd,&lt;/p&gt;
&lt;p&gt;Here are my board information:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; 1) modem fw is mfw-m1_nrf9160_0.6.8-30.alpha.&lt;/p&gt;
&lt;p&gt;&amp;nbsp; 2) board version is 0.7.0&lt;/p&gt;
&lt;p&gt;&amp;nbsp; 3) carrier is Verizon. The signal strength is about -80db ~ -90db.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We have another board in China. It has the same problem. Its information:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; 1) nRF9160-NB-MFW_030_12_prealpha&lt;/p&gt;
&lt;p&gt;&amp;nbsp; 2) board version is 0.8.2&lt;/p&gt;
&lt;p&gt;&amp;nbsp; 3) carrier is China Mobile.&amp;nbsp;&lt;span&gt;The signal strength is about -85db ~ -95db.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Could the problem be related to the carrier registration? I guess, maybe some registration procedure is missed for my board or SIM card?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best,&lt;/p&gt;
&lt;p&gt;Kai&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LTE TCP socket stability testing</title><link>https://devzone.nordicsemi.com/thread/178390?ContentTypeID=1</link><pubDate>Tue, 26 Mar 2019 13:56:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24c35f22-76ec-4bba-909d-0616184135c3</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi Kai,&lt;/p&gt;
&lt;div&gt;[quote user=""]1) is this a proper test case for testing LTE/network stability?[/quote]&lt;/div&gt;
&lt;p&gt;&amp;nbsp;Yes, I don&amp;#39;t see anything wrong with the test&amp;nbsp;description.&lt;/p&gt;
[quote user=""]2) is anything missed in the coding for correctly configuring the modem?[/quote]
&lt;p&gt;I don&amp;#39;t see anything wrong in your code. You can see how we configure the modem in the&amp;nbsp;lte_link_control driver&amp;nbsp;&lt;a href="https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/drivers/lte_link_control/lte_lc.c"&gt;here&lt;/a&gt;. When it comes to TCP, you can find a sample for that in &lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/tcp/src/main.c"&gt;this fork.&lt;/a&gt;&lt;/p&gt;
[quote user=""]3) does the test result meet your expectation?[/quote]
&lt;p&gt;&amp;nbsp;No, the&amp;nbsp;instability you are seeing is not&amp;nbsp;expected&amp;nbsp;behavior.&lt;/p&gt;
[quote user=""]4) has Nordic done similar testing?[/quote]
&lt;p&gt;&amp;nbsp;I&amp;#39;m running the code you attached, and I have not been able to reproduce the issue. I have been running the test for almost 2 hours now, and the loop counter is now at ~700. I will let the test run overnight.&lt;/p&gt;
&lt;p&gt;I tested with modem fw:&amp;nbsp;&lt;span&gt;mfw-m1_nrf9160_0.6.8-30.alpha&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;What version of the modem fw are you using for the test?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Sigurd&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>