本文整理汇总了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