From e67bc84e3af2393565b83e0ac31d9a7423b79e85 Mon Sep 17 00:00:00 2001 From: Innovation Date: Fri, 29 Mar 2024 10:25:53 -0500 Subject: [PATCH] Modify vitalsd to reflect changes in 0bf03afb4f82167502b2da5949c652e05d18899f --- src/modules/vitalsd/vitalsd.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/modules/vitalsd/vitalsd.py b/src/modules/vitalsd/vitalsd.py index 12dac72..4da3ea0 100644 --- a/src/modules/vitalsd/vitalsd.py +++ b/src/modules/vitalsd/vitalsd.py @@ -1,6 +1,7 @@ import subprocess import time import requests +import sys from flask import jsonify heartrateCmd = ['itctl', 'get', 'heart'] @@ -44,17 +45,29 @@ battery = 0 urlBase = 'http://localhost:5000' urlHeartrate = urlBase + '/api/vitals/heartrate' urlSteps = urlBase + '/api/fitness/steps' +urlAddCyberware = urlBase + '/api/cyberware/add' #urlBattery = urlBase + # Cyberware management not yet implemented +# Add to Cyberware and get UUID +uuidRequest = requests.post(urlAddCyberware, json={ 'name': "PineTime", 'hotpluggable': True, 'canSet': [ '/api/vitals/heartrate', '/api/fitness/steps' ] }) +if(uuidRequest.status_code == 204): + uuid = uuidRequest.json()['uuid'] +else: + sys.exit("Failed to get UUID") + + while True: try: heartrate = getHeartrate() steps = getSteps() #battery = getBattery() - requests.post(urlHeartrate, json={ 'heartrate': heartrate } ) - requests.post(urlSteps, json={ 'steps': steps }) + requests.post(urlHeartrate, json={ 'heartrate': heartrate, 'uuid': uuid } ) + requests.post(urlSteps, json={ 'steps': steps, 'uuid': uuid }) except: print("An exception occured. TODO: Exception report to frontend.") time.sleep(1) + +# Disconnect Cyberware +requests.post(urlRemoveCyberware, json={ 'uuid': uuid })