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

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

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

Children
  • 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);
    }

Related