Created
May 28, 2013 11:47
-
-
Save korayal/5662180 to your computer and use it in GitHub Desktop.
salon ışığı açmatik
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import sys | |
UDP_IP = "192.168.1.254" | |
UDP_PORT = 5000 | |
MESSAGE = "AT+D" + sys.argv[1] + "," + chr(0xFE) + chr(int(sys.argv[2])) + chr(0xFE) + chr(0xFF) | |
sock = socket.socket(socket.AF_INET, | |
socket.SOCK_DGRAM) | |
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT)) | |
while True: | |
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes | |
response = map(ord, data) | |
if response[0] == 0: | |
sys.exit("command completed") | |
print "received message:", data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment