B4R Question ArduinoBLE lib wrapping EMPTY issue

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

working to wrap the ArduinoBLE library to be used with an Arduino GIGA R1.

Getting this error when compiling a test sketch:
B4X:
Basic\B4R\Objects\src\rCore.h:614:40: error: expected unqualified-id before ';' token 614 | static B4RString* EMPTY; | ^ In file included from C:...

I confirmed the issue is caused by a macro named EMPTY coming from the Arduino GIGA (mbed / Zephyr / CMSIS) core.
Undefining EMPTY in B4RDefines.h is not sufficient, because the macro is reintroduced per translation unit by the Arduino core.

The only robust fix is to undefine EMPTY locally in rCore.h:
B4X:
// --- Fix macro collision with Zephyr / mbed ---
#ifdef EMPTY
  #undef EMPTY
#endif
static B4RString* EMPTY;
This keeps API compatibility and avoids renaming core symbols.

Another option would be to rename EMPTY to EMPTYSTR in rCore.h and rCore.cpp:
B4X:
static B4RString* EMPTYSTR;

static B4RString be_empty;
B4RString* B4RString::EMPTYSTR = be_empty.wrap("");

Is there another solution for this instead modifying the B4R rCore?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Another option would be to rename EMPTY to EMPTYSTR in rCore.h and rCore.cpp:
This will not work without updating B4R as the compiler emits code referencing this variable. I will change this variable name in the next update. For now you will need to modify rCore.h.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Hello @rwblinn,
I presume that you're creating another excellent library for the community.

I do have a B4R wrap of the ArduinoBLE library I obviously called it rArduinoBLE, if you would be willing to test it for me. I remember wrapping the Peripheral code, I may or may not have wrapped in the Central code. I wrapped this library when I was updating Erel's original the B4A BLE Peripheral library. I think it's working fully, but I didn't really test it that much as what I needed was for Android production hardware and not Arduino/ESP, so I just left it, well until I saw your post, then I quickly tested this.

ESP32 Peripheral - Android screenshot below:
1000089421.png


Let me know, and I'll PM you the code...
 
Last edited:
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Thanks Peter.
In the meantime have created first version of 2 libraries rArduinoBLECentral & Peripheral.
Tested and working OK.
Happy to test yours.
See my PM.
 
Upvote 0
Top