annotate console.lua @ 9:129ac4eef472 default tip

Add comments to the code.
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sun, 07 Jun 2015 14:38:33 +0200
parents aac66151e58e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
1 function lua_console(conn)
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
2 function send_output(str)
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
3 if (conn~=nil) then
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
4 conn:send(str);
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
5 end;
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
6 end;
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
7 node.output(send_output, 0);
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
8 conn:on("receive", function (conn, pl) node.input(pl) end);
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
9 conn:on("disconnection", function (conn) node.output(nil) end);
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
10 end;
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
11
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
12 function lua_init()
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
13 while wifi.ap.getip() == '' do
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
14 tmr.delay(50000);
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
15 print("Waiting for IP...");
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
16 end
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
17 lua_server = net.createServer(net.TCP, 180);
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
18 lua_server:listen(2323, lua_console);
aac66151e58e Lua console and a file downloading script
Radomir Dopieralski <sheep-devel@sheep.art.pl>
parents:
diff changeset
19 end