Code: Select all
FAILED: BT_TUNER_SLAVE_AI.elf
cmd.exe /C "cd . && C:\Espressif\tools\xtensa-esp32-elf\esp-2022r1-11.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -mlongcalls -Wno-frame-address @CMakeFiles\BT_TUNER_SLAVE_AI.elf.rsp -o BT_TUNER_SLAVE_AI.elf && cd ."
c:/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(main.c.obj):(.literal.bt_task+0x18): undefined reference to `esp_bt_gap_is_connection'
c:/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(main.c.obj):(.literal.bt_task+0x1c): undefined reference to `esp_read_data'
c:/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(main.c.obj):(.literal.bt_task+0x20): undefined reference to `esp_send_data'
c:/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(main.c.obj): in function `bt_task':
C:/Users/konec/ESP-IDF/BT_TUNER_SLAVE_AI/main/main.c:34: undefined reference to `esp_bt_gap_is_connection'
c:/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: C:/Users/konec/ESP-IDF/BT_TUNER_SLAVE_AI/main/main.c:41: undefined reference to `esp_read_data'
c:/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: C:/Users/konec/ESP-IDF/BT_TUNER_SLAVE_AI/main/main.c:55: undefined reference to `esp_send_data'
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.
Code: Select all
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_bt.h"
#include "esp_bt_main.h"
#include "esp_gap_bt_api.h"
#include "esp_log.h"
#include "esp_bt_device.h"
#include "esp_spp_api.h"
#include <string.h>
#include "nvs.h"
#include "nvs_flash.h"
#define TAG "BT_SLAVE"
// Deklarace funkcí
bool esp_bt_gap_is_connection();
int esp_read_data(uint8_t *buf, int size);
void esp_send_data(uint8_t *data, int size);
void bt_task(void *pvParameters) {
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
esp_bt_controller_init(&bt_cfg);
esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT);
esp_bt_dev_set_device_name("ESP_SLAVE"); // Nastavení názvu zařízení
vTaskDelay(1000 / portTICK_PERIOD_MS);
while (1) {
// Čekání na připojení
if (!esp_bt_gap_is_connection()) {
ESP_LOGI(TAG, "Čekám na připojení...");
vTaskDelay(2000 / portTICK_PERIOD_MS);
continue;
}
// Příjem dat ze spojení
uint8_t buf[256];
int len = esp_read_data(buf, sizeof(buf));
if (len > 0) {
buf[len] = '\0';
ESP_LOGI(TAG, "Přijato: %s", buf);
}
// Odeslání dat na spojení
char data_to_send[] = "Hello from Slave!";
esp_send_data((uint8_t *)data_to_send, strlen(data_to_send));
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
void app_main() {
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_log_level_set(TAG, ESP_LOG_INFO);
xTaskCreate(&bt_task, "bt_task", 2048, NULL, 5, NULL);
}