Page 1 of 1

Building project with libnmea-esp32 component

Posted: Sat Jul 04, 2020 8:37 pm
by philipp
Hi!

I recently got my ESP32 and am working on my first project.
For that, I try to connect to a NEO 6M GPS module.

I found the NMEA library which was turned into an ESP32 component.

I had issues compiling the code, so I tried to just get the component to work first.

I created a new ESP-IDF project in Eclipse.
I overwrote the code in main.c with the code from the example.
I created a new folder "components" and git cloned the NMEA repo recursively in there.

This is what my project looks like within Eclipse:
Image

All other (example) projects that only make use of the IDF compile fine.

Issue:
When building the project, nmea.h can't be found.

Image

How can I fix this?
Any help is greatly appreciated.

Philipp

Re: Building project with libnmea-esp32 component

Posted: Sun Jul 05, 2020 9:03 am
by chegewara
First thing you should do is to move libnmea 1 folder up in tree, because you dont have CMakeLists.txt in libnmea-esp32. Then probably add to your CMakeLists.txt in main:

Code: Select all

REQUIRES libnmea
https://docs.espressif.com/projects/esp ... ystem.html

Re: Building project with libnmea-esp32 component

Posted: Mon Jul 06, 2020 5:52 pm
by philipp
Thanks a lot for your reply, chegewara!

The documentation link you provided is very helpful, I must've missed that part of the docu so far.

libnmea-esp is a wrapper for libnmea, so that it works as an ESP IDF component. But: It seems that this was written for the old version of the ESP IDF (v3), since it has no CMakeLists.txt, but a make file instead.

Instead of moving libnmea one folder up like you suggested, I'd rather add a CMakeLists.txt to libnmea-esp32 to keep the libnmea folder exactly the way it is from the repo. Otherwise, one would have to edit the CMakeLists.txt in libnmea-esp32 which isn't ideal.

Also, after reading the documentation, all folders within the components folder of the project are already included by default, so a require should not be necessary.
Therefore, I would like to write a CMakeLists.txt that has libnmea as a subfolder and serves as an ESP IDF component wrapper for it.
This is described here, but the example with mbedtls is very involved for a beginner like me.

The documentation briefly mentions this here.

Image

I looked at the mbedtls component, but it seems quite involved for somebody who is new to CMake and CMakeLists.txt files.

What I wanna do?
Build a wrapper around the libnmea library, so I can use it as component.

Folder structure:
Image

Code: Select all

- NMEA_Test/
             - CMakeLists.txt
             - sdkconfig
             - components/ - libnmea-esp32/ - CMakeLists.txt
                                            - libnmea
             - main/       - CMakeLists.txt
                           - main.c

             - build/
Where libnmea is the direct GitHub repo of the library cloned.
I would like to keep libnmea completely the same as in their github repo, so I just write the wrapper around it.

I am now struggling with writing the CMakeLists.txt within libnmea-esp32.
This is what I had tried, but it is obviously wrong (and doesn't work).

Code: Select all

idf_build_get_property(idf_target IDF_TARGET)
idf_build_get_property(python PYTHON)

idf_component_register(INCLUDE_DIRS "libnmea/src/nmea" "libnmea/src/parsers")

Any pointers?