// WARNING: Please don't edit this file. It was generated by Python/WinRT v3.1.0

#include "py.Windows.Devices.Bluetooth.Rfcomm.h"

namespace py::cpp::Windows::Devices::Bluetooth::Rfcomm
{
    // ----- RfcommDeviceService class --------------------

    static PyObject* _new_RfcommDeviceService(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService>::type_name);
        return nullptr;
    }

    static void _dealloc_RfcommDeviceService(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* RfcommDeviceService_Close(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"Close", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                {
                    auto _gil = release_gil();
                    self->obj.Close();
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_FromIdAsync(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"FromIdAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::hstring>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService::FromIdAsync(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_GetDeviceSelector(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"GetDeviceSelector", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService::GetDeviceSelector(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_GetDeviceSelectorForBluetoothDevice(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"GetDeviceSelectorForBluetoothDevice", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Devices::Bluetooth::BluetoothDevice>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService::GetDeviceSelectorForBluetoothDevice(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_GetDeviceSelectorForBluetoothDeviceAndServiceId(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 2)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"GetDeviceSelectorForBluetoothDeviceAndServiceId", 2);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(2);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Devices::Bluetooth::BluetoothDevice>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId>(args, 1);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService::GetDeviceSelectorForBluetoothDeviceAndServiceId(param0, param1);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_GetDeviceSelectorForBluetoothDeviceAndServiceIdWithCacheMode(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 3)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"GetDeviceSelectorForBluetoothDeviceAndServiceId", 3);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(3);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Devices::Bluetooth::BluetoothDevice>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId>(args, 1);
                auto param2 = py::convert_to<winrt::Windows::Devices::Bluetooth::BluetoothCacheMode>(args, 2);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService::GetDeviceSelectorForBluetoothDeviceAndServiceId(param0, param1, param2);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_GetDeviceSelectorForBluetoothDeviceWithCacheMode(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 2)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"GetDeviceSelectorForBluetoothDevice", 2);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(2);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Devices::Bluetooth::BluetoothDevice>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::Devices::Bluetooth::BluetoothCacheMode>(args, 1);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService::GetDeviceSelectorForBluetoothDevice(param0, param1);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_GetSdpRawAttributesAsync(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"GetSdpRawAttributesAsync", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.GetSdpRawAttributesAsync();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_GetSdpRawAttributesWithCacheModeAsync(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"GetSdpRawAttributesAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Devices::Bluetooth::BluetoothCacheMode>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.GetSdpRawAttributesAsync(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_RequestAccessAsync(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"RequestAccessAsync", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.RequestAccessAsync();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_get_ConnectionHostName(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"ConnectionHostName");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.ConnectionHostName();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_get_ConnectionServiceName(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"ConnectionServiceName");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.ConnectionServiceName();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_get_MaxProtectionLevel(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"MaxProtectionLevel");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.MaxProtectionLevel();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_get_ProtectionLevel(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"ProtectionLevel");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.ProtectionLevel();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_get_ServiceId(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"ServiceId");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.ServiceId();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_get_Device(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"Device");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Device();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceService_get_DeviceAccessInformation(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService", L"DeviceAccessInformation");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.DeviceAccessInformation();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_RfcommDeviceService(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_RfcommDeviceService(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _enter_RfcommDeviceService(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self, PyObject* /*unused*/) noexcept
    {
        return Py_NewRef(self);
    }

    static PyObject* _exit_RfcommDeviceService(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService* self, PyObject* /*unused*/) noexcept
    {
        try
        {
            {
                auto _gil = py::release_gil();
                self->obj.Close();
            }

            Py_RETURN_FALSE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_RfcommDeviceService[] = {
        { "close", reinterpret_cast<PyCFunction>(RfcommDeviceService_Close), METH_VARARGS, nullptr },
        { "get_sdp_raw_attributes_async", reinterpret_cast<PyCFunction>(RfcommDeviceService_GetSdpRawAttributesAsync), METH_VARARGS, nullptr },
        { "get_sdp_raw_attributes_with_cache_mode_async", reinterpret_cast<PyCFunction>(RfcommDeviceService_GetSdpRawAttributesWithCacheModeAsync), METH_VARARGS, nullptr },
        { "request_access_async", reinterpret_cast<PyCFunction>(RfcommDeviceService_RequestAccessAsync), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_RfcommDeviceService, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_RfcommDeviceService), METH_O | METH_STATIC, nullptr },
        { "__enter__", reinterpret_cast<PyCFunction>(_enter_RfcommDeviceService), METH_NOARGS, nullptr },
        { "__exit__", reinterpret_cast<PyCFunction>(_exit_RfcommDeviceService), METH_VARARGS, nullptr },
        { }};

    static PyGetSetDef _getset_RfcommDeviceService[] = {
        { "connection_host_name", reinterpret_cast<getter>(RfcommDeviceService_get_ConnectionHostName), nullptr, nullptr, nullptr },
        { "connection_service_name", reinterpret_cast<getter>(RfcommDeviceService_get_ConnectionServiceName), nullptr, nullptr, nullptr },
        { "max_protection_level", reinterpret_cast<getter>(RfcommDeviceService_get_MaxProtectionLevel), nullptr, nullptr, nullptr },
        { "protection_level", reinterpret_cast<getter>(RfcommDeviceService_get_ProtectionLevel), nullptr, nullptr, nullptr },
        { "service_id", reinterpret_cast<getter>(RfcommDeviceService_get_ServiceId), nullptr, nullptr, nullptr },
        { "device", reinterpret_cast<getter>(RfcommDeviceService_get_Device), nullptr, nullptr, nullptr },
        { "device_access_information", reinterpret_cast<getter>(RfcommDeviceService_get_DeviceAccessInformation), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_RfcommDeviceService[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_RfcommDeviceService) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_RfcommDeviceService) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_RfcommDeviceService) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_RfcommDeviceService) },
        { }};

    static PyType_Spec type_spec_RfcommDeviceService = {
        "winrt._winrt_windows_devices_bluetooth_rfcomm.RfcommDeviceService",
        sizeof(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceService),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_RfcommDeviceService};

    static PyGetSetDef getset_RfcommDeviceService_Static[] = {
        { }};

    static PyMethodDef methods_RfcommDeviceService_Static[] = {
        { "from_id_async", reinterpret_cast<PyCFunction>(RfcommDeviceService_FromIdAsync), METH_VARARGS, nullptr },
        { "get_device_selector", reinterpret_cast<PyCFunction>(RfcommDeviceService_GetDeviceSelector), METH_VARARGS, nullptr },
        { "get_device_selector_for_bluetooth_device", reinterpret_cast<PyCFunction>(RfcommDeviceService_GetDeviceSelectorForBluetoothDevice), METH_VARARGS, nullptr },
        { "get_device_selector_for_bluetooth_device_and_service_id", reinterpret_cast<PyCFunction>(RfcommDeviceService_GetDeviceSelectorForBluetoothDeviceAndServiceId), METH_VARARGS, nullptr },
        { "get_device_selector_for_bluetooth_device_and_service_id_with_cache_mode", reinterpret_cast<PyCFunction>(RfcommDeviceService_GetDeviceSelectorForBluetoothDeviceAndServiceIdWithCacheMode), METH_VARARGS, nullptr },
        { "get_device_selector_for_bluetooth_device_with_cache_mode", reinterpret_cast<PyCFunction>(RfcommDeviceService_GetDeviceSelectorForBluetoothDeviceWithCacheMode), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_RfcommDeviceService_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_RfcommDeviceService_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_RfcommDeviceService_Static) },
        { }
    };

    static PyType_Spec type_spec_RfcommDeviceService_Static = {
        "winrt._winrt_windows_devices_bluetooth_rfcomm.RfcommDeviceService_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_RfcommDeviceService_Static};

    // ----- RfcommDeviceServicesResult class --------------------

    static PyObject* _new_RfcommDeviceServicesResult(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceServicesResult>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceServicesResult>::type_name);
        return nullptr;
    }

    static void _dealloc_RfcommDeviceServicesResult(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceServicesResult* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* RfcommDeviceServicesResult_get_Error(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceServicesResult* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceServicesResult", L"Error");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Error();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommDeviceServicesResult_get_Services(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceServicesResult* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceServicesResult", L"Services");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Services();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_RfcommDeviceServicesResult(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceServicesResult>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_RfcommDeviceServicesResult(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceServicesResult>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_RfcommDeviceServicesResult[] = {
        { "_assign_array_", _assign_array_RfcommDeviceServicesResult, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_RfcommDeviceServicesResult), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_RfcommDeviceServicesResult[] = {
        { "error", reinterpret_cast<getter>(RfcommDeviceServicesResult_get_Error), nullptr, nullptr, nullptr },
        { "services", reinterpret_cast<getter>(RfcommDeviceServicesResult_get_Services), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_RfcommDeviceServicesResult[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_RfcommDeviceServicesResult) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_RfcommDeviceServicesResult) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_RfcommDeviceServicesResult) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_RfcommDeviceServicesResult) },
        { }};

    static PyType_Spec type_spec_RfcommDeviceServicesResult = {
        "winrt._winrt_windows_devices_bluetooth_rfcomm.RfcommDeviceServicesResult",
        sizeof(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommDeviceServicesResult),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_RfcommDeviceServicesResult};

    // ----- RfcommServiceId class --------------------

    static PyObject* _new_RfcommServiceId(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId>::type_name);
        return nullptr;
    }

    static void _dealloc_RfcommServiceId(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* RfcommServiceId_AsShortId(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceId", L"AsShortId", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.AsShortId();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommServiceId_AsString(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceId", L"AsString", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.AsString();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommServiceId_FromShortId(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceId", L"FromShortId", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<uint32_t>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId::FromShortId(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommServiceId_FromUuid(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceId", L"FromUuid", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::guid>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId::FromUuid(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommServiceId_get_Uuid(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceId", L"Uuid");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Uuid();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommServiceId_get_GenericFileTransfer(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceId", L"GenericFileTransfer");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId::GenericFileTransfer();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommServiceId_get_ObexFileTransfer(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceId", L"ObexFileTransfer");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId::ObexFileTransfer();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommServiceId_get_ObexObjectPush(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceId", L"ObexObjectPush");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId::ObexObjectPush();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommServiceId_get_PhoneBookAccessPce(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceId", L"PhoneBookAccessPce");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId::PhoneBookAccessPce();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommServiceId_get_PhoneBookAccessPse(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceId", L"PhoneBookAccessPse");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId::PhoneBookAccessPse();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommServiceId_get_SerialPort(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceId", L"SerialPort");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId::SerialPort();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_RfcommServiceId(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_RfcommServiceId(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_RfcommServiceId[] = {
        { "as_short_id", reinterpret_cast<PyCFunction>(RfcommServiceId_AsShortId), METH_VARARGS, nullptr },
        { "as_string", reinterpret_cast<PyCFunction>(RfcommServiceId_AsString), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_RfcommServiceId, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_RfcommServiceId), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_RfcommServiceId[] = {
        { "uuid", reinterpret_cast<getter>(RfcommServiceId_get_Uuid), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_RfcommServiceId[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_RfcommServiceId) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_RfcommServiceId) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_RfcommServiceId) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_RfcommServiceId) },
        { }};

    static PyType_Spec type_spec_RfcommServiceId = {
        "winrt._winrt_windows_devices_bluetooth_rfcomm.RfcommServiceId",
        sizeof(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_RfcommServiceId};

    static PyGetSetDef getset_RfcommServiceId_Static[] = {
        { "generic_file_transfer", reinterpret_cast<getter>(RfcommServiceId_get_GenericFileTransfer), nullptr, nullptr, nullptr },
        { "obex_file_transfer", reinterpret_cast<getter>(RfcommServiceId_get_ObexFileTransfer), nullptr, nullptr, nullptr },
        { "obex_object_push", reinterpret_cast<getter>(RfcommServiceId_get_ObexObjectPush), nullptr, nullptr, nullptr },
        { "phone_book_access_pce", reinterpret_cast<getter>(RfcommServiceId_get_PhoneBookAccessPce), nullptr, nullptr, nullptr },
        { "phone_book_access_pse", reinterpret_cast<getter>(RfcommServiceId_get_PhoneBookAccessPse), nullptr, nullptr, nullptr },
        { "serial_port", reinterpret_cast<getter>(RfcommServiceId_get_SerialPort), nullptr, nullptr, nullptr },
        { }};

    static PyMethodDef methods_RfcommServiceId_Static[] = {
        { "from_short_id", reinterpret_cast<PyCFunction>(RfcommServiceId_FromShortId), METH_VARARGS, nullptr },
        { "from_uuid", reinterpret_cast<PyCFunction>(RfcommServiceId_FromUuid), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_RfcommServiceId_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_RfcommServiceId_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_RfcommServiceId_Static) },
        { }
    };

    static PyType_Spec type_spec_RfcommServiceId_Static = {
        "winrt._winrt_windows_devices_bluetooth_rfcomm.RfcommServiceId_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_RfcommServiceId_Static};

    // ----- RfcommServiceProvider class --------------------

    static PyObject* _new_RfcommServiceProvider(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceProvider>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceProvider>::type_name);
        return nullptr;
    }

    static void _dealloc_RfcommServiceProvider(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceProvider* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* RfcommServiceProvider_CreateAsync(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceProvider", L"CreateAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceProvider::CreateAsync(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommServiceProvider_StartAdvertising(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceProvider", L"StartAdvertising", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Networking::Sockets::StreamSocketListener>(args, 0);

                {
                    auto _gil = release_gil();
                    self->obj.StartAdvertising(param0);
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommServiceProvider_StartAdvertisingWithRadioDiscoverability(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 2)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceProvider", L"StartAdvertising", 2);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(2);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Networking::Sockets::StreamSocketListener>(args, 0);
                auto param1 = py::convert_to<bool>(args, 1);

                {
                    auto _gil = release_gil();
                    self->obj.StartAdvertising(param0, param1);
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommServiceProvider_StopAdvertising(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceProvider", L"StopAdvertising", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                {
                    auto _gil = release_gil();
                    self->obj.StopAdvertising();
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* RfcommServiceProvider_get_SdpRawAttributes(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceProvider* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceProvider", L"SdpRawAttributes");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.SdpRawAttributes();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* RfcommServiceProvider_get_ServiceId(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceProvider* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Bluetooth.Rfcomm.RfcommServiceProvider", L"ServiceId");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.ServiceId();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_RfcommServiceProvider(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceProvider>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_RfcommServiceProvider(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceProvider>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_RfcommServiceProvider[] = {
        { "start_advertising", reinterpret_cast<PyCFunction>(RfcommServiceProvider_StartAdvertising), METH_VARARGS, nullptr },
        { "start_advertising_with_radio_discoverability", reinterpret_cast<PyCFunction>(RfcommServiceProvider_StartAdvertisingWithRadioDiscoverability), METH_VARARGS, nullptr },
        { "stop_advertising", reinterpret_cast<PyCFunction>(RfcommServiceProvider_StopAdvertising), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_RfcommServiceProvider, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_RfcommServiceProvider), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_RfcommServiceProvider[] = {
        { "sdp_raw_attributes", reinterpret_cast<getter>(RfcommServiceProvider_get_SdpRawAttributes), nullptr, nullptr, nullptr },
        { "service_id", reinterpret_cast<getter>(RfcommServiceProvider_get_ServiceId), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_RfcommServiceProvider[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_RfcommServiceProvider) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_RfcommServiceProvider) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_RfcommServiceProvider) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_RfcommServiceProvider) },
        { }};

    static PyType_Spec type_spec_RfcommServiceProvider = {
        "winrt._winrt_windows_devices_bluetooth_rfcomm.RfcommServiceProvider",
        sizeof(py::wrapper::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceProvider),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_RfcommServiceProvider};

    static PyGetSetDef getset_RfcommServiceProvider_Static[] = {
        { }};

    static PyMethodDef methods_RfcommServiceProvider_Static[] = {
        { "create_async", reinterpret_cast<PyCFunction>(RfcommServiceProvider_CreateAsync), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_RfcommServiceProvider_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_RfcommServiceProvider_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_RfcommServiceProvider_Static) },
        { }
    };

    static PyType_Spec type_spec_RfcommServiceProvider_Static = {
        "winrt._winrt_windows_devices_bluetooth_rfcomm.RfcommServiceProvider_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_RfcommServiceProvider_Static};

    // ----- Windows.Devices.Bluetooth.Rfcomm Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.Devices.Bluetooth.Rfcomm");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_devices_bluetooth_rfcomm",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::Devices::Bluetooth::Rfcomm

PyMODINIT_FUNC PyInit__winrt_windows_devices_bluetooth_rfcomm(void) noexcept
{
    using namespace py::cpp::Windows::Devices::Bluetooth::Rfcomm;

    if (py::import_winrt_runtime() == -1)
    {
        return nullptr;
    }

    py::pyobj_handle module{PyModule_Create(&module_def)};

    if (!module)
    {
        return nullptr;
    }

    auto inspectable_meta_type = py::get_inspectable_meta_type();
    if (!inspectable_meta_type)
    {
        return nullptr;
    }

    auto object_type = py::get_object_type();
    if (!object_type)
    {
        return nullptr;
    }

    py::pyobj_handle object_bases{PyTuple_Pack(1, object_type)};

    if (!object_bases)
    {
        return nullptr;
    }

    py::pyobj_handle RfcommDeviceService_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!RfcommDeviceService_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_RfcommDeviceService_Static{PyType_FromSpecWithBases(&type_spec_RfcommDeviceService_Static, RfcommDeviceService_Static_bases.get())};
    if (!type_RfcommDeviceService_Static)
    {
        return nullptr;
    }

    py::pytype_handle RfcommDeviceService_type{py::register_python_type(module.get(), &type_spec_RfcommDeviceService, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_RfcommDeviceService_Static.get()))};
    if (!RfcommDeviceService_type)
    {
        return nullptr;
    }

    py::pytype_handle RfcommDeviceServicesResult_type{py::register_python_type(module.get(), &type_spec_RfcommDeviceServicesResult, object_bases.get(), inspectable_meta_type)};
    if (!RfcommDeviceServicesResult_type)
    {
        return nullptr;
    }

    py::pyobj_handle RfcommServiceId_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!RfcommServiceId_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_RfcommServiceId_Static{PyType_FromSpecWithBases(&type_spec_RfcommServiceId_Static, RfcommServiceId_Static_bases.get())};
    if (!type_RfcommServiceId_Static)
    {
        return nullptr;
    }

    py::pytype_handle RfcommServiceId_type{py::register_python_type(module.get(), &type_spec_RfcommServiceId, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_RfcommServiceId_Static.get()))};
    if (!RfcommServiceId_type)
    {
        return nullptr;
    }

    py::pyobj_handle RfcommServiceProvider_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!RfcommServiceProvider_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_RfcommServiceProvider_Static{PyType_FromSpecWithBases(&type_spec_RfcommServiceProvider_Static, RfcommServiceProvider_Static_bases.get())};
    if (!type_RfcommServiceProvider_Static)
    {
        return nullptr;
    }

    py::pytype_handle RfcommServiceProvider_type{py::register_python_type(module.get(), &type_spec_RfcommServiceProvider, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_RfcommServiceProvider_Static.get()))};
    if (!RfcommServiceProvider_type)
    {
        return nullptr;
    }


    return module.detach();
}
