diff --git a/software/backend/defines.py b/software/backend/defines.py index ea5ba99..51fe92b 100644 --- a/software/backend/defines.py +++ b/software/backend/defines.py @@ -14,6 +14,7 @@ DATABASE_NAME = 'backend_database.db' # Topics: Topics = { "ROBOT_ACTION_DRIVE": "ROBOT/ACTION/DRIVE", + "ROBOT_ACTION_DRIVEALL": "ROBOT/ACTION/DRIVEALL", "ROBOT_ACTION_GETPOSITION": "ROBOT/ACTION/GETPOSITION", "ROBOT_ACTION_GETBATTERY": "ROBOT/ACTION/GETBATTERY", @@ -23,6 +24,8 @@ Topics = { "ROBOT_DATA_PICTURE": "ROBOT/DATA/PICTURE", "ROBOT_DATA_ERROR": "ROBOT/DATA/ERROR", "ROBOT_DATA_ROBOTREADY": "ROBOT/DATA/ROBOTREADY", + "ROBOT_DATA_PICTURE": "ROBOT/DATA/PICTURE", + "ROBOT_DATA_ALL": "ROBOT/DATA/ALL", "BACKEND_ACTION_DRIVE": "BACKEND/ACTION/DRIVE", "BACKEND_ACTION_DRIVEALL": "BACKEND/ACTION/DRIVEALL", @@ -54,7 +57,12 @@ SENSORDATA = { "SoilMoisture": 0.0, "Brightness": 0, "PlantID": 0, - "ActionID": 0 + "ActionID": "" +} + +ALLSENSORDATA = { + "SensorData": [], + "ActionID": "" } # TODO When sensor is available diff --git a/software/roboter/raspy/defines.py b/software/roboter/raspy/defines.py index a002e9a..5e76927 100644 --- a/software/roboter/raspy/defines.py +++ b/software/roboter/raspy/defines.py @@ -8,6 +8,8 @@ MQTT_BROKER_LOCAL = "192.168.0.199" MQTT_BROKER_GLOBAL = "mqtt.eclipseprojects.io" RASPI_CLIENT_ID = "smart_farming_raspi" BACKEND_CLIENT_ID = "smart_farming_server" +MAX_PLANT_COUNT = 6 +DATABASE_NAME = 'backend_database.db' # Topics: Topics = { @@ -26,7 +28,7 @@ Topics = { "ROBOT_DATA_ALL": "ROBOT/DATA/ALL", "BACKEND_ACTION_DRIVE": "BACKEND/ACTION/DRIVE", - "BACKEND_ACTION_DRIVEPALL": "BACKEND/ACTION/DRIVEALL", + "BACKEND_ACTION_DRIVEALL": "BACKEND/ACTION/DRIVEALL", "BACKEND_ACTION_GETPOSITION": "BACKEND/ACTION/GETPOSITION", "BACKEND_ACTION_GETBATTERY": "BACKEND/ACTION/GETBATTERY", "BACKEND_ACTION_GETALLDATA": "BACKEND/ACTION/GETALLDATA", @@ -44,7 +46,6 @@ Topics = { "BACKEND_DATA_ERROR": "BACKEND/DATA/ERROR", "BACKEND_DATA_ROBOTREADY": "BACKEND/DATA/ROBOTREADY" - } # MQTT Messages: @@ -83,10 +84,9 @@ DRIVE = { } DRIVEALL = { - "PlantIDs": [], + "PlantID": [0, 0], # List containing PlantIDs sorted ascending "ActionID": "" } - # GETPOSITION -> no message needed # GETBATTERY -> no message needed @@ -128,7 +128,7 @@ BATTERY = { PLANTCOUNT = { "CurrenCount": 0, - "maxCount": 0 + "MaxCount": 0 } # endregion @@ -153,6 +153,8 @@ DELETEPLANT = { # GETBATTERY -> no message needed -# GETALLDATA -> no message needed +GETALLDATA = { + "PlantNames": [] +} # endregion diff --git a/software/roboter/raspy/functions.py b/software/roboter/raspy/functions.py index 6b81cf4..8dea768 100644 --- a/software/roboter/raspy/functions.py +++ b/software/roboter/raspy/functions.py @@ -106,7 +106,6 @@ def drive_plant_all_thread(plantIDs: list, actionID, client: mqtt.Client): return - # TODO Test error handling logging.info("Measuring Sensors") try: sensordata = {} @@ -173,7 +172,6 @@ def drive_plant(client: mqtt.Client, userdata, message: mqtt.MQTTMessage): thread.start() -# TODO Test Drive all Plants # FIXME Only possible with color codes def drive_plant_all(client: mqtt.Client, userdata, message: mqtt.MQTTMessage): """ diff --git a/software/roboter/raspy/mainProg.py b/software/roboter/raspy/mainProg.py index 36c0e39..054dba7 100644 --- a/software/roboter/raspy/mainProg.py +++ b/software/roboter/raspy/mainProg.py @@ -58,13 +58,9 @@ def main(): client.connect(MQTT_BROKER_GLOBAL) # client.connect("192.168.137.197") # Local Broker - - # CHECK forever or start - client.loop_start() - logging.info("Robot initialised") - while True: - pass + + client.loop_forever() # Loop_start not needed if __name__ == "__main__": diff --git a/software/roboter/raspy/raspy_sensors.py b/software/roboter/raspy/raspy_sensors.py index 74d5c25..47e5242 100644 --- a/software/roboter/raspy/raspy_sensors.py +++ b/software/roboter/raspy/raspy_sensors.py @@ -89,7 +89,6 @@ def readMCP3008(): return percentage -# TODO Function for all sensors def readSensors(sensorData): """ Read DHT22, TSL2561 and Humidity Sensor