<?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>nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46086/nrf9160-dk-http-post-to-my-webserver</link><description>Dear , 
 
 I want to use LTE_M of nRF9160 DK to POST to my webserver 
 Do you have any suggestions? 
 
 Thanks, 
 Regards 
 hng</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Aug 2019 04:43:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46086/nrf9160-dk-http-post-to-my-webserver" /><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/201720?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2019 04:43:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea7fb81b-035d-4251-a99a-d512284d8bcb</guid><dc:creator>vishal</dc:creator><description>&lt;p&gt;Hi Vidar and Hoang,&lt;/p&gt;
&lt;p&gt;Actually I want to do same simple HTTP post message to server, with this I am able to successfully run and flash merge.hex file into nRF91 DK. But unable to get signal strength I want to see all logs that we have printed in printk(); function.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To flash build into nRF91 DK is only sufficient to flash merge.hex or I need to flash also .elf file as well.&lt;/p&gt;
&lt;p&gt;Thanks and looking forward your response..!!!&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/187880?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 11:41:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18469b48-21c3-4604-ac88-622123d3e374</guid><dc:creator>Hoang</dc:creator><description>&lt;p&gt;Dear &lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Ja, increasing the delay didn&amp;#39;t help. Currently, the solution is: control the socket&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hng&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/187876?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 11:36:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76eaac48-9f75-40b7-9905-86457c9cfa3e</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The function returns &amp;quot;Not enough space&amp;quot; after a while. Increasing the delay did not help. Maybe you can try to keep the socket open rather than open and close it for every command.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void main (void)
{
  printk(&amp;quot;Test is starting \n&amp;quot;); 

   
    
    while(1){

   
      int lte_err= nRF_LTE_check();
      if(lte_err==0){ printk(&amp;quot;  find LTE_M signal........... \n&amp;quot;); }
      else{ printk(&amp;quot; Couldnt find LTE_M signal........... %s \n&amp;quot;, strerror(errno));}
      k_sleep(8000);
   
    }
   
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/187842?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 09:27:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d3f06f0-66c3-4095-bc25-3d34c5c6feb1</guid><dc:creator>Hoang</dc:creator><description>&lt;p&gt;Dear &lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Sorry for snippers, it missed the&amp;nbsp;LTEfound&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/lte_5F00_post_5F00_get.c"&gt;devzone.nordicsemi.com/.../lte_5F00_post_5F00_get.c&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/20602.main.c"&gt;devzone.nordicsemi.com/.../20602.main.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/187835?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 09:12:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:799201de-5014-4b28-b4eb-b42c8422901a</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Can you upload your entire project directory here so I can try to debug it? Some of the variable definitions are missing from the code snippets above.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/187827?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 08:56:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a74ff0c-9832-441f-9fa1-c1f543b1a515</guid><dc:creator>Hoang</dc:creator><description>&lt;p&gt;Dear &lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I tried, the same thing happened&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int nRF_LTE_check(void)
{
    int err;
    const char *ATREG=&amp;quot;AT+CEREG?&amp;quot;; 
	int at_socket_fd = socket(AF_LTE, 0, NPROTO_AT);
    printk(&amp;quot;Checking LTE_M signal.............\n\r&amp;quot;);

	if (at_socket_fd &amp;lt; 0) {
		err = 1; 
	}
    else {
    int bytes_written = send(at_socket_fd, ATREG, strlen(ATREG), 0);
    if (bytes_written &amp;gt; 0) {
	int r_bytes = blocking_recv(at_socket_fd, recv_buf,sizeof(recv_buf), MSG_DONTWAIT);
	if (r_bytes &amp;gt; 0) {
	printk(&amp;quot;%s&amp;quot;, recv_buf);
    if (recv_buf== LTEfound) 
       {
      err = 0; 
      printk(&amp;quot;Found LTE_M signal \n&amp;quot;);
        }
    else {
       printk(&amp;quot;Couldnt find the LTE_M signal \n&amp;quot;);
       err =1;
        }
 }
  }
          }
	printk(&amp;quot;Closing socket\n\r&amp;quot;);
    (void)close(at_socket_fd);
    return err; 
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;my loop:&amp;nbsp;&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;net/socket.h&amp;gt;
#include &amp;lt;misc/printk.h&amp;gt;
#include &amp;lt;zephyr/types.h&amp;gt;
#include &amp;lt;math.h&amp;gt;
#include &amp;lt;uart.h&amp;gt;
#include &amp;lt;soc.h&amp;gt;
#include &amp;lt;gpio.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;     /* atof */
#include &amp;lt;autoconf.h&amp;gt;

void main (void)
{
  printk(&amp;quot;Test is starting \n&amp;quot;); 

   
    
    while(1){

   
      int lte_err= nRF_LTE_check();
      if(lte_err==0){ printk(&amp;quot;  find LTE_M signal........... \n&amp;quot;); }
      else{ printk(&amp;quot; Couldnt find LTE_M signal........... \n&amp;quot;);}
      k_sleep(2000);
   
    }
   
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and my prj.conf&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_SERIAL=y
CONFIG_TRUSTED_EXECUTION_NONSECURE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_1_NRF_UARTE=y
CONFIG_UART_2_NRF_UARTE=y

CONFIG_GPIO=y

CONFIG_NETWORKING=y
CONFIG_NET_BUF_USER_DATA_SIZE=1
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_RAW_MODE=y
CONFIG_BSD_LIBRARY=y


CONFIG_STDOUT_CONSOLE=y

CONFIG_TEST_RANDOM_GENERATOR=y

CONFIG_LOG=n
CONFIG_LOG_DEFAULT_LEVEL=4
#CONFIG_HEAP_MEM_POOL_SIZE=1024
CONFIG_MAIN_STACK_SIZE= 8192
CONFIG_HEAP_MEM_POOL_SIZE=8192


# LTE link control
#CONFIG_LTE_LINK_CONTROL=y
CONFIG_UART_2_NRF_TX_BUFFER_SIZE=1024&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/187818?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 08:41:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e73b1810-d45f-46da-b27f-fa70ff9d5759</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;A 2-second delay should be sufficient. Can you try to increase the stack sizes in your project *.conf file?&lt;/p&gt;
&lt;p&gt;e.g.,&lt;/p&gt;
&lt;p&gt;CONFIG_MAIN_STACK_SIZE= 8192&lt;/p&gt;
&lt;p&gt;CONFIG_HEAP_MEM_POOL_SIZE=8192&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/187800?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 08:13:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3643434e-ffca-4e74-9555-4706b8308c69</guid><dc:creator>Hoang</dc:creator><description>&lt;p&gt;Dear &lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;had 2s delay between&lt;/p&gt;
&lt;p&gt;How long should I add ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for fast responds,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;hng&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/187799?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 08:10:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e657222-a36e-4294-ad27-fe1d967d34f8</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I believe a bug in the BSD library causes this. I get the &amp;quot;no memory&amp;quot; error when call socket send in a loop without any delay in-between. I have reported this internally. A workaround, for now, is to add a delay between each post request.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/187767?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 06:30:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:411cc475-e363-4926-bcd2-96077d96d627</guid><dc:creator>Hoang</dc:creator><description>&lt;p&gt;Dear&lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I tried to run this http post in a loop&lt;/p&gt;
&lt;p&gt;first, i will check the LTE_M signal&amp;nbsp;&amp;quot;AT+CEREG?&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It returns:&amp;nbsp;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;Checking LTE_M signal.............

+CEREG: 0,5,&amp;quot;765D&amp;quot;,&amp;quot;0110C303&amp;quot;,7

OK

Found the LTE_M signal 
Closing socket

  find LTE_M signal........... 
Checking LTE_M signal.............

+CEREG: 0,5,&amp;quot;765D&amp;quot;,&amp;quot;0110C303&amp;quot;,7

OK

Found the LTE_M signal 
Closing socket

  find LTE_M signal........... 
Checking LTE_M signal.............

+CEREG: 0,5,&amp;quot;765D&amp;quot;,&amp;quot;0110C303&amp;quot;,7

OK

Found the LTE_M signal 
Closing socket

  find LTE_M signal........... 
Checking LTE_M signal.............

+CEREG: 0,5,&amp;quot;765D&amp;quot;,&amp;quot;0110C303&amp;quot;,7

OK

Found the LTE_M signal 
Closing socket

  find LTE_M signal........... 
Checking LTE_M signal.............

+CEREG: 0,5,&amp;quot;765D&amp;quot;,&amp;quot;0110C303&amp;quot;,7

OK

Found the LTE_M signal 
Closing socket

  find LTE_M signal........... 
Checking LTE_M signal.............

+CEREG: 0,5,&amp;quot;765D&amp;quot;,&amp;quot;0110C303&amp;quot;,7

OK

Found the LTE_M signal 
Closing socket

  find LTE_M signal........... 
Checking LTE_M signal.............

+CEREG: 0,5,&amp;quot;765D&amp;quot;,&amp;quot;0110C303&amp;quot;,7

OK

Found the LTE_M signal 
Closing socket

  find LTE_M signal........... 
Checking LTE_M signal.............

Closing socket

 Couldnt find LTE_M signal........... 
Checking LTE_M signal.............

Closing socket

 Couldnt find LTE_M signal........... 
Checking LTE_M signal.............
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;After 7times, &amp;quot;AT+CEREG?&amp;quot; return NOTHING!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Why is the problem, the buffer is full? or something wrong in my code?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Plz help me.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks so much&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;hng&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/184071?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2019 12:30:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c191b3f1-3b0a-4c33-83dc-b06402e24ad6</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for sharing the solution here.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/184069?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2019 12:27:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f6cf6f8-5161-41df-843a-574035fef595</guid><dc:creator>Hoang</dc:creator><description>&lt;p&gt;It works, just fixed a little bit:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
/******************************************&amp;quot;**************************************/
#define MAXLINE 4096
#define HTTP_HOST &amp;quot;142.xx.xx.192&amp;quot;  //my webserver
#define HTTP_PORT 80
#define HTTP_PATH &amp;quot;/&amp;quot;
#define TEST_STRING  &amp;quot;Hello from nRF9160 DK&amp;quot;

#define POST_TEMPLATE &amp;quot;POST %s? HTTP/1.1\r\n&amp;quot;\
		&amp;quot;Host: %s\r\n&amp;quot;\
		&amp;quot;Connection: keep-alive\r\n&amp;quot;\
	        &amp;quot;Content-type: application/x-www-form-urlencoded\r\n&amp;quot;\
		&amp;quot;Content-length: %d\r\n\r\n&amp;quot;\
		&amp;quot;%s&amp;quot;
/************************************************************************/
void app_http_post()
{  
	//int err; 
    struct sockaddr_in local_addr;
	struct addrinfo *res;

	local_addr.sin_family = AF_INET;
	local_addr.sin_port = htons(0);
	local_addr.sin_addr.s_addr = 0;

	      
	int err = getaddrinfo(HTTP_HOST, NULL, NULL, &amp;amp;res);

	printk(&amp;quot;getaddrinfo err: %d\n\r&amp;quot;, err);
	((struct sockaddr_in *)res-&amp;gt;ai_addr)-&amp;gt;sin_port = htons(HTTP_PORT);
        
        char send_buf[MAXLINE + 1];
	
	int send_data_len_post = snprintf(send_buf,
				         500, /*total length should not exceed MTU size*/
				         POST_TEMPLATE, HTTP_PATH,
				         HTTP_HOST, strlen(TEST_STRING),
				         TEST_STRING);

	printk(&amp;quot;send err: %d\n\r&amp;quot;, send_data_len_post);


	int client_fd = socket(AF_INET, SOCK_STREAM, 0);

	printk(&amp;quot;client_fd: %d\n\r&amp;quot;, client_fd);
	err = bind(client_fd, (struct sockaddr *)&amp;amp;local_addr,
		   sizeof(local_addr));
	printk(&amp;quot;bind err: %d\n\r&amp;quot;, err);
        // connect
	err = blocking_connect(client_fd, (struct sockaddr *)res-&amp;gt;ai_addr,
			       sizeof(struct sockaddr_in));
	printk(&amp;quot;connect err: %d\n\r&amp;quot;, err);
       //send
    blocking_send(client_fd, send_buf, send_data_len_post, 0);
    k_sleep(1000);
       
	printk(&amp;quot;\n\r HTTP POST Finished. \n\r&amp;quot;);
	close(client_fd);

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks so much&lt;/p&gt;
&lt;p&gt;Regards,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;hng&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/182255?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2019 07:25:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a78ad0c-450f-48d8-84bc-96a2fa312e00</guid><dc:creator>Hoang</dc:creator><description>&lt;p&gt;Thank Vidar,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I will try it&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;hng&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK HTTP POST to my Webserver</title><link>https://devzone.nordicsemi.com/thread/182163?ContentTypeID=1</link><pubDate>Mon, 15 Apr 2019 14:59:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb7085dd-cec6-4e81-a352-65679d04fac1</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Please see my&amp;nbsp;response here:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/46094/how-to-make-http-post-no-libcurl"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/46094/how-to-make-http-post-no-libcurl&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>