I tried the library on Arduino and it works correctly. Now I tried to use it on esp-idf project it didn't work. First i got many compilation errors. After that I checked on every code file and tried to customize the library as I wish. This is my project tree:
I managed to successfully build the project. So here is the main file code:
// Convert the MAC address string to a byte array
if (sscanf(mac, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
&addr[0], &addr[1], &addr[2],
&addr[3], &addr[4], &addr[5]) != 6) {
ESP_LOGE(PS4_TAG, "Could not convert %s to a MAC address", mac);
return false;
}
ps4SetBluetoothMacAddress(addr);
// Set the event and connection callbacks
ps4SetEventCallback(event_callback);
ps4SetConnectionCallback(connection_callback);
// Initialize NVS — it is used by the PS4 library to store the paired devices list
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
// Initialize and enable Bluedroid stack if necessary
esp_bluedroid_status_t btState = esp_bluedroid_get_status();
if (btState == ESP_BLUEDROID_STATUS_UNINITIALIZED) {
if (esp_bluedroid_init() != ESP_OK) {
ESP_LOGE(PS4_TAG, "esp_bluedroid_init failed");
return false;
}
}
if (btState != ESP_BLUEDROID_STATUS_ENABLED) {
if (esp_bluedroid_enable() != ESP_OK) {
ESP_LOGE(PS4_TAG, "esp_bluedroid_enable failed");
return false;
}
}
// Initialize the PS4 controller
ps4Init();
return true;
}
`
and here is the output:
So this is a problem in bluetooth configd. But I already tried all kind of configs and i have the same error.
I know that i am using ps4 controller library not ps3. However i believe it is similar issue. (also the ps4 repo is not active anymore so you are my last resort)
I tried the library on Arduino and it works correctly. Now I tried to use it on esp-idf project it didn't work. First i got many compilation errors. After that I checked on every code file and tried to customize the library as I wish. This is my project tree: I managed to successfully build the project. So here is the main file code:
`
include
include
include "esp_system.h"
include "esp_mac.h"
include "esp_log.h"
include "nvs_flash.h"
include "ps4.h"
include "ps4_init.h"
define PS4_TAG "PS4"
void event_callback(ps4_t ps4, ps4_event_t event) { // Handle PS4 controller events here ESP_LOGI(PS4_TAG, "PS4 event received"); }
void connection_callback(uint8_t isConnected) { // Handle PS4 controller connection changes here if (isConnected) { ESP_LOGI(PS4_TAG, "PS4 controller connected"); } else { ESP_LOGI(PS4_TAG, "PS4 controller disconnected"); } }
bool ps4_controller_begin(const char* mac) { esp_bd_addr_t addr;
}
bool ps4_controller_init() { esp_bluedroid_status_t btState = esp_bluedroid_get_status();
}
void app_main() { if (ps4_controller_init()) { ps4_controller_begin("5c:96:56:ab:fa:40"); } //ps4_controller_begin("b8:94:36:5a:96:8e");
} ` and here is the output: So this is a problem in bluetooth configd. But I already tried all kind of configs and i have the same error. I know that i am using ps4 controller library not ps3. However i believe it is similar issue. (also the ps4 repo is not active anymore so you are my last resort)