PetoiCamp / OpenCatEsp32

An ESP32-based open source quadruped robot pet framework for developing Boston Dynamics-style four-legged robots that are perfect for STEM, coding & robotics education, IoT robotics applications, AI-enhanced robotics application services, research, and DIY robotics kit development.
MIT License
78 stars 28 forks source link

testBLE_uart sketch fails to compile #17

Open FlexoTim opened 2 weeks ago

FlexoTim commented 2 weeks ago

The sketch contains an stl::string variable which is illegal.

borntoleave commented 2 weeks ago

What compiler are you using? Arduino IDE would generate a warning but still compiles. I've modified it to String to clear the warning.

FlexoTim commented 2 weeks ago

I'm using the Arduino IDE v2..3.2. I also use the arduino-cli but not on this issue. The compiler is: xtensa-esp32-elf-g++ (crosstool-NG esp-12.2.0_20230208) 12.2.0 The error I get should is not be compiler dependent:

std::string rxValue = pCharacteristic->getValue();

will never compile because there's no conversion from String to stl::string.

There's another warning on

char * genBleID(int suffixDigits = 2, char prefix[] = CONNECTION_NAME)

because CONNECTION_NAME is a string literal, and the pointer isn't const. that's a different issue.

este-este commented 2 weeks ago

I am able to compile the testBLE_uart.ino using either Arduino IDE 2.2.1 or Arduino IDE 1.8.19. Target Board (under Tools menu) is the Arduino ESP32 > ESP32 Dev Module. I get no warnings.

In Windows 10, this is the path to the tool which indicates what compiler version I am using: ...\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\esp-2021r2-patch5-8.4.0

FlexoTim commented 2 weeks ago

I'm attaching the error log for completeness. Issue 17 log.txt

I'm at a loss for words here. This needs to be nailed down. From my perspective, this is a C++ language issue. I would argue a compiler that accepts the code in question is broken.

The code in question (which is the code that git says was changed) is std::string rxValue = pCharacteristic->getValue();

The function BLECharacteristic::getValue returns a String object. The String class provides no conversion operator to a type that can be used to initialize a std::string. This is the error.

The statement can be simplified to make it more direct: std::string rxValue = String("abcd");

If the compiler doesn't declare this as an error then I don't know what it's doing.

borntoleave commented 2 weeks ago

Have you been able to try my fix, which was uploaded yesterday? https://github.com/PetoiCamp/OpenCatEsp32/commit/5be1d6b50e6b225b4c0da11a58b2bb7439f522d2#diff-ff52102038a6d9e40a9227b172b6dd4a49b2ed6ffb50b20a45e79e2711b2d3d3

FlexoTim commented 2 weeks ago

Yes. Sorry for the delay; distractions on my end I got the changes from the repository and successfully built

Sketch uses 1115061 bytes (85%) of program storage space. Maximum is 1310720 bytes. Global variables use 35004 bytes (10%) of dynamic memory, leaving 292676 bytes for local variables. Maximum is 327680 bytes.

The issue is resolved from my POV. Thanks