From d728cdd343f25a94fa020f9d9f7f5073c4713e2e Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Tue, 12 Mar 2024 14:56:08 +0100 Subject: [PATCH] Add BluetoothLEAdvertisementWatcherStoppedEventArgs --- ...hleadvertisementwatcherstoppedeventargs.go | 24 +++++++++++++++++++ windows/devices/bluetooth/bluetootherror.go | 23 ++++++++++++++++++ winrt.go | 3 ++- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 windows/devices/bluetooth/bluetootherror.go diff --git a/windows/devices/bluetooth/advertisement/bluetoothleadvertisementwatcherstoppedeventargs.go b/windows/devices/bluetooth/advertisement/bluetoothleadvertisementwatcherstoppedeventargs.go index c2ce775..0d12fdd 100644 --- a/windows/devices/bluetooth/advertisement/bluetoothleadvertisementwatcherstoppedeventargs.go +++ b/windows/devices/bluetooth/advertisement/bluetoothleadvertisementwatcherstoppedeventargs.go @@ -6,9 +6,11 @@ package advertisement import ( + "syscall" "unsafe" "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/devices/bluetooth" ) const SignatureBluetoothLEAdvertisementWatcherStoppedEventArgs string = "rc(Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementWatcherStoppedEventArgs;{dd40f84d-e7b9-43e3-9c04-0685d085fd8c})" @@ -17,6 +19,13 @@ type BluetoothLEAdvertisementWatcherStoppedEventArgs struct { ole.IUnknown } +func (impl *BluetoothLEAdvertisementWatcherStoppedEventArgs) GetError() (bluetooth.BluetoothError, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiBluetoothLEAdvertisementWatcherStoppedEventArgs)) + defer itf.Release() + v := (*iBluetoothLEAdvertisementWatcherStoppedEventArgs)(unsafe.Pointer(itf)) + return v.GetError() +} + const GUIDiBluetoothLEAdvertisementWatcherStoppedEventArgs string = "dd40f84d-e7b9-43e3-9c04-0685d085fd8c" const SignatureiBluetoothLEAdvertisementWatcherStoppedEventArgs string = "{dd40f84d-e7b9-43e3-9c04-0685d085fd8c}" @@ -33,3 +42,18 @@ type iBluetoothLEAdvertisementWatcherStoppedEventArgsVtbl struct { func (v *iBluetoothLEAdvertisementWatcherStoppedEventArgs) VTable() *iBluetoothLEAdvertisementWatcherStoppedEventArgsVtbl { return (*iBluetoothLEAdvertisementWatcherStoppedEventArgsVtbl)(unsafe.Pointer(v.RawVTable)) } + +func (v *iBluetoothLEAdvertisementWatcherStoppedEventArgs) GetError() (bluetooth.BluetoothError, error) { + var out bluetooth.BluetoothError + hr, _, _ := syscall.SyscallN( + v.VTable().GetError, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out bluetooth.BluetoothError + ) + + if hr != 0 { + return bluetooth.BluetoothErrorSuccess, ole.NewError(hr) + } + + return out, nil +} diff --git a/windows/devices/bluetooth/bluetootherror.go b/windows/devices/bluetooth/bluetootherror.go new file mode 100644 index 0000000..315b407 --- /dev/null +++ b/windows/devices/bluetooth/bluetootherror.go @@ -0,0 +1,23 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package bluetooth + +type BluetoothError int32 + +const SignatureBluetoothError string = "enum(Windows.Devices.Bluetooth.BluetoothError;i4)" + +const ( + BluetoothErrorSuccess BluetoothError = 0 + BluetoothErrorRadioNotAvailable BluetoothError = 1 + BluetoothErrorResourceInUse BluetoothError = 2 + BluetoothErrorDeviceNotConnected BluetoothError = 3 + BluetoothErrorOtherError BluetoothError = 4 + BluetoothErrorDisabledByPolicy BluetoothError = 5 + BluetoothErrorNotSupported BluetoothError = 6 + BluetoothErrorDisabledByUser BluetoothError = 7 + BluetoothErrorConsentRequired BluetoothError = 8 + BluetoothErrorTransportNotSupported BluetoothError = 9 +) diff --git a/winrt.go b/winrt.go index 6996c0c..5a83e76 100644 --- a/winrt.go +++ b/winrt.go @@ -11,7 +11,7 @@ package winrt //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementWatcherStatus //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementWatcher -method-filter add_Received -method-filter remove_Received -method-filter add_Stopped -method-filter remove_Stopped -method-filter Start -method-filter Stop -method-filter get_Status -method-filter get_AllowExtendedAdvertisements -method-filter put_AllowExtendedAdvertisements -method-filter get_ScanningMode -method-filter put_ScanningMode -method-filter !* //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementReceivedEventArgs -method-filter get_RawSignalStrengthInDBm -method-filter get_BluetoothAddress -method-filter get_Advertisement -method-filter !* -//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementWatcherStoppedEventArgs -method-filter !* +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementWatcherStoppedEventArgs //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.Advertisement.BluetoothLEManufacturerData //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisement -method-filter get_LocalName -method-filter put_LocalName -method-filter get_ServiceUuids -method-filter get_ManufacturerData -method-filter get_DataSections -method-filter !* //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementDataSection -method-filter get_DataType -method-filter !* @@ -25,6 +25,7 @@ package winrt //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.BluetoothAddressType //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.BluetoothDeviceId -method-filter !FromId //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.BluetoothCacheMode +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.BluetoothError //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattSession -method-filter FromDeviceIdAsync -method-filter get_MaintainConnection -method-filter put_MaintainConnection -method-filter get_CanMaintainConnection -method-filter Close -method-filter get_MaxPduSize -method-filter add_MaxPduSizeChanged -method-filter remove_MaxPduSizeChanged -method-filter !* //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceServicesResult -method-filter !get_ProtocolError