aed3 / PS4-esp32

Use a ps4 controller with an esp32
328 stars 103 forks source link

error: 'ESP_BT_CONNECTABLE' undeclared (first use in this function) #31

Closed FluffuKarma closed 2 years ago

FluffuKarma commented 2 years ago

I get this error when I try to compile the examples:

C:\Users\emili\Documents\Arduino\libraries\PS4-esp32-master\src\ps4_spp.c: In function 'sppCallback':

C:\Users\emili\Documents\Arduino\libraries\PS4-esp32-master\src\ps4_spp.c:87:30: error: 'ESP_BT_CONNECTABLE' undeclared (first use in this function)

     esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_NON_DISCOVERABLE);

                              ^

C:\Users\emili\Documents\Arduino\libraries\PS4-esp32-master\src\ps4_spp.c:87:30: note: each undeclared identifier is reported only once for each function it appears in

C:\Users\emili\Documents\Arduino\libraries\PS4-esp32-master\src\ps4_spp.c:87:50: error: 'ESP_BT_NON_DISCOVERABLE' undeclared (first use in this function)

     esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_NON_DISCOVERABLE);

                                                  ^

C:\Users\emili\Documents\Arduino\libraries\PS4-esp32-master\src\ps4_spp.c:87:5: error: too many arguments to function 'esp_bt_gap_set_scan_mode'

     esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_NON_DISCOVERABLE);

     ^

In file included from C:\Users\emili\Documents\Arduino\libraries\PS4-esp32-master\src\ps4_spp.c:4:0:

C:\Users\emili\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6/tools/sdk/include/bt/esp_gap_bt_api.h:370:11: note: declared here

 esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode);

           ^

exit status 1
Error compiling for board DOIT ESP32 DEVKIT V1.
JavadRah commented 2 years ago

just update your library and ESP board to the latest version and try again.

JGuillotinE commented 2 years ago

Yes the same error has occurred with me and I have done both update library and ESP board:

Owl-In-Bowl commented 2 years ago

same for me, i tried with different version of the esp32 board inside the Arduino IDE, but the issue seems to come from the library itself. using the ESP32 devModule

FluffuKarma commented 2 years ago

I fixed the issue by changing

#if CONFIG_IDF_COMPATIBILITY >= IDF_COMPATIBILITY_MASTER_D9CE0BB
    esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_NON_DISCOVERABLE);
#elif CONFIG_IDF_COMPATIBILITY >= IDF_COMPATIBILITY_MASTER_21AF1D7
    esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE);
#endif

to

//#if CONFIG_IDF_COMPATIBILITY >= IDF_COMPATIBILITY_MASTER_D9CE0BB
    //esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_NON_DISCOVERABLE);
//#elif CONFIG_IDF_COMPATIBILITY >= IDF_COMPATIBILITY_MASTER_21AF1D7
    esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE);
//#endif

at line 86 in ps4_spp.c of the library