Skip to content

ESP32-S2: Add UDP with recvfrom_into and sendto #3708

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

Merged
merged 10 commits into from
Nov 26, 2020
Merged

ESP32-S2: Add UDP with recvfrom_into and sendto #3708

merged 10 commits into from
Nov 26, 2020

Conversation

hierophect
Copy link
Collaborator

This PR implements the sendto and recvfrom_into functions in socketpool/Socket, enabling datagram send and receive. Tested on Saola 1 Wrover with Scott's modification to the Adafruit NTP library:

https://github.com/tannewt/Adafruit_CircuitPython_NTP/blob/raw_ntp/adafruit_ntp.py

Note that I had to replace instances of time.gmtime with time.localtime to get this to work, since gmtime is not implemented in Circuitpython. code.py sketch is as follows:

import wifi
import socketpool
import adafruit_ntp
import time
from secrets import secrets

# connect to wifi
print("Connecting to %s"%secrets["ssid"])
wifi.radio.connect(secrets["ssid"], secrets["password"])
pool = socketpool.SocketPool(wifi.radio)
ntp = adafruit_ntp.NTP(pool)

while True:
    print(ntp.datetime)
    time.sleep(1)

@hierophect hierophect added the espressif applies to multiple Espressif chips label Nov 17, 2020
@hierophect hierophect requested review from tannewt and jepler November 17, 2020 21:21
@askpatrickw
Copy link

@hierophect, I was able to build and test this on a UMFeatherS2.

Along with the changes to the NTP library, I also had to comment out the check for the Epoch on line 61 in the NTP library.

I could also set the RTC to ntp.datetime.

r = rtc.RTC()
r.datetime = ntp.datetime

Copy link

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The esp_idf submodule has been mistakenly updated to an old ref, please correct it.

@hierophect hierophect requested a review from jepler November 24, 2020 19:51
@tannewt
Copy link
Member

tannewt commented Nov 24, 2020

@hierophect There is a translation conflict still.

Copy link

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@jepler jepler merged commit 7923aa0 into adafruit:main Nov 26, 2020
@hierophect hierophect deleted the esp32s2-udp branch February 9, 2021 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
espressif applies to multiple Espressif chips
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants