I have a struct with a few values in it.
struct myData_t{
uint8_t myNum; //Just a number
char DevID[15]; //Human redable device name
byte myChomp; //one byte should do it.
}someData = {120,"MyDevice01",200};
I would ideally like to send the Struct over LoRa without having to send each variable, Is there a way to do this?
I did make an attempt to setup a template similar tot he onbe I used for storing my config in eeprom but that did not seem to work.
template int LoRa_writeAnything(char* data, const T& value){
const byte* p = (const byte*)(const void*)&value;
unsigned int i;
for (i = 0; i < sizeof(value); i++)
data[i]=*p++;
return i;
}
#define BUFFER_SIZE 124 // Define the payload size here
char txpacket[BUFFER_SIZE];
LoRa_writeAnything(txpacket, someData); //this should take the struct and put it in the buffer
Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); //send the package out
Any thoughts on how this could be done easier?