From c8cf9fa5ad39a4ce309f2a11a04dc93cd19c0eae Mon Sep 17 00:00:00 2001 From: Moritz Perschke <moritz.perschke@uibk.ac.at> Date: Thu, 27 Oct 2022 12:15:06 +0200 Subject: [PATCH] added broadcast of own mac to setup method in esp32-espnow-recv --- host/esp32-espnow-recv/platformio.ini | 4 ++-- host/esp32-espnow-recv/src/main.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/host/esp32-espnow-recv/platformio.ini b/host/esp32-espnow-recv/platformio.ini index 73a15dd..808a5bb 100644 --- a/host/esp32-espnow-recv/platformio.ini +++ b/host/esp32-espnow-recv/platformio.ini @@ -13,8 +13,8 @@ platform = espressif32 board = esp32-c3-devkitm-1 monitor_speed = 115200 framework = arduino -monitor_port = /dev/ttyUSB1 -upload_port = /dev/ttyUSB1 +; monitor_port = /dev/ttyUSB1 +; upload_port = /dev/ttyUSB1 build_flags = -I include -DCORE_DEBUG_LEVEL=5 diff --git a/host/esp32-espnow-recv/src/main.cpp b/host/esp32-espnow-recv/src/main.cpp index 61baf52..0a40053 100644 --- a/host/esp32-espnow-recv/src/main.cpp +++ b/host/esp32-espnow-recv/src/main.cpp @@ -11,6 +11,8 @@ long time1 = 0; +uint8_t hostMac[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; + //SoftwareSerial mySerial(RXD2, TXD2); enum MessageType{ @@ -95,6 +97,14 @@ void setup() } Serial.println("ESPNow init success"); + // tell all clients that this is now the host + // can probably be removed after testing + response hello; + hello.type = hostChange; + esp_read_mac(hello.mac, ESP_MAC_WIFI_STA); + hello.time = 0; + esp_now_send(hostMac, (uint8_t*) &hello, sizeof(hello)); + esp_now_register_recv_cb(on_data_recv); // write your initialization code here } -- GitLab