Hi,
let me describe the scenario first, I have multiple ESP32 which are planned to be working together.
One of them is the SERVER. The server got its mac address set hardcoded to:
uint8_t ServerMACAddress[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0xFF};
the CLIENTS set their MAC address by a value read from a potentiometer,
declaration top of the code:
uint8_t customMACAddress[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
and modification in setup()
// read value from potentiometer and map it to 16 possible values
IDpotValue = map(analogRead(IDpotPin), 0, 1000, 0, 15);
// set the last digit of the MAC address
customMACAddress[5] = IDpotValue;
// set the local MAC address
esp_wifi_set_mac(WIFI_IF_STA, &customMACAddress[0]);
so the last digit wil be changed to a value between 0 and F
Until here there is no problem, code works, server receives data and with the first message the IDpotValue from the client(s).
Now I want to make the server respond to that message and am trying to set the target mac address to the id where the message came from.
So same procedure on server side, top of the code:
uint8_t clientMACAddress[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
and in the receiption/response code:
clientMACAddress[5] = receivedClientID;
// trying to send the message:
esp_err_t result = esp_now_send(clientMACAddress, (uint8_t *) &comData, sizeof(comData));
The transmitted data are ints, BUT the message sending fails. No matter if I use the received int or do it manually by like clientMACAddress[5] = 14.
However if I hardcode the clientMACAddress to
uint8_t clientMACAddress[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x0E};
The message sending succeeds.
What am I doing wrong here ?
Now some last words because it probably comes up:
Yes I know changing the MAC addresses isn't ideal but I
a) don't want to fetch each MAC from every (new) mcu
b) don't want to flash each mcu with a specific code
c) don't want a huge overhead of pairing code that involves even BLE, because I need the flash space
IF there is a way of pairing without that, I am of course ok with that but all articles and descriptions I found about it (for now) are either using fetched MAC addresses or BLE for initial pairing.