Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

reliable indicator for out of range? #28

Open
beta-tester opened this issue Oct 12, 2021 · 4 comments
Open

reliable indicator for out of range? #28

beta-tester opened this issue Oct 12, 2021 · 4 comments

Comments

@beta-tester
Copy link

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
Copy link
Author

beta-tester commented Oct 14, 2021

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.

@JavadRah
Copy link

@beta-tester can you share your source code?

@beta-tester
Copy link
Author

beta-tester commented Oct 14, 2021

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);
  }
}

@JavadRah
Copy link

JavadRah commented Oct 17, 2021

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 35f2caa) and test it again?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants