Post your best Lua script examples here

User avatar
By alexhi
#6878 This is good script, but conn:connect(7777,"255.255.255.255") not work my WIFI. Router kill broadcast "255.255.255.255"
This is work OK. conn:connect(7777,"192.168.1.255")
User avatar
By Peter
#7008 see http://en.wikipedia.org/wiki/Broadcast_address
A special definition exists for the IP broadcast address 255.255.255.255. It is the broadcast address of the zero network or 0.0.0.0, which in Internet Protocol standards stands for this network, i.e. the local network. Transmission to this address is limited by definition, in that it is never forwarded by the routers connecting the local network to other networks.

With my router it works in the same subnet to all wifi and ethernet clients with IP in range 192.168.1.*
User avatar
By Peter
#33952 The esp01 is running over 10 month without problems! Not continuously, but after a reboot ( by watchdog?) the esp is very fast up again. Here an examle from the log:
2015-11-06 15:21:26.3022|INFO|up=1313266;heap=8312;E=79514;G=7234
2015-11-06 15:21:57.4585|INFO|up=27;heap=8832;E=1;G=0
Up Time was 1.3Mio seconds = 15 days.

Here is also an python script to receive the udp packets:

Code: Select allimport socket

UDP_IP = "0.0.0.0"
UDP_PORT = 15000

sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))

while True:
    data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
    print("received message:", data)


....................
Output:
received message: b'up=2145;heap=8496;E=178;G=22'
received message: b'up=2158;heap=8480;E=178;G=23'
received message: b'up=2159;heap=8496;E=179;G=23'
received message: b'up=2172;heap=8480;E=180;G=23'
received message: b'up=2185;heap=8496;E=180;G=24'
received message: b'up=2198;heap=8480;E=182;G=24'
received message: b'up=2211;heap=8496;E=182;G=25'
received message: b'up=2225;heap=8480;E=184;G=25'