Code an array of structures
Posted: Sat Dec 23, 2023 10:12 pm
Hi for my project https://github.com/rin67630/Victron_VE_on_Steroids/ I have coded an UDP transmission between modules that works pretty well:
The information is grouped in a single structure payload[]
The structure is copied byte-by-byte to a char array, transmitted over UDP, and at the destination the char array is replicated back into the same structure.
Now I would like to have n copies of that structure in the destination ESP32: an array of n instances of that structure, so the ESP32 could keep track of several senders, indexed by the array.
Has someone an idea on how to code that?
Thank you for your help...
The information is grouped in a single structure payload[]
Code: Select all
struct payload {
//***Operating Values from Victron/SmartShunt***
float BatV; // V Battery voltage, V
float BatV1; // V Battery voltage, V (Double or half Voltage)
float BatI; // I Battery current, A
float BatW; // BatV*BatI
float PanV; // VPV Panel voltage, V
float PanI; // PanW/PanV
float PanW; // PPV Panel power, W
float LodI; // IL Load Current A
float LodW; // LodI*BatV
float IOhm; // dV / dI
int ChSt; // CS Charge state, 0 to 9
int Err; // ERR Error code, 0 to 119
boolean LodOn; // LOAD ON Load output state, ON/OFF
} payload;
Now I would like to have n copies of that structure in the destination ESP32: an array of n instances of that structure, so the ESP32 could keep track of several senders, indexed by the array.
Has someone an idea on how to code that?
Thank you for your help...