Fix env variables
This commit is contained in:
9
rpi/.env
9
rpi/.env
@@ -0,0 +1,9 @@
|
|||||||
|
LOCAL_BROKER_ADDRESS=127.0.0.1
|
||||||
|
LOCAL_BROKER_PORT=1883
|
||||||
|
LOCAL_USERNAME=system
|
||||||
|
LOCAL_PASSWORD=hepl
|
||||||
|
|
||||||
|
API_BROKER_ADDRESS=192.168.15.125
|
||||||
|
API_BROKER_PORT=1883
|
||||||
|
API_USERNAME=pi-1
|
||||||
|
API_PASSWORD=hepl
|
||||||
|
|||||||
16
rpi/main.py
16
rpi/main.py
@@ -2,7 +2,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
from dotenv import load_dotenv
|
||||||
from controllers.mqtt_forwarder import MQTTForwarder
|
from controllers.mqtt_forwarder import MQTTForwarder
|
||||||
from hardware.light.lora_light_sensor_reader import LoraLightSensorReader
|
from hardware.light.lora_light_sensor_reader import LoraLightSensorReader
|
||||||
from hardware.screen.screen import Screen
|
from hardware.screen.screen import Screen
|
||||||
@@ -10,16 +10,20 @@ from hardware.rfid.reader import RfidReader
|
|||||||
from services.detection_service import DetectionService
|
from services.detection_service import DetectionService
|
||||||
from services.mqtt_service import MQTTService
|
from services.mqtt_service import MQTTService
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
client_id = "pi-1"
|
client_id = "pi-1"
|
||||||
|
|
||||||
local_broker_address = os.environ.get("LOCAL_BROKER_ADDRESS", "127.0.0.1")
|
local_broker_address = os.environ.get("LOCAL_BROKER_ADDRESS", "127.0.0.1")
|
||||||
local_broker_port = int(os.environ.get("LOCAL_BROKER_PORT", 1883))
|
local_broker_port = int(os.environ.get("LOCAL_BROKER_PORT", 1883))
|
||||||
|
local_username = os.environ.get("LOCAL_USERNAME")
|
||||||
|
local_password = os.environ.get("LOCAL_USERNAME")
|
||||||
|
|
||||||
api_broker_address = os.environ.get("API_BROKER_ADDRESS", "127.0.0.1")
|
api_broker_address = os.environ.get("API_BROKER_ADDRESS", "127.0.0.1")
|
||||||
api_broker_port = int(os.environ.get("API_BROKER_PORT", 1883))
|
api_broker_port = int(os.environ.get("API_BROKER_PORT", 1883))
|
||||||
|
api_username = os.environ.get("API_USERNAME")
|
||||||
|
api_password = os.environ.get("API_PASSWORD")
|
||||||
|
|
||||||
screen = Screen()
|
screen = Screen()
|
||||||
rfid_reader = RfidReader("/dev/serial0", 9600)
|
rfid_reader = RfidReader("/dev/serial0", 9600)
|
||||||
@@ -29,16 +33,16 @@ local_broker = MQTTService(
|
|||||||
local_broker_address,
|
local_broker_address,
|
||||||
local_broker_port,
|
local_broker_port,
|
||||||
client_id="system",
|
client_id="system",
|
||||||
username="system",
|
username=local_username,
|
||||||
password="hepl",
|
password=local_password,
|
||||||
)
|
)
|
||||||
|
|
||||||
api_broker = MQTTService(
|
api_broker = MQTTService(
|
||||||
api_broker_address,
|
api_broker_address,
|
||||||
api_broker_port,
|
api_broker_port,
|
||||||
client_id=client_id,
|
client_id=client_id,
|
||||||
username="pi-1",
|
username=api_username,
|
||||||
password="hepl",
|
password=api_password,
|
||||||
)
|
)
|
||||||
|
|
||||||
detection_service = DetectionService()
|
detection_service = DetectionService()
|
||||||
|
|||||||
Reference in New Issue
Block a user