Skip to content
Snippets Groups Projects
Commit c3cbbd46 authored by Moritz Perschke's avatar Moritz Perschke
Browse files

changed oversight in espnow

parent 85496e15
No related branches found
No related tags found
4 merge requests!39Merge Develop into Main,!19development into master,!17Inital Host, initial Client,!15Rs485 finalization
......@@ -64,11 +64,11 @@ void on_data_recv(const uint8_t *mac, const uint8_t *incomingData, int len)
received_msg.epoch_seconds); // see https://www.esp32.com/viewtopic.php?t=9965, maybe this needs an offset
Serial.println(Time::getInstance().getEpochSeconds());
if (!preferences.isKey("host")) {
preferences.putBytes("host", received_msg.host, sizeof(received_msg.host));
ESP_LOGI(TAG, "host MAC address saved to flash");
preferences.putBytes("host", received_msg.host, sizeof(received_msg.host));
ESP_LOGI(TAG, "host MAC address saved to flash");
// add host to peers
add_host_to_peers(received_msg);
// add host to peers
add_host_to_peers(received_msg);
}
}
case hostChange:{
......@@ -80,10 +80,17 @@ void on_data_recv(const uint8_t *mac, const uint8_t *incomingData, int len)
esp_now_del_peer(old);
}
// add new host
preferences.putBytes("host", received_msg.host, sizeof(received_msg.host));
ESP_LOGI(TAG, "Host Mac address saved to flash:");
for(int i=0; i<6; i++){
Serial.print(received_msg.host[i], HEX);
Serial.print(":");
}
Serial.println();
add_host_to_peers(received_msg);
}
default:{
return;
break;
}
}
preferences.end();
......@@ -110,7 +117,6 @@ esp_err_t espnow_setup()
hostInfo.encrypt = false;
esp_now_add_peer(&hostInfo);
preferences.clear();
esp_now_register_recv_cb(on_data_recv);
esp_now_register_send_cb(on_data_sent);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment