Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

projects:wifi-doorbell [2015/05/14 19:35] (current)
Line 1: Line 1:
 +Dzwonek do drzwi hakerspejsu zrobiony z modułu ESP8266 z odpalonym NodeMCU.
  
 +
 +
 +==== Kod ====
 +<​code>​
 +
 +
 +function wait_for_wifi_conn ( func )
 +   ​tmr.alarm (1, 200, 1, function ( )
 +      if wifi.sta.getip ( ) == nil then
 +         print ("​."​)
 +      else
 +         ​tmr.stop (1)
 +         ​func()
 +      end
 +   end)
 +end
 +
 +wifi.setmode(wifi.STATION)
 +wifi.sta.config("​hackerspace.pl-guests","​topkek"​)
 +wifi.sta.connect()
 +gpio.mode(3,​gpio.OUTPUT)
 +gpio.write(3,​gpio.HIGH)
 +
 +wait_for_wifi_conn ( function() ​
 +--while wifi.sta.status() ~= 5 do
 +--tmr.delay(1000000)
 +--print(wifi.sta.status())
 +--end
 +print(wifi.sta.getip())
 +sk=net.createConnection(net.TCP,​ 0)
 +sk:​on("​sent",​ function(conn) print("​sent."​);​ conn:​close() end)
 +sk:​on("​connection",​ function(conn) print("​papiez tanczy ,_,") end)
 +sk:​on("​disconnection",​ function(conn) print("​disco."​);​ node.dsleep(0,​1) end)
 +sk:​connect(4200,"​10.8.1.15"​)
 +sk:​send("​SMOKE /weed HTTP/​1.1\r\n\r\n"​)
 +end)
 +</​code>​
projects/wifi-doorbell.txt · Last modified: 2015/05/14 19:35 (external edit)