def delete_robot(user, robot_id): if not user: return jsonify({'message': 'Not authorized'}), 401 robot = Robot.find_by_id(robot_id) if not robot: return jsonify({'message': 'Robot not found'}), 404 robot.delete_from_db() return jsonify({'message': 'success'}), 200
def override_robot(user): if not user: return jsonify({'message': 'Not authorized'}), 401 robot_id = request.json.get('robot_id', None) robot = Robot.find_by_id(robot_id) if not robot: return jsonify({'message': 'Robot not found'}), 400 # Send manual command to robot robot.sendManual('manual') return jsonify({}), 201
def send_manual_robot(user): if not user: return jsonify({'message': 'Not authorized'}), 401 robot_id = request.json.get('robot_id', None) command = request.json.get('command', None) robot = Robot.find_by_id(robot_id) if not robot: return jsonify({'message': 'Robot not found'}), 400 if not command: return jsonify({'message': 'No command found'}), 400 if command not in [ 'auto', 'manual', 'forward', 'backward', 'right', 'left', 'exit', 'stop' ]: return jsonify({'message': 'Command not found'}), 400 # Send manual command to robot robot.sendManual(command) return jsonify({}), 201