Last active
April 19, 2020 17:54
-
-
Save iamatulsingh/3679c051fc6a7957cb075abdff3a77be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def heart_rate_data(self): | |
self.hr_countdown = None | |
try: | |
service, = [s for s in self.getServices() if s.uuid == self.hrmid] | |
_ = service.getCharacteristics(forUUID=str(self.hrmmid)) | |
desc = self.getDescriptors(service.hndStart, service.hndEnd) | |
d, = [d for d in desc if d.uuid == self.cccid] | |
self.writeCharacteristic(d.handle, b'\x01\x00') | |
def print_hr(cHandle, data): | |
self.hr_countdown = time.perf_counter() | |
self._log.info(data[1]) | |
self.delegate.handleNotification = print_hr | |
self._log.info("Waiting for Heart Rate notification ...") | |
while True: | |
try: | |
if self.hr_countdown and (time.perf_counter() - self.hr_countdown) >= 3: | |
self._log.info("HRM completed") | |
break | |
else: | |
self.waitForNotifications(3.) | |
except KeyboardInterrupt: | |
self._log.info("HRM operation closed by user") | |
self.writeCharacteristic(d.handle, b'\x00\x00') | |
break | |
except BTLEException as btlE: | |
self._log.error(f"{btlE}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment