I'm trying to use paho_mqtt_embedded_c client on my esp32 DevKitC running freeRTOS.
I'm using Kolban's esp32 port available here https://github.com/nkolban/esp32-snippe ... embedded_c
The library compile well as a component. However when I try to use the function NetworkConnect I have the following error :
Code: Select all
$ make
CC main.o
AR libmain.a
LD app-template.elf
<project_path>/build/paho_mqtt_embedded_c/libpaho_mqtt_embedded_c.a(MQTTLinux.o):(.literal.NetworkConnectSSL+0x38): undefined reference to `mbedtls_debug_set_threshold'
<project_path>/build/paho_mqtt_embedded_c/libpaho_mqtt_embedded_c.a(MQTTLinux.o): In function `NetworkConnectSSL':
<project_path>/components/paho_mqtt_embedded_c/MQTTClient-C/src/linux/MQTTLinux.c:203: undefined reference to `mbedtls_debug_set_threshold'
collect2: error: ld returned 1 exit status
<esp-idf_path>/make/project.mk:322 : la recette pour la cible « <project_path>/build/app-template.elf » a échouée
make: *** [<project_path>/build/app-template.elf] Erreur 1
Code: Select all
#include <esp_event.h>
#include <esp_event_loop.h>
#include <esp_system.h>
#include <esp_wifi.h>
#include <freertos/FreeRTOS.h>
#include <lwip/sockets.h>
#include <nvs_flash.h>
#include "MQTTClient.h"
// The IP address that we want our device to have.
#define DEVICE_IP "192.168.128.186"
// The Gateway address where we wish to send packets.
// This will commonly be our access point.
#define DEVICE_GW "192.168.128.161"
// The netmask specification.
#define DEVICE_NETMASK "255.255.255.0"
#define SSID "<ssid>"
#define PASSWORD "<ap_password>"
esp_err_t esp32_wifi_eventHandler(void *ctx, system_event_t *event) {
// Your event handling code here...
if (event->event_id == SYSTEM_EVENT_STA_GOT_IP) {
//Do nothing
}
return ESP_OK;
}
void app_main(void)
{
nvs_flash_init();
tcpip_adapter_init();
tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA); // Don't run a DHCP client
tcpip_adapter_ip_info_t ipInfo;
inet_pton(AF_INET, DEVICE_IP, &ipInfo.ip);
inet_pton(AF_INET, DEVICE_GW, &ipInfo.gw);
inet_pton(AF_INET, DEVICE_NETMASK, &ipInfo.netmask);
tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_STA, &ipInfo);
ESP_ERROR_CHECK( esp_event_loop_init(esp32_wifi_eventHandler, NULL) );
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
wifi_config_t sta_config = {
.sta = {
.ssid = SSID,
.password = PASSWORD,
.bssid_set = false
}
};
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &sta_config) );
ESP_ERROR_CHECK( esp_wifi_start() );
ESP_ERROR_CHECK( esp_wifi_connect() );
Network network;
NetworkInit(&network);
NetworkConnect(&network, "192.168.128.161", 1883);
}
Code: Select all
mbedtls_debug_set_threshold(4); // Log at verbose only