-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_.py
77 lines (61 loc) · 1.62 KB
/
server_.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
77
# -*- coding: utf-8 -*-
import bluetooth
import os
import sys
import time
import time
import serial
print "Searching for devices..."
print ""
nearby_devices = bluetooth.discover_devices()
num = 0
print "Select your device by entering its coresponding number..."
for i in nearby_devices:
num+=1
print num , ": " , bluetooth.lookup_name( i )
selection = input("> ") - 1
print "You have selected", bluetooth.lookup_name(nearby_devices[selection])
bd_addr = nearby_devices[selection]
port = 1
sock = bluetooth.BluetoothSocket( bluetooth.RFCOMM )
sock.connect((bd_addr, port))
data = ""
cmd2 = 'feh -F --auto-zoom ~/disable_display/img/1_lf.png &'
cmd1 = 'feh -F --auto-zoom ~/disable_display/img/2_ri.png &'
smile = 'feh -F --auto-zoom ~/disable_display/img/3_smile.png &'
default = 'feh -F --auto-zoom img/default.png &'
kill = 'pkill -9 -ef feh'
count = 0
ser = serial.Serial('/dev/ttyACM0',9600, timeout = 1)
while 1:
why=ser.read(1)
if(why == '1'):
os.system(cmd1)
while(why == '1'):
why=ser.readline(1)
sock.send('1')
time.sleep(0.005)
sock.send('9')
os.system(default)
elif(why == '2'):
os.system(cmd2)
while(why == '2'):
why=ser.readline(1)
sock.send('2')
time.sleep(0.005)
sock.send('9')
os.system(default)
elif(why == '3'):
os.system(smile)
while(why == '3'):
why=ser.readline(1)
sock.send('3')
time.sleep(0.005)
sock.send('9')
os.system(default)
elif(why == '4'):
sock.send('4')
os.system(kill)
if(sock.recv == '8'):
os.system("python sms.py")
os.systme("feh -F --auto-zoom img/4.png &")