nrf9160: LTE + GPS + MQTT - GPS Blocked


Hi,

I am trying to understand either the timing or feature I am missing with respect to LTE, GPS and MQTT.  I have read a number of posts and questions on a similar topic, but didnt find what I was doing wrong.

I have a 9160DK which connects fine to LTE and MQTT or LTE and GPS but I cant get all 3 to connect.

When I have LTE and MQTT connected, the GPS stays in NRF_MODEM_GNSS_EVT_BLOCKED state and never gets UNBLOCKED. But when I have LTE and GPS only (no MQTT) it gets UNBLOCKED in a few seconds. I can only think that the MQTT is keeping the LTE connection open or busy such that LTE never goes into PSM.

When setting up the modem, I believe I am setting PSM with the following commands, and dont get any errors:
```
lte_lc_init();
lte_lc_psm_req(true);
lte_lc_edrx_req(true);
lte_lc_connect();
```

Output of CPSMS, indicates to me it is in PSM.
```
AT+CPSMS? : +CPSMS: 1,,,"00000011","00100001"
```

After the LTE is connected/setup, I call the following sequence without error (error checking is in the code, removed from the post)

nrf_modem_gnss_init();
nrf_modem_gnss_event_handler_set(gnss_event_handler)
nrf_modem_gnss_nmea_mask_set(NRF_MODEM_GNSS_NMEA_RMC_MASK |
    NRF_MODEM_GNSS_NMEA_GGA_MASK |
    NRF_MODEM_GNSS_NMEA_GLL_MASK |
    NRF_MODEM_GNSS_NMEA_GSA_MASK |
    NRF_MODEM_GNSS_NMEA_GSV_MASK)
    nrf_modem_gnss_fix_retry_set(0)
    nrf_modem_gnss_fix_interval_set(1)
    nrf_modem_gnss_start()

For testing purposes, If I have a while (1) {}, after the above,  it will connect to LTE and GPS and all works fine.

But the goal of the project is to send GPS and ANT+ data to an MQTT broker, so after the LTE + GPS setup above, I have;


mqtt_client_init( client );
… set up the broker details - as per mqtt_simple example …
mqtt_connect( &client );

MQTT connects and I can send a sample string to the broker, so I know that is all working - connectivity etc…

But, if I have MQTT connected, it never connects to GPS, its GPS stays in a BLOCKED state

I have an external modem connected and its outside. I know there is no issues with the physical setup, because as soon as I dont connect to the broker it all works fine.

Q: Do I need to set the modem differently ?

Q: Do I need to disconnect from MQTT for GPS to work and then reconnect when I want to send any data ?

Q: Am I missing a setting on the MQTT setup/config so it allows the LTE go into PSM mode ?

regards

-brett

  • Hi Brett,

     

    Brett said:
    I have most of this working now, or well enough.  The transition times between BlOCKED, UNBLOCKED and transfer are manageable for this testing.

    I'm glad to hear of this progress!

    Brett said:
    However, after about 200->300 seconds it varies, I stop getting any GNSS events. I know, the system is still running as I have a poll on 5seconds and it keeps counting up.

    The unit is not moving whilst I am testing, but is there any reason it would go to sleep after X period ?

    Could this be because of the mqtt keep-alive going active? This is a "ping" to the server to maintain the mqtt connection, which happens every "CONFIG_MQTT_KEEPALIVE".

    Depending on the network you're connected to, and its overall routing/firewall rules etc, this can be in the range of 1 minute to tens of minutes. Each network has its own individual limitations on this.

     

    Kind regards,

    Håkon

  • Hi Håkon

    Could this be because of the mqtt keep-alive going active? This is a "ping" to the server to maintain the mqtt connection, which happens every "CONFIG_MQTT_KEEPALIVE".

    The CONFIG_MQTT_KEEPALIVE is set to 1200, so its a bit different.  The more confusing part is that there are no GNSS events at all.  Usually when its in a BLOCKED state, I still get some events come in - even if its not a FIX.

    I have another issue in this project where the mqtt_publish is blocking (it hits the mutex_lock and never comes out), it looks the same as caseID 232209, which you also worked on.  Am I best to open a new case to keep the topic of this case consistent, or is it ok to ask that question in here, since it still kind of related ?

    regards
    -brett

  • Hi Brett,

     

    Brett said:
    The CONFIG_MQTT_KEEPALIVE is set to 1200, so its a bit different.  The more confusing part is that there are no GNSS events at all.  Usually when its in a BLOCKED state, I still get some events come in - even if its not a FIX.

    Do you have any asynchronous threads / interrupts that trigger a send() from the application? That will cause the modem to immediately start sending, thus blocking the GNSS from running until you're in idle again.

    Do you print the CSCON notification? If so, you should see that the link becomes active if this is the case.

    Brett said:
    I have another issue in this project where the mqtt_publish is blocking (it hits the mutex_lock and never comes out), it looks the same as caseID 232209, which you also worked on.  Am I best to open a new case to keep the topic of this case consistent, or is it ok to ask that question in here, since it still kind of related ?

    If this is related to the above scenario, the modem might be trying to send data (if the link quality is bad for instance).

    If this is an issue that you are able to reproduce, I would recommend that you open a new case, and attach a application log output + a modem trace showing the issue.

     

    Kind regards,

    Håkon

Related