A2DP Source Reconnections -> Tied to i2s.is_master? #696
-
I've been banging my head on this problem for a few days now. My original test sketch worked perfectly. Now that I am integrating the ability to change between a source and a sink on reboot I run into these problems... Short story: If I use i2s.is_master = false then a2dp reconnections do not work properly. It sometimes works if it disconnect within the first few seconds, but after a good connection is established the esp32 never actually disconnects from the speaker therefore never reconnects. I finally figured out if I simply turn on i2s,is_master = true then it works perfectly every time. Why? Here is my code to init the bluetooth. Depending on btrole its either a sink or a source and it gets initialized based on that. After spending days going thru debug logging and all kinds of testing it comes down to one simple change, is_master = true or false. I believe this is not your library but maybe the esp-idf core but I'm not sure. Arduino core 3.1.3 up to 3.2.0. SDK 5.3.2 up to 5.4. AudioTools up and down the range of changes over the past few months. No changes - except is_master = false/true seems to be pretty telling that's where the problem is.
Theres nothing going on in loop() other than delay(10). After wusing the debug logging I don't even see an attempt to disconnect from a speaker that disappears. There is nothing. Here is output from normal working conditions where you can see connections and disconnections working great if is_master = false. As soon as I turn on is_master = true the backend never sees the speaker disconnect therefore it never even tries to scan and reconnect. I can reproduce the problem simply by changing the is_master property.
I'm testing this on a dev wroom not on my pcb with another clock present - so I don't know if the underlying idf framework is looking for a clock and can't find one so it gets confused ... but I need a way to determine this at runtime so I can compensate for it. I have 8 wrooms on a pcb sharing i2s audio (working perfectly) but need the ability to change the roles from sink to source between them. Obviously one needs to be the clock which I will handle - but I think this is going to be a problem either way. PS - Phil your libraries are great. I cannot believe how much work you have put into this and still have time in the day to do anything else. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I would not know why that would be. Are you sure that you provide proper data to A2DP: if A2DP would not get proper audio data, then it would automatically disconnect... |
Beta Was this translation helpful? Give feedback.
I would not know why that would be.
I am always using the ESP32 as master both when attaching an external DAC and ADC!
Are you sure that you provide proper data to A2DP: if A2DP would not get proper audio data, then it would automatically disconnect...