diff --git a/src/ps4_int.h b/src/ps4_int.h index 145cc70..c400978 100644 --- a/src/ps4_int.h +++ b/src/ps4_int.h @@ -19,14 +19,49 @@ #endif // ARDUINO_ARCH_ESP32 /** ESP-IDF compatibility configuration option choices */ -#define IDF_COMPATIBILITY_MASTER_21165ED 3 -#define IDF_COMPATIBILITY_MASTER_D9CE0BB 2 -#define IDF_COMPATIBILITY_MASTER_21AF1D7 1 +// #define IDF_COMPATIBILITY_MASTER_21165ED 3 +// #define IDF_COMPATIBILITY_MASTER_D9CE0BB 2 +// #define IDF_COMPATIBILITY_MASTER_21AF1D7 1 -#ifndef CONFIG_IDF_COMPATIBILITY -#define CONFIG_IDF_COMPATIBILITY IDF_COMPATIBILITY_MASTER_21165ED +// #ifndef CONFIG_IDF_COMPATIBILITY +// #define CONFIG_IDF_COMPATIBILITY IDF_COMPATIBILITY_MASTER_21165ED + +/* Detect ESP-IDF releases */ +#if __has_include("esp_idf_version.h") +#include + +#else + +/* Detect Arduino releases */ +#if __has_include("core_version.h") +#include +#endif + +/* Arduino releases using IDF v3.2.3 */ +#if defined(ARDUINO_ESP32_RELEASE_1_0_4) || defined(ARDUINO_ESP32_RELEASE_1_0_3) +#define ESP_IDF_VERSION_MAJOR 3 +#define ESP_IDF_VERSION_MINOR 2 +#define ESP_IDF_VERSION_PATCH 3 #endif +/* Arduino releases using IDF v3.2.2 */ +#if defined(ARDUINO_ESP32_RELEASE_1_0_3) || defined(ARDUINO_ESP32_RELEASE_1_0_2) || defined(ARDUINO_ESP32_RELEASE_1_0_1) || defined(ARDUINO_ESP32_RELEASE_1_0_0) +#define ESP_IDF_VERSION_MAJOR 3 +#define ESP_IDF_VERSION_MINOR 2 +#define ESP_IDF_VERSION_PATCH 2 +#endif + +// Macro to convert IDF version number into an integer +#define ESP_IDF_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch)) + +// Current IDF version, as an integer +#define ESP_IDF_VERSION ESP_IDF_VERSION_VAL(ESP_IDF_VERSION_MAJOR, \ + ESP_IDF_VERSION_MINOR, \ + ESP_IDF_VERSION_PATCH) + +#endif // __has_include("esp_idf_version.h") + + /** Size of the output report buffer for the Dualshock and Navigation * controllers */ #define PS4_SEND_BUFFER_SIZE 77 diff --git a/src/ps4_spp.c b/src/ps4_spp.c index b3f6b1a..dbda7d9 100644 --- a/src/ps4_spp.c +++ b/src/ps4_spp.c @@ -83,9 +83,11 @@ static void sppCallback(esp_spp_cb_event_t event, esp_spp_cb_param_t* param) { ESP_LOGI(PS4_TAG, "ESP_SPP_INIT_EVT"); esp_bt_dev_set_device_name("ESP Host"); -#if CONFIG_IDF_COMPATIBILITY >= IDF_COMPATIBILITY_MASTER_D9CE0BB +// #if CONFIG_IDF_COMPATIBILITY >= IDF_COMPATIBILITY_MASTER_D9CE0BB +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_NON_DISCOVERABLE); -#elif CONFIG_IDF_COMPATIBILITY >= IDF_COMPATIBILITY_MASTER_21AF1D7 +// #elif CONFIG_IDF_COMPATIBILITY >= IDF_COMPATIBILITY_MASTER_21AF1D7 +#else esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE); #endif