SNTP on a different port lwip Compilation Error

thethinker
Posts: 57
Joined: Thu Mar 01, 2018 1:26 am

SNTP on a different port lwip Compilation Error

Postby thethinker » Wed Mar 07, 2018 1:28 am

My SNTP server is on a different port than port 123, and I'm trying to use the SNTP client app to connect to that port,also I might want the software to be able to change the port. In the original ESP-IDF SNTP code, there does not seem to be a function to change the port, in fact the port is getting pre-combiled. For this reason I have decided to actually copy the sntp source and include it as a component in my project and then modify it to my needs. How ever after copying the code as component which follows the following directory structure:
Component
------sntp
---------include
---------------sntp.h
---------------sntp_opts.h
---------component.mk (empty file)
---------sntp.c

I get the following results:

Code: Select all

CXX build/main/utils.o
CXX build/main/main.o
AR build/main/libmain.a
CC build/sntp/sntp.o
In file included from /home/xxxx/ESP32/esp-idf/components/lwip/include/lwip/lwip/arch.h:43:0,
                 from /home/xxxx/ESP32/esp-idf/components/lwip/include/lwip/lwip/debug.h:35,
                 from /home/xxxx/ESP32/esp-idf/components/lwip/include/lwip/lwip/opt.h:46,
                 from /home/xxxx/ESP32/esp-idf/components/lwip/include/lwip/apps/sntp/sntp_opts.h:35,
                 from /home/xxxx/ESP32/esp-idf/components/lwip/include/lwip/apps/sntp/sntp.h:35,
                 from /prj_folder/ESP32/prj_name/components/sntp/./sntp.c:48:
/prj_folder/ESP32/prj_name/components/sntp/./sntp.c: In function 'sntp_request':
/home/xxxx/ESP32/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:157:38: error: the comparison will always evaluate as 'false' for the address of 'sntp_server_address' will never be NULL [-Werror=address]
 #define ipaddr_ntoa(addr)   (((addr) == NULL) ? "NULL" : \
                                      ^
/home/xxxx/ESP32/esp-idf/components/lwip/include/lwip/port/arch/cc.h:71:44: note: in definition of macro 'LWIP_PLATFORM_DIAG'
 #define LWIP_PLATFORM_DIAG(x)   do {printf x;} while(0)
                                            ^
/prj_folder/ESP32/prj_name/components/sntp/./sntp.c:516:5: note: in expansion of macro 'LWIP_DEBUGF'
     LWIP_DEBUGF(SNTP_DEBUG_TRACE, ("sntp_request: current server address is %s\n",
     ^
/prj_folder/ESP32/prj_name/components/sntp/./sntp.c:517:7: note: in expansion of macro 'ipaddr_ntoa'
       ipaddr_ntoa(&sntp_server_address)));
       ^
/home/xxxx/ESP32/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:71:50: error: the comparison will always evaluate as 'true' for the address of 'sntp_server_address' will never be NULL [-Werror=address]
 #define IP_IS_V6(ipaddr)              (((ipaddr) != NULL) && IP_IS_V6_VAL(*(ipaddr)))
                                                  ^
/home/xxxx/ESP32/esp-idf/components/lwip/include/lwip/lwip/debug.h:105:34: note: in expansion of macro 'LWIP_PLATFORM_DIAG'
                                  LWIP_PLATFORM_DIAG(message); \
                                  ^
/prj_folder/ESP32/prj_name/components/sntp/./sntp.c:516:5: note: in expansion of macro 'LWIP_DEBUGF'
     LWIP_DEBUGF(SNTP_DEBUG_TRACE, ("sntp_request: current server address is %s\n",
     ^
/home/xxxx/ESP32/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:158:5: note: in expansion of macro 'IP_IS_V6'
   ((IP_IS_V6(addr)) ? ip6addr_ntoa(ip_2_ip6(addr)) : ip4addr_ntoa(ip_2_ip4(addr))))
     ^
/prj_folder/ESP32/prj_name/components/sntp/./sntp.c:517:7: note: in expansion of macro 'ipaddr_ntoa'
       ipaddr_ntoa(&sntp_server_address)));
       ^
cc1: some warnings being treated as errors
/home/xxxx/ESP32/esp-idf/make/component_wrapper.mk:273: recipe for target 'sntp.o' failed
make[1]: *** [sntp.o] Error 1
/home/xxxx/ESP32/esp-idf/make/project.mk:450: recipe for target 'component-sntp-build' failed
make: *** [component-sntp-build] Error 2

I just copy pasted the orginal component and have not modified it yet, so it should compile, anybody have any idea why this is happening?

thethinker
Posts: 57
Joined: Thu Mar 01, 2018 1:26 am

Re: SNTP on a different port lwip Compilation Error

Postby thethinker » Thu Mar 08, 2018 1:22 am

Still struggling with this :cry: :|

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: SNTP on a different port lwip Compilation Error

Postby loboris » Thu Mar 08, 2018 9:39 am

I think you have to copy the whole directory structure from esp-idf/components directory (in your case lwip) to the project's components directory.

thethinker
Posts: 57
Joined: Thu Mar 01, 2018 1:26 am

Re: SNTP on a different port lwip Compilation Error

Postby thethinker » Thu Mar 08, 2018 11:47 pm

Hi,
Thank you for replying. I believe that is not true, if I copy all the components, then instead of using the libraries from ESP-IDF It will use my project folder to compile all the libraries. That defeats the purpose of having this whole advanced build system. I want all the other libraries to update every time I update the ESP-IDF.


thethinker
Posts: 57
Joined: Thu Mar 01, 2018 1:26 am

Re: SNTP on a different port lwip Compilation Error

Postby thethinker » Fri Mar 09, 2018 12:36 am

wiFive!

Thank you verymuch!
I knew it must have been one of these flags! I just missed the :
"CFLAGS += -Wno-address # lots of LWIP source files evaluate macros that check address of stack variables"

Who is online

Users browsing this forum: radurotaru19 and 128 guests