Build error when using date_time.h lib

Hi,

I want to use a timestamp in my payload when ever I send data to the cloud.

First I wanted to use the ntp example from HÃ¥kon found here: https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160/ntp

But as suggested in another thread here in devzone I went with the date_time lib: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/include/date_time.html

In prj.conf I added:

CONFIG_DATE_TIME=y
CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=10

In kconfig I added:

config DATE_TIME_UPDATE_INTERVAL_SECONDS
    int "Date time update interval, in seconds"
    default 3600
	
menuconfig DATE_TIME
    bool "Date time library"
    select AT_CMD
    select SNTP
    depends on BSD_LIBRARY

In main.c I added:

//on top
#include <date_time.h>

//in main() after I etablished my lte connection:
date_time_update();

This is my build error:

What am I missing?

Also, the date_time lib is missing if using the toolchain manager to download and install the ncs version 1.3.0.

Now I'm using master branch.

Best,

Tim

Parents
  • Hi Tim

    First: You do not need to make your own Kconfig with DATE_TIME. This is already done in "ncs/nrf/lib/date_time/Kconfig".

    I added "date_time" to the zephyr basic blinky sample. SES found date_time.h when I ran it. However it did get the same "sntp_time_request" error as you got in master when I tried to build the code.

    prj.conf first try:

    CONFIG_GPIO=y
    CONFIG_NETWORKING=y
    CONFIG_BSD_LIBRARY=y
    CONFIG_DATE_TIME=y
    CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=10

    Then I did some digging, and it is strange that date_time do complain about K_SECONDS(...) not being u32_t.
    Anyway, I found k_timeout_t defined in sys_clock.h. Here I also found the option "CONFIG_LEGACY_TIMEOUT_API", so I tried that. I also had to add a couple of other configs to make it work.

    Some of the configs might not be necessary, but here is the full prj.conf I was able to successfully build with:

    CONFIG_GPIO=y
    CONFIG_NETWORKING=y
    CONFIG_BSD_LIBRARY=y
    CONFIG_DATE_TIME=y
    CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=10
    
    CONFIG_LEGACY_TIMEOUT_API=y
    CONFIG_HEAP_MEM_POOL_SIZE=1024
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NET_SOCKETS=y

    Be careful though, using the legacy timeout api might have downsides.

    Regards, 

    Hellesvik

Reply Children
No Data
Related