hello, i am using the A2DP_SINK example from de SDK. I need to work with the data wich comes from the bluetooth but i am strugling quite a lot. I see on a post that you can "intercept" the data in the write_ringbuf from the app_core, using a function that takes de *data and returning the new data to use:
size_t write_ringbuf(const uint8_t *data, size_t size)
{
size_t item_size = 0;
BaseType_t done = pdFALSE;
if (ringbuffer_mode == RINGBUFFER_MODE_DROPPING) {
//ESP_LOGW(BT_APP_CORE_TAG, "ringbuffer is full, drop this packet!");
vRingbufferGetInfo(s_ringbuf_i2s, NULL, NULL, NULL, NULL, &item_size);
if (item_size <= RINGBUF_PREFETCH_WATER_LEVEL) {
//ESP_LOGI(BT_APP_CORE_TAG, "ringbuffer data decreased! mode changed: RINGBUFFER_MODE_PROCESSING");
ringbuffer_mode = RINGBUFFER_MODE_PROCESSING;
}
return 0;
}
// codigo que agrego
uint8_t *volumedData = (uint8_t *)malloc(sizeof(uint8_t)*size);
done = xRingbufferSend(s_ringbuf_i2s,(void*) volume_control_changeVolume(data, volumedData, size, master_volume) , size, portMAX_DELAY);
// data
free(volumedData);
// fin codigo que agrego
//done = xRingbufferSend(s_ringbuf_i2s, (void *)data, size, (TickType_t)0);
if (!done) {
//ESP_LOGW(BT_APP_CORE_TAG, "ringbuffer overflowed, ready to decrease data! mode changed: RINGBUFFER_MODE_DROPPING");
ringbuffer_mode = RINGBUFFER_MODE_DROPPING;
}
if (ringbuffer_mode == RINGBUFFER_MODE_PREFETCHING) {
vRingbufferGetInfo(s_ringbuf_i2s, NULL, NULL, NULL, NULL, &item_size);
if (item_size >= RINGBUF_PREFETCH_WATER_LEVEL) {
//ESP_LOGI(BT_APP_CORE_TAG, "ringbuffer data increased! mode changed: RINGBUFFER_MODE_PROCESSING");
ringbuffer_mode = RINGBUFFER_MODE_PROCESSING;
if (pdFALSE == xSemaphoreGive(s_i2s_write_semaphore)) {
//ESP_LOGE(BT_APP_CORE_TAG, "semphore give failed");
}
}
}
return done ? size : 0;
}
however i am quite stack because i have no idea which is the format off the data. The data is the same as a normal PCMdata like an MP3 data format? Or is diferrent?
I thought that the data was given as :
LEFT_CHANEL_FIRST8bit , LEFT_CHANEL_SECOND8bit, RIGHT_CHANEL_FIRST8bit , RIGHT_CHANEL_SECOND8bit
so my code to recover the data was:
uint8_t *volume_control_changeVolume(const uint8_t *data, uint8_t *outputData, size_t size, uint8_t volume) {
const int numBytesShifted = 2;
uint8_t my_volume = 16;
int16_t pcmData;
int channel = 0;
memcpy(outputData, data, size);
size_t h = 0;
for (h = 0; h < size; h += numBytesShifted) {
printf("%d",data[h]);
printf("%d",data[h+1]);
pcmData = ((uint16_t) data[h +1 ] << 8) | data[h];
xQueueSend(queue_data_out,&pcmData,0);
}
return outputData;
}
but that does not work for me to recover the data and work with them.
.
Any help is welcome!
Bluetooth example question
-
- Posts: 1
- Joined: Thu Dec 07, 2023 2:48 pm
Return to “General Discussion”
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: No registered users and 88 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.