Last active
July 19, 2016 20:17
-
-
Save TobleMiner/0dd17e1b0c8957b1e3ec38a96ced6e38 to your computer and use it in GitHub Desktop.
Doorlockd prototype
This file contains hidden or 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
#!/bin/env python3 | |
import socket | |
import RPi.GPIO as gpio | |
import time | |
GPIO = 7 | |
LISTEN_ADDRESS = '127.0.0.1' | |
LISTEN_PORT = 3214 | |
OPEN_TIME = 5 | |
gpio.setmode(gpio.BOARD) | |
gpio.setup(GPIO, gpio.OUT) | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
sock.bind((LISTEN_ADDRESS, LISTEN_PORT)) | |
while True: | |
data, addr = sock.recvfrom(1024) | |
print(data) | |
if data == b"open": | |
gpio.output(GPIO, gpio.HIGH) | |
time.sleep(OPEN_TIME) | |
gpio.output(GPIO, gpio.LOW) |
This file contains hidden or 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
[Unit] | |
Description=Doord | |
[Service] | |
ExecStart=/usr/local/sbin/doord.py | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or 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
#!/bin/env python3 | |
import socket | |
SERVER_ADDRESS = '127.0.0.1' | |
SERVER_PORT = 3214 | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
sock.sendto(b'open', (SERVER_ADDRESS, SERVER_PORT)) |
This file contains hidden or 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
. | |
. | |
. | |
. | |
door:x:1002:1003::/home/door:/usr/local/bin/open |
This file contains hidden or 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
# | |
# /etc/shells | |
# | |
/bin/sh | |
/bin/bash | |
/usr/local/bin/open | |
# End of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment