Remove volume simulator
This commit is contained in:
2
ESP32/.vscode/settings.json
vendored
2
ESP32/.vscode/settings.json
vendored
@@ -9,7 +9,7 @@
|
|||||||
"interface/ftdi/esp32_devkitj_v1.cfg",
|
"interface/ftdi/esp32_devkitj_v1.cfg",
|
||||||
"target/esp32.cfg"
|
"target/esp32.cfg"
|
||||||
],
|
],
|
||||||
"idf.portWin": "COM3",
|
"idf.portWin": "COM5",
|
||||||
"idf.pythonBinPathWin": "C:\\Users\\ms\\.espressif\\python_env\\idf4.4_py3.8_env\\Scripts\\python.exe",
|
"idf.pythonBinPathWin": "C:\\Users\\ms\\.espressif\\python_env\\idf4.4_py3.8_env\\Scripts\\python.exe",
|
||||||
"idf.toolsPathWin": "C:\\Users\\ms\\.espressif",
|
"idf.toolsPathWin": "C:\\Users\\ms\\.espressif",
|
||||||
"idf.flashType": "UART"
|
"idf.flashType": "UART"
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ static const char *s_a2d_conn_state_str[] = {"Disconnected", "Connecting", "Conn
|
|||||||
static const char *s_a2d_audio_state_str[] = {"Suspended", "Stopped", "Started"};
|
static const char *s_a2d_audio_state_str[] = {"Suspended", "Stopped", "Started"};
|
||||||
static esp_avrc_rn_evt_cap_mask_t s_avrc_peer_rn_cap;
|
static esp_avrc_rn_evt_cap_mask_t s_avrc_peer_rn_cap;
|
||||||
static _lock_t s_volume_lock;
|
static _lock_t s_volume_lock;
|
||||||
static xTaskHandle s_vcs_task_hdl = NULL;
|
//static xTaskHandle s_vcs_task_hdl = NULL;
|
||||||
static uint8_t s_volume = 0;
|
static uint8_t s_volume = 0;
|
||||||
static bool s_volume_notify;
|
static bool s_volume_notify;
|
||||||
|
|
||||||
@@ -71,9 +71,9 @@ void bt_app_a2d_cb(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param)
|
|||||||
void bt_app_a2d_data_cb(const uint8_t *data, uint32_t len)
|
void bt_app_a2d_data_cb(const uint8_t *data, uint32_t len)
|
||||||
{
|
{
|
||||||
write_ringbuf(data, len);
|
write_ringbuf(data, len);
|
||||||
if (++s_pkt_cnt % 100 == 0) {
|
// if (++s_pkt_cnt % 100 == 0) {
|
||||||
ESP_LOGI(BT_AV_TAG, "Audio packet count %u", s_pkt_cnt);
|
// ESP_LOGI(BT_AV_TAG, "Audio packet count %u", s_pkt_cnt);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_app_alloc_meta_buffer(esp_avrc_ct_cb_param_t *param)
|
void bt_app_alloc_meta_buffer(esp_avrc_ct_cb_param_t *param)
|
||||||
@@ -297,32 +297,32 @@ static void volume_set_by_controller(uint8_t volume)
|
|||||||
_lock_release(&s_volume_lock);
|
_lock_release(&s_volume_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void volume_set_by_local_host(uint8_t volume)
|
// static void volume_set_by_local_host(uint8_t volume)
|
||||||
{
|
// {
|
||||||
ESP_LOGI(BT_RC_TG_TAG, "Volume is set locally to: %d%%", (uint32_t)volume * 100 / 0x7f);
|
// ESP_LOGI(BT_RC_TG_TAG, "Volume is set locally to: %d%%", (uint32_t)volume * 100 / 0x7f);
|
||||||
_lock_acquire(&s_volume_lock);
|
// _lock_acquire(&s_volume_lock);
|
||||||
s_volume = volume;
|
// s_volume = volume;
|
||||||
_lock_release(&s_volume_lock);
|
// _lock_release(&s_volume_lock);
|
||||||
|
|
||||||
if (s_volume_notify) {
|
// if (s_volume_notify) {
|
||||||
esp_avrc_rn_param_t rn_param;
|
// esp_avrc_rn_param_t rn_param;
|
||||||
rn_param.volume = s_volume;
|
// rn_param.volume = s_volume;
|
||||||
esp_avrc_tg_send_rn_rsp(ESP_AVRC_RN_VOLUME_CHANGE, ESP_AVRC_RN_RSP_CHANGED, &rn_param);
|
// esp_avrc_tg_send_rn_rsp(ESP_AVRC_RN_VOLUME_CHANGE, ESP_AVRC_RN_RSP_CHANGED, &rn_param);
|
||||||
s_volume_notify = false;
|
// s_volume_notify = false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
static void volume_change_simulation(void *arg)
|
// static void volume_change_simulation(void *arg)
|
||||||
{
|
// {
|
||||||
ESP_LOGI(BT_RC_TG_TAG, "start volume change simulation");
|
// ESP_LOGI(BT_RC_TG_TAG, "start volume change simulation");
|
||||||
|
|
||||||
for (;;) {
|
// for (;;) {
|
||||||
vTaskDelay(10000 / portTICK_RATE_MS);
|
// vTaskDelay(10000 / portTICK_RATE_MS);
|
||||||
|
|
||||||
uint8_t volume = (s_volume + 5) & 0x7f;
|
// uint8_t volume = (s_volume + 5) & 0x7f;
|
||||||
volume_set_by_local_host(volume);
|
// volume_set_by_local_host(volume);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
static void bt_av_hdl_avrc_tg_evt(uint16_t event, void *p_param)
|
static void bt_av_hdl_avrc_tg_evt(uint16_t event, void *p_param)
|
||||||
{
|
{
|
||||||
@@ -335,10 +335,10 @@ static void bt_av_hdl_avrc_tg_evt(uint16_t event, void *p_param)
|
|||||||
rc->conn_stat.connected, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
rc->conn_stat.connected, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||||
if (rc->conn_stat.connected) {
|
if (rc->conn_stat.connected) {
|
||||||
// create task to simulate volume change
|
// create task to simulate volume change
|
||||||
xTaskCreate(volume_change_simulation, "vcsT", 2048, NULL, 5, &s_vcs_task_hdl);
|
//xTaskCreate(volume_change_simulation, "vcsT", 2048, NULL, 5, &s_vcs_task_hdl);
|
||||||
} else {
|
} else {
|
||||||
vTaskDelete(s_vcs_task_hdl);
|
//vTaskDelete(s_vcs_task_hdl);
|
||||||
ESP_LOGI(BT_RC_TG_TAG, "Stop volume change simulation");
|
//ESP_LOGI(BT_RC_TG_TAG, "Stop volume change simulation");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,9 +33,6 @@
|
|||||||
#include "esp_avrc_api.h"
|
#include "esp_avrc_api.h"
|
||||||
#include "driver/i2s.h"
|
#include "driver/i2s.h"
|
||||||
|
|
||||||
//#define CONFIG_CLASSIC_BT_ENABLED 1
|
|
||||||
//#define CONFIG_BT_SPP_ENABLED 1
|
|
||||||
|
|
||||||
/* event for handler "bt_av_hdl_stack_up */
|
/* event for handler "bt_av_hdl_stack_up */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@@ -64,9 +61,6 @@ void app_main(void)
|
|||||||
.bits_per_sample = 16,
|
.bits_per_sample = 16,
|
||||||
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, // 2-channels
|
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, // 2-channels
|
||||||
.communication_format = I2S_COMM_FORMAT_STAND_I2S,
|
.communication_format = I2S_COMM_FORMAT_STAND_I2S,
|
||||||
//.communication_format = I2S_COMM_FORMAT_I2S,
|
|
||||||
//.dma_buf_count = 6,
|
|
||||||
//.dma_buf_len = 60,
|
|
||||||
.dma_buf_count = 8,
|
.dma_buf_count = 8,
|
||||||
.dma_buf_len = 64,
|
.dma_buf_len = 64,
|
||||||
.intr_alloc_flags = 0, // Default interrupt priority
|
.intr_alloc_flags = 0, // Default interrupt priority
|
||||||
@@ -76,14 +70,12 @@ void app_main(void)
|
|||||||
i2s_driver_install(i2s_num, &i2s_config, 0, NULL);
|
i2s_driver_install(i2s_num, &i2s_config, 0, NULL);
|
||||||
|
|
||||||
i2s_pin_config_t pin_config = {
|
i2s_pin_config_t pin_config = {
|
||||||
.bck_io_num = 25, //CONFIG_EXAMPLE_I2S_BCK_PIN,
|
.bck_io_num = 25,
|
||||||
.ws_io_num = 26, //CONFIG_EXAMPLE_I2S_LRCK_PIN,
|
.ws_io_num = 26,
|
||||||
.data_out_num = 33, //CONFIG_EXAMPLE_I2S_DATA_PIN,
|
.data_out_num = 33,
|
||||||
.data_in_num = I2S_PIN_NO_CHANGE
|
.data_in_num = I2S_PIN_NO_CHANGE};
|
||||||
};
|
|
||||||
i2s_set_pin(i2s_num, &pin_config);
|
i2s_set_pin(i2s_num, &pin_config);
|
||||||
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE));
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE));
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
@@ -129,13 +121,13 @@ void app_main(void)
|
|||||||
* Set default parameters for Legacy Pairing
|
* Set default parameters for Legacy Pairing
|
||||||
* Use fixed pin code
|
* Use fixed pin code
|
||||||
*/
|
*/
|
||||||
esp_bt_pin_type_t pin_type = ESP_BT_PIN_TYPE_FIXED;
|
// esp_bt_pin_type_t pin_type = ESP_BT_PIN_TYPE_FIXED;
|
||||||
esp_bt_pin_code_t pin_code;
|
// esp_bt_pin_code_t pin_code;
|
||||||
pin_code[0] = '1';
|
// pin_code[0] = '1';
|
||||||
pin_code[1] = '2';
|
// pin_code[1] = '2';
|
||||||
pin_code[2] = '3';
|
// pin_code[2] = '3';
|
||||||
pin_code[3] = '4';
|
// pin_code[3] = '4';
|
||||||
esp_bt_gap_set_pin(pin_type, 4, pin_code);
|
// esp_bt_gap_set_pin(pin_type, 4, pin_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_app_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
|
void bt_app_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
|
||||||
@@ -181,6 +173,7 @@ void bt_app_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
|
static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
|
||||||
{
|
{
|
||||||
ESP_LOGD(BT_AV_TAG, "%s evt %d", __func__, event);
|
ESP_LOGD(BT_AV_TAG, "%s evt %d", __func__, event);
|
||||||
|
|||||||
Reference in New Issue
Block a user