Getting song metadata with AVRCP commands (classic bluetooth)
Posted: Fri Jul 28, 2017 5:42 pm
Hi.
I'm trying to get song metadata (title, album, artist, etc..) from the android phone connected to ESP32 via bluetooth.
Phone supports this feature, I tested it on raspberry pi.
I've compiled a2dp example code and got the phone to connect and stream music.
Then I used provided esp_avrc_ct_send_passthrough_cmd() function to send media button presses and that
is also working fine. I can see that media player on the phone responds to those commands.
esp-idf doesn't yet supports fetching metadata from target devices so I dug around to see how esp_avrc_ct_send_passthrough_cmd()
actually transfers passthrough commands. It has some hoops but ultimately it led me to BTA_AvRemoteCmd() in bt_av_api.c.
To confirm that this is the right function I constructed a new passthrough command and sent it with BTA_AvRemoteCmd().
Media player responded properly.
The same file (btw_av_api.c) contains BTA_AvMetaCmd() with the following comment: "Send a Metadata/Advanced Control command"
I had a bit of trouble constructing a proper message for the function since the documentation is very scarce but
I managed to find this volume setting code (line 1238) for android and ported it over. It doesn't work unfortunately.
I'm using a proper handle (btc_rc_vb.rc_handle). For transaction label I used 0x0, which should be ok since I don't have
consequtive messages.
Then I reconfigured it for metadata request (AVRC_PDU_GET_ITEM_ATTRIBUTES) but I still had no success.
There is also BTA_AvVendorCmd for sending vendor specific commands, which to my understanding can be used to
achieve the same effect since metadata is just a subset of vendor specific commands. It too doesn't't work.
I'm using Wireshark to capture packets on the smartphone side and I see AVRCP passthrough commands (play, pause, etc) but
no vendor specific commands (metadata) are ever received, not even a improperly formatted ones.
Am I missing something in the process? Feature mask from target (phone) says it supports vendor commands.
I'm trying to get song metadata (title, album, artist, etc..) from the android phone connected to ESP32 via bluetooth.
Phone supports this feature, I tested it on raspberry pi.
I've compiled a2dp example code and got the phone to connect and stream music.
Then I used provided esp_avrc_ct_send_passthrough_cmd() function to send media button presses and that
is also working fine. I can see that media player on the phone responds to those commands.
esp-idf doesn't yet supports fetching metadata from target devices so I dug around to see how esp_avrc_ct_send_passthrough_cmd()
actually transfers passthrough commands. It has some hoops but ultimately it led me to BTA_AvRemoteCmd() in bt_av_api.c.
To confirm that this is the right function I constructed a new passthrough command and sent it with BTA_AvRemoteCmd().
Media player responded properly.
The same file (btw_av_api.c) contains BTA_AvMetaCmd() with the following comment: "Send a Metadata/Advanced Control command"
I had a bit of trouble constructing a proper message for the function since the documentation is very scarce but
I managed to find this volume setting code (line 1238) for android and ported it over. It doesn't work unfortunately.
I'm using a proper handle (btc_rc_vb.rc_handle). For transaction label I used 0x0, which should be ok since I don't have
consequtive messages.
Then I reconfigured it for metadata request (AVRC_PDU_GET_ITEM_ATTRIBUTES) but I still had no success.
There is also BTA_AvVendorCmd for sending vendor specific commands, which to my understanding can be used to
achieve the same effect since metadata is just a subset of vendor specific commands. It too doesn't't work.
I'm using Wireshark to capture packets on the smartphone side and I see AVRCP passthrough commands (play, pause, etc) but
no vendor specific commands (metadata) are ever received, not even a improperly formatted ones.
Am I missing something in the process? Feature mask from target (phone) says it supports vendor commands.