Skip to content

Instantly share code, notes, and snippets.

@korayal
Created May 28, 2013 11:47
Show Gist options
  • Save korayal/5662180 to your computer and use it in GitHub Desktop.
Save korayal/5662180 to your computer and use it in GitHub Desktop.
salon ışığı açmatik
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