爱摄影的寸头怪 2024-01-16 14:11 采纳率: 0%
浏览 15

ESP32的BLE移植


D:/ESP32_Project/NES_V1/components/BLE/BLE.C:117:1: warning: missing initializer for member 'esp_ble_adv_params_t::peer_addr' [-Wmissing-field-initializers]
  117 | };
      | ^
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:117:1: warning: missing initializer for member 'esp_ble_adv_params_t::peer_addr_type' [-Wmissing-field-initializers]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:143:1: warning: missing initializer for member 'gatts_profile_inst::app_id' [-Wmissing-field-initializers]
  143 | };
      | ^
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:143:1: warning: missing initializer for member 'gatts_profile_inst::conn_id' [-Wmissing-field-initializers]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:143:1: warning: missing initializer for member 'gatts_profile_inst::service_handle' [-Wmissing-field-initializers]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:143:1: warning: missing initializer for member 'gatts_profile_inst::service_id' [-Wmissing-field-initializers]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:143:1: warning: missing initializer for member 'gatts_profile_inst::char_handle' [-Wmissing-field-initializers]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:143:1: warning: missing initializer for member 'gatts_profile_inst::char_uuid' [-Wmissing-field-initializers]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:143:1: warning: missing initializer for member 'gatts_profile_inst::perm' [-Wmissing-field-initializers]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:143:1: warning: missing initializer for member 'gatts_profile_inst::property' [-Wmissing-field-initializers]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:143:1: warning: missing initializer for member 'gatts_profile_inst::descr_handle' [-Wmissing-field-initializers]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:143:1: warning: missing initializer for member 'gatts_profile_inst::descr_uuid' [-Wmissing-field-initializers]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:204:1: sorry, unimplemented: non-trivial designated initializers not supported
  204 | };
      | ^
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:204:1: sorry, unimplemented: non-trivial designated initializers not supported
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:204:1: sorry, unimplemented: non-trivial designated initializers not supported
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:204:1: sorry, unimplemented: non-trivial designated initializers not supported
D:/ESP32_Project/NES_V1/components/BLE/BLE.C: In function 'void gatts_profile_event_handler(esp_gatts_cb_event_t, esp_gatt_if_t, esp_ble_gatts_cb_param_t*)':
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:58: warning: missing initializer for member 'esp_ble_conn_update_params_t::min_int' [-Wmissing-field-initializers]
  429 |             esp_ble_conn_update_params_t conn_params = {0};
      |                                                          ^
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:58: warning: missing initializer for member 'esp_ble_conn_update_params_t::max_int' [-Wmissing-field-initializers]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:58: warning: missing initializer for member 'esp_ble_conn_update_params_t::latency' [-Wmissing-field-initializers]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:58: warning: missing initializer for member 'esp_ble_conn_update_params_t::timeout' [-Wmissing-field-initializers]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:439:14: error: jump to case label
  439 |         case ESP_GATTS_DISCONNECT_EVT:
      |              ^~~~~~~~~~~~~~~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:42: note:   crosses initialization of 'esp_ble_conn_update_params_t conn_params'
  429 |             esp_ble_conn_update_params_t conn_params = {0};
      |                                          ^~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:443:14: error: jump to case label
  443 |         case ESP_GATTS_CREAT_ATTR_TAB_EVT:{
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:42: note:   crosses initialization of 'esp_ble_conn_update_params_t conn_params'
  429 |             esp_ble_conn_update_params_t conn_params = {0};
      |                                          ^~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:458:14: error: jump to case label
  458 |         case ESP_GATTS_STOP_EVT:            break;
      |              ^~~~~~~~~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:42: note:   crosses initialization of 'esp_ble_conn_update_params_t conn_params'
  429 |             esp_ble_conn_update_params_t conn_params = {0};
      |                                          ^~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:459:14: error: jump to case label
  459 |         case ESP_GATTS_OPEN_EVT:            break;
      |              ^~~~~~~~~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:42: note:   crosses initialization of 'esp_ble_conn_update_params_t conn_params'
  429 |             esp_ble_conn_update_params_t conn_params = {0};
      |                                          ^~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:460:14: error: jump to case label
  460 |         case ESP_GATTS_CANCEL_OPEN_EVT:     break;
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:42: note:   crosses initialization of 'esp_ble_conn_update_params_t conn_params'
  429 |             esp_ble_conn_update_params_t conn_params = {0};
      |                                          ^~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:461:14: error: jump to case label
  461 |         case ESP_GATTS_CLOSE_EVT:           break;
      |              ^~~~~~~~~~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:42: note:   crosses initialization of 'esp_ble_conn_update_params_t conn_params'
  429 |             esp_ble_conn_update_params_t conn_params = {0};
      |                                          ^~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:462:14: error: jump to case label
  462 |         case ESP_GATTS_LISTEN_EVT:          break;
      |              ^~~~~~~~~~~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:42: note:   crosses initialization of 'esp_ble_conn_update_params_t conn_params'
  429 |             esp_ble_conn_update_params_t conn_params = {0};
      |                                          ^~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:463:14: error: jump to case label
  463 |         case ESP_GATTS_CONGEST_EVT:
      |              ^~~~~~~~~~~~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:42: note:   crosses initialization of 'esp_ble_conn_update_params_t conn_params'
  429 |             esp_ble_conn_update_params_t conn_params = {0};
      |                                          ^~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:465:14: error: jump to case label
  465 |         case ESP_GATTS_UNREG_EVT:
      |              ^~~~~~~~~~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:42: note:   crosses initialization of 'esp_ble_conn_update_params_t conn_params'
  429 |             esp_ble_conn_update_params_t conn_params = {0};
      |                                          ^~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:467:14: error: jump to case label
  467 |         case ESP_GATTS_DELETE_EVT:
      |              ^~~~~~~~~~~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:42: note:   crosses initialization of 'esp_ble_conn_update_params_t conn_params'
  429 |             esp_ble_conn_update_params_t conn_params = {0};
      |                                          ^~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:469:9: error: jump to case label
  469 |         default:
      |         ^~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:429:42: note:   crosses initialization of 'esp_ble_conn_update_params_t conn_params'
  429 |             esp_ble_conn_update_params_t conn_params = {0};
      |                                          ^~~~~~~~~~~
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_UNREG_EVT' not handled in switch [-Werror=switch]
  327 |     switch (event) {
      |            ^
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_CREATE_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_ADD_INCL_SRVC_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_ADD_CHAR_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_ADD_CHAR_DESCR_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_DELETE_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_STOP_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_DISCONNECT_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_OPEN_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_CANCEL_OPEN_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_CLOSE_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_LISTEN_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_CONGEST_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_RESPONSE_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_CREAT_ATTR_TAB_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_SET_ATTR_VAL_EVT' not handled in switch [-Werror=switch]
D:/ESP32_Project/NES_V1/components/BLE/BLE.C:327:12: error: enumeration value 'ESP_GATTS_SEND_SERVICE_CHANGE_EVT' not handled in switch [-Werror=switch]
cc1plus.exe: some warnings being treated as errors
ninja: build stopped: subcommand failed.

有没有在ESP32的BLE移植过程中出现上面问题的兄弟姐妹们,要怎么解决呀

  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2024-01-16 16:13
    关注

    【以下回答由 GPT 生成】

    这个问题的警告是由于在成员变量esp_ble_adv_params_t::peer_addr中缺少初始化造成的。要解决这个问题,你需要给esp_ble_adv_params_t::peer_addr成员变量添加适当的初始化值。

    具体的解决方案如下:

    1. 打开/ESP32_Project/NES_V1/components/BLE/BLE.C文件。
    2. 寻找esp_ble_adv_params_t结构体定义的地方。
    3. 在结构体定义中找到esp_bd_addr_t类型的peer_addr成员变量。
    4. 添加{0}作为初始化值,确保peer_addr成员变量被正确初始化。
    5. 保存文件并重新编译项目。

    根据你提供的代码,这是一个代码示例:

    typedef struct {
        // 其他成员变量
        esp_bd_addr_t peer_addr;
        // 其他成员变量
    } esp_ble_adv_params_t;
    

    你需要将esp_bd_addr_t类型的peer_addr成员变量改为以下形式:

    typedef struct {
        // 其他成员变量
        esp_bd_addr_t peer_addr{0};
        // 其他成员变量
    } esp_ble_adv_params_t;
    

    这样,编译时就不会再出现warning: missing initializer警告了。

    希望这个解决方案对你有帮助。如果还有其他问题,请随时提问。



    【相关推荐】



    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^
    评论

报告相同问题?

问题事件

  • 创建了问题 1月16日