(request: WSGIRequest)
return HttpResponse("Stopped scanning")
Enables scanning of bluetooth devices.
Enables scanning of bluetooth devices.
Enables scanning of bluetooth devices .
def set_bluetooth_scanning(request: WSGIRequest) -> HttpResponse:
    """Enables scanning of bluetooth devices."""
    enabled = request.POST.get("value") == "true"
    if enabled:
        if redis.get("bluetoothctl_active"):
            return HttpResponseBadRequest("Already Scanning")

        _scan_bluetooth.delay()
        return HttpResponse("Started scanning")

    if not redis.get("bluetoothctl_active"):
        return HttpResponseBadRequest("Currently not scanning")
    # this is another request, so we don't have a handle of the current bluetoothctl process
    # terminate the process by name and release the lock
    subprocess.call("pkill bluetoothctl".split())
    redis.set("bluetoothctl_active", False)
    return HttpResponse("Stopped scanning")
def set_bluetooth_scanning ( request : WSGIRequest ) -> HttpResponse : enabled = request . POST . get ( "value" ) == "true" if enabled : if redis . get ( "bluetoothctl_active" ) : return HttpResponseBadRequest ( "Already Scanning" ) _scan_bluetooth . delay ( ) return HttpResponse ( "Started scanning" ) if not redis . get ( "bluetoothctl_active" ) : return HttpResponseBadRequest ( "Currently not scanning" ) # this is another request, so we don't have a handle of the current bluetoothctl process # terminate the process by name and release the lock subprocess . call ( "pkill bluetoothctl" . split ( ) ) redis . set ( "bluetoothctl_active" , False ) return HttpResponse ( "Stopped scanning" )