ESP32-Bluetooth-BLE-Remote-Control
ESP32-Bluetooth-BLE-Remote-Control copied to clipboard
Serial monitor is not displaying the right buttons
Hello,
I would like to thank you so much for your awesome work. It is very clear and well documented. Thanks to your code, I managed to create a connection between my esp32 dev board and my VR Box controller. Triggers and joystick are working perfectly. But the "B" buttons is not showing on the serial monitor. About the A, C and D, I let you see this pdf that shows my serial monitor : https://www.dropbox.com/s/9yv8pdn48ai4nl9/VRBOX%20buttons%20not%20working.pdf?dl=0
Could you help me to make the serial monitor displays the right buttons please ?
Again, thank you for your work, it helps me a lot !
Hello i helped @aelghozi solve the problem "in real life", the problem was caused by a different version of the controler and of the firmware. The difference is in the data sent when A or B are pressed. The second byte (pData[1]) is equal to 0x50 when A or B pressed. And the first byte (pData[0]) is equal to 0X01 when A is pressed and equal to 0X02 when B is pressed.
As you can see in the following link A and B are reverse compared to the other version of the VR box : https://www.miniplanes.fr/telecommande-bluetooth-pour-casques-vr#tabs-description
The following diff shows the change i made to make it work. It has been tested and seems to work fine.
@@ -63,8 +63,8 @@ enum
// ===== VR Box Button Masks =====
#define VB_LOW_TRIGGER 0x01
#define VB_UPR_TRIGGER 0x02
-#define VB_BUTTON_A 0x10
-#define VB_BUTTON_B 0x20
+#define VB_BUTTON_A 0x01
+#define VB_BUTTON_B 0x02
#define VB_BUTTON_C 0x01
#define VB_BUTTON_D 0x02
#define FRESHFLAG 0x80
@@ -192,10 +192,11 @@ static void notifyCallback(
else if (2 == length)
{
// show the received data
- if (0x05 == (pData[0] & 0x0F))
+ if (pData[1] == 0x50)
{
+
// A/B button report, wake the A/B button handler task
- VrBoxData[VB_BTNAB] = pData[0] & 0xF0;
+ VrBoxData[VB_BTNAB] = pData[0] & 0x0F;
if (HandleAB)
vTaskResume(HandleAB);
}