Hello,
I'm facing a bigger problem. For an EMC test, I need to send a Bluetooth test signal for verification.
This is done using the function:
esp_phy_bt_tx_tone
When I do this with VS Code and the Espressif IDF, there's no issue.
I just need to set the entry
CONFIG_ESP_PHY_ENABLE_CERT_TEST=y
in the SDKConfig (menuconfig).
Here’s the example in VS Code with IDF:
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "nvs_flash.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_bt.h"//#include "esp_bt_main.h"
#include "esp_phy_cert_test.h"
static const char *TAG = "BLE_CW_TONE";
static esp_err_t bt_ctrl_start(void)
{
esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT);
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
esp_err_t err = esp_bt_controller_init(&bt_cfg);
if (err != ESP_OK) return err;
err = esp_bt_controller_enable(ESP_BT_MODE_BLE);
return err;
}
static void bt_ctrl_stop(void)
{
esp_bt_controller_disable();
esp_bt_controller_deinit();
}
extern "C" void app_main(void)
{
ESP_ERROR_CHECK(nvs_flash_init());
ESP_LOGI(TAG, "Starting BLE controller…");
ESP_ERROR_CHECK(bt_ctrl_start());
uint32_t chan = 19; // 2402 + 2*19 = 2440 MHz
uint32_t power = 0; //
while(1)
{
ESP_LOGI(TAG, "Start BLE CW tone: chan=%"PRIu32" (%.0f MHz), power(attn)=%"PRIu32"*0.25 dB", chan, 2402.0 + 2.0*chan, power);
esp_phy_bt_tx_tone(/*start=*/1, /*chan=*/chan, /*power=*/power);
vTaskDelay(pdMS_TO_TICKS(2000));
ESP_LOGI(TAG, "Stop BLE CW tone");
esp_phy_bt_tx_tone(/*start=*/0, /*chan=*/0, /*power=*/0);
vTaskDelay(pdMS_TO_TICKS(2000));
}
bt_ctrl_stop();
ESP_LOGI(TAG, "Done.");
}
This compiles fine and runs on the esp32-s3.
Now, unfortunately, I need all of this to work in VisualMicro / Arduino, but I always get a linker error when I try it.
Here is also the Arduino-Version:
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "nvs_flash.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_bt.h"
#include "esp_phy_cert_test.h" // enthält esp_phy_bt_tx_tone()
static void startBleTone(uint32_t chan, uint32_t powerAttenQuarterdB)
{
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
esp_err_t err = esp_bt_controller_init(&bt_cfg);
if (err != ESP_OK) {
Serial.printf("Controller init failed: %d\n", err);
return;
}
err = esp_bt_controller_enable(ESP_BT_MODE_BLE);
if (err != ESP_OK) {
Serial.printf("Controller enable failed: %d\n", err);
return;
}
esp_phy_bt_tx_tone(1,chan,powerAttenQuarterdB);
}
static void stopBleTone()
{
esp_bt_controller_disable();
esp_bt_controller_deinit();
}
void setup() {
Serial.begin(115200);
delay(1000);
uint32_t chan = 19;
uint32_t power = 0;
Serial.println("Start BLE CW tone...");
startBleTone(chan, power);
delay(10000);
Serial.println("Stop BLE CW tone");
stopBleTone();
}
void loop() {
}
At compiling, I get this Link Error:
ld.exe: EMC_BLE_TEST.cpp.o:(.literal._Z5setupv+0x20): undefined reference to esp_phy_bt_tx_tone
ld.exe: EMC_BLE_TEST.cpp.o: in function setup()
EMC_BLE_TEST.ino:49: undefined reference to esp_phy_bt_tx_tone
The problem is that I have to integrate all of this into my main project, which is currently written using VisualMicro / Arduino.
Of course, I’ve already tried asking ChatGPT for help. Apparently, I would need to compile the core libraries myself and then move them into the global libs folder — but that could affect other projects.
Any suggestions?
Project Setup:
ESP32-S3
Latest Arduino-IDF (3.3.1)
Latest VisualMicro (2025.0721.04)
Regards
John