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

GPS/LTE_M/NB-IoT nRF91

Dear, 

I am using :

ncs: v0.4.0 

SES 4.16 

firmware: mfwnrf916007029alpha

Hardware: nRF9160 DK v: 0.8.5

I want to do: 

1. Enable and get GPS position ("AT\%XSYSTEMMODE=0,0,1,0") and data from BMP280 sensor  --> store it in data_pack

2. Turnoff GPS and Enable LTE_M: ("AT\%XSYSTEMMODE=1,0,0,0") & use HTTP POST to post data_pack to my webserver 

3. Switch to NB-IoT: ("AT\%XSYSTEMMODE=0,1,0,0") & use HTTP POST to post data_pack to my webserver

Is it posiblie to do like that now?

I know: "The current modem firmware, v0.7.0-29-alpha, allows you to choose the system mode via command %XSYSTEMMODE, but it does not support them concurrently, meaning that you cannot have GPS + NB-IoT, or GPS + CAT M1, enabled simultaneously at this time."  https://devzone.nordicsemi.com/f/nordic-q-a/48077/gps-http-post

I can switch: AT\%XSYSTEMMODE=0,0,1,0/AT\%XSYSTEMMODE=1,0,0,0/AT\%XSYSTEMMODE=0,1,0,0 but I couldn't POST data to my webserver.

Do you have any suggestions?

Thanks,

Regards, 

hng

