min-protocol / min

The MIN protocol specification and reference implementation
257 stars 88 forks source link

How to include in C++ project? #43

Closed hongquan closed 1 year ago

hongquan commented 1 year ago

I'm trying to integrate MIN to my project, which targets ESP32, based on Arduino framework and developped in PlatformIO.

I tried to implement the min_application_handler callback in my _pccomm.cpp file, (the feature/include-min branch), but got linking error:

$ pio run

Linking .pio/build/esp-wrover-kit/firmware.elf
/home/quan/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp-wrover-kit/libb33/libmin-proto.a(min.c.o):(.literal.min_poll+0x0): undefined reference to `min_application_handler'
/home/quan/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp-wrover-kit/libb33/libmin-proto.a(min.c.o): in function `valid_frame_received':
/home/quan/Works/AgriConnect/Embedded/ebee-esp32/lib/min-proto/min.c:431: undefined reference to `min_application_handler'
collect2: error: ld returned 1 exit status
*** [.pio/build/esp-wrover-kit/firmware.elf] Error 1

Could you tell me what is the proper way to include, or how to fix it?

Note that, the main branch contains a working code, where I put


#include "min.c"

at the end of _pccomm.cpp, but I feel it is ugly. I try to include *.h file only.

hongquan commented 1 year ago

Fixed, it is due to missing const in function parameters.