Browse Source

function layout added

master
caliskanbi 1 year ago
parent
commit
14fea73572

+ 72
- 1
software/backend/data_handling_functions.py View File



This file contains all functions, which handle the different cases. This file contains all functions, which handle the different cases.
Every function should return json format with the wanted data from the database Every function should return json format with the wanted data from the database
"""
"""
import paho.mqtt.client as mqtt


def data_handler(client: mqtt.Client, message) -> dict:
"""
main entrypoint for a message handling method
:param client:
:param message:
:return:
"""
if message.topic.startwith('BackEnd'):

if message.topic == "BackEnd/Action/All":
action_all(client, message)
elif message.topic == "BackEnd/Action/GetPosition":
action_get_position(client, message)
elif message.topic == "BackEnd/Action/GetBattery":
action_get_battery(client, message)
elif message.topic == "BackEnd/Action/GetAllData":
action_get_all_data(client, message)

elif message.topic.startwith('Robot'):

if message.topic == "Robot/Data/SensorData":
data_sensordata(client, message)
elif message.topic == "Robot/Data/Position":
data_position(client, message)
elif message.topic == "Robot/Data/Battery":
data_battery(client, message)
elif message.topic == "Robot/Data/Picture":
data_picture(client, message)


# START ACTION FUNCTION DEFINITIONS

def action_all(client, message):
pass


def action_get_position(client, message):
pass


def action_get_battery(client, message):
pass


def action_get_all_data(client, message):
pass


# END ACTION FUNCTION DEFINITIONS

# START ROBOT FUNCTION DEFINITIONS

def data_sensordata(client, message):
pass


def data_position(client, message):
pass


def data_battery(client, message):
pass


def data_picture(client, message):
pass

# END ROBOT FUNCTION DEFINITIONS

+ 3
- 1
software/backend/defines.py View File

contains all constants for the backend architecture of the smart garden project contains all constants for the backend architecture of the smart garden project
""" """


MQTT_BROKER_LOCAL = ""
MQTT_BROKER_LOCAL = "lorem ipsum"
MQTT_BROKER_GLOBAL = "mqtt.eclipseprojects.io" MQTT_BROKER_GLOBAL = "mqtt.eclipseprojects.io"
RASPI_CLIENT_ID = "lorem ipsum"
BACKEND_CLIENT_ID = "lorem ipsum"

+ 7
- 5
software/backend/main.py View File

import paho.mqtt.client as mqtt import paho.mqtt.client as mqtt
from defines import MQTT_BROKER_LOCAL, MQTT_BROKER_GLOBAL from defines import MQTT_BROKER_LOCAL, MQTT_BROKER_GLOBAL
from plantdatabase import PlantDataBase from plantdatabase import PlantDataBase
from data_handling_functions import data_handler



def on_message(client, userdata, message): def on_message(client, userdata, message):
print(f'message received! {message.topic}') print(f'message received! {message.topic}')
data_handler(client, message)




def on_connect(client, userdata, flags, rc): def on_connect(client, userdata, flags, rc):
client.subscribe("Robot/Data/Picture") client.subscribe("Robot/Data/Picture")


# FrontEnd topics # FrontEnd topics
client.subscribe("BackEnd/Data/SensorData")
client.subscribe("BackEnd/Data/SensorDataAll")
client.subscribe("BackEnd/Data/Position")
client.subscribe("BackEnd/Data/Battery")
client.subscribe("BackEnd/Data/Picture")
client.subscribe("BackEnd/Action/All")
client.subscribe("BackEnd/Action/GetPosition")
client.subscribe("BackEnd/Action/GetBattery")
client.subscribe("BackEnd/Action/GetAllData")


# END TOPIC SUBSCRIPTIONS # END TOPIC SUBSCRIPTIONS
else: else:

Loading…
Cancel
Save