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

  • Hello,

    Do you have "debug options" enabled in the board configuration settings?

    Will have a look at your issue but will not have an answer before Monday. 

    Kind regards,
    Øyvind

  • Hi,

    Thanks for your reply. Debug Options are disabled in board configuration.

    Kind Regards,
    Iman

  • My apologies for the late reply. Will get back to you today. 

    Kind regards,
    Øyvind

  • Could you provide more information on how you have integrated the SUPL library to the Asset Tracker v2? 

  • 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

Related