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

gps and lte work simultaneously

Hi!

I am trying use aws iot sample and over this the gps example to obtain location and transmit a aws iot core, but I have problem with manage of lte and gps functions, 

I found this functions to control lte modem

lte_lc_init_and_connect_async(lte_lc_evt_handler_thandler);//only once
//
lte_lc_connect_async(lte_lc_evt_handler_thandler);//
//
lte_lc_edrx_req(bool enable);

I undertand that line 1 initialize and connect the lte modem, then 

I don't understand the difference between line 3 and line 5 and therfore how to use that functions

how to use psm to achieve gps and lte work tougether?

which are the functions to control gps work?

thanks in advance 

Julio

  • Hello Julio,

    I don't understand the difference between line 3 and line 5 and therfore how to use that functions

    The function in line 3 will connect the modem to the LTE network, while the function in line 5 will ask the network for eDRX. You can find an overview of the LTE API in the LTE link controller library:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/include/modem/lte_lc.html

    which are the functions to control gps work?

    Please have a look at:

    https://github.com/nrfconnect/sdk-nrf/blob/master/include/drivers/gps.h

    There is also an example which could be a good entry point:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.5.0/nrf/samples/nrf9160/agps/README.html

    how to use psm to achieve gps and lte work tougether?

    LTE has priority over GPS, but GPS will run when possible. But it should run “long enough” to be of any use. To achieve this, you can use PSM to silence LTE and make sure that your are not transmitting anything to the LTE network.

    I hope this answers your questions!

    Cheers!

    Markus

  • Hi Markus

    I have read the links that you share, but I still with out undertand two things

    1- LTE and GPS manage

    over the aws iot sample all function to control LTE modem are these?:

    i) lte_lc_init_and_connect_async()

    ii) lte_lc_psm_req(true)

    iii) lte_lc_offline()

    iv) lte_lc_connect()

    if they are all, I don't understand the order called each of them, because (i) must be the first I supouse, but in main function is the last of them

    I try to do this:

    after L508 I put

    int pr = lte_lc_psm_req(true);
    if (pr) {
    	printk("Requesting PSM failed, error: %d\n", pr);
    }
    printk("Starting GPS application\n");//gps sample code
    if (init_app() != 0) { 
        return -1;
    }

    and return "Failed to initialize modem" with these values in at command

    #define AT_XSYSTEMMODE "AT\%XSYSTEMMODE=0,0,1,0";//gps sample code
    #define AT_ACTIVATE_GPS "AT+CFUN=31";//gps sample code

    2- which one is the recursive function for transmitt to aws?

    where is the control function of transmittion? in main function there is not a loop, I wanna to know where is the transmition control to apply the manage lte and gps  the correct place in code 

    I am very lost in these code, any help I will appreciate a lot

    Julio

  • Hello Julio,

    I’m sorry for the delayed answer. You asked some very good question and I had to dig a little into the code myself being able to give you a proper answer.

    tracking said:
    and return "Failed to initialize modem" with these values in at command

    I recommend you to initialise the modem by adding CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y to your prj.conf instead of using the AT Commands.

    tracking said:

    2- which one is the recursive function for transmitt to aws?

    where is the control function of transmittion?

    The AWS IoT application is using Threads, which you can read more about here:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/kernel/threads/workqueue.html

    Basically, the two main threads are connect_work_fn and shadow_update_work_fn, where as connect_work_fn is calling the aws_iot_event_handler via which shadow_update_work_fn will be called. Hence, you should use the shadow_update_work_fn thread to transmit to AWS.

    I hope this will help you!

    Cheers,

    Markus

  • Hi Markus!

    I prove with this but still without work

    I recommend you to initialise the modem by adding CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y to your prj.conf

    Thank you for thread explanation, I undertand better with and added two threads more for gps control (agps sample)

    k_delayed_work_init(&gps_start_work, gps_start_work_fn);
    k_delayed_work_init(&reboot_work, reboot_work_fn);

    if I leave the default modem configuration of aws iot sample (L372 and L327) can I run gps with these configuration without problems?

    static void work_init(void)
    {   //aws_iot threads
    	k_delayed_work_init(&shadow_update_work, shadow_update_work_fn);
    	k_delayed_work_init(&connect_work, connect_work_fn);
    	k_delayed_work_init(&shadow_update_version_work,
    			    shadow_update_version_work_fn);
        //gps threads of agps sample
    	k_delayed_work_init(&gps_start_work, gps_start_work_fn);
    	k_delayed_work_init(&reboot_work, reboot_work_fn);
    }
    
    static void gps_start_work_fn(struct k_work *work)
    {
    	int err;
    	struct gps_config gps_cfg = {
    		.nav_mode = GPS_NAV_MODE_PERIODIC,
    		.power_mode = GPS_POWER_MODE_DISABLED,
    		.timeout = 120,
    		.interval = 240,
    		.priority = true,
    	};
    	ARG_UNUSED(work);
    	err = gps_start(gps_dev, &gps_cfg);
    	if (err) {
    	    printk("Failed to start GPS, error: %d", err);
    		return;
    	}
            printk("Periodic GPS search started with interval %d s, timeout %d s",  
    		gps_cfg.interval, gps_cfg.timeout);
    }

  • Hello Julio,

    Yes, since you have configured your modem with the option CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y, you can run GPS with the modem configuration of the AWS IoT sample.

    To make your GPS functionality run as smoothly as possible, it is important that you use the GPS stack “long enough”. You can achieve that by putting the LTE stack to idle using PSM/eDRX.

    Regards,

    Markus

Related