tried with modified code, but no luck:
from m5stack import *
from m5ui import *
from uiflow import *
import wifiCfg
import network
import socket
import module
#WiFi
wifiCfg.screenShow()
wifiCfg.autoConnect(lcdShow=True)
wifiIp = wifiCfg.wlan_sta.ifconfig()[0]
title0 = M5Title(title="SERVER-EXAMPLE", x=95, fgcolor=0xFFFFFF, bgcolor=0xff001d)
label0 = M5TextBox(10, 40, "WiFi ip :" + str(wifiIp), lcd.FONT_Ubuntu, 0xfff500, rotate=0)
counter = 0
#Ethernet
lan = module.get(module.LANBASE)
eth0Ip = lan.get_if_config()[0]
label1 = M5TextBox(10, 60, "Eth0 ip :" + str(eth0Ip), lcd.FONT_Ubuntu, 0xfff500, rotate=0)
lan.tcp_udp_config(eth0Ip, 80, 1, 1) ## es muss ein call gemacht werden, damit das Programm weiter läuft
#Choose ip address
#ip = wifiIp # works
ip = eth0Ip # does not work
label2 = M5TextBox(10, 80, "SERVER is running", lcd.FONT_Ubuntu, 0xfff500, rotate=0)
label3 = M5TextBox(10, 100, "waiting...", lcd.FONT_Ubuntu, 0xfff500, rotate=0)
label4 = M5TextBox(10, 120, "received?", lcd.FONT_Ubuntu, 0xfff500, rotate=0)
if ip == wifiIp:
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.settimeout(30)
server.bind((wifiIp, 80))
while True:
server.listen(1)
(conn, addr) = server.accept()
request = conn.recv(4096)
if request:
counter = counter + 1
request = str(request)
conn, addr = server.accept()
label3.setText(str(counter))
label4.setText(str(request))
response = 'Hello, world!'
conn.sendall(response)
conn.close()
wait_ms(2)
if ip == eth0Ip:
while True:
if lan.is_available_packet(1):
counter = counter + 1
request = str(lan.tcp_receive_packet(0))
label3.setText(str(counter))
label4.setText(str(request))
response = 'Hello, world!'
lan.tcp_send_packet(response)
wait_ms(2)