Asset Tracker v2 SUPL Integration

Hi,

This might sound like a silly question, but is there a way to use SUPL library with Asset Tracker v2 with LwM2M integration without having to trade off logging? SUPL library is quite massive and linking against it requires AT client library and logging to be disabled. Even trying to enable LOG_MINIMAL seems not to be sufficient:

.
.
.
[30/30] Linking C executable zephyr\zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       40410 B        48 KB     82.21%
             RAM:       28024 B     211736 B     13.24%
        IDT_LIST:          0 GB         2 KB      0.00%
[425/447] Linking C executable zephyr\zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
cmd.exe /C "cd . && C:\ncs\toolchains\v2.2.0\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe  -gdwarf-4 @CMakeFiles\zephyr_pre0.rsp -o zephyr\zephyr_pre0.elf  && cmd.exe /C "cd /D C:\ncs\v2.2.0\nrf\applications\asset_tracker_v2\build\zephyr && C:\ncs\toolchains\v2.2.0\opt\bin\cmake.exe -E echo ""
c:/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: zephyr\zephyr_pre0.elf section `rodata' will not fit in region `FLASH'
c:/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: region `FLASH' overflowed by 35440 bytes
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'c:\ncs\toolchains\v2.2.0\opt\bin\cmake.EXE' --build 'c:\ncs\v2.2.0\nrf\applications\asset_tracker_v2\build'

Kind Regards,
Iman

Parents Reply Children
  • Hi,

    Sure.

    I am using LwM2M, so, in overyal-lwm2m.conf:

    CONFIG_SUPL_CLIENT_LIB=y

    I have also copied (and slightly modified) assistance.h and assistance_supl.c from 9160 GNSS sample.

    Changes to Asset Tracker v2 code:

    In main.c:

    .
    .
    .
        self.thread_id = k_current_get();

    #if defined(CONFIG_SUPL_CLIENT_LIB)
        assistance_init();
    #endif

        err = module_start(&self);
        if (err) {
            LOG_ERR("Failed starting module, error: %d", err);
            SEND_ERROR(app, APP_EVT_ERROR, err);
        }
    .
    .
    .

    In lwmem_codec.c:

    .
    .
    .
    int cloud_codec_encode_agps_request(struct cloud_codec_data *output,
                        struct cloud_data_agps_request *agps_request)
    {
    #if defined(CONFIG_SUPL_CLIENT_LIB)
           /* SUPL doesn't usually provide satellite real time integrity information. If GNSS asks
            * only for satellite integrity, the request should be ignored.
            */
           if (agps_request->request.sv_mask_ephe == 0 &&
               agps_request->request.sv_mask_alm == 0 &&
               agps_request->request.data_flags == NRF_MODEM_GNSS_AGPS_INTEGRITY_REQUEST) {
                   LOG_INF(" Ignoring assistance request for only satellite integrity\r\n");
           } else {
                   LOG_INF(" Assistance data needed, ephe 0x%08x, alm 0x%08x, flags 0x%02x\r\n",
                           agps_request->request.sv_mask_ephe,
                           agps_request->request.sv_mask_alm,
                           agps_request->request.data_flags);
                   assistance_request(&agps_request->request);
           }
           return -ENODATA;
    #else
        ARG_UNUSED(output);

        int err;

        err = location_assistance_agps_set_mask(&agps_request->request);
        if (err) {
            LOG_ERR("location_assistance_agps_set_mask, error: %d", err);
            return err;
        }

        /* Disable filtered A-GPS. */
        location_assist_agps_set_elevation_mask(-1);

        err = lwm2m_engine_set_u32(LWM2M_PATH(LWM2M_OBJECT_CONNECTIVITY_MONITORING_ID, 0,
                              CELLID),
                       agps_request->cell);
        if (err) {
            return err;
        }

        err = lwm2m_engine_set_u16(LWM2M_PATH(LWM2M_OBJECT_CONNECTIVITY_MONITORING_ID, 0,
                              SMNC),
                       agps_request->mnc);
        if (err) {
            return err;
        }

        err = lwm2m_engine_set_u16(LWM2M_PATH(LWM2M_OBJECT_CONNECTIVITY_MONITORING_ID, 0,
                              SMCC),
                       agps_request->mcc);
        if (err) {
            return err;
        }

        err = lwm2m_engine_set_u16(LWM2M_PATH(LWM2M_OBJECT_CONNECTIVITY_MONITORING_ID, 0,
                              LAC),
                       agps_request->area);
        if (err) {
            return err;
        }

        agps_request->queued = false;
        return 0;
    #endif
    }
    .
    .
    .

    In src/cloud/CMakeLists.txt:

    target_sources_ifdef(CONFIG_SUPL_CLIENT_LIB app
                         PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/lwm2m_integration/assistance_supl.c)                    

    The only change I made to assistance_supl.c was to hard-code SUPL_SERVER and SUPL_SERVER_PORT:


    #define SUPL_SERVER        "supl.google.com"
    #define SUPL_SERVER_PORT   7276

    //BUILD_ASSERT(sizeof(CONFIG_GNSS_SAMPLE_SUPL_HOSTNAME) > 1, "Server hostname must be configured");

    Hope this helps.

    Kind Regards,
    Iman

  • Iman, thank you for providing this information. Would if be possible to share your project instead?

    Have you considered using nRF Cloud AGPS instead?

    Do you have P-GPS enabled as well? This requires a good amount of flash.

    Kind regards,
    Øyvind

  • Hi,

    Thanks for your reply.

    I am not using P-GPS.

    I thought about using nRF Cloud AGPS, but I'd rather use LwM2M location assistance mechanism if I could implement it in my LwM2M server (which is basically a Leshan server object). This would get rid of the massive SUPL library altogether.

    Do you have any documentations (or better yet, a working sample) regarding how to respond to a LwM2M location assistant request?

    Also, project folder here. asset_tracker_v2.7z

    I have created a few logger macros to replace LOG_XXX so that I could have some sort of logging while using SUPL. You can perform a Find/Replace to revert back to normal logging.

    Kind Regards,
    Iman

  • Hi Iman, 


    ibiglari said:
    Do you have any documentations (or better yet, a working sample) regarding how to respond to a LwM2M location assistant request?

    Yes, our nRF Cloud documentation shows how to communicate with the nRF Cloud Location services: https://docs.nrfcloud.com/LocationServices/LocationServicesOverview/

    Have a look at the LwM2M location services which uses AVsystems.

    Kind regards,

    Øyvind

  • Hi,

    Had a quick look. While it sounds promising, I'm afraid the costs are a setback. Specially since it seems that REST API does not have the same number of free calls per month as MQTT Disappointed

    I might end up implementing SUPL support on my server side instead of the client if SUPL library cannot be somehow shrunk. I opened another ticket for that, but not sure if that is going to be feasible.

    In the meantime, were you able to reproduce the issue with the code I attached?

    Kind Regards,
    Iman

Related