Problem importing MQTT example to my code
Problem importing MQTT example to my code
I know the easy way is open an Mqtt example from ESP idf and use that but that's not always possible. What if later you want to use another example then you will have to somehow import the "right stuff" from one example into the other.
So this is my case. I have built a project around the https OTA advanced example and now I want to include the mqtt support (example code).
I have imported all the necessary functions and files (I had to copy paste the whole damn directory esp-idf\components\mqtt\esp-mqtt\include into my project to make "mqtt_client.h" work since it couldn't be found no matter what I did).
Now I get an error of not finding "CONFIG_BROKER_BIN_SIZE_TO_SEND" which is setup by the menuconfig (sdkconfig file) . The problem is that if I open menuconfig there is no mqtt setup anywhere so I can't set it up . My sdkconfig file is missing all this
#
# ESP-MQTT Configurations
#
CONFIG_MQTT_PROTOCOL_311=y
# CONFIG_MQTT_PROTOCOL_5 is not set
CONFIG_MQTT_TRANSPORT_SSL=y
CONFIG_MQTT_TRANSPORT_WEBSOCKET=y
CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y
# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set
# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set
# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set
# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set
# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set
# CONFIG_MQTT_CUSTOM_OUTBOX is not set
# end of ESP-MQTT Configurations
# Example Configuration
#
CONFIG_BROKER_URI="mqtts://276f887f0c9540c4b3d8a6be52700425.s2.eu.hivemq.cloud:8883"
CONFIG_BROKER_CERTIFICATE_OVERRIDE=""
CONFIG_BROKER_BIN_SIZE_TO_SEND=20000
# end of Example Configuration
Since I know sdkconfig can't be edited how do I activate those in menuconfig to be able to make my code work ?
Thanks in advance
So this is my case. I have built a project around the https OTA advanced example and now I want to include the mqtt support (example code).
I have imported all the necessary functions and files (I had to copy paste the whole damn directory esp-idf\components\mqtt\esp-mqtt\include into my project to make "mqtt_client.h" work since it couldn't be found no matter what I did).
Now I get an error of not finding "CONFIG_BROKER_BIN_SIZE_TO_SEND" which is setup by the menuconfig (sdkconfig file) . The problem is that if I open menuconfig there is no mqtt setup anywhere so I can't set it up . My sdkconfig file is missing all this
#
# ESP-MQTT Configurations
#
CONFIG_MQTT_PROTOCOL_311=y
# CONFIG_MQTT_PROTOCOL_5 is not set
CONFIG_MQTT_TRANSPORT_SSL=y
CONFIG_MQTT_TRANSPORT_WEBSOCKET=y
CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y
# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set
# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set
# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set
# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set
# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set
# CONFIG_MQTT_CUSTOM_OUTBOX is not set
# end of ESP-MQTT Configurations
# Example Configuration
#
CONFIG_BROKER_URI="mqtts://276f887f0c9540c4b3d8a6be52700425.s2.eu.hivemq.cloud:8883"
CONFIG_BROKER_CERTIFICATE_OVERRIDE=""
CONFIG_BROKER_BIN_SIZE_TO_SEND=20000
# end of Example Configuration
Since I know sdkconfig can't be edited how do I activate those in menuconfig to be able to make my code work ?
Thanks in advance
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Problem importing MQTT example to my code
Be found by ... what? If the build process cannot find the file, you probably need to REQUIRE the component via cmake. If only the IDE is confused, but the build succeeds, idf.py reconfigure and a reset of the IntelliSense database may do the trick.since it couldn't be found no matter what I did
CONFIG_BROKER_BIN_SIZE_TO_SEND is a setting of the MQTT example application itself. It's not used/needed for MQTT operation
outside of the example.
I recommend to generally first get a grasp of what parts of an example's code actually do or demonstrate, and to only then copy relevant pieces of example code into your application.
Re: Problem importing MQTT example to my code
The error I get is this
[1/10] Performing build step for 'bootloader'
[1/1] cmd.exe /C "cd /D F:\_Jim\Programming\ESP32_codes\SmartHome\SmartHome_OTA_MQTT_basic\build\bootloader\esp-idf\esptool_py && c:\Applications\Programming\ESP\tools\python_env\idf5.1_py3.11_env\Scripts\python.exe C:/Applications/Programming/ESP/esp-idf/components/partition_table/check_sizes.py --offset 0x9000 bootloader 0x1000 F:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/build/bootloader/bootloader.bin"
Bootloader binary size 0x6880 bytes. 0x1780 bytes (18%) free.
[2/8] Building C object esp-idf/mqtt/CMakeFiles/__idf_mqtt.dir/mqtt.c.obj
FAILED: esp-idf/mqtt/CMakeFiles/__idf_mqtt.dir/mqtt.c.obj
C:\Applications\Programming\ESP\tools\tools\xtensa-esp32-elf\esp-12.2.0_20230208\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe -DESP_PLATFORM -DIDF_VER=\"v5.1.1\" -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DSOC_MMU_PAGE_SIZE=CONFIG_MMU_PAGE_SIZE -D_GNU_SOURCE -D_POSIX_READER_WRITER_LOCKS -IF:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/build/config -IF:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/components/mqtt/include -IC:/Applications/Programming/ESP/esp-idf/components/newlib/platform_include -IC:/Applications/Programming/ESP/esp-idf/components/freertos/FreeRTOS-Kernel/include -IC:/Applications/Programming/ESP/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/include -IC:/Applications/Programming/ESP/esp-idf/components/freertos/esp_additions/include/freertos -IC:/Applications/Programming/ESP/esp-idf/components/freertos/esp_additions/include -IC:/Applications/Programming/ESP/esp-idf/components/freertos/esp_additions/arch/xtensa/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_hw_support/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_hw_support/include/soc -IC:/Applications/Programming/ESP/esp-idf/components/esp_hw_support/include/soc/esp32 -IC:/Applications/Programming/ESP/esp-idf/components/esp_hw_support/port/esp32/. -IC:/Applications/Programming/ESP/esp-idf/components/esp_hw_support/port/esp32/private_include -IC:/Applications/Programming/ESP/esp-idf/components/heap/include -IC:/Applications/Programming/ESP/esp-idf/components/log/include -IC:/Applications/Programming/ESP/esp-idf/components/soc/include -IC:/Applications/Programming/ESP/esp-idf/components/soc/esp32 -IC:/Applications/Programming/ESP/esp-idf/components/soc/esp32/include -IC:/Applications/Programming/ESP/esp-idf/components/hal/esp32/include -IC:/Applications/Programming/ESP/esp-idf/components/hal/include -IC:/Applications/Programming/ESP/esp-idf/components/hal/platform_port/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_rom/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_rom/include/esp32 -IC:/Applications/Programming/ESP/esp-idf/components/esp_rom/esp32 -IC:/Applications/Programming/ESP/esp-idf/components/esp_common/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_system/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_system/port/soc -IC:/Applications/Programming/ESP/esp-idf/components/esp_system/port/include/private -IC:/Applications/Programming/ESP/esp-idf/components/xtensa/include -IC:/Applications/Programming/ESP/esp-idf/components/xtensa/esp32/include -IC:/Applications/Programming/ESP/esp-idf/components/lwip/include -IC:/Applications/Programming/ESP/esp-idf/components/lwip/include/apps -IC:/Applications/Programming/ESP/esp-idf/components/lwip/include/apps/sntp -IC:/Applications/Programming/ESP/esp-idf/components/lwip/lwip/src/include -IC:/Applications/Programming/ESP/esp-idf/components/lwip/port/include -IC:/Applications/Programming/ESP/esp-idf/components/lwip/port/freertos/include -IC:/Applications/Programming/ESP/esp-idf/components/lwip/port/esp32xx/include -IC:/Applications/Programming/ESP/esp-idf/components/lwip/port/esp32xx/include/arch -IC:/Applications/Programming/ESP/esp-idf/components/esp_event/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_http_client/include -IC:/Applications/Programming/ESP/esp-idf/components/nvs_flash/include -IC:/Applications/Programming/ESP/esp-idf/components/spi_flash/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_partition/include -IC:/Applications/Programming/ESP/esp-idf/components/app_update/include -IC:/Applications/Programming/ESP/esp-idf/components/bootloader_support/include -IC:/Applications/Programming/ESP/esp-idf/components/bootloader_support/bootloader_flash/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_app_format/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_https_ota/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_netif/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_wifi/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_wifi/wifi_apps/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_phy/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_phy/esp32/include -IC:/Applications/Programming/ESP/esp-idf/examples/common_components/protocol_examples_common/include -IF:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/components/ota -IF:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/main -IC:/Applications/Programming/ESP/esp-idf/components/driver/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/deprecated -IC:/Applications/Programming/ESP/esp-idf/components/driver/analog_comparator/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/dac/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/gpio/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/gptimer/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/i2c/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/i2s/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/ledc/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/mcpwm/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/parlio/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/pcnt/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/rmt/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/sdio_slave/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/sdmmc/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/sigma_delta/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/spi/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/temperature_sensor/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/touch_sensor/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/twai/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/uart/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/usb_serial_jtag/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/touch_sensor/esp32/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_pm/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_ringbuf/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_timer/include -IF:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/components/ble_helper/include -IC:/Applications/Programming/ESP/esp-idf/components/tcp_transport/include -IC:/Applications/Programming/ESP/esp-idf/components/esp-tls -IC:/Applications/Programming/ESP/esp-idf/components/esp-tls/esp-tls-crypto -IC:/Applications/Programming/ESP/esp-idf/components/mbedtls/port/include -IC:/Applications/Programming/ESP/esp-idf/components/mbedtls/mbedtls/include -IC:/Applications/Programming/ESP/esp-idf/components/mbedtls/mbedtls/library -IC:/Applications/Programming/ESP/esp-idf/components/mbedtls/esp_crt_bundle/include -mlongcalls -Wno-frame-address -fdiagnostics-color=always -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -Og -fmacro-prefix-map=F:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic=. -fmacro-prefix-map=C:/Applications/Programming/ESP/esp-idf=/IDF -fstrict-volatile-bitfields -fno-jump-tables -fno-tree-switch-conversion -DconfigENABLE_FREERTOS_DEBUG_OCDAWARE=1 -std=gnu17 -Wno-old-style-declaration -MD -MT esp-idf/mqtt/CMakeFiles/__idf_mqtt.dir/mqtt.c.obj -MF esp-idf\mqtt\CMakeFiles\__idf_mqtt.dir\mqtt.c.obj.d -o esp-idf/mqtt/CMakeFiles/__idf_mqtt.dir/mqtt.c.obj -c F:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/components/mqtt/mqtt.c
F:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/components/mqtt/mqtt.c:14:10: fatal error: mqtt_client.h: No such file or directory
14 | #include "mqtt_client.h"
| ^~~~~~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.
* The terminal process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command ninja " terminated with exit code: 1.
The ckamelists file is this
[1/10] Performing build step for 'bootloader'
[1/1] cmd.exe /C "cd /D F:\_Jim\Programming\ESP32_codes\SmartHome\SmartHome_OTA_MQTT_basic\build\bootloader\esp-idf\esptool_py && c:\Applications\Programming\ESP\tools\python_env\idf5.1_py3.11_env\Scripts\python.exe C:/Applications/Programming/ESP/esp-idf/components/partition_table/check_sizes.py --offset 0x9000 bootloader 0x1000 F:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/build/bootloader/bootloader.bin"
Bootloader binary size 0x6880 bytes. 0x1780 bytes (18%) free.
[2/8] Building C object esp-idf/mqtt/CMakeFiles/__idf_mqtt.dir/mqtt.c.obj
FAILED: esp-idf/mqtt/CMakeFiles/__idf_mqtt.dir/mqtt.c.obj
C:\Applications\Programming\ESP\tools\tools\xtensa-esp32-elf\esp-12.2.0_20230208\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe -DESP_PLATFORM -DIDF_VER=\"v5.1.1\" -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DSOC_MMU_PAGE_SIZE=CONFIG_MMU_PAGE_SIZE -D_GNU_SOURCE -D_POSIX_READER_WRITER_LOCKS -IF:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/build/config -IF:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/components/mqtt/include -IC:/Applications/Programming/ESP/esp-idf/components/newlib/platform_include -IC:/Applications/Programming/ESP/esp-idf/components/freertos/FreeRTOS-Kernel/include -IC:/Applications/Programming/ESP/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/include -IC:/Applications/Programming/ESP/esp-idf/components/freertos/esp_additions/include/freertos -IC:/Applications/Programming/ESP/esp-idf/components/freertos/esp_additions/include -IC:/Applications/Programming/ESP/esp-idf/components/freertos/esp_additions/arch/xtensa/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_hw_support/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_hw_support/include/soc -IC:/Applications/Programming/ESP/esp-idf/components/esp_hw_support/include/soc/esp32 -IC:/Applications/Programming/ESP/esp-idf/components/esp_hw_support/port/esp32/. -IC:/Applications/Programming/ESP/esp-idf/components/esp_hw_support/port/esp32/private_include -IC:/Applications/Programming/ESP/esp-idf/components/heap/include -IC:/Applications/Programming/ESP/esp-idf/components/log/include -IC:/Applications/Programming/ESP/esp-idf/components/soc/include -IC:/Applications/Programming/ESP/esp-idf/components/soc/esp32 -IC:/Applications/Programming/ESP/esp-idf/components/soc/esp32/include -IC:/Applications/Programming/ESP/esp-idf/components/hal/esp32/include -IC:/Applications/Programming/ESP/esp-idf/components/hal/include -IC:/Applications/Programming/ESP/esp-idf/components/hal/platform_port/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_rom/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_rom/include/esp32 -IC:/Applications/Programming/ESP/esp-idf/components/esp_rom/esp32 -IC:/Applications/Programming/ESP/esp-idf/components/esp_common/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_system/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_system/port/soc -IC:/Applications/Programming/ESP/esp-idf/components/esp_system/port/include/private -IC:/Applications/Programming/ESP/esp-idf/components/xtensa/include -IC:/Applications/Programming/ESP/esp-idf/components/xtensa/esp32/include -IC:/Applications/Programming/ESP/esp-idf/components/lwip/include -IC:/Applications/Programming/ESP/esp-idf/components/lwip/include/apps -IC:/Applications/Programming/ESP/esp-idf/components/lwip/include/apps/sntp -IC:/Applications/Programming/ESP/esp-idf/components/lwip/lwip/src/include -IC:/Applications/Programming/ESP/esp-idf/components/lwip/port/include -IC:/Applications/Programming/ESP/esp-idf/components/lwip/port/freertos/include -IC:/Applications/Programming/ESP/esp-idf/components/lwip/port/esp32xx/include -IC:/Applications/Programming/ESP/esp-idf/components/lwip/port/esp32xx/include/arch -IC:/Applications/Programming/ESP/esp-idf/components/esp_event/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_http_client/include -IC:/Applications/Programming/ESP/esp-idf/components/nvs_flash/include -IC:/Applications/Programming/ESP/esp-idf/components/spi_flash/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_partition/include -IC:/Applications/Programming/ESP/esp-idf/components/app_update/include -IC:/Applications/Programming/ESP/esp-idf/components/bootloader_support/include -IC:/Applications/Programming/ESP/esp-idf/components/bootloader_support/bootloader_flash/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_app_format/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_https_ota/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_netif/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_wifi/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_wifi/wifi_apps/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_phy/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_phy/esp32/include -IC:/Applications/Programming/ESP/esp-idf/examples/common_components/protocol_examples_common/include -IF:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/components/ota -IF:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/main -IC:/Applications/Programming/ESP/esp-idf/components/driver/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/deprecated -IC:/Applications/Programming/ESP/esp-idf/components/driver/analog_comparator/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/dac/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/gpio/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/gptimer/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/i2c/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/i2s/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/ledc/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/mcpwm/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/parlio/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/pcnt/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/rmt/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/sdio_slave/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/sdmmc/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/sigma_delta/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/spi/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/temperature_sensor/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/touch_sensor/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/twai/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/uart/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/usb_serial_jtag/include -IC:/Applications/Programming/ESP/esp-idf/components/driver/touch_sensor/esp32/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_pm/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_ringbuf/include -IC:/Applications/Programming/ESP/esp-idf/components/esp_timer/include -IF:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/components/ble_helper/include -IC:/Applications/Programming/ESP/esp-idf/components/tcp_transport/include -IC:/Applications/Programming/ESP/esp-idf/components/esp-tls -IC:/Applications/Programming/ESP/esp-idf/components/esp-tls/esp-tls-crypto -IC:/Applications/Programming/ESP/esp-idf/components/mbedtls/port/include -IC:/Applications/Programming/ESP/esp-idf/components/mbedtls/mbedtls/include -IC:/Applications/Programming/ESP/esp-idf/components/mbedtls/mbedtls/library -IC:/Applications/Programming/ESP/esp-idf/components/mbedtls/esp_crt_bundle/include -mlongcalls -Wno-frame-address -fdiagnostics-color=always -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -Og -fmacro-prefix-map=F:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic=. -fmacro-prefix-map=C:/Applications/Programming/ESP/esp-idf=/IDF -fstrict-volatile-bitfields -fno-jump-tables -fno-tree-switch-conversion -DconfigENABLE_FREERTOS_DEBUG_OCDAWARE=1 -std=gnu17 -Wno-old-style-declaration -MD -MT esp-idf/mqtt/CMakeFiles/__idf_mqtt.dir/mqtt.c.obj -MF esp-idf\mqtt\CMakeFiles\__idf_mqtt.dir\mqtt.c.obj.d -o esp-idf/mqtt/CMakeFiles/__idf_mqtt.dir/mqtt.c.obj -c F:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/components/mqtt/mqtt.c
F:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/components/mqtt/mqtt.c:14:10: fatal error: mqtt_client.h: No such file or directory
14 | #include "mqtt_client.h"
| ^~~~~~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.
* The terminal process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command ninja " terminated with exit code: 1.
The ckamelists file is this
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Problem importing MQTT example to my code
The problem may be that your (project-local) component is named "mqtt", and it declares a dependency on a component named "mqtt". I guess you want the dependency of your mqtt component to refer to "the other" (IDF's) mqtt component, which probably won't work as long as both components are named identically.
Rename your mqtt component.
Rename your mqtt component.
Re: Problem importing MQTT example to my code
That was the problem. Thank you !
Re: Problem importing MQTT example to my code
The program compiles without errors but I get an error during running of the code. It seems it resets when it gets to ESPLOGI() macro. any ideas why is that ? I have included the log component in the cmakelists files where it is used so it should have been ok
*TAG pointer is set at
global.h
extern char *TAG ;
main.c
char *TAG;
*TAG pointer is set at
global.h
extern char *TAG ;
main.c
char *TAG;
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Problem importing MQTT example to my code
Of course, you also need to initialize TAG before using it.char *TAG;
(Declaring the log tag in a header file is rather uncommon. You usually want multiple tags in your application (e.g. one tag per .c file) so that you can better correlate logged messages to code.)
Re: Problem importing MQTT example to my code
I thought of that but I had put char *TAG="ggg"; above the app_main() function in the globals declarations.
I put it inside the app_main() and it worked.
Thanks
I put it inside the app_main() and it worked.
Thanks
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Problem importing MQTT example to my code
Btw, in order to not confuse the linker more than necessary, I suggest declaring tags as static globals inside each .c file:
or
(Making TAG const helps the compiler with optimizations; the type const char allows the compiler to put the string into flash instead of RAM, which is a good thing unless you want to use the string/tag in IRAM code.)
Code: Select all
static const char* const TAG = "mytag";
Code: Select all
static const char TAG[] = "mytag";
Who is online
Users browsing this forum: No registered users and 111 guests