clients.publish(Topics["ROBOT_DATA_POSITION"], json.dumps(position, indent=4), qos=1) | clients.publish(Topics["ROBOT_DATA_POSITION"], json.dumps(position, indent=4), qos=1) | ||||
def get_BatteryStatus(client: mqtt.Client, userdata, message: mqtt.MQTTMessage): | |||||
def get_batteryStatus(client: mqtt.Client, userdata, message: mqtt.MQTTMessage): | |||||
""" | """ | ||||
Callback function for battery status request | Callback function for battery status request | ||||
Function to read battery status from ev3 and send via MQTT in form of BATTERY | Function to read battery status from ev3 and send via MQTT in form of BATTERY |
#Add callbacks | #Add callbacks | ||||
client.message_callback_add(Topics["ROBOT_ACTION_DRIVE"], functions.drive_plant) | client.message_callback_add(Topics["ROBOT_ACTION_DRIVE"], functions.drive_plant) | ||||
client.message_callback_add(Topics["ROBOT_ACTION_GETPOSITION"], functions.get_position) | client.message_callback_add(Topics["ROBOT_ACTION_GETPOSITION"], functions.get_position) | ||||
client.message_callback_add(Topics["ROBOT_ACTION_GETBATTERY"], functions.get_BatteryStatus) | |||||
client.message_callback_add(Topics["ROBOT_ACTION_GETBATTERY"], functions.get_batteryStatus) | |||||
client.message_callback_add(Topics["ROBOT_ACTION_DRIVEALL"], functions.drive_plant_all) | client.message_callback_add(Topics["ROBOT_ACTION_DRIVEALL"], functions.drive_plant_all) | ||||
#Subscribe to topics | #Subscribe to topics |