樹莓派學習記錄---pybluez raspberry pi 3藍牙接收與發送
##接收藍牙藍牙訊息和發送藍牙信息 ##a87091988@gmail.com import bluetooth import time bd_addr = "44:44:10:04:0F:77" # here need to modify. use hciconfig to get address port = 1 sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM ) sock.connect((bd_addr, port)) sock.send("hello!!") try: while True: time.sleep(1) localtime = time.asctime( time.localtime(time.time()) ) sock.send(str(localtime)) data = sock.recv(1024) if len(data) == 0: break print data except IOError: pass sock.close()