Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. SLEEP_TIME = 30 * 1000 * 1000
  2.  
  3. function do_spania()
  4.   print("Polaczono")
  5.   print(wifi.sta.getip())
  6.   print("Ide spac na ".. SLEEP_TIME/1000/1000 .."s")
  7.   node.dsleep(SLEEP_TIME)
  8. end
  9.  
  10. local function startup()
  11.  tmr.stop(0)
  12.  if abort == true then  --zatrzymaj program
  13.   return
  14.  else                   --wykonuj program
  15.  
  16.   if wifi.sta.getip() ~= nil then --juz polaczony do sieci
  17.    do_spania()
  18.   else
  19.    tmr.alarm(1, 500, 1, function()
  20.     if wifi.sta.getip() == nil then
  21.      print("Waiting for IP...")
  22.     else
  23.      tmr.stop(1)
  24.      do_spania()
  25.     end
  26.    end)
  27.   end
  28.  end                    --koniec warunku zatrzymania programu
  29. end
  30.  
  31.  --dofile ("program_DHT22.lua")
  32.  --if wifi.sta.status() ~= 0 then --NOT STATION_IDLE
  33.  --   wifi.sta.disconnect()
  34.  --end
  35.  
  36. local abort = false
  37. local switch = 1
  38. gpio.mode(switch,gpio.INPUT,gpio.PULLUP)
  39.  
  40. GPIO14 = 5
  41. gpio.mode(GPIO14,gpio.OUTPUT)
  42. gpio.write(GPIO14,gpio.HIGH)
  43.  
  44. wifi.setmode(wifi.STATION)
  45. wifi.sta.config("SSID","PWD")
  46. wifi.sta.connect()
  47.  
  48. print("Modul uruchomiony")
  49. print('Czekam na sygnal przerwania')
  50. tmr.alarm(0,2000,0,startup)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement