unsigned char unitNumber = 0xff;
const String asText[] = {
"B4:E6:2D:8E:50:A1",
"B4:E6:2D:8E:67:45",
};
uint8_t broadcastAddress[][6] = {
/* 0 */ {0xb4, 0xe6, 0x2d, 0x8e, 0x50, 0xa1},
/* 1 */ {0xb4, 0xe6, 0x2d, 0x8e, 0x67, 0x45},
};
void selectUnit()
{
char asChars[20];
unitNumber = 0xff; // no it doesn't
// String myMACAddress = WiFi.macAddress(); // if you use this for real...
// String myMACAddress = "B4:E6:2D:8E:67:45"; // simulated! will succeed
String myMACAddress = "B4:E7:2D:8E:67:45"; // simulated! will fail
Serial.print("I am "); Serial.println(myMACAddress);
if (myMACAddress == asText[0]) unitNumber = 1;
else if (myMACAddress == asText[1]) unitNumber = 0;
if (unitNumber == 0xff) {
Serial.println(" MACAddress assignment fail!");
for (; ; ); // whatever you want to do when you have no partner. Me, I die.
}
else {
Serial.print("I'll talk to unit "); Serial.print(unitNumber);
Serial.print(" at "); Serial.println(asText[unitNumber]);
}
}
void setup() {
Serial.begin(9600);
Serial.println("unit selection test");
selectUnit();
}
void loop() {}