Originally published at: https://blog.golioth.io/adding-golioth-example-code-to-your-esp-idf-project/
In our previous blog post, we demonstrated how to add the Golioth Firmware SDK to an ESP-IDF project. As you start integrating Golioth into your projects, you’ll likely want to build upon the examples we’ve provided and reuse the same utility functions from the common code. The common code is a great starting point to help you quickly evaluate Golioth, but it’s important to keep its intended use in mind. It’s designed for demonstration and prototyping, not for production. The API is subject to change without notice, so relying on it long-term could introduce breaking changes. Additionally, certain features, like WiFi management, are kept simple for ease of use but may not cover all edge cases, such as handling multiple connection retries. When you’re ready to move toward production, plan to replace the common code with a more robust and tailored implementation. Building on the Previous Blog Post In the last blog post, we started with the Wi-Fi station example, added the Firmware SDK, and sent some logs to the cloud. Now, we’ll take it a step further by integrating Firmware SDK common code into your application. The first step is to make your project aware of the ESP-IDF common code included in the Firmware SDK. To include it in your project, update your main/CMakeLists.txt file with the following: set(esp_idf_common “…/submodules/golioth-firmware-sdk/examples/esp_idf/common”) This line defines a macro named esp_idf_common, which simplifies referencing the location of the common code in your build system. Next, we need to include the directories where the header files for the common code reside. Add the following to main/CMakeLists.txt: set(includes “${esp_idf_common}” ) Here, ${esp_idf_common} points to the folder containing the header files, where the function declarations…