nRF5 SDK is not maintained anymore
More Info: Consider nRF Connect SDK for new designs

nRF9160 nrf_socket() hangs indefinitely

Hello!

I'm working with nRF9160 on a custom board and I'm trying to use SUPL to improve time to first fix, I'm following the sample nrf9160/gnss/src/assistance_supl.c. I'm at a point where the gnss event handler receives NRF_MODEM_GNSS_EVT_AGPS_REQ event in which I call nrf_socket(NRF_AF_UNSPEC, NRF_SOCK_STREAM, NRF_IPPROTO_TCP). However, this returns 22 (EINVAL) which means invalid argument. I tried using nrf_socket(NRF_AF_INET, NRF_SOCK_STREAM, NRF_IPPROTO_TCP) too, but this will hang indefinitely. Any help would be highly appreciated!

Operating System: Ubuntu 20.04.4 LTS

West version: v0.12.0

Zephyr OS build v2.7.99-ncs1-2223-g240c7b9a691f

Modem HW: nRF9160 SICA B0A

Modem SW: nrf9160_1.3.1

  • Hi,

     

    You should not mix nrf_ prefixed socket operations with the non-prefixed socket operations.

    Could you try running the sample as-is with agps / supl (supl.google.com) enabled?

     

    Kind regards,

    Håkon

  • I was a little unclear, sorry about that. I'm not flashing the sample to our custom board but I'm using it as an example how I could use SUPL to improve TTFF. We have previously used nrf_socket() elsewhere so I assumed it would best to use that for the sake of consistency.

    I'll try the unmodified sample on my DK next Monday but I doubt I'll run into any issues.

    How can I debug what happens in nrf_socket()?

  • Hi,

     

    kvo1 said:
    How can I debug what happens in nrf_socket()?

    If you're stuck inside nrf_socket(), that is code inside libmodem (static library), so it is not directly debug-able, but you should be able to see where you're stuck by entering debug mode and checking the stack trace / cpu registers.

    Zephyr OS build v2.7.99-ncs1-2223-g240c7b9a691f

    This indicates that you're on main branch at this moment, it this intentional? Any specific reason why you're not using a tagged version of ncs?

     

    Kind regards,

    Håkon

  • This indicates that you're on main branch at this moment, it this intentional? Any specific reason why you're not using a tagged version of ncs?

    Good question. I switched to V2.0.0.


    I tried to cut too many corners which resulted in this behavior. Seems like nrf_connect has to be handled outside of main thread and I added a work queue like in the sample. Everything seems to work perfectly now!

    Thank you for your time!

Related