From 36c8020cbcbdb4354751f88726b28d1e521e1154 Mon Sep 17 00:00:00 2001 From: lbernstone Date: Tue, 19 Jun 2018 02:33:50 -0600 Subject: [PATCH] Added WiFi.disconnect to ESPNow examples. Fixes https://github.com/espressif/arduino-esp32/issues/1425 (#1511) --- libraries/ESP32/examples/ESPNow/Basic/Master/Master.ino | 3 ++- libraries/ESP32/examples/ESPNow/Basic/Slave/Slave.ino | 3 ++- libraries/ESP32/examples/ESPNow/Multi-Slave/Master/Master.ino | 3 ++- libraries/ESP32/examples/ESPNow/Multi-Slave/Slave/Slave.ino | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/ESP32/examples/ESPNow/Basic/Master/Master.ino b/libraries/ESP32/examples/ESPNow/Basic/Master/Master.ino index 26e020f6..9e3c02e2 100644 --- a/libraries/ESP32/examples/ESPNow/Basic/Master/Master.ino +++ b/libraries/ESP32/examples/ESPNow/Basic/Master/Master.ino @@ -40,6 +40,7 @@ esp_now_peer_info_t slave; // Init ESP Now with fallback void InitESPNow() { + WiFi.disconnect(); if (esp_now_init() == ESP_OK) { Serial.println("ESPNow Init Success"); } @@ -259,4 +260,4 @@ void loop() { // wait for 3seconds to run the logic again delay(3000); -} \ No newline at end of file +} diff --git a/libraries/ESP32/examples/ESPNow/Basic/Slave/Slave.ino b/libraries/ESP32/examples/ESPNow/Basic/Slave/Slave.ino index 21e963b8..4ed8d52f 100644 --- a/libraries/ESP32/examples/ESPNow/Basic/Slave/Slave.ino +++ b/libraries/ESP32/examples/ESPNow/Basic/Slave/Slave.ino @@ -36,6 +36,7 @@ // Init ESP Now with fallback void InitESPNow() { + WiFi.disconnect(); if (esp_now_init() == ESP_OK) { Serial.println("ESPNow Init Success"); } @@ -87,4 +88,4 @@ void OnDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len) { void loop() { // Chill -} \ No newline at end of file +} diff --git a/libraries/ESP32/examples/ESPNow/Multi-Slave/Master/Master.ino b/libraries/ESP32/examples/ESPNow/Multi-Slave/Master/Master.ino index 87b8c331..bbd783e6 100644 --- a/libraries/ESP32/examples/ESPNow/Multi-Slave/Master/Master.ino +++ b/libraries/ESP32/examples/ESPNow/Multi-Slave/Master/Master.ino @@ -59,6 +59,7 @@ int SlaveCnt = 0; // Init ESP Now with fallback void InitESPNow() { + WiFi.disconnect(); if (esp_now_init() == ESP_OK) { Serial.println("ESPNow Init Success"); } @@ -242,4 +243,4 @@ void loop() { // wait for 3seconds to run the logic again delay(1000); -} \ No newline at end of file +} diff --git a/libraries/ESP32/examples/ESPNow/Multi-Slave/Slave/Slave.ino b/libraries/ESP32/examples/ESPNow/Multi-Slave/Slave/Slave.ino index 8837d9c1..42ce40ba 100644 --- a/libraries/ESP32/examples/ESPNow/Multi-Slave/Slave/Slave.ino +++ b/libraries/ESP32/examples/ESPNow/Multi-Slave/Slave/Slave.ino @@ -36,6 +36,7 @@ // Init ESP Now with fallback void InitESPNow() { + WiFi.disconnect(); if (esp_now_init() == ESP_OK) { Serial.println("ESPNow Init Success"); } @@ -90,4 +91,4 @@ void OnDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len) { void loop() { // Chill -} \ No newline at end of file +}