This guide provides pretty good explanation how to transmit popular data types over ESP-NOW, including String and 'char *'
The structure used:
typedef struct struct_message {
char a[32];
int b;
float c;
String d;
bool e;
} struct_message;
It works really well as in provided example:
strcpy(myData.a, "THIS IS A CHAR");
myData.b = random(1,20);
myData.c = 1.2;
myData.d = "Hello";
myData.e = false;
However, attempt to transmit variable data fails. Examples:
strcpy(myData.a, "THIS IS A CHAR");
myData.b = random(1,20);
myData.c = 1.2;
String temp = "Hello" + String(5);
myData.d = temp; // This transmits gibberish
myData.e = false;
String temp = "Hello" + String(5);
strcpy(myData.a, temp.c_str()); // Transmits nothing
myData.b = random(1,20);
myData.c = 1.2;
myData.d = "Hello";
myData.e = false;
I think my lack of C++ understanding blocks me to resolve the problem of transmission of variable string or bytearray.
Update:
1.
myData.d = "HelloHelloHello";
2.
strcpy(myData.a, temp.c_str()); // Transmits nothing
Thanks!