-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Open
Description
Basic Infos
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it.
- I have filled out all fields below.
Platform
- Hardware: Any ESP8266, like ESP-12F or D1 mini
- Core Version: 3.0.2
- Development Env: The repro below is for Arduino IDE, issue happens in PlatformIO as well
- Operating System: Windows
Settings in IDE
- Module: Generic ESP8266 Module
- Flash Mode: DOUT compatible
- Flash Size: 1MB
- lwip Variant: v2 Lower Memory
- Reset Method: nodemcu
- Flash Frequency: 40Mhz
- CPU Frequency: 80Mhz
- Upload Using: SERIAL
- Upload Speed: 115200
Problem Description
To reproduce this, you need two ESP8266.
Load the first one with a sketch that continuously sends ESP-NOW broadcasts, like this one:
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <espnow.h>
uint8_t broadcastAddress[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
void setup()
{
Serial.begin(115200);
WiFi.disconnect();
WiFi.mode(WIFI_STA);
wifi_set_channel(6);
esp_now_init();
delay(10);
esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER);
}
void loop()
{
Serial.printf("Channel: %u\n", wifi_get_channel());
int data = 1234;
esp_now_send(broadcastAddress, (uint8_t*)&data, sizeof(data));
delay(500);
}
Load the second one with a sketch that displays a text when an ESP-NOW message is received, like this one:
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <espnow.h>
void on_espnow_receive(uint8_t *mac_addr, uint8_t *data, uint8_t len) {
Serial.printf("Received %u bytes from ", len);
for (uint8_t b = 0; b < 6 ; b++)
Serial.printf("%02hhX", mac_addr[b]);
Serial.println();
}
void on_scan_done(void *arg, STATUS status) {}
void setup() {
delay(3000);
Serial.begin(115200);
WiFi.disconnect();
WiFi.mode(WIFI_STA);
// struct scan_config config = {0};
// wifi_station_scan(&config, on_scan_done);
wifi_set_channel(6);
esp_now_init();
delay(10);
Serial.printf("Channel: %u\n", wifi_get_channel());
esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER);
esp_now_register_recv_cb(on_espnow_receive);
}
void loop() {
delay(1000);
}
If you now run the receiver, in the Serial Monitor you'll see many received messages, just as expected:
Received 4 bytes from ...
Received 4 bytes from ...
Received 4 bytes from ...
Now uncomment the two commented lines in the receiver sketch:
struct scan_config config = {0};
wifi_station_scan(&config, on_scan_done);
You can also call WiFi.scanNetworks()
instead of wifi_station_scan(&config, on_scan_done)
, it has the same effect.
If you then run the receiver again, you'll still get a message from time to time, but much much fewer, almost every message is lost.
Received 4 bytes from ...
Metadata
Metadata
Assignees
Labels
No labels