Bluetooth connection of PS4 controller and RemoteXY interface

BWV999
Posts: 2
Joined: Mon Jun 24, 2024 7:06 pm

Bluetooth connection of PS4 controller and RemoteXY interface

Postby BWV999 » Fri Jun 28, 2024 4:17 pm

I am trying to connect a PS4 controller and display an interface on a phone using the RemoteXY library. Both function properly on separate sketches, but if i combine them, the connection to one device or the other is not possible. The order in which i call PS4.begin("C0:49:EF:E7:CD:5E"); or RemoteXY_Init (); determines wich one is working. I suspect some conflict in the BT serial configuration, but the initialisation code is in the libraries. I have trouble navigating the library functions to determine the origin of the problem. Here are both libraries in question:

https://github.com/RemoteXY/RemoteXY-Arduino-library
https://github.com/xman4242/PS4-ESP32

Here is my arduino code
  1. #include <PS4Controller.h>
  2. #include <ps4.h>
  3. #include <ps4_int.h>
  4.  
  5. //////////////////////////////////////////////
  6. //        RemoteXY include library          //
  7. //////////////////////////////////////////////
  8.  
  9. // you can enable debug logging to Serial at 115200
  10. //#define REMOTEXY__DEBUGLOG    
  11.  
  12. // RemoteXY select connection mode and include library
  13. #define REMOTEXY_MODE__ESP32CORE_BLUETOOTH
  14.  
  15. #include <BluetoothSerial.h>
  16.  
  17. // RemoteXY connection settings
  18. #define REMOTEXY_BLUETOOTH_NAME "RemoteXY"
  19.  
  20.  
  21. #include <RemoteXY.h>
  22.  
  23. // RemoteXY GUI configuration  
  24. #pragma pack(push, 1)  
  25. uint8_t RemoteXY_CONF[] =   // 55 bytes
  26.   { 255,12,0,11,0,48,0,17,0,0,0,31,1,106,200,1,1,3,0,2,
  27.   18,36,44,22,0,2,26,31,31,79,78,0,79,70,70,0,7,51,77,40,
  28.   10,36,2,26,2,11,67,6,77,40,10,4,2,26,11 };
  29.  
  30. // this structure defines all the variables and events of your control interface
  31. struct {
  32.  
  33.     // input variables
  34.   uint8_t switch_01; // =1 if switch ON and =0 if OFF
  35.   char edit_01[11]; // string UTF8 end zero
  36.  
  37.     // output variables
  38.   char text_01[11]; // string UTF8 end zero
  39.  
  40.     // other variable
  41.   uint8_t connect_flag;  // =1 if wire connected, else =0
  42.  
  43. } RemoteXY;  
  44. #pragma pack(pop)
  45.  
  46. /////////////////////////////////////////////
  47. //           END RemoteXY include          //
  48. /////////////////////////////////////////////
  49.  
  50.  
  51.  
  52. const byte pin_sortie_relais_alimentation = 12;
  53. byte dernier_etat_switch_01 = 0;
  54.  
  55. void setup()
  56. {
  57.   Serial.begin(115200);
  58.   PS4.begin("C0:49:EF:E7:CD:5E"); //ESP
  59.   RemoteXY_Init ();
  60.  
  61.   pinMode(pin_sortie_relais_alimentation, OUTPUT);
  62.   digitalWrite(pin_sortie_relais_alimentation, RemoteXY.switch_01);
  63.  
  64.   Serial.println("adresse MAC BT");
  65.  
  66.   uint8_t baseMac[6];
  67.   // Get the MAC address of the Bluetooth interface
  68.   esp_read_mac(baseMac, ESP_MAC_BT);
  69.   Serial.print("Bluetooth MAC: ");
  70.   for (int i = 0; i < 5; i++) {
  71.     Serial.printf("%02X:", baseMac[i]);
  72.   }
  73.   Serial.printf("%02X\n", baseMac[5]);
  74.   Serial.println("");
  75. }
  76.  
  77. void loop()
  78. {
  79.   RemoteXY_Handler ();
  80.  
  81.   if (RemoteXY.switch_01 != dernier_etat_switch_01){
  82.     dernier_etat_switch_01 = RemoteXY.switch_01;
  83.     digitalWrite(pin_sortie_relais_alimentation, RemoteXY.switch_01);
  84.     //Serial.println("Relais : " + switch_01);
  85.   }
  86.   itoa(millis(), RemoteXY.text_01, 10);
  87.   //if (PS4.Circle()) Serial.println("Circle Button");
  88.  
  89. }

Who is online

Users browsing this forum: No registered users and 110 guests