Modify vitalsd to reflect changes in 0bf03afb4f
This commit is contained in:
parent
0bf03afb4f
commit
e67bc84e3a
|
@ -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 })
|
||||
|
|
Loading…
Reference in a new issue