-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindemo.py
76 lines (70 loc) · 1.84 KB
/
indemo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import RPi.GPIO as GPIO
import time
import os
import thread
# this version we turn off all kill script, just for DEMO with sound
# sound play with buzzer instand of speaker
# change pinout id here if you use diffrent pin
killbutton=15
alarmbutton=14
buzzer=2
# put our private keys here, those keys in this dir will be overwrited if you enabled "self-destory"
keyDir='keys'
ssh = "ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null "
# please add your server list and keys here
servers = [
"-i keys/key1 [email protected]",
"-i keys/key1 [email protected]"]
status_unlock=False
status_fire=False
status_alarmTone=False
GPIO.setmode(GPIO.BCM)
GPIO.setup(killbutton, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
GPIO.setup(alarmbutton, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
GPIO.setup(buzzer, GPIO.OUT)
def killall():
print("kill all servers")
# do evil codes here
def alarmKey(channel):
global status_unlock,status_fire
print("key unlocked")
status_unlock = True
while True:
if(GPIO.input(alarmbutton) != 1):
status_unlock=False
print("disable alarm")
return
if GPIO.input(killbutton)==1:
status_fire=True
print("firing")
killall()
time.sleep(5)
print("reset all")
status_unlock=False
status_fire=False
return
time.sleep(0.1)
GPIO.add_event_detect(alarmbutton, GPIO.RISING, callback=alarmKey, bouncetime=300)
p = GPIO.PWM(buzzer, 50)
while True:
if(status_unlock and status_fire):
p.start(50)
p.ChangeFrequency(880)
time.sleep(5)
p.stop()
elif(status_unlock):
if status_alarmTone:
p.start(50)
p.ChangeFrequency(262)
time.sleep(0.5)
p.stop()
status_alarmTone=False
else:
p.start(50)
p.ChangeFrequency(659)
time.sleep(0.5)
p.stop()
status_alarmTone=True
else:
time.sleep(0.1)
GPIO.cleanup()