Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending AVRCP commands #7

Open
lmore377 opened this issue Mar 22, 2021 · 11 comments
Open

Sending AVRCP commands #7

lmore377 opened this issue Mar 22, 2021 · 11 comments

Comments

@lmore377
Copy link

I figured out how to send some AVRCP commands. Basically you just run this, replacing <command> with one of the commands below.

esp_avrc_ct_send_passthrough_cmd(0, <command>, ESP_AVRC_PT_CMD_STATE_PRESSED);

You can see all the commands here but it seems like only the ones below work (I tried just the hex codes for other commands but my phone didn't respond to any except these. I don't know if they're not supported by the avrc library or my phone).

ESP_AVRC_PT_CMD_PLAY
ESP_AVRC_PT_CMD_STOP
ESP_AVRC_PT_CMD_PAUSE
ESP_AVRC_PT_CMD_FORWARD
ESP_AVRC_PT_CMD_BACKWARD
ESP_AVRC_PT_CMD_REWIND
ESP_AVRC_PT_CMD_FAST_FORWARD

You can see more info about that specific method here.

@tierneytim
Copy link
Owner

Great Idea to get these commands built-in. I've been snowed under by work recently But I can see the light again and will add this to the to-do list.

@biglee991228
Copy link

I tested but only "play","stop" and "pause" functions worked.
here's my loop()
if(Serial.available()){
//read until a terminator. after this point there should only be numbers
command = Serial.readStringUntil('#');
if(command.equals("play")){
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_PLAY, ESP_AVRC_PT_CMD_STATE_PRESSED);
Serial.println("play");
}
if(command.equals("pause")){
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_PAUSE, ESP_AVRC_PT_CMD_STATE_PRESSED);
Serial.println("pause");
}
if(command.equals("FF")){
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_FAST_FORWARD, ESP_AVRC_PT_CMD_STATE_PRESSED);
Serial.println("fast_forward");
}
if(command.equals("RW")){
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_REWIND, ESP_AVRC_PT_CMD_STATE_PRESSED);
Serial.println("rewind");
}
if(command.equals("stop")){
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_STOP, ESP_AVRC_PT_CMD_STATE_PRESSED);
Serial.println("stop");
}
if(command.equals("forward")){
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_FORWARD, ESP_AVRC_PT_CMD_STATE_PRESSED);
Serial.println("forward");
}
if(command.equals("backward")){
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_BACKWARD, ESP_AVRC_PT_CMD_STATE_PRESSED);
Serial.println("backward");
}
}

@lmore377
Copy link
Author

@biglee991228 fast forward and rewind didn't work for me either but everything else does. Have you tried using a different app and/or device?

@biglee991228
Copy link

@lmore377
I got it!
if(Serial.available()){
//read until a terminator. after this point there should only be numbers
command = Serial.readStringUntil('#');
if(command.equals("play")){
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_PLAY, ESP_AVRC_PT_CMD_STATE_PRESSED);
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_PLAY, ESP_AVRC_PT_CMD_STATE_RELEASED);
Serial.println("play");
}
if(command.equals("pause")){
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_PAUSE, ESP_AVRC_PT_CMD_STATE_PRESSED);
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_PAUSE, ESP_AVRC_PT_CMD_STATE_RELEASED);
Serial.println("pause");
}
if(command.equals("stop")){
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_STOP, ESP_AVRC_PT_CMD_STATE_PRESSED);
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_STOP, ESP_AVRC_PT_CMD_STATE_RELEASED);
Serial.println("stop");
}
if(command.equals("forward")){
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_FORWARD, ESP_AVRC_PT_CMD_STATE_PRESSED);
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_FORWARD, ESP_AVRC_PT_CMD_STATE_RELEASED);
Serial.println("forward");
}
if(command.equals("backward")){
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_BACKWARD, ESP_AVRC_PT_CMD_STATE_PRESSED);
esp_avrc_ct_send_passthrough_cmd(0, ESP_AVRC_PT_CMD_BACKWARD, ESP_AVRC_PT_CMD_STATE_RELEASED);
Serial.println("backward");
}
}
don't forget "RELEASED“!

@lmore377
Copy link
Author

My device doesn't seem to need/respond to the released commands but I'll keep that in mind if something pops up

@biglee991228
Copy link

my phone can be controlled by my chevey car (linux OS),so it must can be controlled by the passthrough command from ESP32.
because the AVRCP profile is the same thing.

@haldi4803
Copy link

Great idea.
I have 3 buttons on my EPS32 board which seems like a perfect use case for that!

@ES-KO
Copy link

ES-KO commented Apr 27, 2021

Is it somehow possible to detect, if the device is connected?

@tierneytim
Copy link
Owner

for checking connection events see here . I could add a variable to the class that monitors this connection.

@ES-KO
Copy link

ES-KO commented May 17, 2021

That would be pretty cool,
cause my programing skills are just on a basic level …

@brad-colbert
Copy link

brad-colbert commented Jul 5, 2021

What about "receiving" volume control commands? Is that possible (assuming my streaming device sends them)?

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

No branches or pull requests

6 participants