本文整理匯總了Python中gattlib.GATTRequester.read_by_handle方法的典型用法代碼示例。如果您正苦於以下問題:Python GATTRequester.read_by_handle方法的具體用法?Python GATTRequester.read_by_handle怎麽用?Python GATTRequester.read_by_handle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gattlib.GATTRequester
的用法示例。
在下文中一共展示了GATTRequester.read_by_handle方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: GATTRequester
# 需要導入模塊: from gattlib import GATTRequester [as 別名]
# 或者: from gattlib.GATTRequester import read_by_handle [as 別名]
from gattlib import GATTRequester, GATTResponse
address = "B8:27:EB:AA:82:FA"
requester = GATTRequester(address)
data = requester.read_by_handle(0x000c)
print(data[0])
示例2: OnBPButtonClick
# 需要導入模塊: from gattlib import GATTRequester [as 別名]
# 或者: from gattlib.GATTRequester import read_by_handle [as 別名]
def OnBPButtonClick(self):
f = open("bp.csv", 'wt')
writer = csv.writer(f)
writer.writerow( ('sys', 'dia','pulse') )
req = GATTRequester("98:4F:EE:0F:59:D6")
req.write_by_handle(0x000e,str(bytearray([02])))
tt = req.read_by_handle(0x0010)[0]
pp = []
for c in tt:
pp.append(ord(c))
print pp
if(pp[1] == 2):
while(1):
try:
tt = req.read_by_handle(0x0010)[0]
pp = []
for c in tt:
pp.append(ord(c))
if(pp[0] == 3):
break
except Exception,e:
print e
try:
name = req.read_by_uuid("2A40")[0]
#steps = (req.read_by_handle(0x0009)[0])
print type(name)
value = []
for c in name:
value.append((c))
print value
print "sys :"+value[1]+value[2]+value[3]+"\n"
print "dia :"+value[6]+value[7]+value[8]+"\n"
print "sys :"+value[11]+value[12]+value[13]+"\n"
writer.writerow((value[1]+value[2]+value[3],value[6]+value[7]+value[8],value[11]+value[12]+value[13]))
except Exception,e:
#name = False
print e
示例3: OnGSRButtonClick
# 需要導入模塊: from gattlib import GATTRequester [as 別名]
# 或者: from gattlib.GATTRequester import read_by_handle [as 別名]
def OnGSRButtonClick(self):
req = GATTRequester("98:4F:EE:0F:59:D6")
temp = []
f = open("gsr.csv", 'a')
writer = csv.writer(f)
writer.writerow( ('timestamp', 'gsr') )
flagTemp = 0;
flagBP = 1;
flagGSR = 0;
req.write_by_handle(0x000e,str(bytearray([01])))
tt = req.read_by_handle(0x0010)[0]
示例4: Reader
# 需要導入模塊: from gattlib import GATTRequester [as 別名]
# 或者: from gattlib.GATTRequester import read_by_handle [as 別名]
class Reader(object):
def __init__(self, address):
self.requester = GATTRequester(address, False)
self.connect()
self.request_data()
def connect(self):
print("Connecting...", end=' ')
sys.stdout.flush()
self.requester.connect(True)
print("OK!")
def request_data(self):
data = self.requester.read_by_handle(0x1)[0]
print("bytes received:", end=' ')
for b in data:
print(hex(ord(b)), end=' ')
print("")
示例5: GATTResponse
# 需要導入模塊: from gattlib import GATTRequester [as 別名]
# 或者: from gattlib.GATTRequester import read_by_handle [as 別名]
response = GATTResponse()
req.connect()
req.read_by_handle_async(0x3A, response)
while not response.received():
time.sleep(0.1)
steps = response.received()[0]
#print "steps..."
#print type(steps)
#print steps
#for b in steps:
# print hex(ord(b)),' '
req.write_by_handle(0x3C, str(bytearray([0xff, 0xff])))
req.write_by_handle(0x3E, str(bytearray([0x64])))
data = req.read_by_handle(0x3C)[0]
#for d in data:
# print hex(ord(d)),' '
#print("")
req.write_by_handle(0x3A, str(bytearray([0x0, 0x0])))
for i in range(1000):
data = req.read_by_handle(0x39)[0]
for d in data:
print hex(ord(d)),
print("")
i = 0
axl = 0x00
axh = 0x00
for d in data:
if i > 5 and i <= 11:
if i == 6: # get axl and axh