cancel
Showing results for 
Search instead for 
Did you mean: 

NTP using STM32CubeExpansion_Cloud_AWS_H5_V1.0.0 example

ffjunq
Associate III

Hello, I hope you are well.

I'm working with a project, where the base code is the example "STM32CubeExpansion_Cloud_AWS_H5_V1.0.0", I need the current time somehow. So I thought about SNTP, however, I don't have much knowledge on the subject, I would like to know if there is any simple way to get the time using the connections that the example makes with AWS.

Can anyone help me? Thanks in advance!

3 REPLIES 3
grd
ST Employee

Hi @ffjunq,

the LwIP middleware library integrated in this package provides an SNTP client example.

Alternatively, you may find more convenient to simply parse the unix timestamp passed by AWS IoT Core in some message metadata (see for instance the device shadow service: https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html).

Cheers

 

 

ffjunq
Associate III

Thank you for your support @grd

I really need it to be SNTP. However, I am facing difficulties, I am not familiar with the LwIP stack.

I tried some ways, for example: https://community.st.com/t5/stm32cubeide-mcus/lwip-sntp-what-does-it-actually-do/td-p/319642/page/2, where it was cited by @Piranha: https://stackoverflow.com/questions/61932743/how-does-the-sntp-app-of-the-lwip-component-set-the-time-it-receives. When I run this example the code crashes. I don't know how to continue, can you help me?

ffjunq
Associate III

Here are some changes I made to the code in an attempt to implement SNTP:

File sntp.c:

ffjunq_0-1715083886091.png

File init.c

ffjunq_1-1715083934521.png

File sntp_opts.h

ffjunq_2-1715083998862.png

ffjunq_3-1715084026120.png

File lwipopts_freertos.h

ffjunq_4-1715084092015.png

When running the code, I see the following log:

ffjunq_5-1715099105408.png

I noticed that when I debug the code, I get stuck on the following:

ffjunq_6-1715099172220.png

It's possible that this issue is related to this struct, however, I'm still investigating.

ffjunq_7-1715100374258.png