当前位置: 首页>>代码示例>>Python>>正文


Python GATTRequester.read_by_uuid方法代码示例

本文整理汇总了Python中gattlib.GATTRequester.read_by_uuid方法的典型用法代码示例。如果您正苦于以下问题:Python GATTRequester.read_by_uuid方法的具体用法?Python GATTRequester.read_by_uuid怎么用?Python GATTRequester.read_by_uuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gattlib.GATTRequester的用法示例。


在下文中一共展示了GATTRequester.read_by_uuid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: OnBPButtonClick

# 需要导入模块: from gattlib import GATTRequester [as 别名]
# 或者: from gattlib.GATTRequester import read_by_uuid [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
开发者ID:ioarun,项目名称:cognitivehealthcare,代码行数:45,代码来源:gateway_publisher.py

示例2: DiscoveryService

# 需要导入模块: from gattlib import GATTRequester [as 别名]
# 或者: from gattlib.GATTRequester import read_by_uuid [as 别名]
    return r.text

service = DiscoveryService()
devices = service.discover(2)

for addr, name in devices.items():
	print("%s (%s)" % (name,addr))
	print(name)
	if(name=="RapidPrototype"):
		req=GATTRequester(addr,False)
		req.connect(True)
		status="connected" if req.is_connected() else "not connectd"
		print(status)
		prevData="00"
		while(True):
			data=req.read_by_uuid("A495FF21-C5B1-4B44-B512-1370F02D74DE")
			data=str(data)
			data=data[4:6]
			if(data=="00" and prevData=="01"):
				print("Box is open")
				val = {
                                        "sensor_id": "pillbox",
                                        "value": 0
                                }
				post(host, val)
			if(data=="01" and prevData=="00"):
				print("Box is closed")
				val = {
                                        "sensor_id": "pillbox",
                                        "value": 1
                                }
开发者ID:PseudoSky,项目名称:rpcs-sensors,代码行数:33,代码来源:blex.py

示例3: DiscoveryService

# 需要导入模块: from gattlib import GATTRequester [as 别名]
# 或者: from gattlib.GATTRequester import read_by_uuid [as 别名]
from gattlib import GATTRequester
import time

from gattlib import DiscoveryService

service = DiscoveryService("hci0")
devices = service.discover(2)

print "Nearby devices :",devices.items()

req = GATTRequester("Bluetooth MAC Adress of Peripheral")
while 1:
	name = req.read_by_uuid("2a37")[0]
	value = []
	for c in name:
		value.append(ord(c))
	if(name):
		print "Sensor value : ",value[1]

	else:
		print "*************************************"
		#time.sleep(1)
开发者ID:ioarun,项目名称:cognitivehealthcare,代码行数:24,代码来源:ble_read_example.py

示例4: GATTRequester

# 需要导入模块: from gattlib import GATTRequester [as 别名]
# 或者: from gattlib.GATTRequester import read_by_uuid [as 别名]
devices = scanner.scan(5.0)
bAddr = ""
for dev in devices:
    if "6c:72:20" in dev.addr and dev.getValueText(1) and dev.getValueText(7) and dev.getValueText(9):
        bAddr = dev.addr
        print "[+] Komfy switch found: %s (%s), RSSI=%d dB" % (dev.addr, dev.addrType, dev.rssi)
if not bAddr:
    print "No Komfy switches found"
    sys.exit(1)

req = GATTRequester(bAddr.encode("ascii", "ignore"), False, "hci0")
req.connect(True, "public", "none", 0, 78)

# request SSID
wifiSsid = req.read_by_uuid("0xb006")[0]
reg = re.search(r"(:\s\"(.*)\")", wifiSsid)
wifiSsid = reg.groups()[1].replace("\\", "")

# request komfy encoded wifi password
wifiPassKomfy64 = req.read_by_uuid("0xb007")[0]
reg = re.search(r"(:\s\"(.*)\")", wifiPassKomfy64)
wifiPassKomfy64 = reg.groups()[1].replace("\\", "")

# convert password to real base64
wifiPassBase64 = ""
for char in wifiPassKomfy64:
    i = komfy64Alphabet.index(char)
    wifiPassBase64 += base64Alphabet[i]

wifiPass = base64.b64decode(wifiPassBase64)
开发者ID:MeteorAdminz,项目名称:exploit-database,代码行数:32,代码来源:40633.py


注:本文中的gattlib.GATTRequester.read_by_uuid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。