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

Implementing metadata on Arduino IDE #29

Closed
GregOneX opened this issue Jan 21, 2021 · 3 comments
Closed

Implementing metadata on Arduino IDE #29

GregOneX opened this issue Jan 21, 2021 · 3 comments

Comments

@GregOneX
Copy link

Hello, recently I've discovered this awesome library which helped me make my project a lot easier. As adding an OLED display and an ADC took only a few lines of code. The thing is that I don't know how to implement the "send_metadata_cmd" as well as CASE "ESP_AVRC_CT_METADATA_RSP_EVT" so that I could store these attributes to some variables on Arduino IDE.

Adding this code: esp_avrc_ct_send_metadata_cmd(0, ESP_AVRC_MD_ATTR_TITLE); to void loop() compiled successfully, but I just can't confirm it works as I mentioned above.

If someone already tried this, I would really appreciate the help, as I just can't seem to find answers.

Best regards,
Greg

@lukaszradziak
Copy link

try add:

BluetoothA2DPSink.h:

public:
  virtual void set_AVRC_metadata(void (*callBack)(uint8_t, const uint8_t*));

protected:
  void (*AVRC_metadata)(uint8_t, const uint8_t*) = NULL;

BluetoothA2DPSink.cpp

void BluetoothA2DPSink::set_AVRC_metadata(void (*callBack)(uint8_t, const uint8_t*)){
   this->AVRC_metadata = callBack;
}

and replace:

case ESP_AVRC_CT_METADATA_RSP_EVT: {
ESP_LOGI(BT_AV_TAG, "AVRC metadata rsp: attribute id 0x%x, %s", rc->meta_rsp.attr_id, rc->meta_rsp.attr_text);
free(rc->meta_rsp.attr_text);
break;
}

 case ESP_AVRC_CT_METADATA_RSP_EVT: {
        if (AVRC_metadata!=NULL){
            AVRC_metadata(rc->meta_rsp.attr_id, rc->meta_rsp.attr_text);
        }
        ESP_LOGI(BT_AV_TAG, "AVRC metadata rsp: attribute id 0x%x, %s", rc->meta_rsp.attr_id, rc->meta_rsp.attr_text);
        free(rc->meta_rsp.attr_text);
        break;
}

and in project:

void avrc_metadata_callback(uint8_t data1, const uint8_t *data2)
{
  Serial.printf("AVRC metadata rsp: attribute id 0x%x, %s\n", data1, data2);
}
a2dp_sink.set_AVRC_metadata(avrc_metadata_callback);
a2dp_sink.start("BT");

@biglee991228
Copy link

@lukasilestam
thanks a lot !
I got it and successed
ESP_LOGD(BT_AV_TAG, "%s", func);
//Register notifications and request metadata
esp_avrc_ct_send_metadata_cmd(0, ESP_AVRC_MD_ATTR_TITLE | ESP_AVRC_MD_ATTR_ARTIST | ESP_AVRC_MD_ATTR_ALBUM | ESP_AVRC_MD_ATTR_GENRE | ESP_AVRC_MD_ATTR_PLAYING_TIME);//
esp_avrc_ct_send_register_notification_cmd(1, ESP_AVRC_RN_TRACK_CHANGE, 0);
and I added "ESP_AVRC_MD_ATTR_PLAYING_TIME"

@pschatzmann
Copy link
Owner

I have add this logic to the basic code.
Please note that the method to register the callback is called:

a2dp_sink.set_avrc_metadata_callback

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

4 participants