PS4-esp32 icon indicating copy to clipboard operation
PS4-esp32 copied to clipboard

reliable indicator for out of range?

Open beta-tester opened this issue 4 years ago • 4 comments

hi, at first, thank you for the great library!

i want to use this to remote control a toy car or robot.

i just tried out the example PS4SendData.ino and noticed, when i reach the maximum range of the bluetooth communication, i receive on the log the following message each time the PS4.sendToController() method fails:

E (1052482) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: failed

then i realized that PS4.isConnected() is not a good indicator to see that i am just out of range with my PS4 controller, because it still gives true in that situation.

using this error message would be mutch better as an indicator when i am just out of range.

unfortunately PS4.sendToController() isn't giving any return value/error code. would it be possible to pass through the error value so that it is possible to react to an error?

or is there another better way to see when the PS4 controler is just out of range?

beta-tester avatar Oct 12 '21 16:10 beta-tester

using this error message would be mutch better as an indicator when i am just out of range.

unfortunately PS4.sendToController() isn't giving any return value/error code. would it be possible to pass through the error value so that it is possible to react to an error?

no, i found out that i not get those error messages that often, when i already get lost the control of my toy, if i increade the delay value slightly in the main loop.

so i try to see if i can look at the lastPacket if there is something like a timestamp that will change periodically. if it does not change anymore, then i am out of range and can ingage an emergency stop in my toy.

beta-tester avatar Oct 14 '21 06:10 beta-tester

@beta-tester can you share your source code?

JavadRah avatar Oct 14 '21 15:10 JavadRah

at the moment it is just the example code of PS4SendData.ino. i just changed the delay from 10 to 20 to 50 and with 50 didn't got the error messages that early as with a delay of 10 or 20, even i already lost the control and the rumble of the controller didn't followed the triggers L2 & R2 anymore until i steped closer to the ESP32 again.

#include <PS4Controller.h>

void setup() {
  Serial.begin(115200);

  PS4.begin("1a:2b:3c:01:01:01");
  Serial.println("Ready.");
}

void loop() {
  if (PS4.isConnected()) {
    PS4.setRumble(PS4.L2Value(), PS4.R2Value());
    PS4.sendToController();
    delay(50);
  }
}

beta-tester avatar Oct 14 '21 18:10 beta-tester

I think your problem is the same as #26 ! Can you downgrade your ESP board to 1.0.4 and download commit before #25 (commit number 35f2caa258) and test it again?

JavadRah avatar Oct 17 '21 05:10 JavadRah