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

Enable GPS at startup instead of pushing the button SW3 in Thingy:91

Hello people, 

As the tittle states, I'm looking for a way to simply enable the GPS module in the thingy:91. 

I'm working in the tag v1.1.0

I've been tryng to force with a function like this one: 

void force_gps(void) {
	if (!atomic_get(&send_data_enable)) {
		printk("Link not ready, long press disregarded\n");
		return;
	}

	printk("Starting GPS\n");
	gps_control_enable();
	gps_control_start(K_SECONDS(1));
}

According to what I saw in the code:  

static void long_press_handler(struct k_work *work)
{
	if (!atomic_get(&send_data_enable)) {
		printk("Link not ready, long press disregarded\n");
		return;
	}

	if (gps_control_is_enabled()) {
		printk("Stopping GPS\n");
		gps_control_disable();
	} else {
		printk("Starting GPS\n");
		gps_control_enable();
		gps_control_start(K_SECONDS(1));
	}
}

And this is where I am calling the function: 

void cloud_event_handler(const struct cloud_backend *const backend,
			 const struct cloud_event *const evt,
			 void *user_data)
{
	ARG_UNUSED(user_data);

	switch (evt->type) {
	case CLOUD_EVT_CONNECTED:
		printk("CLOUD_EVT_CONNECTED\n");
		k_delayed_work_cancel(&cloud_reboot_work);
		ui_led_set_pattern(UI_CLOUD_CONNECTED);
		break;
	case CLOUD_EVT_READY:
		printk("CLOUD_EVT_READY\n");
		ui_led_set_pattern(UI_CLOUD_CONNECTED);

#if defined(CONFIG_BOOTLOADER_MCUBOOT)
		/* Mark image as good to avoid rolling back after update */
		boot_write_img_confirmed();
#endif

		sensors_start();

		// activate gps func
		k_sleep(20000);
		force_gps();

		break;
		///............... a lot more code
}

My real question is: Is the GPS module be able to activate it propperly at startup by setting something different in the code like the .config file?

Parents Reply Children
No Data
Related