This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF9160 date-time example

Hey,

I have isnstalled ncs v1.3.1 and the toolchain specified in the instructions ofr 1.3.1.


I am trying to utlise the date-time library in the https_client example. 

I ahve included the header in the main and after the network connection is established I call:

s64_t date_time_stamp;
k_sleep(K_MSEC(25000)); //Wait some time to make sure the Date-Time update has happened
date_time_now(&date_time_stamp); 
printk("Date time: %016llX\n", date_time_stamp);


In the prj.conf file I have added:

CONFIG_DATE_TIME=y
CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=10


When I try to build I am getting:
[0/147] Performing build step for 'spm_subimage'
ninja: no work to do.
[114/145] Building C object modules/nrf/lib/date_time/CMakeFiles/..__nrf__lib__date_time.dir/date_time.c.obj
FAILED: modules/nrf/lib/date_time/CMakeFiles/..__nrf__lib__date_time.dir/date_time.c.obj 
ccache /home/firstName/gnuarmemb/bin/arm-none-eabi-gcc -DBUILD_VERSION=v2.3.0-rc1-ncs2 -DEXT_API_MAGIC=0x281ee6de,0xb845acea,23298 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,23298 -DKERNEL -DNRF9160_XXAA -DNRF_TRUSTZONE_NONSECURE -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/firstName/ncs/zephyr/include -Izephyr/include/generated -I/home/firstName/ncs/zephyr/soc/arm/nordic_nrf/nrf91 -I/home/firstName/ncs/zephyr/subsys/net/lib/sockets/. -I../../../include -I../../../lib/at_notif/. -I../../../lib/at_cmd_parser/include -I/home/firstName/ncs/nrfxlib/bsdlib/include -I/home/firstName/ncs/modules/hal/cmsis/CMSIS/Core/Include -I/home/firstName/ncs/modules/hal/nordic/nrfx -I/home/firstName/ncs/modules/hal/nordic/nrfx/drivers/include -I/home/firstName/ncs/modules/hal/nordic/nrfx/mdk -I/home/firstName/ncs/modules/hal/nordic/. -isystem /home/firstName/ncs/zephyr/lib/libc/minimal/include -isystem /home/firstName/gnuarmemb/bin/../lib/gcc/arm-none-eabi/9.3.1/include -isystem /home/firstName/gnuarmemb/bin/../lib/gcc/arm-none-eabi/9.3.1/include-fixed -Os -imacros/home/firstName/ncs/nrf/applications/date/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfpu=fpv5-sp-d16 -mfloat-abi=hard -imacros/home/firstName/ncs/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-address-of-packed-member -Wno-pointer-sign -Wpointer-arith -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/home/firstName/ncs/nrf/applications/date=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/firstName/ncs/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/firstName/ncs=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT modules/nrf/lib/date_time/CMakeFiles/..__nrf__lib__date_time.dir/date_time.c.obj -MF modules/nrf/lib/date_time/CMakeFiles/..__nrf__lib__date_time.dir/date_time.c.obj.d -o modules/nrf/lib/date_time/CMakeFiles/..__nrf__lib__date_time.dir/date_time.c.obj   -c /home/firstName/ncs/nrf/lib/date_time/date_time.c
In file included from /home/firstName/ncs/zephyr/include/kernel_includes.h:41,
                 from /home/firstName/ncs/zephyr/include/kernel.h:17,
                 from /home/firstName/ncs/zephyr/include/zephyr.h:18,
                 from /home/firstName/ncs/nrf/lib/date_time/date_time.c:8:
/home/firstName/ncs/nrf/lib/date_time/date_time.c: In function 'time_NTP_server_get':
/home/firstName/ncs/zephyr/include/sys_clock.h:85:28: error: incompatible type for argument 2 of 'sntp_time_request'
   85 | #define Z_TIMEOUT_TICKS(t) ((k_timeout_t) { .ticks = (t) })
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                            |
      |                            k_timeout_t {aka struct <anonymous>}
/home/firstName/ncs/zephyr/include/sys_clock.h:87:25: note: in expansion of macro 'Z_TIMEOUT_TICKS'
   87 | #define Z_TIMEOUT_MS(t) Z_TIMEOUT_TICKS(k_ms_to_ticks_ceil32(MAX(t, 0)))
      |                         ^~~~~~~~~~~~~~~
/home/firstName/ncs/zephyr/include/kernel.h:1585:24: note: in expansion of macro 'Z_TIMEOUT_MS'
 1585 | #define K_MSEC(ms)     Z_TIMEOUT_MS(ms)
      |                        ^~~~~~~~~~~~
/home/firstName/ncs/zephyr/include/kernel.h:1597:24: note: in expansion of macro 'K_MSEC'
 1597 | #define K_SECONDS(s)   K_MSEC((s) * MSEC_PER_SEC)
      |                        ^~~~~~
/home/firstName/ncs/nrf/lib/date_time/date_time.c:166:4: note: in expansion of macro 'K_SECONDS'
  166 |    K_SECONDS(CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS),
      |    ^~~~~~~~~
/home/firstName/ncs/nrf/lib/date_time/date_time.c:121:64: note: expected 'u32_t' {aka 'unsigned int'} but argument is of type 'k_timeout_t' {aka 'struct <anonymous>'}
  121 | static int sntp_time_request(struct ntp_servers *server, u32_t timeout,
      |                                                          ~~~~~~^~~~~~~
[119/145] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mem_slab.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/firstName/ncs/nrf/applications/date/build


Is there something I have missed?

Or is there an example available somewhere to get this working?

Related