Scientia est Potentia
ㅁㄴㅇ 본문
from bluepy import btle
import time
class MyDelegate(btle.DefaultDelegate):
def __init__(self):
btle.DefaultDelegate.__init__(self)
# ... initialise here
def handleNotification(self, cHandle, data):
#print("\n- handleNotification -\n")
print(data)
# ... perhaps check cHandle
# ... process 'data'
# Initialisation -------
p = btle.Peripheral("34:AB:95:5A:10:A2")
# Setup to turn notifications on, e.g.
svc = p.getServiceByUUID("6E400001-B5A3-F393-E0A9-E50E24DCCA9E")
ch_Tx = svc.getCharacteristics("6E400002-B5A3-F393-E0A9-E50E24DCCA9E")[0]
ch_Rx = svc.getCharacteristics("6E400003-B5A3-F393-E0A9-E50E24DCCA9E")[0]
p.setDelegate( MyDelegate())
setup_data = b" "
p.writeCharacteristic(ch_Rx.valHandle+1, setup_data)
while True:
message = bytes(b'a')
message1 = bytes(b'b')
try:
ch_Tx.write(message, True)
ch_Tx.write(message1, True)
time.sleep(5)
except btle.BTLEException:
print("btle.BTLEException");
'01 HardWare > 019 HW_etc.' 카테고리의 다른 글
CygLiDAR D1 - 아두이노 사용하여 라이다 거리 측정하기 (0) | 2022.06.11 |
---|---|
CygLiDAR D1 사용기 - 통신속도 변경하기 (0) | 2022.06.07 |
CygLiDAR d1 아두이노 Uart/Serial 통신(SoftwareSerial) (0) | 2022.06.06 |
우분투 USB 드라이버 (0) | 2022.06.02 |
CygLiDAR 사용기 3 (0) | 2022.06.02 |