I have my main project (wifi station). it works and compiles, it connects to wifi no problem.
So now i'm writing more code, and to have good order i cretead a functions.c and functions.h files, in a subfolder.
The problem is that if i just write the prototype in the .h and definitions of functions in .c, it won't find the function. If i write the definition of function directly on .h it works.
esp_zbo_functions.c
Code: Select all
#include "esp_zbo_functions.h"
#include "esp_log.h"
bool test = false;
void open_tcp_connection(void){
if(!test){
ESP_LOGI(DEBUG, "test");
test = true;
}
}
Code: Select all
#ifndef ESP_ZBO_FUNCTIONS_H
#define ESP_ZBO_FUBCTIONS_H
static const char *DEBUG = "DEBUG";
void open_tcp_connection(void);
#endif /* ESP_ZBO_FUBCTIONS_H */
Code: Select all
void app_main(void)
{
//Initialize NVS
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
ESP_LOGI(DEBUG, "pre wifi_init_sta");
ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");
wifi_init_sta();
ESP_LOGI(DEBUG, "pass wifi_init_sta");
while(true){
if(wifi_connected == true){
open_tcp_connection();
}
}
}
Generated C:/Users/Nico/Desktop/Proyectos/Cargadores_OCPP/esp32/esp_zbo/build/bootloader/bootloader.bin
[101/101] cmd.exe /C "cd /D C:\Users\Nico\Desktop\Proyectos\Cargadores_OCPP\esp32\esp_zbo\build\bootloader\esp-idf\esptool_py && C:\Users\Nico\.espressif\python_env\idf5.0_py3.8_env\Scripts\python.exe C:/Users/Nico/esp/esp-idf/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 C:/Users/Nico/Desktop/Proyectos/Cargadores_OCPP/esp32/esp_zbo/build/bootloader/bootloader.bin"
Bootloader binary size 0x6700 bytes. 0x900 bytes (8%) free.
[841/843] Linking CXX executable esp_zbo.elf
FAILED: esp_zbo.elf
cmd.exe /C "cd . && C:\Users\Nico\.espressif\tools\xtensa-esp32-elf\esp-2022r1-11.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -mlongcalls -Wno-frame-address @CMakeFiles\esp_zbo.elf.rsp -o esp_zbo.elf && cd ."
c:/users/nico/.espressif/tools/xtensa-esp32-elf/esp-2022r1-11.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(esp_zbo_main.c.obj):(.literal.app_main+0x24): undefined reference to `open_tcp_connection'
c:/users/nico/.espressif/tools/xtensa-esp32-elf/esp-2022r1-11.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(esp_zbo_main.c.obj): in function `app_main':
C:/Users/Nico/Desktop/Proyectos/Cargadores_OCPP/esp32/esp_zbo/main/esp_zbo_main.c:165: undefined reference to `open_tcp_connection'
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.