質問編集履歴
2
アドレスを××に
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,9 +36,9 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
bd_addr1 = "
|
39
|
+
bd_addr1 = "××:××:××:××:××:××" #the address
|
40
40
|
|
41
|
-
port1 = 1 #Connect Port
|
41
|
+
port1 = 1 #Connect Port
|
42
42
|
|
43
43
|
sock1 = bluetooth.BluetoothSocket(bluetooth.RFCOMM) #config
|
44
44
|
|
1
情報不足の指摘があったためつき追記
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Python
|
1
|
+
Python Bluetooth通信におけるデータの送信
|
test
CHANGED
@@ -30,12 +30,62 @@
|
|
30
30
|
|
31
31
|
###該当のソースコード
|
32
32
|
|
33
|
+
import bluetooth
|
33
34
|
|
34
|
-
|
35
|
-
|
35
|
+
from time import sleep
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
#
|
39
|
+
bd_addr1 = "00:06:66:7D:BE:90" #the address form the Arduino
|
40
40
|
|
41
|
+
port1 = 1 #Connect Port (raspberry pi to Arduino)
|
42
|
+
|
43
|
+
sock1 = bluetooth.BluetoothSocket(bluetooth.RFCOMM) #config
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
print "connect......"
|
48
|
+
|
41
|
-
|
49
|
+
sleep(2)
|
50
|
+
|
51
|
+
sock1.connect((bd_addr1 ,port1))
|
52
|
+
|
53
|
+
print "connected"
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
sleep(1)
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
print("Entering main loop now")
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
try:
|
66
|
+
|
67
|
+
while 1:
|
68
|
+
|
69
|
+
print "input"
|
70
|
+
|
71
|
+
tosend = raw_input()
|
72
|
+
|
73
|
+
if tosend != 'q':
|
74
|
+
|
75
|
+
#sock1.sendall(tosend)
|
76
|
+
|
77
|
+
sock1.sendall("0")
|
78
|
+
|
79
|
+
else:
|
80
|
+
|
81
|
+
break
|
82
|
+
|
83
|
+
print "Wait...."
|
84
|
+
|
85
|
+
sleep(0.01)
|
86
|
+
|
87
|
+
sock.close()
|
88
|
+
|
89
|
+
except KeyboardInterrupt:
|
90
|
+
|
91
|
+
pass
|