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

nRF9160 DK HTTP POST to my Webserver

Dear , 

I want to use LTE_M of nRF9160 DK to POST to my webserver

Do you have any suggestions?

Thanks, 

Regards

hng

Parents Reply Children
  • Dear

    I tried to run this http post in a loop

    first, i will check the LTE_M signal "AT+CEREG?"

    It returns:  

    Checking LTE_M signal.............
    
    +CEREG: 0,5,"765D","0110C303",7
    
    OK
    
    Found the LTE_M signal 
    Closing socket
    
      find LTE_M signal........... 
    Checking LTE_M signal.............
    
    +CEREG: 0,5,"765D","0110C303",7
    
    OK
    
    Found the LTE_M signal 
    Closing socket
    
      find LTE_M signal........... 
    Checking LTE_M signal.............
    
    +CEREG: 0,5,"765D","0110C303",7
    
    OK
    
    Found the LTE_M signal 
    Closing socket
    
      find LTE_M signal........... 
    Checking LTE_M signal.............
    
    +CEREG: 0,5,"765D","0110C303",7
    
    OK
    
    Found the LTE_M signal 
    Closing socket
    
      find LTE_M signal........... 
    Checking LTE_M signal.............
    
    +CEREG: 0,5,"765D","0110C303",7
    
    OK
    
    Found the LTE_M signal 
    Closing socket
    
      find LTE_M signal........... 
    Checking LTE_M signal.............
    
    +CEREG: 0,5,"765D","0110C303",7
    
    OK
    
    Found the LTE_M signal 
    Closing socket
    
      find LTE_M signal........... 
    Checking LTE_M signal.............
    
    +CEREG: 0,5,"765D","0110C303",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.............
    

    After 7times, "AT+CEREG?" return NOTHING!

    Why is the problem, the buffer is full? or something wrong in my code? 

    Plz help me. 

    Thanks so much 

    Regards, 

    hng

  • I believe a bug in the BSD library causes this. I get the "no memory" 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. 

  • Dear

    I had 2s delay between

    How long should I add ?

    Thanks for fast responds, 

    Regards, 

    hng

  • A 2-second delay should be sufficient. Can you try to increase the stack sizes in your project *.conf file?

    e.g.,

    CONFIG_MAIN_STACK_SIZE= 8192

    CONFIG_HEAP_MEM_POOL_SIZE=8192

  • Dear

    I tried, the same thing happened  

    int nRF_LTE_check(void)
    {
        int err;
        const char *ATREG="AT+CEREG?"; 
    	int at_socket_fd = socket(AF_LTE, 0, NPROTO_AT);
        printk("Checking LTE_M signal.............\n\r");
    
    	if (at_socket_fd < 0) {
    		err = 1; 
    	}
        else {
        int bytes_written = send(at_socket_fd, ATREG, strlen(ATREG), 0);
        if (bytes_written > 0) {
    	int r_bytes = blocking_recv(at_socket_fd, recv_buf,sizeof(recv_buf), MSG_DONTWAIT);
    	if (r_bytes > 0) {
    	printk("%s", recv_buf);
        if (recv_buf== LTEfound) 
           {
          err = 0; 
          printk("Found LTE_M signal \n");
            }
        else {
           printk("Couldnt find the LTE_M signal \n");
           err =1;
            }
     }
      }
              }
    	printk("Closing socket\n\r");
        (void)close(at_socket_fd);
        return err; 
    }

    my loop: 

    #include <zephyr.h>
    #include <net/socket.h>
    #include <misc/printk.h>
    #include <zephyr/types.h>
    #include <math.h>
    #include <uart.h>
    #include <soc.h>
    #include <gpio.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>     /* atof */
    #include <autoconf.h>
    
    void main (void)
    {
      printk("Test is starting \n"); 
    
       
        
        while(1){
    
       
          int lte_err= nRF_LTE_check();
          if(lte_err==0){ printk("  find LTE_M signal........... \n"); }
          else{ printk(" Couldnt find LTE_M signal........... \n");}
          k_sleep(2000);
       
        }
       
    }

    and my prj.conf

    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

Related