Linker Error : undefined reference to `wifi_prov_scheme_ble'

tomi_kuye
Posts: 1
Joined: Tue Aug 19, 2025 6:28 pm

Linker Error : undefined reference to `wifi_prov_scheme_ble'

Postby tomi_kuye » Tue Aug 19, 2025 7:09 pm

Hello,

I am working on provisioning my custom esp32s3 board with wifi credentials over ble.

However I am getting the below linker error

Code: Select all

provision.c.obj):(.literal.provision_device+0x0): undefined reference to `wifi_prov_scheme_ble'
/Users/tomikuye/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/main/libmain.a(provision.c.obj):(.literal.provision_device+0x4): undefined reference to `wifi_prov_scheme_ble_event_cb_free_btdm'
collect2: error: ld returned 1 exit status
I am unsure why this is happening, most of my code was copied and pasted from various ESP-IDF examples! The wifi_provisioning header files are confirmed in my esp-idf directory. Would appreciate any help here, version is 5.4.1

Here is my provisioning code:

Code: Select all

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_event.h"
#include "freertos/event_groups.h"
#include "esp_wifi.h"
#include "esp_log.h"
#include "esp_mac.h"
#include "mode_manager.h"
#include "nvs_flash.h"
#include "string.h"
#include "provision.h"
#include "wifi_provisioning/manager.h"
#include "wifi_provisioning/scheme_ble.h"

const char *service_name = "PROV_12345";
const char *service_key  = "NULL";

wifi_prov_security_t security = WIFI_PROV_SECURITY_1;
const char *pop = "abcd1234";


static const char *TAG = "Provisioning Manager";
static EventGroupHandle_t wifi_event_group;

void provision_device()
{
        wifi_init();
        wifi_prov_mgr_config_t config = 
        {
            .scheme = wifi_prov_scheme_ble,
            .scheme_event_handler = WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM // 
        };
        ESP_ERROR_CHECK( wifi_prov_mgr_init(config) );

bool provisioned = false;
ESP_ERROR_CHECK(wifi_prov_mgr_is_provisioned(&provisioned));

    if (!provisioned) 
    {
        ESP_LOGI(TAG, "Starting provisioning");
        ESP_ERROR_CHECK( wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key) );
    } 
    else 
    {
        ESP_LOGI(TAG, "Already provisioned, starting WiFi");
        ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
        ESP_ERROR_CHECK(esp_wifi_start());
    }

}

static void event_handler(void* arg, esp_event_base_t event_base,
                          int32_t event_id, void* event_data)
{
    if (event_base == WIFI_PROV_EVENT) {
        switch (event_id) {
            case WIFI_PROV_START:
                ESP_LOGI(TAG, "Provisioning started");
                break;
            case WIFI_PROV_CRED_RECV: {
                wifi_sta_config_t *wifi_sta_cfg = (wifi_sta_config_t *)event_data;
                ESP_LOGI(TAG, "Received Wi-Fi credentials"
                         "\n\tSSID     : %s\n\tPassword : %s",
                         (const char *) wifi_sta_cfg->ssid,
                         (const char *) wifi_sta_cfg->password);
                break;
            }
            case WIFI_PROV_CRED_FAIL: {
                wifi_prov_sta_fail_reason_t *reason = (wifi_prov_sta_fail_reason_t *)event_data;
                ESP_LOGE(TAG, "Provisioning failed!\n\tReason : %s"
                         "\n\tPlease reset to factory and retry provisioning",
                         (*reason == WIFI_PROV_STA_AUTH_ERROR) ?
                         "Wi-Fi station authentication failed" : "Wi-Fi access-point not found");
                break;
            }
            case WIFI_PROV_CRED_SUCCESS:
                ESP_LOGI(TAG, "Provisioning successful");
                break;
            case WIFI_PROV_END: {
                /* De-initialize manager once provisioning is finished */
                wifi_prov_mgr_deinit();
                ESP_LOGI(TAG, " to de-initialize provisioning manager ");
                break;
            }
            default:
                break;
        }
    }
    else if (event_base == WIFI_EVENT) {
        switch (event_id) {
            case WIFI_EVENT_STA_START:
                ESP_LOGI(TAG, "WiFi started, connecting...");
                esp_wifi_connect();
                break;
            case WIFI_EVENT_STA_CONNECTED:
                ESP_LOGI(TAG, "Connected to WiFi network");
                break;
            case WIFI_EVENT_STA_DISCONNECTED:
                ESP_LOGE(TAG, "Disconnected from WiFi, retrying...");
                esp_wifi_connect();  // Auto-retry
                break;
        }
}
}

static void wifi_init(void)
{
    ESP_ERROR_CHECK(esp_netif_init());
    ESP_ERROR_CHECK(esp_event_loop_create_default());
    esp_netif_create_default_wifi_sta();

   
    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
    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 );

    wifi_event_group = xEventGroupCreate();
    ESP_ERROR_CHECK(esp_event_handler_register(WIFI_PROV_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL));

    ESP_ERROR_CHECK(esp_wifi_init(&cfg));
    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
    //ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
    ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE));
    ESP_ERROR_CHECK(esp_wifi_start());

}
And here is my CMakeFile

Code: Select all

idf_component_register(SRCS "provision.c" "vcr_timing.c" "pair.c" "mode_manager.c" "vcr.c" "main.c" "battery_life.c" "sleep.c"
                        INCLUDE_DIRS "."
                        REQUIRES wifi_provisioning nvs_flash esp_driver_i2c esp_driver_gpio esp_driver_ledc max1704x drv2605 tca9548
                         )
Thanks to all in advance!

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot], meta-externalagent and 1 guest