SHARE
TWEET

Untitled

a guest Sep 11th, 2014 366 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import socket
  2. import time
  3. import urllib2
  4. import re
  5.  
  6. sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.SOL_UDP)
  7. sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
  8. sock.sendto("001,@?", 0, ('255.255.255.255' , 9760))
  9.  
  10. sock2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  11. sock2.bind(('0.0.0.0', 9761))
  12.  
  13. while True:
  14.         data, addr = sock2.recvfrom(1024) # buffer size is 1024 bytes
  15.         print "received message:", data
  16.         if re.search("1\\,\\?W=.*",data):
  17.                 m = re.search(r"(\d+)\,(\d+)\,(\d+),(\d+)",data)
  18.                 sock.sendto("001,@?", 0, ('255.255.255.255' , 9760))
  19.                 time.sleep(30)
  20.                 urllib2.urlopen("http://192.168.0.1:8080/json.htm?type=command&param=udevice&idx=46&nvalue=0&svalue="+m.group(1)+";"+m.group(3))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top