def start_mav_connection(request): try: #try to connect to drone via mavlink ready = Manager.get_instance().start_mav() #return true if mavlink connection is ready if ready: string = "connected" #starting continuous method for get data thread.start_new_thread(Manager.get_instance().run_mav, ()) else: string = "unable to connect" except: string = "error on server" return HttpResponse(string, content_type="text/plain")
def mav_connection_status(request): if Manager.get_instance().is_mav_connected(): return HttpResponse("OK", content_type="text/plain") return HttpResponse("closed", content_type="text/plain")
def close_mav_connection(request): try: Manager.get_instance().stop_mav() return HttpResponse("closed", content_type="text/plain") except: return HttpResponse("failed to close", content_type="text/plain")