Parents
  • Hi hng,

     

    I am very sorry for not seeing the last post in the linked case.

    The system has a flaw when you accept an answer, then add a new reply, it will still mark the case as resolved, so I do not get a notification or state-change on that topic, unfortunately.

     

    From the last reply, it seems that you are not able to successfully connect over NB-IoT in your area, as you do not get the Cell ID, MCC, MNC, and other registration information. You could try to ask your local network providers if there's a nb-iot coverage issue in your area.

    Cat M1 still works fine, right?

     

    Kind regards,

    Håkon

  • Dear

    Thats ok Håkon. 

    I verified the NB-IoT in Horten, Vestfold with iBasis: NO. Then, I used another sim card (telia), I got NB-IoT signal but no LTE-M. I will find someone else, can supply both LTE-M and NB-IoT. 

    But, what do you think about my plan: 

    I want to do: 

    1. Enable and get GPS position ("AT\%XSYSTEMMODE=0,0,1,0") and data from BMP280 sensor  --> store it in data_pack

    2. Turnoff GPS and Enable LTE_M: ("AT\%XSYSTEMMODE=1,0,0,0") & use HTTP POST to post data_pack to my webserver 

    3. Switch to NB-IoT: ("AT\%XSYSTEMMODE=0,1,0,0") & use HTTP POST to post data_pack to my webserver

    Is it possible to do like that now?

    Regards,

    hng

  • Disappointed

    For example, with iBasis sim ( LTE_M). 

    1. Enable and get GPS position ("AT\%XSYSTEMMODE=0,0,1,0") and data from BMP280 sensor  --> store it in data_pack

    2. Turnoff GPS and Enable LTE_M: ("AT\%XSYSTEMMODE=1,0,0,0") & use HTTP POST to post data_pack to my webserver

    Can we? I can't use GPS if I LTE link control library present.

  • You should see the note in the top of the documentation here:

    https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/mob_termination_ctrl_status/xsystemmode_set.html?cp=2_1_3_30_0

     

    The CFUN=4 command corresponds to function lte_lc.c::lte_lc_offline()

    Then switch the xsystemmode to your wanted mode, and you can call lte_lc.c::lte_lc_normal() to start up again.

     

    Kind regards,

    Håkon

  • Dear 

    Im NOT good enough to understand you all. 

    1. "You need to manually start the modem unless you have the LTE Link control library present. It's best just to leave that one enabled."

            GPS COULDNT get position when I kept : 

    # LTE link control
    CONFIG_LTE_LINK_CONTROL=y

    in prj.conf. 

    From me: the option CONFIG_LTE_LINK_CONTROL=y will connect LTE when the nrf9160 starts. 

    I used : AT+CFUN=4 (or lte_lc_offline()), then enable GPS, and run gps

    #define AT_CFUN4        "AT+CFUN=4"
    #define AT_XSYSTEMMODE "AT\%XSYSTEMMODE=0,0,1,0"
    #define AT_MAGPIO      "AT\%XMAGPIO=1,0,0,1,1,1574,1577"
    #define AT_CFUN        "AT+CFUN=1"
    static const char     at_commands[][31]  = {AT_CFUN4,AT_XSYSTEMMODE, AT_MAGPIO, AT_CFUN };

    but then, the GPS keeps scanning ...................... without fix

    anning [|] [1B][1;1H[1B][2JTracking: 0 Using: 0 Unhealthy: 0
    Seconds since last fix 536
    
    Scanning [/] [1B][1;1H[1B][2JTracking: 0 Using: 0 Unhealthy: 0
    Seconds since last fix 536
    
    Scanning [-] [1B][1;1H[1B][2JTracking: 0 Using: 0 Unhealthy: 0
    Seconds since last fix 537
    
    Scanning [\] [1B][1;1H[1B][2JTracking: 0 Using: 0 Unhealthy: 0
    Seconds since last fix 537
    
    Scanning [|] [1B][1;1H[1B][2JTracking: 0 Using: 0 Unhealthy: 0
    Seconds since last fix 538
    
    Scanning [/] [1B][1;1H[1B][2JTracking: 0 Using: 0 Unhealthy: 0
    Seconds since last fix 538
    
    Scanning [-] [1B][1;1H[1B][2JTracking: 0 Using: 0 Unhealthy: 0
    Seconds since last fix 539
    
    Scanning [\] [1B][1;1H[1B][2JTracking: 0 Using: 0 Unhealthy: 0
    Seconds since last fix 539
    
    Scanning [|] 

    (when I ran without option: CONFIG_LTE_LINK_CONTROL=y, just about less then 50s, it got fixed location:

    Scanning [|] [1B][1;1H[1B][2JTracking: 2 Using: 0 Unhealthy: 0
    Seconds since last fix 26
    
    Scanning [/] [1B][1;1H[1B][2JTracking: 2 Using: 0 Unhealthy: 0
    Seconds since last fix 27
    
    Scanning [-] [1B][1;1H[1B][2JTracking: 2 Using: 0 Unhealthy: 0
    Seconds since last fix 27
    
    Scanning [\] [1B][1;1H[1B][2JTracking: 2 Using: 0 Unhealthy: 0
    Seconds since last fix 0
    ---------------------------------
    Longitude:  10.484627
    
    Latitude:   59.407533
    
    Altitude:   55.224106
    
    Speed:      1.476133
    
    Heading:    0.000000
    
    Date:       20-06-2019
    Time (UTC): 07:17:30
    
    NMEA strings:
    $GPGGA,071730.74,5924.45197,N,01029.7760,E,1,05,3.93,55.22,M,0,,*26
    
    
    $GPGLL,5924.45197,N,01029.7760,E,071730.74,A,A*50
    
    
    $GPGSA,A,3,02,12,24,25,,,,,,,,,4.80,3.93,2.75,1*1A
    
    
    $GPGSV,2,1,5,12,84,188,42,24,45,150,42,25,44,253,40,2,16,123,35,1*6B
    
    
    $GPGSV,2,2,5,32,00,000,31,1*62
    
    
    $GPRMC,071730.74,A,5924.45197,N,01029.7760,E,2.86,0.0,200619,,,A,V*2D

    )

    (my nrf9160 dk stayed outside and the same position)

    Something is wrong on my setup?

    Thanks, 

    Ragards, 

    hng

  • Dear

    This is my code

    GPS_LTE_June20.7z

    I hope you can help me to review and give me the solution for this problem

    thanks

    Regards

    hng

Reply Children
  • Hi,

     

    Including sources without headers isn't recommended.

    What you should do is create header files for each of your C-files (except main.c) and rather include them in the CMakeLists.txt. Add these lines to your Cmakelists.txt:

    target_sources(app PRIVATE src/lte_post_get.c)
    target_sources(app PRIVATE src/gps.c)
    zephyr_include_directories(src)

    And create the appropriate header files lte_post_get.h and gps.h in the src/ dir, which should hold the function declarations.

     

    To take the modem off line you can call this function:

    https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/drivers/lte_link_control/lte_lc.c#L140

     

    Then you can change the system mode.

    Then take the modem online again:

    https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/drivers/lte_link_control/lte_lc.c#L158

     

    However; there's no function to "wait for connection" that does not overwrite the xsystemmode.

    This function will set the default xsystemmode (LTE M1 unless explicitly stated otherwise), but will also wait for the connection to be made.

    https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/drivers/lte_link_control/lte_lc.c#L131

     

    What you can do for quick testing is to comment out these three lines (111 to 113), and just use the above mentioned functions:

    https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/drivers/lte_link_control/lte_lc.c#L111

     

    Kind regards,

    Håkon

  • Dear

    I am using ncs: v0.4.0 , so lte_link_control is lit differently from your link. I will try to update and try again 

    Thanks

    Regards

    hng

  • Dear 

    I added the option: 

             CONFIG_LTE_AUTO_INIT_AND_CONNECT=n

    to avoid auto connect LTE when GPS is connecting. 

    Then, I found the position from gps, then enable LTE:

               AT+CFUN=4 (lte_lc_normal())/AT\%XSYSTEMMODE=1,0,0,0/AT+CFUN=1

         connect to LTE: lte_lc_init_and_connect(); 

    then, i get LTE signal: +COPS: 0,2,"24201",7

    then, I POSTed my webserver. but I received nothing!!!

    Sending data to webserver
    getaddrinfo err: 0
    
    send err: 166
    
    client_fd: -1
    
    bind err: -1
    
    connect err: -1
    

    I added the header files, then you can review easy now. 

    Could you plz help me

    GPS_LTE_June21.7z

    Thanks,

    Regards,

    hng

  • Hi,

     

    Your code prints "client_fd: -1", which indicates that the socket is not allocated. Looking through the code, it seems that you do not close your sockets after you're done, for instance in nRF_offGPS_onLTE. For every created socket(), there should be a corresponding close(). This also goes for the getaddrinfo(), which should also have a corresponding freeaddrinfo() within the same scope.

     

    Kind regards,

    Håkon

  • Dear

    Thanks so much

    I could  :

    (1) GPS position

    (2) LTE-M connection 

    (3) http post with LTE-M to my webserver

    I tried to release the LTE-M socket() after posting and run loop (1)-(2)-(3) again. But, I couldn't connect to gps socket again.

    void app_http_post(char *PostString)
    {  
    	//int err; 
            printk("Sending data to webserver\n");
            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, &res);
    
    	printk("getaddrinfo err: %d\n\r", err);
    	((struct sockaddr_in *)res->ai_addr)->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(PostString),
    				         PostString);
    
    	printk("send err: %d\n\r", send_data_len_post);
    	int client_fd = socket(AF_INET, SOCK_STREAM, 0);
    	printk("client_fd: %d\n\r", client_fd);
    	err = bind(client_fd, (struct sockaddr *)&local_addr, sizeof(local_addr));
    	printk("bind err: %d\n\r", err);
           	err = blocking_connect(client_fd, (struct sockaddr *)res->ai_addr,sizeof(struct sockaddr_in));
    	printk("connect err: %d\n\r", err);
            int numbytes = blocking_send(client_fd, send_buf, send_data_len_post, 0);
            printk("send err: %d\n\r", numbytes);
    
            freeaddrinfo(res); // free getaddrinfo(HTTP_HOST, NULL, NULL, &res);
            k_sleep(1000);
            printk("Close socket \n\r");
           	close(client_fd); // close the socket
           
       
    }

    and : lte_lc_offline(); 

    but, I couldnt connect to GPS socket 

    fd = nrf_socket(NRF_AF_LOCAL, NRF_SOCK_DGRAM, NRF_PROTO_GNSS);

    the source code: 

    GPS_LTE_June25.7z

    The second time, it will return: 

    Could not init socket (err: -1)

    Thanks, 

    Regards, 

Related