-
Notifications
You must be signed in to change notification settings - Fork 7.7k
How to turn on and off A2DP sink without loosing memory #8204
Unanswered
dharmikP17
asked this question in
Q&A
-
I am using ESP32 (2.0.5) with Arduino IDE (2.0.2). All settings are default.
My requirement is to turn off the A2DP and start wifi then switch back to A2DP. So I have basic code that just turn on and off the A2DP sink and there is memory leak in heap everytime it goes through this cycle.
#include "BluetoothA2DPSink.h"
#include "BluetoothSerial.h"
BluetoothA2DPSink a2dp_sink;
BluetoothSerial SerialBT;
bool flag_init_serialbt = true;
void connection_state_changed(esp_a2d_connection_state_t state, void *ptr) {
Serial.println(a2dp_sink.to_str(state));
}
void audio_state_changed(esp_a2d_audio_state_t state, void *ptr) {
Serial.println(a2dp_sink.to_str(state));
}
void setup() {
Serial.begin(115200);
pinMode(2, OUTPUT);
// a2dp_sink.set_on_connection_state_changed(connection_state_changed);
// a2dp_sink.set_on_audio_state_changed(audio_state_changed);
a2dp_sink.start("ESP_A2DP_test", false);
SerialBT.begin("ESP_A2DP_test");
}
void loop() {
a2dp_sink.end();
Serial.print("free heap : ");
Serial.println(ESP.getFreeHeap());
delay(3000);
a2dp_sink.start("ESP_A2DP_test", false);
delay(3000);
}
There is an option to release memory in a2dp_sink.end(bool release_memory)
method but then it will not let me turn on again saying re-start does not work with end(true)
.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment