-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
espnow cannot send to a broadcast address #9380
Comments
Update; |
I'm planning to take a look at this and #7903. For reference: ( https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/error-codes.html ) ESP_ERR_ESPNOW_INTERNAL (0x306a): Internal error ESP_ERR_ESPNOW_NOT_FOUND (0x3069): ESPNOW peer is not found leave a note here if you've done (or are doing) any work on it, so no effort gets duplicated. |
I was unable to get circuitpython to reliably (or in most cases - at all) communicate with micropython over espnow (packet corruption and loss mostly when it semi-worked, or nothing at all most of the time probably due to code issue in the peer address setup/handling). |
Adding b'\xff\xff\xff\xff\xff\xff' as a peer does not work for me : Without the possibility of sending gratuitous broadcast packets and receiving them, it is not possible to pair ESPNow devices. Is there any update on this? |
I am using circuitpython + ESPNow for a custom sensor and this has been working reliably for the past few months - also using the broadcast adress. My receiver is additionally using wifi, so I had to fix the Wifi channel in my router settings (in this case to channel 6). Here are snippets of my code: async def handle_esp_now():
e = espnow.ESPNow()
while True:
await asyncio.sleep(0.1)
if not e: continue
packet = e.read()
last_received_data = json.loads(packet.msg.decode())
if "topic" in last_received_data:
mqtt_client.publish(last_received_data["topic"], json.dumps(last_received_data)) Transmitter: # hack to switch channel that is used for ESPNow
# this takes just a few milliseconds, so doesn't waste a lot of power
wifi.radio.start_ap(" ", "", channel=6, max_connections=0)
wifi.radio.stop_ap()
e = espnow.ESPNow()
peer = espnow.Peer(mac=b'\xff\xff\xff\xff\xff\xff', channel=6)
e.peers.append(peer)
...
data = {
"voltage": voltage,
"topic": "state/circuitpy-sensor3"
}
message = json.dumps(data)
e.send(message, peer) If I remember correctly, the seeming redundancy (specifying the channel twice, i.e. once in the wifi settings as well as in the |
Well, this is precious information! |
Switch to MicroPython - it properly supports channel selection and broadcast addresses. |
Sadly, MicroPython has other issues that make it even less desirable for me. For example, the default hardware transmission mode of Circuitpython gives me twice the range of MicroPython's default mode (neither can be switched, it's another bug see #9790 and micropython#16179). |
CircuitPython version
Code/REPL
Behavior
Description
Change the "if 0:" to "if 1:" and this is what we see:-
The logically identical code in micropython works fine
MicroPython version:
Additional information
It also does not allow channel numbers - the below errors out:-
peer = espnow.Peer(b'\x24\xdc\xc3\x8b\xe1\xc8', channel=9)
as mentioned in #7903
The "receiver" side of the code does seem to semi-work (gets packets from my micro-python version) but experiences a very high number of read error exceptions
espnowclient.py
The text was updated successfully, but these errors were encountered: