示例#1
0
def socket_connect():
    socketId = str(uuid.uuid4())
    current_app.clients.append(socketId)
    session['socketId'] = socketId
    print("Client Connected. Active sockets:", len(app.clients))
    Arduino.start_socket_interval_readings(SOCKET_SAMPLING_INTERVAL)
    emit('connected response', {'socketId': socketId})
    emit('new leader', {'leader': app.clients[0]}, broadcast=True)
示例#2
0
def socket_disconnect():
    print("Disconnect funciton...")
    current_app.clients.remove(session['socketId'])
    if len(app.clients) < 1: Arduino.stop_socket_interval_readings()
    else: emit('new leader', {'leader': app.clients[0]})
    print('Client disconnected. Active Sockets:', len(app.clients))
示例#3
0
def adjustSessionStart(startTimeData):
    newHour, newMin = startTimeData["start_time"].split(":")
    response = Arduino.adjustSessionStart(int(newHour), int(newMin))
    # Need to add error feedback; check that time is not in the future
    emit('cmd_response', {'response': response})
示例#4
0
def startSession():
    print("End Session")
    Arduino.stopSession()
    emit('cmd_response', {'response': 'Session Ended'})
示例#5
0
def startSession():
    print("Start Session")
    Arduino.startSession()
    emit('cmd_response', {'response': 'Session Started'})
示例#6
0
def getSmokeSessionData():
    emit('smokeSessionData', Arduino.getDataFromSessionStart())
示例#7
0
def arduinoStatus():
    Arduino.updateReadings()
    emit('statusData', Arduino.makeStatusDict(), broadcast=True)