Combination of GNSS and HTTP_CLIENT problem

Hi,

I am trying to send GPS coordinates over HTTP, but get some problems when is comes to the use of lte_lc functions: lte_lc_init(), lte_lc_psm_reg(true), lte_lc_connect(), lte_lc_init_and_connect(), lte_lc_power_off(). We want to send coordinates after each fix. The first fix and post works well, but the second time the code fails. If lte_lc_power_off() is enabled in the http_send() fuction the second fix wont appear. If lte_lc_power_off() is removed the second call of http_send() fails, "error: -119". I guess it is something that is going wrong in the usage of these functions, but I don't know what. The code used are based on https_client sample and location sample.  

void send_to_http(){
    lte_lc_init_and_connect();
    
    //bla bla. lots of http server code
    
    lte_lc_power_off();
}

void get_gps(){
    loop{ //this repeats for each gps fix
    
        //coordinates received
        
        send_to_http();
    }
}

void main(void){

    lte_lc_init();
    lte_lc_psm_reg(true);
    lte_lc_connect();
    
    get_gps();
}

  • Solved it:

    void send_to_http(){
        //lte_lc_init_and_connect(); REMOVED THESE
        
        //bla bla. lots of http server code
        
        //lte_lc_power_off(); REMOVED THESE
    }
    
    void get_gps(){
        loop{ //this repeats for each gps fix
    
        //coordinates received
    
        send_to_http();
        }
    }
    
    void main(void){
    
        lte_lc_init();
        lte_lc_psm_reg(true);
        lte_lc_connect();
        
        get_gps();
    }

    lte_lc_init_and_connect could only be called once.

Related