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)
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))
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})
def startSession(): print("End Session") Arduino.stopSession() emit('cmd_response', {'response': 'Session Ended'})
def startSession(): print("Start Session") Arduino.startSession() emit('cmd_response', {'response': 'Session Started'})
def getSmokeSessionData(): emit('smokeSessionData', Arduino.getDataFromSessionStart())
def arduinoStatus(): Arduino.updateReadings() emit('statusData', Arduino.makeStatusDict(), broadcast=True)