module:micropython:esp32udpclientserver:esp32udpclientserver
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| module:micropython:esp32udpclientserver:esp32udpclientserver [2021/12/13 11:14] – [Version] omdevelop | module:micropython:esp32udpclientserver:esp32udpclientserver [2022/09/13 11:58] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Esp32UdpClientServer | + | ====== Esp32UdpClientServer ===== |
| [[http:// | [[http:// | ||
| [ | [ | ||
| Line 8: | Line 8: | ||
| ] | ] | ||
| + | ===== Version ===== | ||
| + | * Esp32-Udp-Kommunikation [[: | ||
| + | * [[: | ||
| + | * [[: | ||
| - | [[:Module: | + | ----- |
| - | + | [[http:// | |
| - | [[:Module: | + | [ |
| - | + | [[http:// | |
| - | ===== Benutzung ===== | + | [[http://www.openhardsoftware.de/ |
| - | * Datenaustausch zwischen UdpClient und UdpServer | + | [[http://www.openhardsoftware.de/mediawiki |
| - | * UdpClient(Esp32) wartet (nicht blocking!) auf Daten vom UdpServer(Pc) | + | [[http://www.openhardsoftware.de/nextcloud | NextCloud]] |
| - | * UdpClient(Pc) wartet (nicht blocking!) auf Daten vom UdpServer(Esp32) | + | ] |
| - | + | ||
| - | SourceCode **Esp32UdpClient.py**, | + | |
| - | <code python> | + | |
| - | # | + | |
| - | import time | + | |
| - | import network as NTW | + | |
| - | import socket as SKT | + | |
| - | # | + | |
| - | WL_SSID = ' | + | |
| - | WL_PW = ' | + | |
| - | # | + | |
| - | UDP_IPADDRESS = ' | + | |
| - | UDP_IPPORT = 5005 | + | |
| - | # | + | |
| - | # | + | |
| - | if (' | + | |
| - | # | + | |
| - | print(' | + | |
| - | # | + | |
| - | Wlan = NTW.WLAN(NTW.STA_IF) | + | |
| - | Wlan.active(False) | + | |
| - | Wlan.active(True) | + | |
| - | Wlan.connect(WL_SSID, | + | |
| - | while not(Wlan.isconnected()): | + | |
| - | pass | + | |
| - | print(' | + | |
| - | # | + | |
| - | Socket = SKT.socket(SKT.AF_INET, | + | |
| - | Socket.bind((UDP_IPADDRESS, | + | |
| - | Socket.setblocking(0) | + | |
| - | Loop = True | + | |
| - | while (Loop): | + | |
| - | try: | + | |
| - | Data, Address = Socket.recvfrom(1024) | + | |
| - | if (b' | + | |
| - | Loop = False | + | |
| - | except SKT.error: | + | |
| - | pass | + | |
| - | else: | + | |
| - | print(Data) | + | |
| - | finally: | + | |
| - | # debug print(' | + | |
| - | time.sleep(0.1) | + | |
| - | Socket.close() | + | |
| - | # | + | |
| - | print(' | + | |
| - | # | + | |
| - | </code> | + | |
| - | + | ||
| - | SourceCode **Esp32UdpServer.py**, | + | |
| - | <code python> | + | |
| - | # | + | |
| - | import time | + | |
| - | import network as NTW | + | |
| - | import socket as SKT | + | |
| - | # | + | |
| - | WL_SSID = ' | + | |
| - | WL_PW = ' | + | |
| - | # | + | |
| - | UDP_IPADDRESS = ' | + | |
| - | UDP_IPPORT = 5005 | + | |
| - | # | + | |
| - | # | + | |
| - | if (' | + | |
| - | # | + | |
| - | print(' | + | |
| - | # | + | |
| - | Wlan = NTW.WLAN(NTW.STA_IF) | + | |
| - | Wlan.active(False) | + | |
| - | Wlan.active(True) | + | |
| - | Wlan.connect(WL_SSID, | + | |
| - | while not(Wlan.isconnected()): | + | |
| - | pass | + | |
| - | print(' | + | |
| - | # | + | |
| - | Socket = SKT.socket(SKT.AF_INET, | + | |
| - | for I in range(0, 10): | + | |
| - | print(' | + | |
| - | Socket.sendto(b' | + | |
| - | time.sleep(1.0) | + | |
| - | # | + | |
| - | Socket.sendto(b' | + | |
| - | Socket.close() | + | |
| - | print(' | + | |
| - | # | + | |
| - | </code> | + | |
| - | + | ||
| - | Ausgabe in Terminal: | + | |
| - | <code python> | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
module/micropython/esp32udpclientserver/esp32udpclientserver.1639390486.txt.gz · Last modified: 2021/12/13 12:14 (external edit)