idf 4.3.1蓝牙驱动函数代码报错, 写的极不合理

fland@126.com
Posts: 8
Joined: Thu Oct 28, 2021 2:46 am

idf 4.3.1蓝牙驱动函数代码报错, 写的极不合理

Postby fland@126.com » Fri Dec 03, 2021 7:26 am

编译出错:
D:/ESP32/esp-idf-4.3.1/components/bt/host/bluedroid/stack/smp/smp_act.c: In function 'smp_fast_conn_param':
D:/ESP32/esp-idf-4.3.1/components/bt/host/bluedroid/stack/smp/smp_act.c:1548:5: error: 'else' without a previous 'if'
else {
^~~~

检查源代码是下面这样的,看来这个程序员水平不咋的。
  1. /*******************************************************************************
  2. ** Function     smp_fast_conn_param
  3. ** Description  apply default connection parameter for pairing process
  4. *******************************************************************************/
  5. void smp_fast_conn_param(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
  6. {
  7. #if (BT_MULTI_CONNECTION_ENBALE == FALSE)
  8.     if(p_cb->role == BTM_ROLE_MASTER) {
  9.         L2CA_EnableUpdateBleConnParams(p_cb->pairing_bda, FALSE);
  10.     }
  11. #endif
  12. #if (SMP_SLAVE_CON_PARAMS_UPD_ENABLE == TRUE)
  13.     else {
  14.         tBTM_SEC_DEV_REC    *p_rec = btm_find_dev (p_cb->pairing_bda);
  15.         if(p_rec && p_rec->ble.skip_update_conn_param) {
  16.             //do nothing
  17.             return;
  18.         }
  19.         /* Disable L2CAP connection parameter updates while bonding since
  20.         some peripherals are not able to revert to fast connection parameters
  21.         during the start of service discovery. Connection paramter updates
  22.         get enabled again once service discovery completes. */
  23.         #if (BT_MULTI_CONNECTION_ENBALE == FALSE)
  24.         L2CA_EnableUpdateBleConnParams(p_cb->pairing_bda, FALSE);
  25.         #endif
  26.     }
  27. #endif
  28. }

fland@126.com
Posts: 8
Joined: Thu Oct 28, 2021 2:46 am

Re: idf 4.3.1蓝牙驱动函数代码报错, 写的极不合理

Postby fland@126.com » Fri Dec 03, 2021 8:23 am

应该这样:
  1. void smp_fast_conn_param(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
  2. {
  3. #if (BT_MULTI_CONNECTION_ENBALE == FALSE)
  4.     if(p_cb->role == BTM_ROLE_MASTER) {
  5.         L2CA_EnableUpdateBleConnParams(p_cb->pairing_bda, FALSE);
  6.     }
  7. #if (SMP_SLAVE_CON_PARAMS_UPD_ENABLE == TRUE)
  8.     else {
  9.         tBTM_SEC_DEV_REC    *p_rec = btm_find_dev (p_cb->pairing_bda);
  10.         if(p_rec && p_rec->ble.skip_update_conn_param) {
  11.             //do nothing
  12.             return;
  13.         }
  14.         /* Disable L2CAP connection parameter updates while bonding since
  15.         some peripherals are not able to revert to fast connection parameters
  16.         during the start of service discovery. Connection paramter updates
  17.         get enabled again once service discovery completes. */
  18.         #if (BT_MULTI_CONNECTION_ENBALE == FALSE)
  19.         L2CA_EnableUpdateBleConnParams(p_cb->pairing_bda, FALSE);
  20.         #endif
  21.     }
  22. #endif
  23. #endif
  24. }

ESP_ICY
Posts: 404
Joined: Mon Aug 23, 2021 11:10 am

Re: idf 4.3.1蓝牙驱动函数代码报错, 写的极不合理

Postby ESP_ICY » Fri Dec 03, 2021 10:04 am

感谢指正,请把这个问题反馈在https://github.com/espressif/esp-idf/issues

Who is online

Users browsing this forum: No registered users and 46 guests