Added server stub
This commit is contained in:
41
rpi/main.py
41
rpi/main.py
@@ -1,49 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
import cv2
|
||||
from flask import Flask
|
||||
|
||||
from hardware.screen.screen import Screen
|
||||
from hardware.rfid.reader import RfidReader
|
||||
from services.detection_service import DetectionService
|
||||
from services.mqtt_service import MQTTService
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
screen = Screen()
|
||||
mqtt_service = MQTTService("127.0.0.1", 1883)
|
||||
reader = RfidReader("/dev/serial0", 9600)
|
||||
detection_service = DetectionService()
|
||||
|
||||
def publish(chip_id : int) :
|
||||
screen.displayMessage(str(chip_id))
|
||||
mqtt_service.publish("app", "/board-mate/rfid/scan", str(chip_id), 0)
|
||||
|
||||
def detect() :
|
||||
cap = cv2.VideoCapture(0)
|
||||
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
|
||||
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
|
||||
cap.set(cv2.CAP_PROP_FPS, 30)
|
||||
|
||||
print("Initialized")
|
||||
if not cap.isOpened():
|
||||
print("Error: Could not open camera")
|
||||
exit()
|
||||
|
||||
while True:
|
||||
ret, frame = cap.read()
|
||||
fen = detection_service.get_fen(frame)
|
||||
print(fen)
|
||||
if not ret:
|
||||
print("Error: Failed to grab frame")
|
||||
break
|
||||
@app.route("/party/start", methods=['POST'])
|
||||
def start_party():
|
||||
print("Party started!")
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
screen.enableBackground()
|
||||
screen.displayMessage("Waiting for scan...")
|
||||
reader = RfidReader("/dev/serial0", 9600)
|
||||
reader.subscribe(publish)
|
||||
|
||||
reader.start()
|
||||
reader.subscribe(lambda uid: mqtt_service.publish(
|
||||
"rpi", "/board-mate/rfid/scan", str(uid), 0
|
||||
))
|
||||
|
||||
detect()
|
||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
||||
|
||||
while True:
|
||||
pass
|
||||
|
||||
"""
|
||||
def get_move(prompt, move_queue):
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
from flask import Flask
|
||||
from controllers.device_controller import api_bp
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
app.register_blueprint(api_bp, url_prefix='/devices')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
||||
Reference in New Issue
Block a user