CORRECTED ANSWER
I dug back into my code after a comment from Edgar and figured out some needed adjustments. My original solution was mostly correct, but there were some inaccuracies that I want to correct so I'm not goofing up anyone else in the future that may find this answer useful.
So I was overthinking things a bit. I still don't know that this is the best way of handling it, but it is working on the client side.
So, c-strings are just arrays of 8bit values with a null terminator at the end.
I want to end up my enum values, and my enums are define with byte enum-bases:
enum messageTypeEnum
{
REGISTER_CLIENT = 0x04,
CLIENT_REGISTERED,
UPDATE_CREDENTIALS,
ADD_BRICK,
GAME_FRAME,
ERROR
};
enum clientTypeEnum
{
GAMEBOARD = 0x01,
BRICK_CONTROLLER,
PLAYER_CONTROLLER,
TOUCH_CONTROLLER
};
So, to send up my bytes, I can just build a character array, set each byte in little endian order, and manually terminate it:
NOTE: this is the original assembly that was incorrect. I put the null terminator at the beginning of the buffer thinking "oh, it's little endian so the terminator needs to be at the beginning". Classic sleepy brain mistake :|
client.sendBinary((const char *)buffer, 3);
}
void registerAsAGameBoard()
{
char buffer[3]data[3] = {0, GAMEBOARD, REGISTER_CLIENT, 0};
client.sendBinary((const char **buffer = data;
size_t size = strlen(buffer);
client.sendBinary(buffer, 3size);
}
WhenNow when I call sendBinary with my bytebyte array cast to a const pointer and the length of the buffer my esp32 doesn't crash (hurray!) and the server receives the buffer correctly!!
The server doesn't read the buffer values correctly because all of the other clients are sending messages in big endian, but from here I can just figure outneed to make a waycouple of tellingadjustments on either the client and/or server which directionside to readaccount for the buffers (somehow :P).
I won't be sending any other messages back tofact that the server form this client (at least not atESP32 is little endian and the moment), it's primarily a receiverserver is already coded to receive payloads in big endian, so this shouldbut that shouldn't be good for nowtoo much of a lift.

