repository to manage all files related to the makeathon farm bot project (Software + Documentation).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

data_functions.py 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. """
  2. created by caliskan at 19.04.2023
  3. This file contains all functions, which handle the different cases.
  4. Every function should return json format with the wanted data from the database
  5. """
  6. import paho.mqtt.client as mqtt
  7. from plantdatabase import PlantDataBase
  8. from software.defines import Topics
  9. # Robot Channel Reactions
  10. def data_sensordata(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
  11. print("message received")
  12. # TODO: Store data in database
  13. pass
  14. def data_position(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
  15. # TODO: Forward to frontend in json format
  16. pass
  17. def data_battery(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
  18. # TODO: Forward to frontend in json format
  19. pass
  20. # FrontEnd Channel Reactions
  21. def action_drive(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
  22. # TODO: ROBOT READY CHECK
  23. client.publish(Topics['ROBOT_ACTION_DRIVE'], message.payload).decode("utf-8")
  24. def action_getposition(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
  25. client.publish(Topics['ROBOT_ACTION_GETPOSITION'])
  26. def action_getbattery(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
  27. client.publish(Topics['ROBOT_ACTION_GETBATTERY'])
  28. def action_getalldata(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
  29. # TODO: get data from database
  30. pass