I am trying to change some peer channel to a default value, i implemented the following code:
bool changeToDefaultChannel(){
esp_now_del_peer(slave.peer_addr);
esp_wifi_set_channel(CHANNEL_DEFAULT, WIFI_SECOND_CHAN_NONE);
esp_now_peer_info_t slave_aux;
memcpy(slave_aux.peer_addr, MAC_slave, 6);
slave_aux.channel = CHANNEL_DEFAULT; // pick a channel
slave_aux.encrypt = 0; // no encryption
if (esp_now_add_peer(&slave_aux) != ESP_OK) {
Serial.println("Error al actualizar el canal del peer");
return false;
}else{
Serial.println("Se cambió correctamente de canal la ESP32");
return true;
}
}
In this code the i wanted to change the slave channel to a channel_default, first i delete the peer and then i add it again with the other channel, i use esp_wifi_set_channel to change the esp channel too. (i do the same code in the slave device to change the master to the default channel). I get this error "E (167155) ESPNOW: Peer interface is invalid", i dont know how to solve this (i asked to chat GPT and it told me nonsenses)