nRF9160 device functionality after a week

Hi,

I'm using latest master branch of nRF Connect SDK and pre-released modem FW 1.1.2 which is including ANT->AUX switching. I'm developing a firmware for a custom board that has nRF9160 SiP.

I would like to set the device to start GPS once a week. I have read the Date-Time Library and wondered if it's possible to use that library to set the device to start GPS at the specific time. Does anyone any suggestions how to do that?

But for now I have done it with k_delayed_work_submit_to_queue() and set the delay to one week. One week is 168 hours but that value is not working, I tested some different values and noticed that 163h is the maximum that is working in that function. If the value is 164 hours or more it seems to start the work immediately.

Why is that happening? Is there any other way to get 168 hours working than for example adding another delayed work with 8 hours to queue after 160 hours?

Here is some parts of the code:

static int gps_start_delay_hours = 160;		// one week - 8 hours

/* Stack definition for application workqueue */
K_THREAD_STACK_DEFINE(application_stack_area,
			CONFIG_APPLICATION_WORKQUEUE_STACK_SIZE);		// 2048
static struct k_work_q application_work_q;

static struct k_delayed_work start_gps_work;


/**@brief Callback for GPS events */
static void gps_handler(struct device *dev, struct gps_event *evt)
{
    ...
	case GPS_EVT_SEARCH_STOPPED:
		LOG_INF("GPS_EVT_SEARCH_STOPPED");
		gps_control_set_active(false);

		if (gps_failed_fix_attempts >= CONFIG_GPS_CONTROL_MAX_FAILED_FIX_ATTEMPTS) {
            k_delayed_work_submit_to_queue(&application_work_q,
                    &start_gps_work, K_HOURS(gps_start_delay_hours));
		}

		break;
    ...
}

/**@brief Start GPS. */
static void start_gps(struct k_work *work)
{
	gps_control(1);
}

void main(void)
{
    ...
	k_work_q_start(&application_work_q, application_stack_area,
			K_THREAD_STACK_SIZEOF(application_stack_area),
			CONFIG_APPLICATION_WORKQUEUE_PRIORITY);

    k_delayed_work_init(&start_gps_work, start_gps);
    ...
}

Regards,
Tero

Parents Reply Children
Related