Skip to content
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

testBLE_uart sketch fails to compile #17

Open
FlexoTim opened this issue Jun 11, 2024 · 13 comments
Open

testBLE_uart sketch fails to compile #17

FlexoTim opened this issue Jun 11, 2024 · 13 comments

Comments

@FlexoTim
Copy link

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

@borntoleave
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Collaborator

Have you been able to try my fix, which was uploaded yesterday?
5be1d6b#diff-ff52102038a6d9e40a9227b172b6dd4a49b2ed6ffb50b20a45e79e2711b2d3d3

@FlexoTim
Copy link
Author

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

@borntoleave
Copy link
Collaborator

I found a bug in sending long 'K'-token skills via the mobile app after the modification.
Though
String rxValue = pCharacteristic->getValue().c_str();
and
std::string rxValue = pCharacteristic->getValue();
both compile and should be the same, there's some unknown error in the conversion results the machine's main program break.

@FlexoTim
Copy link
Author

I don't understand.
testBLE_uart doesn't send skill data.

I don't see how

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

can ever legitimately compile. There's no conversion from String to std::string.

@borntoleave
Copy link
Collaborator

borntoleave commented Jul 31, 2024 via email

@FlexoTim
Copy link
Author

FlexoTim commented Jul 31, 2024 via email

@borntoleave
Copy link
Collaborator

borntoleave commented Aug 1, 2024 via email

@FlexoTim
Copy link
Author

FlexoTim commented Aug 2, 2024

I can't see the screenshot file.

I can't replicate the issue without the data used to produce it. What's necessary to replicate what "long skill" command means?

I'm suspicious about how the write of the BLE characteristic is involved with reading skill data. Does this happen with the UART? If it's a problem with the program memory footprint then it will resurface in some other location. If it's a conversion issue, then it should be testable outside of the BLE API.

@borntoleave
Copy link
Collaborator

I'm attaching the image here:
Screenshot 2024-08-01 at 14 48 42

A test command can be imported as a customized mobile app button:
Bittle_MoonWalk.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants