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

Parents
  • Hello, 

    Error: -13 that you get, translates to 

    #define	EACCES 13	/* Permission denied */

    The GPS receiver supports GPS L1 C/A reception. Operation is time multiplexed with LTE modem, and it is possible to obtain the GPS position either while the LTE is in RRC Idle mode or power saving mode (PSM), or when the LTE modem is completely deactivated.

    Please make sure that your device is in PSM or deactivated before starting GPS.


    Kind regards,
    Øyvind

  • Hi,

    In start function, I success enable PSM mode, and receive feedback "PSM parameter update: TAU: 15000, Active time: 6". How to know  my device is in PSM? Are there any events that I can check?

    I see that, in PSM mode, there is sometimes RCC in connected mode, does this affect GPS? So I only need to check RCC whether in idle mode?

  • Nahan_Trogn said:
    Idle, then continue to wait 25-30 seconds, and start AGPS, sometimes SUPL success, many times fail.

     Can you provide some information on what is failing

    Nahan_Trogn said:
    My problem is I don't know when to do the first start for AGPS to obtain SUPL data.

    Does the default AGPS sample work?  


    Have you tried to start with e.g. AGPS sample and add MQTT to this?

  • This is my log file. I manually start AGPS by button, when seeing RRC Idle Event. I achieve 2 successes.2021-06-02T14_24_18.010Z-log.txt

    The Default AGPS example and GPS example work well. I combine AGPS to MQTT_Simple base on the AGPS example.

  • Hello, 

    I've discussed the issue with some of my colleagues. First of all, the error -13 is not permission denied, it is from the SUPL library (nrf\ext\lib\bin\supl\include\supl_session.h)

    #define LIBSUPL_TIMEOUT                     (-13)
    

    In the the GPS struct gps_cfg, please try to remove priority = true, or set to false:

    struct gps_config gps_cfg = {
                .nav_mode = GPS_NAV_MODE_PERIODIC,
                .power_mode = GPS_POWER_MODE_DISABLED,
                .timeout = 360,
                .interval = 360 +
                        30,
                .priority = true,
        };

    And please increase the MQTT keepalive, which is default to 60 seconds in the MQTT library. This value depends on the MQTT broker you are using, i.e. AWS IoT allows a keepalive of maximum 1200 seconds. You could try e.g. 180 seconds:

    CONFIG_MQTT_KEEPALIVE=180
    

    Kind regards,
    Øyvind

  • Hi,

    I've followed your guide. I also set my mqtt alive time to 300s, but the same problem. I do the first start AGPS right after mqtt client connected Event and got -13 error; then I try start in RRC Idle event, also -13

    2021-06-04T10:01:55.590Z INFO Application data folder: C:\Users\Admin\AppData\Roaming\nrfconnect\pc-nrfconnect-linkmonitor
    2021-06-04T10:01:55.823Z DEBUG App pc-nrfconnect-linkmonitor v1.1.10 official
    2021-06-04T10:01:55.828Z DEBUG App path: C:\Users\Admin\.nrfconnect-apps\node_modules\pc-nrfconnect-linkmonitor
    2021-06-04T10:01:55.829Z DEBUG nRFConnect 3.6.1 is supported by the app (^3.6.0)
    2021-06-04T10:01:55.829Z DEBUG nRFConnect path: C:\Users\Admin\AppData\Local\Programs\nrfconnect\resources\app.asar
    2021-06-04T10:01:55.831Z DEBUG HomeDir: C:\Users\Admin
    2021-06-04T10:01:55.834Z DEBUG TmpDir: C:\Users\Admin\AppData\Local\Temp
    2021-06-04T10:02:09.093Z INFO Modem port is opened
    2021-06-04T10:02:09.102Z DEBUG modem >> AT+CFUN?
    2021-06-04T10:02:09.149Z DEBUG modem << +CFUN: 0
    2021-06-04T10:02:09.153Z DEBUG modem << OK
    2021-06-04T10:02:11.511Z DEBUG modem << [00:00:05.235,168] [0m<inf> mqtt_simple: The MQTT simple sample started[0m
    2021-06-04T10:02:11.514Z DEBUG modem << [00:00:05.235,198] [0m<inf> mqtt_simple: Disabling PSM and eDRX[0m
    2021-06-04T10:02:11.517Z DEBUG modem << [00:00:05.251,098] [0m<inf> mqtt_simple: LTE Link Connecting...[0m
    2021-06-04T10:02:20.781Z DEBUG modem >> AT+CFUN?
    2021-06-04T10:02:20.789Z DEBUG modem << +CFUN: 1
    2021-06-04T10:02:20.802Z DEBUG modem << OK
    2021-06-04T10:02:20.809Z DEBUG modem >> AT+CGSN=1
    2021-06-04T10:02:20.820Z DEBUG modem << +CGSN: "352656101397258"
    2021-06-04T10:02:20.822Z DEBUG modem << OK
    2021-06-04T10:02:20.828Z DEBUG modem >> AT+CGMI
    2021-06-04T10:02:20.840Z DEBUG modem << Nordic Semiconductor ASA
    2021-06-04T10:02:20.844Z DEBUG modem << OK
    2021-06-04T10:02:20.854Z DEBUG modem >> AT+CGMM
    2021-06-04T10:02:20.869Z DEBUG modem << nRF9160-SICA
    2021-06-04T10:02:20.873Z DEBUG modem << OK
    2021-06-04T10:02:20.888Z DEBUG modem >> AT+CGMR
    2021-06-04T10:02:20.920Z DEBUG modem << mfw_nrf9160_1.2.3
    2021-06-04T10:02:20.925Z DEBUG modem << OK
    2021-06-04T10:02:20.929Z INFO Nordic Semiconductor ASA nRF9160-SICA [mfw_nrf9160_1.2.3] SerNr: 352656101397258
    2021-06-04T10:02:20.931Z DEBUG modem >> AT+CEMODE?
    2021-06-04T10:02:20.941Z DEBUG modem << +CEMODE: 0
    2021-06-04T10:02:20.946Z DEBUG modem << OK
    2021-06-04T10:02:20.971Z DEBUG modem >> AT%XCBAND=?
    2021-06-04T10:02:20.986Z DEBUG modem << %XCBAND: (1,2,3,4,5,8,12,13,17,19,20,25,26,28,66)
    2021-06-04T10:02:20.995Z DEBUG modem << OK
    2021-06-04T10:02:21.019Z DEBUG modem >> AT+CMEE?
    2021-06-04T10:02:21.040Z DEBUG modem << +CMEE: 0
    2021-06-04T10:02:21.042Z DEBUG modem << OK
    2021-06-04T10:02:21.047Z DEBUG modem >> AT+CMEE=1
    2021-06-04T10:02:21.071Z DEBUG modem << OK
    2021-06-04T10:02:21.077Z DEBUG modem >> AT+CNEC?
    2021-06-04T10:02:21.107Z DEBUG modem << +CNEC: 0
    2021-06-04T10:02:21.109Z DEBUG modem << OK
    2021-06-04T10:02:21.114Z DEBUG modem >> AT+CNEC=24
    2021-06-04T10:02:21.134Z DEBUG modem << OK
    2021-06-04T10:02:21.138Z DEBUG modem >> AT+CGEREP?
    2021-06-04T10:02:21.161Z DEBUG modem << +CGEREP: 0,0
    2021-06-04T10:02:21.167Z DEBUG modem << OK
    2021-06-04T10:02:21.176Z DEBUG modem >> AT+CGDCONT?
    2021-06-04T10:02:21.206Z DEBUG modem << OK
    2021-06-04T10:02:21.211Z DEBUG modem >> AT+CGACT?
    2021-06-04T10:02:21.227Z DEBUG modem << OK
    2021-06-04T10:02:21.242Z DEBUG modem >> AT+CGEREP=1
    2021-06-04T10:02:21.260Z DEBUG modem << OK
    2021-06-04T10:02:21.264Z DEBUG modem >> AT+CIND=1,1,1
    2021-06-04T10:02:21.282Z DEBUG modem << OK
    2021-06-04T10:02:21.289Z DEBUG modem >> AT+CEREG=5
    2021-06-04T10:02:21.307Z DEBUG modem << OK
    2021-06-04T10:02:21.313Z DEBUG modem >> AT+CEREG?
    2021-06-04T10:02:21.336Z DEBUG modem << +CEREG: 5,4,"FFFE","FFFFFFFF",9,0,0,"00000000","00000000"
    2021-06-04T10:02:21.339Z DEBUG modem << OK
    2021-06-04T10:02:21.358Z DEBUG modem >> AT%CESQ=1
    2021-06-04T10:02:21.373Z DEBUG modem << OK
    2021-06-04T10:02:21.375Z DEBUG modem >> AT+CESQ
    2021-06-04T10:02:21.389Z DEBUG modem << +CESQ: 99,99,255,255,255,255
    2021-06-04T10:02:21.393Z DEBUG modem << OK
    2021-06-04T10:02:21.417Z DEBUG modem >> AT%XSIM=1
    2021-06-04T10:02:21.440Z DEBUG modem << OK
    2021-06-04T10:02:21.446Z DEBUG modem >> AT%XSIM?
    2021-06-04T10:02:21.460Z DEBUG modem << %XSIM: 1
    2021-06-04T10:02:21.463Z DEBUG modem << OK
    2021-06-04T10:02:21.488Z DEBUG modem >> AT+CPIN?
    2021-06-04T10:02:21.501Z DEBUG modem << +CPIN: READY
    2021-06-04T10:02:21.504Z DEBUG modem << OK
    2021-06-04T10:02:21.514Z DEBUG modem >> AT+CPINR="SIM PIN"
    2021-06-04T10:02:21.534Z DEBUG modem << +CPINR: "SIM PIN",3
    2021-06-04T10:02:21.537Z DEBUG modem << OK
    2021-06-04T10:02:21.547Z DEBUG modem >> AT+CIMI
    2021-06-04T10:02:21.557Z DEBUG modem << 452040325353031
    2021-06-04T10:02:21.560Z DEBUG modem << OK
    2021-06-04T10:02:21.562Z INFO IMSIdentity: 452040325353031
    2021-06-04T10:02:29.905Z DEBUG modem << %CESQ: 30,1,0,0
    2021-06-04T10:02:29.914Z DEBUG modem << +CEREG: 2,"61B6","090BF716",9,0,0,"11100000","11100000"
    2021-06-04T10:02:30.914Z DEBUG modem << [00:00:24.649,383] [0m<inf> mqtt_simple: LTE cell changed: Cell ID: 151779094, Tracking area: 25014[0m
    2021-06-04T10:03:02.291Z DEBUG modem << %CESQ: 34,1,6,0
    2021-06-04T10:03:08.298Z DEBUG modem << %CESQ: 31,1,0,0
    2021-06-04T10:03:08.306Z DEBUG modem << +CEREG: 2,"FFFE","FFFFFFFF",9,0,0,"11100000","11100000"
    2021-06-04T10:03:09.307Z DEBUG modem << [00:01:03.043,731] [0m<inf> mqtt_simple: LTE cell changed: Cell ID: -1, Tracking area: 65534[0m
    2021-06-04T10:03:09.434Z DEBUG modem << %CESQ: 37,1,11,1
    2021-06-04T10:03:09.443Z DEBUG modem << +CEREG: 2,"61B6","090BE517",9,0,0,"11100000","11100000"
    2021-06-04T10:03:10.445Z DEBUG modem << [00:01:04.179,199] [0m<inf> mqtt_simple: LTE cell changed: Cell ID: 151774487, Tracking area: 25014[0m
    2021-06-04T10:03:38.988Z DEBUG modem << +CSCON: 1
    2021-06-04T10:03:39.993Z DEBUG modem << [00:01:33.733,917] [0m<inf> mqtt_simple: RRC mode: Connected[0m
    2021-06-04T10:03:41.333Z DEBUG modem << +CGEV: ME PDN ACT 0,0
    2021-06-04T10:03:41.343Z DEBUG modem << +CNEC_ESM: 50,0
    2021-06-04T10:03:41.351Z DEBUG modem << +CEREG: 1,"61B6","090BE517",9,,,"11100000","11100000"
    2021-06-04T10:03:41.359Z DEBUG modem << +CIND: "service",1
    2021-06-04T10:03:41.372Z DEBUG modem >> AT+CGDCONT?
    2021-06-04T10:03:41.387Z DEBUG modem << +CGDCONT: 0,"IP","nbiot","9.253.108.208",0,0
    2021-06-04T10:03:41.389Z DEBUG modem << OK
    2021-06-04T10:03:41.403Z DEBUG modem >> AT+COPS=3,2
    2021-06-04T10:03:41.413Z DEBUG modem << OK
    2021-06-04T10:03:41.430Z DEBUG modem >> AT+CGACT?
    2021-06-04T10:03:41.450Z DEBUG modem << +CGACT: 0,1
    2021-06-04T10:03:41.457Z DEBUG modem << OK
    2021-06-04T10:03:41.483Z DEBUG modem >> AT+COPS?
    2021-06-04T10:03:41.506Z DEBUG modem << +COPS: 0,2,"45204",9
    2021-06-04T10:03:41.511Z DEBUG modem << OK
    2021-06-04T10:03:41.534Z DEBUG modem >> AT%XCBAND
    2021-06-04T10:03:41.542Z DEBUG modem << %XCBAND: 3
    2021-06-04T10:03:41.544Z DEBUG modem << OK
    2021-06-04T10:03:41.563Z DEBUG modem >> AT+CGDCONT?
    2021-06-04T10:03:41.578Z DEBUG modem << +CGDCONT: 0,"IP","nbiot","9.253.108.208",0,0
    2021-06-04T10:03:41.580Z DEBUG modem << OK
    2021-06-04T10:03:41.598Z DEBUG modem >> AT+CGACT?
    2021-06-04T10:03:41.612Z DEBUG modem << +CGACT: 0,1
    2021-06-04T10:03:41.617Z DEBUG modem << OK
    2021-06-04T10:03:42.369Z DEBUG modem << [00:01:36.077,423] [0m<inf> mqtt_simple: LTE Link Connected![0m
    2021-06-04T10:03:42.370Z DEBUG modem << [00:01:36.077,545] [0m<inf> mqtt_simple: Network registration status: Connected - home network[0m
    2021-06-04T10:03:42.372Z DEBUG modem << [00:01:36.077,545] [0m<inf> mqtt_simple: PSM parameter update: TAU: -1, Active time: -1[0m
    2021-06-04T10:03:42.373Z DEBUG modem << [00:01:37.003,601] [0m<inf> mqtt_simple: IPv4 Address found 34.199.33.81[0m
    2021-06-04T10:03:42.396Z DEBUG modem << [00:01:37.004,302] [0m<dbg> nrf9160_gps.configure_antenna: MAGPIO set: AT%XMAGPIO=1,1,1,7,1,746,803,2,698,748,2,1710,2200,3,824,894,4,880,960,5,791,849,7,1565,1586[0m
    2021-06-04T10:03:42.397Z DEBUG modem << [00:01:37.004,791] [0m<dbg> nrf9160_gps.configure_antenna: COEX0 set: AT%XCOEX0[0m
    2021-06-04T10:03:42.399Z DEBUG modem << [00:01:37.004,852] [0m<dbg> nrf9160_gps.open_socket: GPS socket created, fd: 1232491587[0m
    2021-06-04T10:03:42.400Z DEBUG modem << [00:01:37.004,974] [0m<inf> mqtt_simple: Start interval[0m
    2021-06-04T10:03:45.117Z DEBUG modem << [00:01:38.844,635] [0m<inf> mqtt_simple: MQTT client connected[0m
    2021-06-04T10:03:45.120Z DEBUG modem << [00:01:38.844,665] [0m<inf> mqtt_simple: Resend 0[0m
    2021-06-04T10:03:45.122Z DEBUG modem << [00:01:38.844,665] [0m<inf> mqtt_simple: Subscribing to: my/subscribe/topic len 18[0m
    2021-06-04T10:03:46.441Z DEBUG modem << [00:01:40.180,664] [0m<inf> mqtt_simple: SUBACK packet id: 1234[0m
    2021-06-04T10:03:50.591Z DEBUG modem << %CESQ: 38,1,5,0
    2021-06-04T10:03:53.446Z DEBUG modem << %CESQ: 38,1,10,1
    2021-06-04T10:04:17.004Z DEBUG modem << +CSCON: 0
    2021-06-04T10:04:18.010Z DEBUG modem << [00:02:11.752,563] [0m<inf> mqtt_simple: RRC mode: Idle[0m
    2021-06-04T10:04:23.563Z DEBUG modem << [00:02:17.255,859] [0m<inf> mqtt_simple: Enter start[0m
    2021-06-04T10:04:23.564Z DEBUG modem << [00:02:17.255,889] [0m<inf> mqtt_simple: START GPS[0m
    2021-06-04T10:04:23.566Z DEBUG modem << [00:02:17.256,652] [0m<dbg> nrf9160_gps.enable_gps: GPS mode is enabled[0m
    2021-06-04T10:04:23.567Z DEBUG modem << [00:02:17.262,542] [0m<dbg> nrf9160_gps.gps_priority_set: GPS priority disabled[0m
    2021-06-04T10:04:23.571Z DEBUG modem << [00:02:17.262,847] [0m<dbg> nrf9160_gps.start: GPS operational[0m
    2021-06-04T10:04:23.572Z DEBUG modem << [00:02:17.262,939] [0m<inf> mqtt_simple: GPS_EVT_SEARCH_STARTED[0m
    2021-06-04T10:04:23.573Z DEBUG modem << [00:02:17.263,092] [0m<dbg> nrf9160_gps.gps_thread: A-GPS data update needed[0m
    2021-06-04T10:04:23.575Z DEBUG modem << [00:02:17.263,092] [0m<inf> mqtt_simple: GPS_EVT_AGPS_DATA_NEEDED[0m
    2021-06-04T10:04:23.577Z DEBUG modem << [00:02:17.263,122] [0m<inf> agps: SUPL is initialized[0m
    2021-06-04T10:04:52.765Z DEBUG modem >> AT
    2021-06-04T10:04:53.766Z ERROR Error: 'AT
    ' timed out
    2021-06-04T10:05:06.909Z INFO Modem port is opened
    2021-06-04T10:05:06.915Z DEBUG modem >> AT+CFUN?
    2021-06-04T10:05:06.936Z DEBUG modem << +CFUN: 0
    2021-06-04T10:05:06.939Z DEBUG modem << OK
    2021-06-04T10:05:09.219Z DEBUG modem << [00:00:05.235,137] [0m<inf> mqtt_simple: The MQTT simple sample started[0m
    2021-06-04T10:05:09.222Z DEBUG modem << [00:00:05.235,168] [0m<inf> mqtt_simple: Disabling PSM and eDRX[0m
    2021-06-04T10:05:09.224Z DEBUG modem << [00:00:05.251,037] [0m<inf> mqtt_simple: LTE Link Connecting...[0m
    2021-06-04T10:05:10.150Z DEBUG modem << +CEREG: 2,"61B6","090BE517",9,0,0,"11100000","11100000"
    2021-06-04T10:05:11.160Z DEBUG modem << [00:00:07.185,882] [0m<inf> mqtt_simple: LTE cell changed: Cell ID: 151774487, Tracking area: 25014[0m
    2021-06-04T10:05:48.592Z DEBUG modem << +CEREG: 2,"FFFE","FFFFFFFF",9,0,0,"11100000","11100000"
    2021-06-04T10:05:49.601Z DEBUG modem << [00:00:45.628,784] [0m<inf> mqtt_simple: LTE cell changed: Cell ID: -1, Tracking area: 65534[0m
    2021-06-04T10:07:24.473Z DEBUG modem << +CEREG: 2,"61E6","090A8C16",9,0,0,"11100000","11100000"
    2021-06-04T10:07:25.484Z DEBUG modem << [00:02:21.513,488] [0m<inf> mqtt_simple: LTE cell changed: Cell ID: 151686166, Tracking area: 25062[0m
    2021-06-04T10:07:41.209Z DEBUG modem << +CSCON: 1
    2021-06-04T10:07:42.215Z DEBUG modem << [00:02:38.250,549] [0m<inf> mqtt_simple: RRC mode: Connected[0m
    2021-06-04T10:07:43.423Z DEBUG modem << +CEREG: 1,"61E6","090A8C16",9,,,"11100000","11100000"
    2021-06-04T10:07:43.433Z DEBUG modem >> AT+COPS=3,2
    2021-06-04T10:07:43.448Z DEBUG modem << OK
    2021-06-04T10:07:43.452Z DEBUG modem >> AT+COPS?
    2021-06-04T10:07:43.461Z DEBUG modem << +COPS: 0,2,"45204",9
    2021-06-04T10:07:43.465Z DEBUG modem << OK
    2021-06-04T10:07:43.484Z DEBUG modem >> AT%XCBAND
    2021-06-04T10:07:43.496Z DEBUG modem << %XCBAND: 3
    2021-06-04T10:07:43.500Z DEBUG modem << OK
    2021-06-04T10:07:43.516Z DEBUG modem >> AT+CGDCONT?
    2021-06-04T10:07:43.530Z DEBUG modem << +CGDCONT: 0,"IP","nbiot","11.145.69.15",0,0
    2021-06-04T10:07:43.533Z DEBUG modem << OK
    2021-06-04T10:07:43.553Z DEBUG modem >> AT+CGACT?
    2021-06-04T10:07:43.564Z DEBUG modem << +CGACT: 0,1
    2021-06-04T10:07:43.568Z DEBUG modem << OK
    2021-06-04T10:07:44.490Z DEBUG modem << [00:02:40.464,630] [0m<inf> mqtt_simple: LTE Link Connected![0m
    2021-06-04T10:07:44.492Z DEBUG modem << [00:02:40.464,721] [0m<inf> mqtt_simple: Network registration status: Connected - home network[0m
    2021-06-04T10:07:44.494Z DEBUG modem << [00:02:40.464,721] [0m<inf> mqtt_simple: PSM parameter update: TAU: -1, Active time: -1[0m
    2021-06-04T10:07:44.495Z DEBUG modem << [00:02:40.958,251] [0m<inf> mqtt_simple: IPv4 Address found 34.199.33.81[0m
    2021-06-04T10:07:44.496Z DEBUG modem << [00:02:40.958,953] [0m<dbg> nrf9160_gps.configure_antenna: MAGPIO set: AT%XMAGPIO=1,1,1,7,1,746,803,2,698,748,2,1710,2200,3,824,894,4,880,960,5,791,849,7,1565,1586[0m
    2021-06-04T10:07:44.497Z DEBUG modem << [00:02:40.959,442] [0m<dbg> nrf9160_gps.configure_antenna: COEX0 set: AT%XCOEX0[0m
    2021-06-04T10:07:44.499Z DEBUG modem << [00:02:40.959,503] [0m<dbg> nrf9160_gps.open_socket: GPS socket created, fd: 1232491587[0m
    2021-06-04T10:07:44.500Z DEBUG modem << [00:02:40.959,625] [0m<inf> mqtt_simple: Start interval[0m
    2021-06-04T10:07:46.181Z DEBUG modem << [00:02:42.198,272] [0m<inf> mqtt_simple: MQTT client connected[0m
    2021-06-04T10:07:46.183Z DEBUG modem << [00:02:42.198,272] [0m<inf> mqtt_simple: Resend 0[0m
    2021-06-04T10:07:46.185Z DEBUG modem << [00:02:42.198,303] [0m<inf> mqtt_simple: Subscribing to: my/subscribe/topic len 18[0m
    2021-06-04T10:07:46.189Z DEBUG modem << [00:02:42.875,274] [0m<inf> mqtt_simple: SUBACK packet id: 1234[0m
    2021-06-04T10:07:50.627Z DEBUG modem << +CEREG: 1,"61E6","090A8C16",9,,,"00000100","00011011"
    2021-06-04T10:07:50.634Z DEBUG modem << [00:02:47.064,575] [0m<inf> mqtt_simple: Enter start[0m
    2021-06-04T10:07:50.635Z DEBUG modem << [00:02:47.064,575] [0m<inf> mqtt_simple: START GPS[0m
    2021-06-04T10:07:50.636Z DEBUG modem << [00:02:47.065,460] [0m<dbg> nrf9160_gps.enable_gps: GPS mode is enabled[0m
    2021-06-04T10:07:50.638Z DEBUG modem << [00:02:47.071,960] [0m<dbg> nrf9160_gps.gps_priority_set: GPS priority disabled[0m
    2021-06-04T10:07:50.639Z DEBUG modem << [00:02:47.072,204] [0m<dbg> nrf9160_gps.start: GPS operational[0m
    2021-06-04T10:07:50.640Z DEBUG modem << [00:02:47.072,296] [0m<inf> mqtt_simple: GPS_EVT_SEARCH_STARTED[0m
    2021-06-04T10:07:50.641Z DEBUG modem << [00:02:47.072,448] [0m<dbg> nrf9160_gps.gps_thread: A-GPS data update needed[0m
    2021-06-04T10:07:50.644Z DEBUG modem << [00:02:47.072,448] [0m<inf> mqtt_simple: GPS_EVT_AGPS_DATA_NEEDED[0m
    2021-06-04T10:07:50.646Z DEBUG modem << [00:02:47.072,479] [0m<inf> agps: SUPL is initialized[0m
    2021-06-04T10:07:50.647Z DEBUG modem << [00:02:47.604,919] [0m<inf> mqtt_simple: PSM parameter update: TAU: 16200, Active time: 8[0m
    2021-06-04T10:07:50.670Z DEBUG modem >> AT+COPS=3,2
    2021-06-04T10:07:50.678Z DEBUG modem << OK
    2021-06-04T10:07:50.690Z DEBUG modem >> AT+COPS?
    2021-06-04T10:07:50.710Z DEBUG modem << +COPS: 0,2,"45204",9
    2021-06-04T10:07:50.713Z DEBUG modem << OK
    2021-06-04T10:07:50.737Z DEBUG modem >> AT%XCBAND
    2021-06-04T10:07:50.757Z DEBUG modem << %XCBAND: 3
    2021-06-04T10:07:50.760Z DEBUG modem << OK
    2021-06-04T10:07:50.779Z DEBUG modem >> AT+CGDCONT?
    2021-06-04T10:07:50.793Z DEBUG modem << +CGDCONT: 0,"IP","nbiot","11.145.69.15",0,0
    2021-06-04T10:07:50.794Z DEBUG modem << OK
    2021-06-04T10:07:50.820Z DEBUG modem >> AT+CGACT?
    2021-06-04T10:07:50.840Z DEBUG modem << +CGACT: 0,1
    2021-06-04T10:07:50.842Z DEBUG modem << OK
    2021-06-04T10:07:52.697Z DEBUG modem << [00:02:48.733,276] [0m<inf> agps: Starting SUPL session[0m
    2021-06-04T10:08:04.547Z DEBUG modem << [00:03:00.553,649] [1;31m<err> agps: SUPL session failed, error: -13[0m
    2021-06-04T10:08:04.549Z DEBUG modem << [00:03:00.553,649] [1;31m<err> agps: SUPL request failed, error: -13[0m
    2021-06-04T10:08:04.550Z DEBUG modem << [00:03:00.553,680] [1;31m<err> mqtt_simple: Failed to request A-GPS data, error: -13[0m
    2021-06-04T10:08:04.552Z DEBUG modem << [00:03:00.553,833] [0m<dbg> nrf9160_gps.gps_thread: Waiting for time window to operate[0m
    2021-06-04T10:08:04.554Z DEBUG modem << [00:03:00.553,833] [0m<inf> mqtt_simple: GPS_EVT_OPERATION_BLOCKED[0m
    2021-06-04T10:08:28.097Z DEBUG modem << [00:03:24.133,697] [0m<inf> mqtt_simple: GPS_EVT_SEARCH_TIMEOUT[0m
    2021-06-04T10:13:04.764Z DEBUG modem >> AT
    2021-06-04T10:13:05.770Z ERROR Error: 'AT
    ' timed out
    2021-06-04T10:13:24.596Z INFO Modem port is opened
    2021-06-04T10:13:24.600Z DEBUG modem >> AT+CFUN?
    2021-06-04T10:13:24.619Z DEBUG modem << +CFUN: 0
    2021-06-04T10:13:24.622Z DEBUG modem << OK
    2021-06-04T10:13:26.926Z DEBUG modem << [00:00:05.235,168] [0m<inf> mqtt_simple: The MQTT simple sample started[0m
    2021-06-04T10:13:26.928Z DEBUG modem << [00:00:05.235,198] [0m<inf> mqtt_simple: Disabling PSM and eDRX[0m
    2021-06-04T10:13:26.929Z DEBUG modem << [00:00:05.251,098] [0m<inf> mqtt_simple: LTE Link Connecting...[0m
    2021-06-04T10:13:38.225Z DEBUG modem << +CEREG: 2,"61E6","090A8C16",9,0,0,"11100000","11100000"
    2021-06-04T10:13:38.622Z DEBUG modem << +CSCON: 1
    2021-06-04T10:13:39.241Z DEBUG modem << [00:00:17.554,443] [0m<inf> mqtt_simple: LTE cell changed: Cell ID: 151686166, Tracking area: 25062[0m
    2021-06-04T10:13:39.242Z DEBUG modem << [00:00:17.951,141] [0m<inf> mqtt_simple: RRC mode: Connected[0m
    2021-06-04T10:13:40.666Z DEBUG modem << +CEREG: 1,"61E6","090A8C16",9,,,"11100000","11100000"
    2021-06-04T10:13:40.676Z DEBUG modem >> AT+COPS=3,2
    2021-06-04T10:13:40.688Z DEBUG modem << OK
    2021-06-04T10:13:40.691Z DEBUG modem >> AT+COPS?
    2021-06-04T10:13:40.705Z DEBUG modem << +COPS: 0,2,"45204",9
    2021-06-04T10:13:40.709Z DEBUG modem << OK
    2021-06-04T10:13:40.737Z DEBUG modem >> AT%XCBAND
    2021-06-04T10:13:40.761Z DEBUG modem << %XCBAND: 3
    2021-06-04T10:13:40.763Z DEBUG modem << OK
    2021-06-04T10:13:40.771Z DEBUG modem >> AT+CGDCONT?
    2021-06-04T10:13:40.795Z DEBUG modem << +CGDCONT: 0,"IP","nbiot","9.44.235.102",0,0
    2021-06-04T10:13:40.797Z DEBUG modem << OK
    2021-06-04T10:13:40.803Z DEBUG modem >> AT+CGACT?
    2021-06-04T10:13:40.810Z DEBUG modem << +CGACT: 0,1
    2021-06-04T10:13:40.812Z DEBUG modem << OK
    2021-06-04T10:13:41.733Z DEBUG modem << [00:00:19.995,178] [0m<inf> mqtt_simple: LTE Link Connected![0m
    2021-06-04T10:13:41.735Z DEBUG modem << [00:00:19.995,300] [0m<inf> mqtt_simple: Network registration status: Connected - home network[0m
    2021-06-04T10:13:41.738Z DEBUG modem << [00:00:19.995,300] [0m<inf> mqtt_simple: PSM parameter update: TAU: -1, Active time: -1[0m
    2021-06-04T10:13:41.741Z DEBUG modem << [00:00:20.795,867] [0m<inf> mqtt_simple: IPv4 Address found 34.199.33.81[0m
    2021-06-04T10:13:41.742Z DEBUG modem << [00:00:20.796,569] [0m<dbg> nrf9160_gps.configure_antenna: MAGPIO set: AT%XMAGPIO=1,1,1,7,1,746,803,2,698,748,2,1710,2200,3,824,894,4,880,960,5,791,849,7,1565,1586[0m
    2021-06-04T10:13:41.743Z DEBUG modem << [00:00:20.797,058] [0m<dbg> nrf9160_gps.configure_antenna: COEX0 set: AT%XCOEX0[0m
    2021-06-04T10:13:41.745Z DEBUG modem << [00:00:20.797,119] [0m<dbg> nrf9160_gps.open_socket: GPS socket created, fd: 1232491587[0m
    2021-06-04T10:13:41.746Z DEBUG modem << [00:00:20.797,241] [0m<inf> mqtt_simple: Start interval[0m
    2021-06-04T10:14:09.085Z DEBUG modem << [00:00:47.395,477] [0m<inf> mqtt_simple: MQTT client connected[0m
    2021-06-04T10:14:09.086Z DEBUG modem << [00:00:47.395,507] [0m<inf> mqtt_simple: Resend 0[0m
    2021-06-04T10:14:09.089Z DEBUG modem << [00:00:47.395,507] [0m<inf> mqtt_simple: Subscribing to: my/subscribe/topic len 18[0m
    2021-06-04T10:14:10.197Z DEBUG modem << [00:00:48.520,507] [0m<inf> mqtt_simple: SUBACK packet id: 1234[0m
    2021-06-04T10:14:40.538Z DEBUG modem << +CSCON: 0
    2021-06-04T10:14:41.544Z DEBUG modem << [00:01:19.869,354] [0m<inf> mqtt_simple: RRC mode: Idle[0m
    2021-06-04T10:15:01.545Z DEBUG modem << +CSCON: 1
    2021-06-04T10:15:01.547Z DEBUG modem << [00:01:40.328,277] [0m<inf> mqtt_simple: Enter start[0m
    2021-06-04T10:15:01.548Z DEBUG modem << [00:01:40.328,308] [0m<inf> mqtt_simple: START GPS[0m
    2021-06-04T10:15:01.549Z DEBUG modem << [00:01:40.329,071] [0m<dbg> nrf9160_gps.enable_gps: GPS mode is enabled[0m
    2021-06-04T10:15:01.550Z DEBUG modem << [00:01:40.334,960] [0m<dbg> nrf9160_gps.gps_priority_set: GPS priority disabled[0m
    2021-06-04T10:15:01.583Z DEBUG modem << [00:01:40.335,266] [0m<dbg> nrf9160_gps.start: GPS operational[0m
    2021-06-04T10:15:01.585Z DEBUG modem << [00:01:40.335,357] [0m<inf> mqtt_simple: GPS_EVT_SEARCH_STARTED[0m
    2021-06-04T10:15:01.587Z DEBUG modem << [00:01:40.335,510] [0m<dbg> nrf9160_gps.gps_thread: A-GPS data update needed[0m
    2021-06-04T10:15:01.590Z DEBUG modem << [00:01:40.335,510] [0m<inf> mqtt_simple: GPS_EVT_AGPS_DATA_NEEDED[0m
    2021-06-04T10:15:01.591Z DEBUG modem << [00:01:40.335,540] [0m<inf> agps: SUPL is initialized[0m
    2021-06-04T10:15:01.592Z DEBUG modem << [00:01:40.853,271] [0m<inf> mqtt_simple: RRC mode: Connected[0m
    2021-06-04T10:15:01.814Z DEBUG modem << +CEREG: 1,"61E6","090A8C16",9,,,"00000100","00011001"
    2021-06-04T10:15:01.830Z DEBUG modem >> AT+COPS=3,2
    2021-06-04T10:15:01.836Z DEBUG modem << OK
    2021-06-04T10:15:01.839Z DEBUG modem >> AT+COPS?
    2021-06-04T10:15:01.846Z DEBUG modem << +COPS: 0,2,"45204",9
    2021-06-04T10:15:01.848Z DEBUG modem << OK
    2021-06-04T10:15:01.866Z DEBUG modem >> AT%XCBAND
    2021-06-04T10:15:01.876Z DEBUG modem << %XCBAND: 3
    2021-06-04T10:15:01.879Z DEBUG modem << OK
    2021-06-04T10:15:01.897Z DEBUG modem >> AT+CGDCONT?
    2021-06-04T10:15:01.910Z DEBUG modem << +CGDCONT: 0,"IP","nbiot","9.44.235.102",0,0
    2021-06-04T10:15:01.912Z DEBUG modem << OK
    2021-06-04T10:15:01.931Z DEBUG modem >> AT+CGACT?
    2021-06-04T10:15:01.949Z DEBUG modem << +CGACT: 0,1
    2021-06-04T10:15:01.953Z DEBUG modem << OK
    2021-06-04T10:15:02.214Z DEBUG modem << +CSCON: 0
    2021-06-04T10:15:02.828Z DEBUG modem << [00:01:41.146,179] [0m<inf> mqtt_simple: PSM parameter update: TAU: 15000, Active time: 8[0m
    2021-06-04T10:15:02.829Z DEBUG modem << [00:01:41.545,898] [0m<inf> mqtt_simple: RRC mode: Idle[0m
    2021-06-04T10:15:03.474Z DEBUG modem << +CSCON: 1
    2021-06-04T10:15:04.486Z DEBUG modem << [00:01:42.806,335] [0m<inf> mqtt_simple: RRC mode: Connected[0m
    2021-06-04T10:15:04.488Z DEBUG modem << [00:01:43.766,693] [0m<inf> agps: Starting SUPL session[0m
    2021-06-04T10:15:16.475Z DEBUG modem << [00:01:54.772,155] [1;31m<err> agps: SUPL session failed, error: -13[0m
    2021-06-04T10:15:16.477Z DEBUG modem << [00:01:54.772,186] [1;31m<err> agps: SUPL request failed, error: -13[0m
    2021-06-04T10:15:16.478Z DEBUG modem << [00:01:54.772,186] [1;31m<err> mqtt_simple: Failed to request A-GPS data, error: -13[0m
    2021-06-04T10:15:16.480Z DEBUG modem << [00:01:54.772,369] [0m<dbg> nrf9160_gps.gps_thread: Waiting for time window to operate[0m
    2021-06-04T10:15:16.481Z DEBUG modem << [00:01:54.772,369] [0m<inf> mqtt_simple: GPS_EVT_OPERATION_BLOCKED[0m
    2021-06-04T10:17:07.304Z DEBUG modem << [00:03:45.635,467] [0m<inf> mqtt_simple: GPS_EVT_SEARCH_TIMEOUT[0m
    2021-06-04T10:17:31.770Z DEBUG modem >> AT+CSCON?
    2021-06-04T10:17:31.782Z DEBUG modem << +CSCON: 1,1
    2021-06-04T10:17:31.784Z DEBUG modem << OK
    2021-06-04T10:18:57.387Z DEBUG modem << +CSCON: 0
    2021-06-04T10:18:58.392Z DEBUG modem << [00:05:36.729,400] [0m<inf> mqtt_simple: RRC mode: Idle[0m
    2021-06-04T10:19:17.094Z DEBUG modem << +CEREG: 1,"61B6","090BE517",9,,,"00000100","00011001"
    2021-06-04T10:19:17.722Z DEBUG modem >> AT+COPS=3,2
    2021-06-04T10:19:17.729Z DEBUG modem << OK
    2021-06-04T10:19:18.105Z DEBUG modem << [00:05:56.438,049] [0m<inf> mqtt_simple: LTE cell changed: Cell ID: 151774487, Tracking area: 25014[0m
    2021-06-04T10:19:18.724Z DEBUG modem >> AT+COPS?
    2021-06-04T10:19:18.733Z DEBUG modem << +COPS: 0,2,"45204",9
    2021-06-04T10:19:18.734Z DEBUG modem << OK
    2021-06-04T10:19:19.096Z DEBUG modem << +CSCON: 1
    

  • Hi, 

    I'm trying to find a solution to this issue, and am currently working with our developers.

    The initial question is: Have you tried implementing MQTT to the AGPS sample? If this sample works as intended, then maybe that would be an easier work-around.

     Our SUPL expert had a look at you case, and says:

    It seems that device gets some A-GPS data and writes that to the modem. It seems as if it couldn't read all of the data or something like that. 
    It takes a long time, so it can't be executed for example in the button handler directly. It should be ran in a separate thread. And the proper way to do it would be to fetch A-GPS data when GNSS asks for it. GPS driver sends event GPS_EVT_AGPS_DATA_NEEDED when it needs A-GPS data. That event contains a structure of type gps_agps_request which indicates what kind of A-GPS data GNSS needs. They should check the AGPS sample, it triggers the fetching of A-GPS data when GPS_EVT_AGPS_DATA_NEEDED is received by the event handler.
    Kind regards,
    Øyvind
Reply
  • Hi, 

    I'm trying to find a solution to this issue, and am currently working with our developers.

    The initial question is: Have you tried implementing MQTT to the AGPS sample? If this sample works as intended, then maybe that would be an easier work-around.

     Our SUPL expert had a look at you case, and says:

    It seems that device gets some A-GPS data and writes that to the modem. It seems as if it couldn't read all of the data or something like that. 
    It takes a long time, so it can't be executed for example in the button handler directly. It should be ran in a separate thread. And the proper way to do it would be to fetch A-GPS data when GNSS asks for it. GPS driver sends event GPS_EVT_AGPS_DATA_NEEDED when it needs A-GPS data. That event contains a structure of type gps_agps_request which indicates what kind of A-GPS data GNSS needs. They should check the AGPS sample, it triggers the fetching of A-GPS data when GPS_EVT_AGPS_DATA_NEEDED is received by the event handler.
    Kind regards,
    Øyvind
Children
Related