RainEagle library plus script for polling data
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.
 
 

75 lines
1.0 KiB

  1. #!/usr/bin/env python
  2. """
  3. based on TalkToEagle.py
  4. """
  5. import socket
  6. import sys
  7. import time
  8. my_macid = "0xd8d5b90000001296"
  9. # Enter your Eagle's IP below
  10. Eagle_IP = "10.1.1.39"
  11. ## list_devices
  12. s = socket.create_connection( (Eagle_IP, 5002), 10)
  13. print s
  14. time.sleep(1)
  15. sendstr = "<LocalCommand>\n<Name>list_devices</Name>\n</LocalCommand>\n"
  16. s.sendall(sendstr)
  17. print
  18. print "sending to Eagle: \n\r"
  19. print sendstr
  20. print
  21. time.sleep(1)
  22. print "Eagle response: \n\r"
  23. while 1:
  24. buf = s.recv(1000)
  25. if not buf:
  26. break
  27. sys.stdout.write(buf)
  28. s.close()
  29. ## get_history_data
  30. s = socket.create_connection( (Eagle_IP, 5002), 10)
  31. print s
  32. time.sleep(1)
  33. sendstr = "<LocalCommand>\n<Name>get_history_data</Name>\n<MacId>{0}</MacId>\n<StartTime>0x00000000</StartTime>\n</LocalCommand>\n".format(my_macid)
  34. s.sendall(sendstr)
  35. print
  36. print "sending to Eagle: \n\r"
  37. print sendstr
  38. print
  39. time.sleep(1)
  40. print "Eagle response: \n\r"
  41. while 1:
  42. buf = s.recv(1000)
  43. if not buf:
  44. break
  45. sys.stdout.write(buf)
  46. s.close()
  47. exit(0)