hello community,
i will have to program ~20 ArduinoEthernet boards - all with the identical sketch -
but every board has a uniq mac and a ipaddress -
so i searching for an idea to 'define' the 'Hardware/Bord-Specific' parameters for all boards -
and than choose in an easy way which one to use for the current upload target (connected board)..
i have two different ideas till now -
1 - use a array to store all possible configs
tDeviceParameters dpDeviceList[] = {
{ // -- not used.
0, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x00 }, // mac
IPAddress(192, 168, 222, 100), // ip
},
{ // development board
1, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x4E }, // mac
IPAddress(192, 168, 222, 101), // ip
},
{ // test board
2, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x43 }, // mac
IPAddress(192, 168, 222, 102), // ip
},
{ // second test board
3, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x45 }, // mac
IPAddress(192, 168, 222, 103), // ip
},
};
tDeviceParameters dpThisDeviceX = dpDeviceList[1]; // number is identical with ID == identical with IPAddress ending.
problem: all infos are using space... but only one is used...
2 - use a list of #ifdef s
#define DEVICE_1
#ifdef DEVICE_1
tDeviceParameters dpThisDevice = {
// development board
1, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x4E }, // mac
IPAddress(192, 168, 222, 101), // ip
};
#endif
#ifdef DEVICE_2
tDeviceParameters dpThisDevice = {
// second test board
2, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x43 }, // mac
IPAddress(192, 168, 222, 102), // ip
};
#endif
#ifdef DEVICE_3
tDeviceParameters dpThisDevice = {
// second test board
3, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x45 }, // mac
IPAddress(192, 168, 222, 103), // ip
};
#endif
//...
this is not so nice from the formating ?! 8)
have someone out there another idea / concept to do something like this?
i have added my test sketch - its the basic UDPSendReceiveString Example with small modifications.
or is the compiler so clever to know that only one of the entrys in an array is used in the software?
sunny greetings
stefan
DeviceInfo.h (408 Bytes)
Example_UDPSendReceiveString.ino (4.15 KB)