Skip to content

BT device not connecting via A2DP #11244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
Admsher opened this issue Apr 13, 2025 · 7 comments
Closed
1 task done

BT device not connecting via A2DP #11244

Admsher opened this issue Apr 13, 2025 · 7 comments
Labels
Status: Awaiting triage Issue is waiting for triage

Comments

@Admsher
Copy link

Admsher commented Apr 13, 2025

Board

ESP32 One

Device Description

Using BLE A2DP with Wifi on ESP32 Chip ( As mentioned in ESP IDF)

Hardware Configuration

SD card reader and OV2460 Camera connected.

Version

latest stable Release (if not listed below)

IDE Name

ESP IDF v5.3

Operating System

WIndows 11

Flash frequency

40 Mhz

PSRAM enabled

yes

Upload speed

115200

Description

I am trying to connect an A2DP speaker to my ESP32 one board using the arduino-audio-tools lbrary, i tried to connect with Arduino IDE At first and i worked fine, but now for some reason the device does'nt connect when ESP IDF v5.3 used even when there are no errors in build or runtime itself and flashes properly. I have tried resetting the speaker itself but no luck there.

Sketch

#define HELIX_LOGGING_ACTIVE false
#include "AudioTools.h"
#include "AudioTools/AudioLibs/A2DPStream.h"
#include "AudioTools/Disk/AudioSourceSDFAT.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"

const char *startFilePath="/music/";
const char* ext="mp3";
AudioSourceSDFAT source(startFilePath, ext, 15);
A2DPStream out;
MP3DecoderHelix decoder;
AudioPlayer player(source, out, decoder);

void setup() {
  Serial.begin(115200);
  AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
  // setup player
  // Setting up SPI if necessary with the right SD pins by calling 
  SPI.begin(14, 12, 13, 15);
  player.setVolume(0.8);
  player.begin();

  // setup output - We send the test signal via A2DP - so we conect to a Bluetooth Speaker
  auto cfg = out.defaultConfig(TX_MODE);
  cfg.silence_on_nodata = true; // prevent disconnect when there is no audio data
  cfg.name = "CLIP 5";  // set the device here. Otherwise the first available device is used for output
  //cfg.auto_reconnect = true;  // if this is use we just quickly connect to the last device ignoring cfg.name
  out.begin(cfg);
}

void loop() {
  player.copy();
}

Debug Message

Image

Other Steps to Reproduce

You can go through the configuration for the flags in this link :https://github.com/pschatzmann/ESP32-A2DP/wiki/Espressif-IDF-as-a-Component
One thing i would also tell you to go through this issue as well for configuring the HAL files: #11167

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@Admsher Admsher added the Status: Awaiting triage Issue is waiting for triage label Apr 13, 2025
@me-no-dev
Copy link
Member

Please take this issue to the relevant external libraries (AudioTools/ESP32-A2DP). There is no action on our side that we can do to help.

@Admsher
Copy link
Author

Admsher commented Apr 14, 2025

I am actually using esp32-arduino as a component so that I could directly import the Arduino ide code here , so thought it would be a relevant issue

@Jason2866
Copy link
Collaborator

Jason2866 commented Apr 14, 2025

@Admsher To solve you can use pioarduino to compile Arduino as an component of IDF.
I made an example how to setup pschatzmann Audio tools here https://github.com/Jason2866/audio-tools-test/tree/issue11181
Weak defines in Arduino Core are not correctly handled when compile Arduino as an component of IDF. The underlying issue is the build workflow of native! IDF. The issue does not occur in ArduinoIDE since the build process workflow does respect and correctly uses weak defines.

The use of weak defines in Arduino Core and Libraries can be forced in Platformio/pioarduino with the setting lib_archive = False
So there is a solution for the issue NOT being really an error in Arduino Core code.

@Admsher
Copy link
Author

Admsher commented Apr 14, 2025

So just to be on the same track, should I use piarduino as a component for my esp-idf project?

@Jason2866
Copy link
Collaborator

Jason2866 commented Apr 14, 2025

Yes, the only known working way to compile Arduino BT projects as a component of IDF is using pioarduino. You have to use WSL when using Windows as OS. Windows can't handle long path and command lines (which will happen in this build variant).

@Admsher
Copy link
Author

Admsher commented Apr 14, 2025

So here is a fix I am in , the board I am using needs to extend it's IRAM from the DRAM for a bigger sketch i am trying to upload on the board, it seems that ESP-IDF is the only IDe that can enable that , will it be possible to confirm if piarduino can let me do that as well?

@Jason2866
Copy link
Collaborator

Jason2866 commented Apr 14, 2025

menuconfig is available when mode Arduino as a component of IDF is used with pioarduino.
So all options from IDF can be configured. So yes. Enabling is done by setting Arduino and espidf as used framework. This setting framework = arduino, espidf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

No branches or pull requests

3 participants