乐鑫技术交流
直播中

向日葵的花季

9年用户 1267经验值
擅长:电源/新能源
私信 关注
[问答]

添加Blufi Function后编译错误怎么解决?

我在我的项目中集成 Blufi 模块,参照实例项目编写代码,在 menuconfig 中开启 Include blufi funcion 后编译报错

  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:46:8: error: uknown type name 'esp_ble_adv_data_t'
  •    46 | static esp_ble_adv_data_t blufi_adv_data = {
  •       |        ^~~~~~~~~~~~~~~~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:47:5: error: field name not in record or union initializer
  •    47 |     .set_scan_rsp = false,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:47:5: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:48:5: error: field name not in record or union initializer
  •    48 |     .include_name = true,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:48:5: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:48:21: warning: excess elements in scalar initializer
  •    48 |     .include_name = true,
  •       |                     ^~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:48:21: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:49:5: error: field name not in record or union initializer
  •    49 |     .include_txpower = true,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:49:5: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:49:24: warning: excess elements in scalar initializer
  •    49 |     .include_txpower = true,
  •       |                        ^~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:49:24: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:50:5: error: field name not in record or union initializer
  •    50 |     .min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:50:5: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:50:21: warning: excess elements in scalar initializer
  •    50 |     .min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
  •       |                     ^~~~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:50:21: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:51:5: error: field name not in record or union initializer
  •    51 |     .max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:51:5: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:51:21: warning: excess elements in scalar initializer
  •    51 |     .max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec
  •       |                     ^~~~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:51:21: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:52:5: error: field name not in record or union initializer
  •    52 |     .appearance = 0x00,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:52:5: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:52:19: warning: excess elements in scalar initializer
  •    52 |     .appearance = 0x00,
  •       |                   ^~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:52:19: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:53:5: error: field name not in record or union initializer
  •    53 |     .manufacturer_len = 0,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:53:5: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:53:25: warning: excess elements in scalar initializer
  •    53 |     .manufacturer_len = 0,
  •       |                         ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:53:25: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:54:5: error: field name not in record or union initializer
  •    54 |     .p_manufacturer_data =  NULL,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:54:5: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:54:29: warning: excess elements in scalar initializer
  •    54 |     .p_manufacturer_data =  NULL,
  •       |                             ^~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:54:29: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:55:5: error: field name not in record or union initializer
  •    55 |     .service_data_len = 0,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:55:5: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:55:25: warning: excess elements in scalar initializer
  •    55 |     .service_data_len = 0,
  •       |                         ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:55:25: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:56:5: error: field name not in record or union initializer
  •    56 |     .p_service_data = NULL,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:56:5: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:56:23: warning: excess elements in scalar initializer
  •    56 |     .p_service_data = NULL,
  •       |                       ^~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:56:23: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:57:5: error: field name not in record or union initializer
  •    57 |     .service_uuid_len = 16,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:57:5: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:57:25: warning: excess elements in scalar initializer
  •    57 |     .service_uuid_len = 16,
  •       |                         ^~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:57:25: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:58:5: error: field name not in record or union initializer
  •    58 |     .p_service_uuid = blufi_service_uuid128,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:58:5: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:58:23: warning: excess elements in scalar initializer
  •    58 |     .p_service_uuid = blufi_service_uuid128,
  •       |                       ^~~~~~~~~~~~~~~~~~~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:58:23: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:59:5: error: field name not in record or union initializer
  •    59 |     .flag = 0x6,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:59:5: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:59:13: warning: excess elements in scalar initializer
  •    59 |     .flag = 0x6,
  •       |             ^~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:59:13: note: (near initialization for 'blufi_adv_data')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:62:8: error: unknown type name 'esp_ble_adv_params_t'
  •    62 | static esp_ble_adv_params_t blufi_adv_params = {
  •       |        ^~~~~~~~~~~~~~~~~~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:63:5: error: field name not in record or union initializer
  •    63 |     .adv_int_min        = 0x100,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:63:5: note: (near initialization for 'blufi_adv_params')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:64:5: error: field name not in record or union initializer
  •    64 |     .adv_int_max        = 0x100,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:64:5: note: (near initialization for 'blufi_adv_params')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:64:27: warning: excess elements in scalar initializer
  •    64 |     .adv_int_max        = 0x100,
  •       |                           ^~~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:64:27: note: (near initialization for 'blufi_adv_params')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:65:5: error: field name not in record or union initializer
  •    65 |     .adv_type           = ADV_TYPE_IND,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:65:5: note: (near initialization for 'blufi_adv_params')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:65:27: warning: excess elements in scalar initializer
  •    65 |     .adv_type           = ADV_TYPE_IND,
  •       |                           ^~~~~~~~~~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:65:27: note: (near initialization for 'blufi_adv_params')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:66:5: error: field name not in record or union initializer
  •    66 |     .own_addr_type      = BLE_ADDR_TYPE_PUBLIC,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:66:5: note: (near initialization for 'blufi_adv_params')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:66:27: warning: excess elements in scalar initializer
  •    66 |     .own_addr_type      = BLE_ADDR_TYPE_PUBLIC,
  •       |                           ^~~~~~~~~~~~~~~~~~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:66:27: note: (near initialization for 'blufi_adv_params')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:69:5: error: field name not in record or union initializer
  •    69 |     .channel_map        = ADV_CHNL_ALL,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:69:5: note: (near initialization for 'blufi_adv_params')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:69:27: warning: excess elements in scalar initializer
  •    69 |     .channel_map        = ADV_CHNL_ALL,
  •       |                           ^~~~~~~~~~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:69:27: note: (near initialization for 'blufi_adv_params')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:70:5: error: field name not in record or union initializer
  •    70 |     .adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
  •       |     ^
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:70:5: note: (near initialization for 'blufi_adv_params')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:70:26: warning: excess elements in scalar initializer
  •    70 |     .adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
  •       |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:70:26: note: (near initialization for 'blufi_adv_params')
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c: In function 'esp_blufi_gap_event_handler':
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:77:9: error: implicit declaration of function 'esp_ble_gap_start_advertising'; did you mean
  • esp_ble_gap_start_ext_scan'? [-Werror=implicit-function-declaration]
  •    77 |         esp_ble_gap_start_advertising(&blufi_adv_params);
  •       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  •       |         esp_ble_gap_start_ext_scan
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c: In function 'esp_blufi_adv_start':
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:374:5: error: implicit declaration of function 'esp_ble_gap_config_adv_data'; did you mean 'esp_ble_gap_config_ext_adv_data_raw'? [-Werror=implicit-function-declaration]
  •   374 |     esp_ble_gap_config_adv_data(&blufi_adv_data);
  •       |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  •       |     esp_ble_gap_config_ext_adv_data_raw
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c: In function 'esp_blufi_adv_stop':
  • D:/Programs/espressif/esp-idf/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c:379:5: error: implicit declaration of function 'esp_ble_gap_stop_advertising'; did you mean  
  • esp_ble_gap_stop_ext_scan'? [-Werror=implicit-function-declaration]
  •   379 |     esp_ble_gap_stop_advertising();
  •       |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  •       |     esp_ble_gap_stop_ext_scan
  • cc1.exe: some warnings being treated as errors
  • [43/144] Building C object esp-idf/protocomm/CMakeFiles/__idf_protocomm.dir/src/transports/protocomm_ble.c.obj
  • ninja: build stopped: subcommand failed.

           
                                 

回帖(2)

王莹

2024-6-11 10:37:40
根据报错的log:你用了 esp_ble_gap_start_advertising 等函数,该函数位于 esp-idf/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h
但是没有引入该函数。

你需要将 “esp_gap_ble_api.h” 引入一下。
举报

李芳

2024-6-11 16:50:52
根据您提供的错误信息,编译错误发生在 `esp_blufi.c` 文件的第 46 行,错误提示为 "unknown type name 'esp_ble_adv_data_t'"。这意味着编译器无法识别 `esp_ble_adv_data_t` 类型。

要解决这个问题,请按照以下步骤操作:

1. 确保您已经正确地包含了所需的头文件。在 `esp_blufi.c` 文件中,应该有以下包含语句:

```c
#include "esp_blufi_api.h"
```

2. 检查您的 `menuconfig` 设置。确保您已经正确地选择了与您的项目相关的蓝牙配置选项。在 `menuconfig` 中,您应该选择以下选项:

```
Component config -> Bluetooth -> Enable BLE (Controller & Host)
Component config -> Bluetooth -> Enable Bluetooth
Component config -> Bluetooth -> Enable BLE (Gap)
Component config -> Bluetooth -> Enable BLE (GATT)
Component config -> Bluetooth -> Enable BLE (GATT Client)
Component config -> Bluetooth -> Enable BLE (GATT Server)
Component config -> Bluetooth -> Enable BLE (Security Manager)
Component config -> Bluetooth -> Enable BLE (SPP)
Component config -> Bluetooth -> Include blufi function
```

3. 确保您的 ESP-IDF 版本是最新的。如果您使用的是较旧的版本,可能会遇到一些兼容性问题。您可以通过以下命令来更新 ESP-IDF:

```bash
cd ~/esp/esp-idf
git pull
```

4. 如果问题仍然存在,请尝试清理项目并重新编译。在命令行中,执行以下命令:

```bash
make clean
make
```

5. 如果以上步骤都无法解决问题,请检查您的项目设置和代码,确保没有其他错误或遗漏。

通过以上步骤,您应该能够解决编译错误。如果问题仍然存在,请提供更多详细信息,以便我们能够更好地帮助您。
举报

更多回帖

发帖
×
20
完善资料,
赚取积分