Arduino as an ESP-IDF component in esp_ble_mesh onoff_server demo

judeepf
Posts: 2
Joined: Wed Jul 26, 2023 11:58 pm

Arduino as an ESP-IDF component in esp_ble_mesh onoff_server demo

Postby judeepf » Fri Jul 28, 2023 2:49 am

Hi all,

I'm a novice in ESP-IDF and I need help with the project I'm working on. I'm trying to use the esp_ble_mesh onoff_server demo and import Arduino libraries as an ESP-IDF component. I am using VSCode and ESP-IDF v4.4 while following this reference: https://espressif-docs.readthedocs-host ... onent.html.

I have tested the onoff_server example (https://github.com/espressif/esp-idf/tr ... off_server) separately and it works. I have imported two Adafruit sensor libraries in the project and successfully called the functions to read the sensor values.

I tried converting the onoff_server project into a library and added it is an esp-idf component, which compiles and builds successfully even after adding #include "on_off_server.h" in the main.cpp. However, when I try to call the functions from this on_off_server component, I receive the following error when building the project.
* Executing task: ninja

[1/6] Performing build step for 'bootloader'
[1/1] cmd.exe /C "cd /D C:\esp44\projects\onoff_server\build\bootloader\esp-idf\esptool_py && c:\esp44\python_env\idf4.4_py3.11_env\Scripts\python.exe C:/esp44/esp-idf/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 C:/esp44/projects/onoff_server/build/bootloader/bootloader.bin"
Bootloader binary size 0x63f0 bytes. 0xc10 bytes (11%) free.
[2/4] Linking CXX executable onoff_server.elf
FAILED: onoff_server.elf
cmd.exe /C "cd . && C:\esp44\tools\xtensa-esp32-elf\esp-2021r2-patch5-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -mlongcalls -Wno-frame-address @CMakeFiles\onoff_server.elf.rsp -o onoff_server.elf && cd ."
c:/esp44/tools/xtensa-esp32-elf/esp-2021r2-patch5-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(main.cpp.obj):(.literal._Z5setupv+0x10): undefined reference to `ble_start()'
c:/esp44/tools/xtensa-esp32-elf/esp-2021r2-patch5-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(main.cpp.obj): in function `setup()':
C:/esp44/projects/onoff_server/main/main.cpp:28: undefined reference to `ble_start()'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

* The terminal process "C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command ninja " terminated with exit code: 1.

I have modified the CMakeLists.txt of the component and main as below, but still results to the above error.

on_off_server Component:

Code: Select all

idf_component_register(SRCS "on_off_server.c" "board.c" 
                    INCLUDE_DIRS "."
                    REQUIRES nvs_flash esp_ble_mesh_defs ble_mesh_example_init)
Main:

Code: Select all

idf_component_register(SRCS "main.cpp"
                    INCLUDE_DIRS "."
                    REQUIRES arduino on_off_server hp_BH1750 Adafruit_LIS3DH ble_mesh_example_init)
Could anyone please help me out? Thank you so much!

Cheers,
Jude

judeepf
Posts: 2
Joined: Wed Jul 26, 2023 11:58 pm

Re: Arduino as an ESP-IDF component in esp_ble_mesh onoff_server demo

Postby judeepf » Mon Jul 31, 2023 7:27 am

RESOLVED: I just added an extern "C" linkage in my function.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 87 guests