21 lines
516 B
Python
21 lines
516 B
Python
import bluetooth
|
|
import time
|
|
server_mac = '8C:E9:EE:C9:33:4D'
|
|
port = 5
|
|
|
|
while True:
|
|
sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
|
|
sock.connect((server_mac, port))
|
|
|
|
try:
|
|
# sock.send("get_status".encode())
|
|
sock.send("get_status".encode('utf-8'))
|
|
data = sock.recv(1024)
|
|
print("서버 응답:", data.decode())
|
|
except bluetooth.btcommon.BluetoothError as e:
|
|
print("Bluetooth 오류 발생:", e)
|
|
finally:
|
|
sock.close()
|
|
|
|
time.sleep(2)
|