Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
836 B

8 years ago
  1. #!/bin/python
  2. import subprocess
  3. import socket
  4. from SCons.Script import DefaultEnvironment
  5. env = DefaultEnvironment()
  6. def is_valid_ip(ip):
  7. try:
  8. socket.inet_aton(ip)
  9. return True
  10. except socket.error:
  11. return False
  12. def before_build_spiffs(source, target, env):
  13. env.Execute("gulp buildfs2")
  14. def before_upload(source, target, env):
  15. upload_port = env.get('UPLOAD_PORT', False)
  16. if upload_port and upload_port[0] == '/':
  17. cmd = ["mosquitto_sub", "-t", upload_port, "-h", "192.168.1.10", "-N", "-C", "1"]
  18. ip = subprocess.check_output(cmd)
  19. if is_valid_ip(ip):
  20. env['UPLOAD_PORT'] = '"' + ip + '"'
  21. #env.AddPreAction("uploadfs", before_upload)
  22. #env.AddPreAction("upload", before_upload)
  23. env.AddPreAction(".pioenvs/%s/spiffs.bin" % env['PIOENV'], before_build_spiffs)