init.lua 881 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --[[ ASSUMPTIONS
  2. yorecipient.txt exists
  3. apikey.txt exists and contains a valid API key
  4. ]]
  5. DEBUG = true
  6. SETUP = false
  7. SETUP_TIMEOUT = 120000
  8. STARTUP_DELAY_TIMER = 0
  9. INTERRUPT_TIMER = 1
  10. INDEX_TIMER = 2
  11. SETUP_INACTIVITY_TIMER = 3
  12. WIFI_WAIT_TIMER = 4
  13. SUCCESS_SETUP_TIMER = 5
  14. YO_RECIPIENT = nil
  15. API_KEY = nil
  16. print("3 second startup delay using timer " .. STARTUP_DELAY_TIMER .. '...')
  17. tmr.alarm(STARTUP_DELAY_TIMER, 3000, 0, function ()
  18. print("Starting.")
  19. function debugMsg(msg)
  20. print("Yo debug: " .. msg)
  21. end
  22. debugMsg('Booting button ' .. node.chipid())
  23. yoRecipientExists = file.open('yorecipient.txt', 'r')
  24. YO_RECIPIENT = file.read()
  25. file.close()
  26. debugMsg('found recipient: ' .. tostring(YO_RECIPIENT))
  27. apiKeyExists = file.open('apikey.txt', 'r')
  28. API_KEY = file.read()
  29. file.close()
  30. debugMsg('api key: ' .. API_KEY)
  31. dofile("interrupt.lua")
  32. end)