Error addinf ESP-NOW peer info
Posted: Wed Dec 08, 2021 5:21 pm
Hi guys,
I'm working whit ESP-NOW protocol to communicate the status of hardware buttons attached to the one board to controll the second one than is in a score point display in the gym attached to the wall.
Ok, I try to add the peer in a separate function that declare a new variable of esp_now_peer_info_t type:
when I call this function the output in the serial is about an error as "(...) ESPNOW peer interface is invalid".
I've solve this problem passing by copy one variable of the same type as argument.
Is this a problem? In case there a solution to this? Is also known?
Thanks in advance,
Alan
I'm working whit ESP-NOW protocol to communicate the status of hardware buttons attached to the one board to controll the second one than is in a score point display in the gym attached to the wall.
Ok, I try to add the peer in a separate function that declare a new variable of esp_now_peer_info_t type:
Code: Select all
void initESPNOW(){
WiFi.mode(WIFI_STA);
pinMode(CONNECTION_LED, OUTPUT);
// Init ESP-NOW
if (esp_now_init() != ESP_OK) {
Serial.println("Error initializing ESP-NOW");
return;
}
esp_now_register_send_cb(OnDataSent);
esp_now_peer_info_t peerInfo;
memcpy(peerInfo.peer_addr, broadcastAddress, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
if (esp_now_add_peer(&peerInfo) != ESP_OK){
Serial.println("Failed to add peer");
return;
}
// esp_now_register_recv_cb(OnDataRecv);
}
I've solve this problem passing by copy one variable of the same type as argument.
Code: Select all
void initESPNOW(esp_now_peer_info_t peerInfo) {
WiFi.mode(WIFI_STA);
pinMode(CONNECTION_LED, OUTPUT);
// Init ESP-NOW
if (esp_now_init() != ESP_OK) {
Serial.println("Error initializing ESP-NOW");
ESP_NOWState = false;
return;
}
esp_now_register_send_cb(OnDataSent);
memcpy(peerInfo.peer_addr, broadcastAddress, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
if (esp_now_add_peer(&peerInfo) != ESP_OK){
Serial.println("Failed to add peer");
return;
}
ESP_NOWState = false;
return;
}
esp_now_register_recv_cb(OnDataRecv);
ESP_NOWState = true;
}
Thanks in advance,
Alan