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
  • Thank Vidar,

    I will try it 

    Regards,

    hng

  • Dear

    I tried, the same thing happened  

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    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");
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    my loop: 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #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){
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    and my prj.conf

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    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
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • 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. 

  • Dear

    Sorry for snippers, it missed the LTEfound

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    #include <zephyr.h>
    #include <net/socket.h>
    #include <misc/printk.h>
    #include <zephyr/types.h>
    #include <math.h>
    #include <soc.h>
    #include <gpio.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h> /* atof */
    #include <autoconf.h>
    #define AT_MAX_CMD_LEN 4096
    #define INVALID_DESCRIPTOR -1
    #define UART_RX_BUF_SIZE 4096
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    #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>
    #include <autoconf.h>
    #include "lte_post_get.c"
    /********************************************/
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi,

    The function returns "Not enough space" 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. 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    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........... %s \n", strerror(errno));}
    k_sleep(8000);
    }
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Dear

    Ja, increasing the delay didn't help. Currently, the solution is: control the socket

    Thanks, 

    Regards, 

    Hng

Reply Children
  • Hi Vidar and Hoang,

    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. 

    To flash build into nRF91 DK is only sufficient to flash merge.hex or I need to flash also .elf file as well.

    Thanks and looking forward your response..!!!