I’m using ESP-NOW to send data to a “client”. Very small data packs. I have it working at the moment by using manually inserted MAC addresses (hard coded). So, I have the proper MAC addresses, it’s reported at boot, and when programming the device.
But, it would be nice if I could use the scanner in the Arduino ESP32/ESSPNOW examples, as the boards I use may change from time to time. (all this code does, is scan the network, looking for an SSID prefix, then reads the associated MAC address.
But when the scanner runs, it reports a very similar MAC address. Usually, off by one digit. How can I tell the scan code to to obtain the correct address?
This is the relevant code from the scan example:
if (SSID.indexOf("Slave") == 0) {
// SSID of interest
Serial.print(i + 1); Serial.print(": "); Serial.print(SSID); Serial.print(" ["); Serial.print(BSSIDstr); Serial.print("]"); Serial.print(" ("); Serial.print(RSSI); Serial.print(")"); Serial.println("");
// Get BSSID => Mac Address of the Slave
int mac[6];
if ( 6 == sscanf(BSSIDstr.c_str(), "%x:%x:%x:%x:%x:%x", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5] ) ) {
for (int ii = 0; ii < 6; ++ii ) {
slaves[SlaveCnt].peer_addr[ii] = (uint8_t) mac[ii];
}
}
slaves[SlaveCnt].channel = CHANNEL; // pick a channel
slaves[SlaveCnt].encrypt = 0; // no encryption
SlaveCnt++;