A2DP Source using I2S input

ChrisP
Posts: 3
Joined: Wed Sep 05, 2018 12:27 pm

A2DP Source using I2S input

Postby ChrisP » Thu Sep 06, 2018 12:59 pm

Hey all,

I've been successful in adapting the A2DP Sink example into a functional (and tested) BT speaker on one ESP32, and now I want to be able to send data to it using another ESP32 running as an A2DP source - getting its audio input from I2S input.

So far I've been unable to achieve this. The code below is what I have added to the provided A2DP source example provided in the ESP-IDF - I've tried playing with it a bit, but no joy. My source identifies and connects to the sink, and begins streaming data, but the data received by the sink is pretty much just noise.

The part in really uncertain about is the 'bt_app_a2d_data_cb' function. I'm pretty sure this is where I need to deal with the input signal for the A2DP source, but I don't really understand this part of the code. I've looked through the function definitions, but I still can't seem to find any meaningful explanation of the 'i2s_read' function or the 'bt_app_a2d_data_cb'. I don't seem to be able to view the code implementations of the 'i2s_read' or 'bt_app_a2d_data_cb'.. I can only see definitions (using eclipse).

All my physical connections to the module are legit. Also, this is my first experience using any RTOS.

I would appreciate some assistance with this, I would like to be able to fix and understand the problem.


Code: Select all


    //***************************************************************
    //****** CONFIG I2S RX ***************************************
    i2s_config_t i2s_config = {
        .mode 				= I2S_MODE_SLAVE | I2S_MODE_RX,
        .sample_rate 			= 44100,
        .bits_per_sample 		= 16,
        .channel_format 		= I2S_CHANNEL_FMT_RIGHT_LEFT,
        .communication_format 	= I2S_COMM_FORMAT_I2S,
        .dma_buf_count 		= 6,
        .dma_buf_len 			= 60,
        .intr_alloc_flags	 	= ESP_INTR_FLAG_LEVEL1
    };

    i2s_driver_install(0, &i2s_config, 0, NULL);

    i2s_pin_config_t pin_config = {
        .bck_io_num 			= CONFIG_I2S_BCK_PIN,
        .ws_io_num 			= CONFIG_I2S_LRCK_PIN,
        .data_out_num 		= -1,
        .data_in_num 			= CONFIG_I2S_DATA_PIN
    };

    i2s_set_pin(0, &pin_config);
    //****** I2S RX CONFIG END  ***********************************
    //*******************************************************************
    



Code: Select all


static int32_t bt_app_a2d_data_cb(uint8_t *data, int32_t len)
{
    if (len < 0 || data == NULL) {
        return 0;
    }

    //size_t bytes_written;
    i2s_read(0, data, len, bytes_written, portMAX_DELAY);
    if (++m_pkt_cnt % 100 == 0) {
    	ESP_LOGI(BT_AV_TAG, "Audio packet count %u", m_pkt_cnt);
    }

    return len;
}





Cheers,
Chris.

gguereque
Posts: 3
Joined: Wed Mar 25, 2020 7:03 pm

Re: A2DP Source using I2S input

Postby gguereque » Wed Apr 15, 2020 6:45 pm

Did you find a good response to solve this issue? I'm stuck exactly in this point.

Regards,

Who is online

Users browsing this forum: Bing [Bot] and 109 guests