added connair
This commit is contained in:
parent
39abc1759d
commit
2b7bec2a26
1 changed files with 23 additions and 0 deletions
23
connair.py
Normal file
23
connair.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
import socket
|
||||
|
||||
UDP_IP = "0.0.0.0"
|
||||
UDP_PORT = 49880
|
||||
HELLO_MESSAGE = "HCGW:VC:Seegel Systeme;MC:RaspyRFM;FW:1.00;IP:192.168.2.125;;"
|
||||
|
||||
sock = socket.socket(socket.AF_INET, # Internet
|
||||
socket.SOCK_DGRAM) # UDP
|
||||
sock.bind((UDP_IP, UDP_PORT))
|
||||
|
||||
while True:
|
||||
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
|
||||
msg = str(data).split(":")
|
||||
|
||||
print "received message:", msg, "from ", addr
|
||||
|
||||
if msg[0] == "SEARCH HCGW":
|
||||
sock.sendto(HELLO_MESSAGE, addr)
|
||||
print "Hello message"
|
||||
|
||||
if msg[0] == "TXP":
|
||||
cmd = msg[1].split(",")
|
||||
print "Command: ", cmd
|
Loading…
Reference in a new issue