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

AGPS with SUPL with MQTT_Simple example

Hi,

I use MQTT_Simple example with AGPS feature;

I add 3 functions, one for init GPS, one for start GPS, and the last for A_GPS request.

static void gps_control_init(void)
{
    int err;

    gps_dev = device_get_binding(CONFIG_NRF9160_GPS_DEV_NAME);
    if (gps_dev == NULL) {
            LOG_ERR("Could not get %s device",
                    log_strdup(CONFIG_NRF9160_GPS_DEV_NAME));
            return -ENODEV;
    }

    err = gps_init(gps_dev, gps_handler);
    if (err) {
            LOG_ERR("Could not initialize GPS, error: %d", err);
            return err;
    }
}

static void start(void)
{
    int err;
    struct gps_config gps_cfg = {
            .nav_mode = GPS_NAV_MODE_PERIODIC,
            .power_mode = GPS_POWER_MODE_DISABLED,
            .timeout = 360,
            .interval = 360 +
                    30,
            .priority = true,
    };

    if (gps_dev == NULL) {
            LOG_ERR("GPS controller is not initialized properly");
            return;
    }

    LOG_INF("Enabling PSM");

    err = lte_lc_psm_req(true);
    if (err) {
            LOG_ERR("PSM request failed, error: %d", err);
    } else {
            LOG_INF("PSM enabled");
    }

    err = gps_start(gps_dev, &gps_cfg);
    if (err) {
            LOG_ERR("Failed to enable GPS, error: %d", err);
            return;
    }

}

static void on_agps_needed(struct gps_agps_request request)
{
	int err;

	err = gps_agps_request(request, GPS_SOCKET_NOT_PROVIDED);
	if (err) {
		LOG_ERR("Failed to request A-GPS data, error: %d", err);
		return;
	}
}

I call Init after "MQTT client connected", and start GPS by button_handler.

When it runs, an error occurs:

I used  nRF9160 GPS driver [experimental], Ubuntu, ncs v1.5.1

Related