write.lua 768 B

12345678910111213141516171819202122232425262728
  1. local wifi = wifi
  2. local file = file
  3. local assert = assert
  4. local type = type
  5. local yo_file = 'yorecipient.txt'
  6. local debug_message = debug_message
  7. --TODO: validate ALL THE THINGS!
  8. module(...)
  9. function yo_recipient(value)
  10. --TODO strip all non-alphanumeric
  11. assert(type(value) == 'string')
  12. file.open(yo_file, 'w+')
  13. file.write(value)
  14. file.close()
  15. end
  16. function new_settings(settings)
  17. --TODO 1-7 length passwords --> ''
  18. --TODO strip all invalid SSID,pw chars
  19. assert(type(settings.ssid) == 'string', 'ssid must be a string')
  20. assert(type(settings.password) == 'string', 'password must be a string')
  21. assert(type(settings.yo_to) == 'string', 'yo_to must be a string')
  22. yo_recipient(settings.yo_to)
  23. wifi.sta.config(settings.ssid, settings.password)
  24. end