How to save a MAC address in preferences ESP32

Hi, i want to make a program that saves a MAC of an incoming message from ESPNOW, you have this callback function:
void OnDataRecv(const uint8_t *mac_addr, const uint8_t *incomingData, int data_len)
So you have the mac_address of the sender, i would like to save it in preferences, i imagine that i have to use get/put Bytes to do that, but i dont know how. I saved the MAC value using this

for(int i=0; i<6;i++)
peerinfo.peer_addr[i] = mac_addr[i]

maybe i have to save it like this?

preferences.putBytes("Key", (uin8_t) peerinfo.peer_addr,6 ) // 6 bytes is size of MAC

but then how can i recover the data? and how can i know if there exist values in that key? i mean getBytes doesnt have a default value when the key doesnt exist. The idea is to recover the data and then pair with the device using the mac stored, so it has to be in the format of peerinfo.peer_addr . Can you help me?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.