summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/drivers/bluetooth.cpp12
-rw-r--r--src/drivers/include/bluetooth.hpp2
2 files changed, 8 insertions, 6 deletions
diff --git a/src/drivers/bluetooth.cpp b/src/drivers/bluetooth.cpp
index 0b30c7c1..f266b51c 100644
--- a/src/drivers/bluetooth.cpp
+++ b/src/drivers/bluetooth.cpp
@@ -47,9 +47,12 @@ auto gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t* param) -> void {
auto avrcp_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t* param)
-> void {
- auto lock = bluetooth::BluetoothState::lock();
- tinyfsm::FsmList<bluetooth::BluetoothState>::dispatch(
- bluetooth::events::internal::Avrc{.type = event, .param = param});
+ esp_avrc_ct_cb_param_t copy = *param;
+ sBgWorker->Dispatch<void>([=]() {
+ auto lock = bluetooth::BluetoothState::lock();
+ tinyfsm::FsmList<bluetooth::BluetoothState>::dispatch(
+ bluetooth::events::internal::Avrc{.type = event, .param = copy});
+ });
}
auto a2dp_cb(esp_a2d_cb_event_t event, esp_a2d_cb_param_t* param) -> void {
@@ -658,7 +661,6 @@ void Connected::react(const events::SourceChanged& ev) {
}
void Connected::react(const events::ChangeVolume& ev) {
- ESP_LOGI(kTag, "send vol %u", ev.volume);
esp_err_t err = esp_avrc_ct_send_set_absolute_volume_cmd(
transaction_num_++, std::clamp<uint8_t>(ev.volume, 0, 0x7f));
if (err != ESP_OK) {
@@ -709,7 +711,7 @@ void Connected::react(const events::internal::A2dp& ev) {
void Connected::react(const events::internal::Avrc& ev) {
switch (ev.type) {
case ESP_AVRC_CT_CONNECTION_STATE_EVT:
- if (ev.param->conn_stat.connected) {
+ if (ev.param.conn_stat.connected) {
// TODO: tell the target about our capabilities
}
// Don't worry about disconnect events; if there's a serious problem
diff --git a/src/drivers/include/bluetooth.hpp b/src/drivers/include/bluetooth.hpp
index 2936fb8e..5fdd527c 100644
--- a/src/drivers/include/bluetooth.hpp
+++ b/src/drivers/include/bluetooth.hpp
@@ -75,7 +75,7 @@ struct A2dp : public tinyfsm::Event {
};
struct Avrc : public tinyfsm::Event {
esp_avrc_ct_cb_event_t type;
- esp_avrc_ct_cb_param_t* param;
+ esp_avrc_ct_cb_param_t param;
};
} // namespace internal
} // namespace events