From 1bf5f13151a73cd696640ed11fbb2f0f8b48ce27 Mon Sep 17 00:00:00 2001 From: Carter Date: Thu, 18 Apr 2024 09:33:50 -0600 Subject: [PATCH] codegen: ble peripheral --- .../gattclientnotificationresult.go | 144 ++++++ .../gattlocalcharacteristic.go | 459 ++++++++++++++++++ .../gattlocalcharacteristicparameters.go | 299 ++++++++++++ .../gattlocalcharacteristicresult.go | 82 ++++ .../gattlocaldescriptorparameters.go | 179 +++++++ .../gattlocalservice.go | 108 +++++ .../gattprotectionlevel.go | 17 + .../gattreadrequest.go | 196 ++++++++ .../gattreadrequestedeventargs.go | 105 ++++ .../gattrequeststate.go | 16 + .../gattserviceprovider.go | 231 +++++++++ .../gattserviceprovideradvertisementstatus.go | 18 + ...attserviceprovideradvertisingparameters.go | 195 ++++++++ .../gattserviceproviderresult.go | 82 ++++ .../gattsubscribedclient.go | 128 +++++ .../gattwriterequest.go | 218 +++++++++ .../gattwriterequestedeventargs.go | 105 ++++ windows/foundation/deferral.go | 102 ++++ .../foundation/deferralcompletedhandler.go | 195 ++++++++ windows/foundation/ireference.go | 45 ++ winrt.go | 20 + 21 files changed, 2944 insertions(+) create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattclientnotificationresult.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattlocalcharacteristic.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattlocalcharacteristicparameters.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattlocalcharacteristicresult.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattlocaldescriptorparameters.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattlocalservice.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattprotectionlevel.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattreadrequest.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattreadrequestedeventargs.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattrequeststate.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattserviceprovider.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattserviceprovideradvertisementstatus.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattserviceprovideradvertisingparameters.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattserviceproviderresult.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattsubscribedclient.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattwriterequest.go create mode 100644 windows/devices/bluetooth/genericattributeprofile/gattwriterequestedeventargs.go create mode 100644 windows/foundation/deferral.go create mode 100644 windows/foundation/deferralcompletedhandler.go create mode 100644 windows/foundation/ireference.go diff --git a/windows/devices/bluetooth/genericattributeprofile/gattclientnotificationresult.go b/windows/devices/bluetooth/genericattributeprofile/gattclientnotificationresult.go new file mode 100644 index 0000000..1316105 --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattclientnotificationresult.go @@ -0,0 +1,144 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/foundation" +) + +const SignatureGattClientNotificationResult string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattClientNotificationResult;{506d5599-0112-419a-8e3b-ae21afabd2c2})" + +type GattClientNotificationResult struct { + ole.IUnknown +} + +func (impl *GattClientNotificationResult) GetSubscribedClient() (*GattSubscribedClient, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattClientNotificationResult)) + defer itf.Release() + v := (*iGattClientNotificationResult)(unsafe.Pointer(itf)) + return v.GetSubscribedClient() +} + +func (impl *GattClientNotificationResult) GetStatus() (GattCommunicationStatus, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattClientNotificationResult)) + defer itf.Release() + v := (*iGattClientNotificationResult)(unsafe.Pointer(itf)) + return v.GetStatus() +} + +func (impl *GattClientNotificationResult) GetProtocolError() (*foundation.IReference, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattClientNotificationResult)) + defer itf.Release() + v := (*iGattClientNotificationResult)(unsafe.Pointer(itf)) + return v.GetProtocolError() +} + +func (impl *GattClientNotificationResult) GetBytesSent() (uint16, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattClientNotificationResult2)) + defer itf.Release() + v := (*iGattClientNotificationResult2)(unsafe.Pointer(itf)) + return v.GetBytesSent() +} + +const GUIDiGattClientNotificationResult string = "506d5599-0112-419a-8e3b-ae21afabd2c2" +const SignatureiGattClientNotificationResult string = "{506d5599-0112-419a-8e3b-ae21afabd2c2}" + +type iGattClientNotificationResult struct { + ole.IInspectable +} + +type iGattClientNotificationResultVtbl struct { + ole.IInspectableVtbl + + GetSubscribedClient uintptr + GetStatus uintptr + GetProtocolError uintptr +} + +func (v *iGattClientNotificationResult) VTable() *iGattClientNotificationResultVtbl { + return (*iGattClientNotificationResultVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattClientNotificationResult) GetSubscribedClient() (*GattSubscribedClient, error) { + var out *GattSubscribedClient + hr, _, _ := syscall.SyscallN( + v.VTable().GetSubscribedClient, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattSubscribedClient + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattClientNotificationResult) GetStatus() (GattCommunicationStatus, error) { + var out GattCommunicationStatus + hr, _, _ := syscall.SyscallN( + v.VTable().GetStatus, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattCommunicationStatus + ) + + if hr != 0 { + return GattCommunicationStatusSuccess, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattClientNotificationResult) GetProtocolError() (*foundation.IReference, error) { + var out *foundation.IReference + hr, _, _ := syscall.SyscallN( + v.VTable().GetProtocolError, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out foundation.IReference + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +const GUIDiGattClientNotificationResult2 string = "8faec497-45e0-497e-9582-29a1fe281ad5" +const SignatureiGattClientNotificationResult2 string = "{8faec497-45e0-497e-9582-29a1fe281ad5}" + +type iGattClientNotificationResult2 struct { + ole.IInspectable +} + +type iGattClientNotificationResult2Vtbl struct { + ole.IInspectableVtbl + + GetBytesSent uintptr +} + +func (v *iGattClientNotificationResult2) VTable() *iGattClientNotificationResult2Vtbl { + return (*iGattClientNotificationResult2Vtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattClientNotificationResult2) GetBytesSent() (uint16, error) { + var out uint16 + hr, _, _ := syscall.SyscallN( + v.VTable().GetBytesSent, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out uint16 + ) + + if hr != 0 { + return 0, ole.NewError(hr) + } + + return out, nil +} diff --git a/windows/devices/bluetooth/genericattributeprofile/gattlocalcharacteristic.go b/windows/devices/bluetooth/genericattributeprofile/gattlocalcharacteristic.go new file mode 100644 index 0000000..3b33649 --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattlocalcharacteristic.go @@ -0,0 +1,459 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/foundation" + "github.com/saltosystems/winrt-go/windows/foundation/collections" + "github.com/saltosystems/winrt-go/windows/storage/streams" +) + +const SignatureGattLocalCharacteristic string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalCharacteristic;{aede376d-5412-4d74-92a8-8deb8526829c})" + +type GattLocalCharacteristic struct { + ole.IUnknown +} + +func (impl *GattLocalCharacteristic) GetUuid() (syscall.GUID, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.GetUuid() +} + +func (impl *GattLocalCharacteristic) GetStaticValue() (*streams.IBuffer, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.GetStaticValue() +} + +func (impl *GattLocalCharacteristic) GetCharacteristicProperties() (GattCharacteristicProperties, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.GetCharacteristicProperties() +} + +func (impl *GattLocalCharacteristic) GetReadProtectionLevel() (GattProtectionLevel, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.GetReadProtectionLevel() +} + +func (impl *GattLocalCharacteristic) GetWriteProtectionLevel() (GattProtectionLevel, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.GetWriteProtectionLevel() +} + +func (impl *GattLocalCharacteristic) CreateDescriptorAsync(descriptorUuid syscall.GUID, parameters *GattLocalDescriptorParameters) (*foundation.IAsyncOperation, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.CreateDescriptorAsync(descriptorUuid, parameters) +} + +func (impl *GattLocalCharacteristic) GetDescriptors() (*collections.IVectorView, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.GetDescriptors() +} + +func (impl *GattLocalCharacteristic) GetUserDescription() (string, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.GetUserDescription() +} + +func (impl *GattLocalCharacteristic) GetPresentationFormats() (*collections.IVectorView, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.GetPresentationFormats() +} + +func (impl *GattLocalCharacteristic) GetSubscribedClients() (*collections.IVectorView, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.GetSubscribedClients() +} + +func (impl *GattLocalCharacteristic) AddSubscribedClientsChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.AddSubscribedClientsChanged(handler) +} + +func (impl *GattLocalCharacteristic) RemoveSubscribedClientsChanged(token foundation.EventRegistrationToken) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.RemoveSubscribedClientsChanged(token) +} + +func (impl *GattLocalCharacteristic) AddReadRequested(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.AddReadRequested(handler) +} + +func (impl *GattLocalCharacteristic) RemoveReadRequested(token foundation.EventRegistrationToken) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.RemoveReadRequested(token) +} + +func (impl *GattLocalCharacteristic) AddWriteRequested(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.AddWriteRequested(handler) +} + +func (impl *GattLocalCharacteristic) RemoveWriteRequested(token foundation.EventRegistrationToken) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.RemoveWriteRequested(token) +} + +func (impl *GattLocalCharacteristic) NotifyValueAsync(value *streams.IBuffer) (*foundation.IAsyncOperation, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.NotifyValueAsync(value) +} + +func (impl *GattLocalCharacteristic) NotifyValueForSubscribedClientAsync(value *streams.IBuffer, subscribedClient *GattSubscribedClient) (*foundation.IAsyncOperation, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristic)) + defer itf.Release() + v := (*iGattLocalCharacteristic)(unsafe.Pointer(itf)) + return v.NotifyValueForSubscribedClientAsync(value, subscribedClient) +} + +const GUIDiGattLocalCharacteristic string = "aede376d-5412-4d74-92a8-8deb8526829c" +const SignatureiGattLocalCharacteristic string = "{aede376d-5412-4d74-92a8-8deb8526829c}" + +type iGattLocalCharacteristic struct { + ole.IInspectable +} + +type iGattLocalCharacteristicVtbl struct { + ole.IInspectableVtbl + + GetUuid uintptr + GetStaticValue uintptr + GetCharacteristicProperties uintptr + GetReadProtectionLevel uintptr + GetWriteProtectionLevel uintptr + CreateDescriptorAsync uintptr + GetDescriptors uintptr + GetUserDescription uintptr + GetPresentationFormats uintptr + GetSubscribedClients uintptr + AddSubscribedClientsChanged uintptr + RemoveSubscribedClientsChanged uintptr + AddReadRequested uintptr + RemoveReadRequested uintptr + AddWriteRequested uintptr + RemoveWriteRequested uintptr + NotifyValueAsync uintptr + NotifyValueForSubscribedClientAsync uintptr +} + +func (v *iGattLocalCharacteristic) VTable() *iGattLocalCharacteristicVtbl { + return (*iGattLocalCharacteristicVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattLocalCharacteristic) GetUuid() (syscall.GUID, error) { + var out syscall.GUID + hr, _, _ := syscall.SyscallN( + v.VTable().GetUuid, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out syscall.GUID + ) + + if hr != 0 { + return syscall.GUID{}, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristic) GetStaticValue() (*streams.IBuffer, error) { + var out *streams.IBuffer + hr, _, _ := syscall.SyscallN( + v.VTable().GetStaticValue, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out streams.IBuffer + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristic) GetCharacteristicProperties() (GattCharacteristicProperties, error) { + var out GattCharacteristicProperties + hr, _, _ := syscall.SyscallN( + v.VTable().GetCharacteristicProperties, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattCharacteristicProperties + ) + + if hr != 0 { + return GattCharacteristicPropertiesNone, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristic) GetReadProtectionLevel() (GattProtectionLevel, error) { + var out GattProtectionLevel + hr, _, _ := syscall.SyscallN( + v.VTable().GetReadProtectionLevel, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattProtectionLevel + ) + + if hr != 0 { + return GattProtectionLevelPlain, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristic) GetWriteProtectionLevel() (GattProtectionLevel, error) { + var out GattProtectionLevel + hr, _, _ := syscall.SyscallN( + v.VTable().GetWriteProtectionLevel, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattProtectionLevel + ) + + if hr != 0 { + return GattProtectionLevelPlain, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristic) CreateDescriptorAsync(descriptorUuid syscall.GUID, parameters *GattLocalDescriptorParameters) (*foundation.IAsyncOperation, error) { + var out *foundation.IAsyncOperation + hr, _, _ := syscall.SyscallN( + v.VTable().CreateDescriptorAsync, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&descriptorUuid)), // in syscall.GUID + uintptr(unsafe.Pointer(parameters)), // in GattLocalDescriptorParameters + uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristic) GetDescriptors() (*collections.IVectorView, error) { + var out *collections.IVectorView + hr, _, _ := syscall.SyscallN( + v.VTable().GetDescriptors, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out collections.IVectorView + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristic) GetUserDescription() (string, error) { + var outHStr ole.HString + hr, _, _ := syscall.SyscallN( + v.VTable().GetUserDescription, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&outHStr)), // out string + ) + + if hr != 0 { + return "", ole.NewError(hr) + } + + out := outHStr.String() + ole.DeleteHString(outHStr) + return out, nil +} + +func (v *iGattLocalCharacteristic) GetPresentationFormats() (*collections.IVectorView, error) { + var out *collections.IVectorView + hr, _, _ := syscall.SyscallN( + v.VTable().GetPresentationFormats, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out collections.IVectorView + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristic) GetSubscribedClients() (*collections.IVectorView, error) { + var out *collections.IVectorView + hr, _, _ := syscall.SyscallN( + v.VTable().GetSubscribedClients, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out collections.IVectorView + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristic) AddSubscribedClientsChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + var out foundation.EventRegistrationToken + hr, _, _ := syscall.SyscallN( + v.VTable().AddSubscribedClientsChanged, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(handler)), // in foundation.TypedEventHandler + uintptr(unsafe.Pointer(&out)), // out foundation.EventRegistrationToken + ) + + if hr != 0 { + return foundation.EventRegistrationToken{}, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristic) RemoveSubscribedClientsChanged(token foundation.EventRegistrationToken) error { + hr, _, _ := syscall.SyscallN( + v.VTable().RemoveSubscribedClientsChanged, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&token)), // in foundation.EventRegistrationToken + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattLocalCharacteristic) AddReadRequested(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + var out foundation.EventRegistrationToken + hr, _, _ := syscall.SyscallN( + v.VTable().AddReadRequested, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(handler)), // in foundation.TypedEventHandler + uintptr(unsafe.Pointer(&out)), // out foundation.EventRegistrationToken + ) + + if hr != 0 { + return foundation.EventRegistrationToken{}, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristic) RemoveReadRequested(token foundation.EventRegistrationToken) error { + hr, _, _ := syscall.SyscallN( + v.VTable().RemoveReadRequested, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&token)), // in foundation.EventRegistrationToken + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattLocalCharacteristic) AddWriteRequested(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + var out foundation.EventRegistrationToken + hr, _, _ := syscall.SyscallN( + v.VTable().AddWriteRequested, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(handler)), // in foundation.TypedEventHandler + uintptr(unsafe.Pointer(&out)), // out foundation.EventRegistrationToken + ) + + if hr != 0 { + return foundation.EventRegistrationToken{}, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristic) RemoveWriteRequested(token foundation.EventRegistrationToken) error { + hr, _, _ := syscall.SyscallN( + v.VTable().RemoveWriteRequested, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&token)), // in foundation.EventRegistrationToken + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattLocalCharacteristic) NotifyValueAsync(value *streams.IBuffer) (*foundation.IAsyncOperation, error) { + var out *foundation.IAsyncOperation + hr, _, _ := syscall.SyscallN( + v.VTable().NotifyValueAsync, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(value)), // in streams.IBuffer + uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristic) NotifyValueForSubscribedClientAsync(value *streams.IBuffer, subscribedClient *GattSubscribedClient) (*foundation.IAsyncOperation, error) { + var out *foundation.IAsyncOperation + hr, _, _ := syscall.SyscallN( + v.VTable().NotifyValueForSubscribedClientAsync, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(value)), // in streams.IBuffer + uintptr(unsafe.Pointer(subscribedClient)), // in GattSubscribedClient + uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} diff --git a/windows/devices/bluetooth/genericattributeprofile/gattlocalcharacteristicparameters.go b/windows/devices/bluetooth/genericattributeprofile/gattlocalcharacteristicparameters.go new file mode 100644 index 0000000..542bf35 --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattlocalcharacteristicparameters.go @@ -0,0 +1,299 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/foundation/collections" + "github.com/saltosystems/winrt-go/windows/storage/streams" +) + +const SignatureGattLocalCharacteristicParameters string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalCharacteristicParameters;{faf73db4-4cff-44c7-8445-040e6ead0063})" + +type GattLocalCharacteristicParameters struct { + ole.IUnknown +} + +func NewGattLocalCharacteristicParameters() (*GattLocalCharacteristicParameters, error) { + inspectable, err := ole.RoActivateInstance("Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalCharacteristicParameters") + if err != nil { + return nil, err + } + return (*GattLocalCharacteristicParameters)(unsafe.Pointer(inspectable)), nil +} + +func (impl *GattLocalCharacteristicParameters) SetStaticValue(value *streams.IBuffer) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristicParameters)) + defer itf.Release() + v := (*iGattLocalCharacteristicParameters)(unsafe.Pointer(itf)) + return v.SetStaticValue(value) +} + +func (impl *GattLocalCharacteristicParameters) GetStaticValue() (*streams.IBuffer, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristicParameters)) + defer itf.Release() + v := (*iGattLocalCharacteristicParameters)(unsafe.Pointer(itf)) + return v.GetStaticValue() +} + +func (impl *GattLocalCharacteristicParameters) SetCharacteristicProperties(value GattCharacteristicProperties) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristicParameters)) + defer itf.Release() + v := (*iGattLocalCharacteristicParameters)(unsafe.Pointer(itf)) + return v.SetCharacteristicProperties(value) +} + +func (impl *GattLocalCharacteristicParameters) GetCharacteristicProperties() (GattCharacteristicProperties, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristicParameters)) + defer itf.Release() + v := (*iGattLocalCharacteristicParameters)(unsafe.Pointer(itf)) + return v.GetCharacteristicProperties() +} + +func (impl *GattLocalCharacteristicParameters) SetReadProtectionLevel(value GattProtectionLevel) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristicParameters)) + defer itf.Release() + v := (*iGattLocalCharacteristicParameters)(unsafe.Pointer(itf)) + return v.SetReadProtectionLevel(value) +} + +func (impl *GattLocalCharacteristicParameters) GetReadProtectionLevel() (GattProtectionLevel, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristicParameters)) + defer itf.Release() + v := (*iGattLocalCharacteristicParameters)(unsafe.Pointer(itf)) + return v.GetReadProtectionLevel() +} + +func (impl *GattLocalCharacteristicParameters) SetWriteProtectionLevel(value GattProtectionLevel) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristicParameters)) + defer itf.Release() + v := (*iGattLocalCharacteristicParameters)(unsafe.Pointer(itf)) + return v.SetWriteProtectionLevel(value) +} + +func (impl *GattLocalCharacteristicParameters) GetWriteProtectionLevel() (GattProtectionLevel, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristicParameters)) + defer itf.Release() + v := (*iGattLocalCharacteristicParameters)(unsafe.Pointer(itf)) + return v.GetWriteProtectionLevel() +} + +func (impl *GattLocalCharacteristicParameters) SetUserDescription(value string) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristicParameters)) + defer itf.Release() + v := (*iGattLocalCharacteristicParameters)(unsafe.Pointer(itf)) + return v.SetUserDescription(value) +} + +func (impl *GattLocalCharacteristicParameters) GetUserDescription() (string, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristicParameters)) + defer itf.Release() + v := (*iGattLocalCharacteristicParameters)(unsafe.Pointer(itf)) + return v.GetUserDescription() +} + +func (impl *GattLocalCharacteristicParameters) GetPresentationFormats() (*collections.IVector, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristicParameters)) + defer itf.Release() + v := (*iGattLocalCharacteristicParameters)(unsafe.Pointer(itf)) + return v.GetPresentationFormats() +} + +const GUIDiGattLocalCharacteristicParameters string = "faf73db4-4cff-44c7-8445-040e6ead0063" +const SignatureiGattLocalCharacteristicParameters string = "{faf73db4-4cff-44c7-8445-040e6ead0063}" + +type iGattLocalCharacteristicParameters struct { + ole.IInspectable +} + +type iGattLocalCharacteristicParametersVtbl struct { + ole.IInspectableVtbl + + SetStaticValue uintptr + GetStaticValue uintptr + SetCharacteristicProperties uintptr + GetCharacteristicProperties uintptr + SetReadProtectionLevel uintptr + GetReadProtectionLevel uintptr + SetWriteProtectionLevel uintptr + GetWriteProtectionLevel uintptr + SetUserDescription uintptr + GetUserDescription uintptr + GetPresentationFormats uintptr +} + +func (v *iGattLocalCharacteristicParameters) VTable() *iGattLocalCharacteristicParametersVtbl { + return (*iGattLocalCharacteristicParametersVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattLocalCharacteristicParameters) SetStaticValue(value *streams.IBuffer) error { + hr, _, _ := syscall.SyscallN( + v.VTable().SetStaticValue, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(value)), // in streams.IBuffer + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattLocalCharacteristicParameters) GetStaticValue() (*streams.IBuffer, error) { + var out *streams.IBuffer + hr, _, _ := syscall.SyscallN( + v.VTable().GetStaticValue, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out streams.IBuffer + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristicParameters) SetCharacteristicProperties(value GattCharacteristicProperties) error { + hr, _, _ := syscall.SyscallN( + v.VTable().SetCharacteristicProperties, + uintptr(unsafe.Pointer(v)), // this + uintptr(value), // in GattCharacteristicProperties + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattLocalCharacteristicParameters) GetCharacteristicProperties() (GattCharacteristicProperties, error) { + var out GattCharacteristicProperties + hr, _, _ := syscall.SyscallN( + v.VTable().GetCharacteristicProperties, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattCharacteristicProperties + ) + + if hr != 0 { + return GattCharacteristicPropertiesNone, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristicParameters) SetReadProtectionLevel(value GattProtectionLevel) error { + hr, _, _ := syscall.SyscallN( + v.VTable().SetReadProtectionLevel, + uintptr(unsafe.Pointer(v)), // this + uintptr(value), // in GattProtectionLevel + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattLocalCharacteristicParameters) GetReadProtectionLevel() (GattProtectionLevel, error) { + var out GattProtectionLevel + hr, _, _ := syscall.SyscallN( + v.VTable().GetReadProtectionLevel, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattProtectionLevel + ) + + if hr != 0 { + return GattProtectionLevelPlain, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristicParameters) SetWriteProtectionLevel(value GattProtectionLevel) error { + hr, _, _ := syscall.SyscallN( + v.VTable().SetWriteProtectionLevel, + uintptr(unsafe.Pointer(v)), // this + uintptr(value), // in GattProtectionLevel + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattLocalCharacteristicParameters) GetWriteProtectionLevel() (GattProtectionLevel, error) { + var out GattProtectionLevel + hr, _, _ := syscall.SyscallN( + v.VTable().GetWriteProtectionLevel, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattProtectionLevel + ) + + if hr != 0 { + return GattProtectionLevelPlain, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristicParameters) SetUserDescription(value string) error { + valueHStr, err := ole.NewHString(value) + if err != nil { + return err + } + hr, _, _ := syscall.SyscallN( + v.VTable().SetUserDescription, + uintptr(unsafe.Pointer(v)), // this + uintptr(valueHStr), // in string + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattLocalCharacteristicParameters) GetUserDescription() (string, error) { + var outHStr ole.HString + hr, _, _ := syscall.SyscallN( + v.VTable().GetUserDescription, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&outHStr)), // out string + ) + + if hr != 0 { + return "", ole.NewError(hr) + } + + out := outHStr.String() + ole.DeleteHString(outHStr) + return out, nil +} + +func (v *iGattLocalCharacteristicParameters) GetPresentationFormats() (*collections.IVector, error) { + var out *collections.IVector + hr, _, _ := syscall.SyscallN( + v.VTable().GetPresentationFormats, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out collections.IVector + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} diff --git a/windows/devices/bluetooth/genericattributeprofile/gattlocalcharacteristicresult.go b/windows/devices/bluetooth/genericattributeprofile/gattlocalcharacteristicresult.go new file mode 100644 index 0000000..ebcce90 --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattlocalcharacteristicresult.go @@ -0,0 +1,82 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/devices/bluetooth" +) + +const SignatureGattLocalCharacteristicResult string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalCharacteristicResult;{7975de9b-0170-4397-9666-92f863f12ee6})" + +type GattLocalCharacteristicResult struct { + ole.IUnknown +} + +func (impl *GattLocalCharacteristicResult) GetCharacteristic() (*GattLocalCharacteristic, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristicResult)) + defer itf.Release() + v := (*iGattLocalCharacteristicResult)(unsafe.Pointer(itf)) + return v.GetCharacteristic() +} + +func (impl *GattLocalCharacteristicResult) GetError() (bluetooth.BluetoothError, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalCharacteristicResult)) + defer itf.Release() + v := (*iGattLocalCharacteristicResult)(unsafe.Pointer(itf)) + return v.GetError() +} + +const GUIDiGattLocalCharacteristicResult string = "7975de9b-0170-4397-9666-92f863f12ee6" +const SignatureiGattLocalCharacteristicResult string = "{7975de9b-0170-4397-9666-92f863f12ee6}" + +type iGattLocalCharacteristicResult struct { + ole.IInspectable +} + +type iGattLocalCharacteristicResultVtbl struct { + ole.IInspectableVtbl + + GetCharacteristic uintptr + GetError uintptr +} + +func (v *iGattLocalCharacteristicResult) VTable() *iGattLocalCharacteristicResultVtbl { + return (*iGattLocalCharacteristicResultVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattLocalCharacteristicResult) GetCharacteristic() (*GattLocalCharacteristic, error) { + var out *GattLocalCharacteristic + hr, _, _ := syscall.SyscallN( + v.VTable().GetCharacteristic, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattLocalCharacteristic + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalCharacteristicResult) 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/genericattributeprofile/gattlocaldescriptorparameters.go b/windows/devices/bluetooth/genericattributeprofile/gattlocaldescriptorparameters.go new file mode 100644 index 0000000..1bf5495 --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattlocaldescriptorparameters.go @@ -0,0 +1,179 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/storage/streams" +) + +const SignatureGattLocalDescriptorParameters string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalDescriptorParameters;{5fdede6a-f3c1-4b66-8c4b-e3d2293b40e9})" + +type GattLocalDescriptorParameters struct { + ole.IUnknown +} + +func NewGattLocalDescriptorParameters() (*GattLocalDescriptorParameters, error) { + inspectable, err := ole.RoActivateInstance("Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalDescriptorParameters") + if err != nil { + return nil, err + } + return (*GattLocalDescriptorParameters)(unsafe.Pointer(inspectable)), nil +} + +func (impl *GattLocalDescriptorParameters) SetStaticValue(value *streams.IBuffer) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalDescriptorParameters)) + defer itf.Release() + v := (*iGattLocalDescriptorParameters)(unsafe.Pointer(itf)) + return v.SetStaticValue(value) +} + +func (impl *GattLocalDescriptorParameters) GetStaticValue() (*streams.IBuffer, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalDescriptorParameters)) + defer itf.Release() + v := (*iGattLocalDescriptorParameters)(unsafe.Pointer(itf)) + return v.GetStaticValue() +} + +func (impl *GattLocalDescriptorParameters) SetReadProtectionLevel(value GattProtectionLevel) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalDescriptorParameters)) + defer itf.Release() + v := (*iGattLocalDescriptorParameters)(unsafe.Pointer(itf)) + return v.SetReadProtectionLevel(value) +} + +func (impl *GattLocalDescriptorParameters) GetReadProtectionLevel() (GattProtectionLevel, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalDescriptorParameters)) + defer itf.Release() + v := (*iGattLocalDescriptorParameters)(unsafe.Pointer(itf)) + return v.GetReadProtectionLevel() +} + +func (impl *GattLocalDescriptorParameters) SetWriteProtectionLevel(value GattProtectionLevel) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalDescriptorParameters)) + defer itf.Release() + v := (*iGattLocalDescriptorParameters)(unsafe.Pointer(itf)) + return v.SetWriteProtectionLevel(value) +} + +func (impl *GattLocalDescriptorParameters) GetWriteProtectionLevel() (GattProtectionLevel, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalDescriptorParameters)) + defer itf.Release() + v := (*iGattLocalDescriptorParameters)(unsafe.Pointer(itf)) + return v.GetWriteProtectionLevel() +} + +const GUIDiGattLocalDescriptorParameters string = "5fdede6a-f3c1-4b66-8c4b-e3d2293b40e9" +const SignatureiGattLocalDescriptorParameters string = "{5fdede6a-f3c1-4b66-8c4b-e3d2293b40e9}" + +type iGattLocalDescriptorParameters struct { + ole.IInspectable +} + +type iGattLocalDescriptorParametersVtbl struct { + ole.IInspectableVtbl + + SetStaticValue uintptr + GetStaticValue uintptr + SetReadProtectionLevel uintptr + GetReadProtectionLevel uintptr + SetWriteProtectionLevel uintptr + GetWriteProtectionLevel uintptr +} + +func (v *iGattLocalDescriptorParameters) VTable() *iGattLocalDescriptorParametersVtbl { + return (*iGattLocalDescriptorParametersVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattLocalDescriptorParameters) SetStaticValue(value *streams.IBuffer) error { + hr, _, _ := syscall.SyscallN( + v.VTable().SetStaticValue, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(value)), // in streams.IBuffer + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattLocalDescriptorParameters) GetStaticValue() (*streams.IBuffer, error) { + var out *streams.IBuffer + hr, _, _ := syscall.SyscallN( + v.VTable().GetStaticValue, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out streams.IBuffer + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalDescriptorParameters) SetReadProtectionLevel(value GattProtectionLevel) error { + hr, _, _ := syscall.SyscallN( + v.VTable().SetReadProtectionLevel, + uintptr(unsafe.Pointer(v)), // this + uintptr(value), // in GattProtectionLevel + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattLocalDescriptorParameters) GetReadProtectionLevel() (GattProtectionLevel, error) { + var out GattProtectionLevel + hr, _, _ := syscall.SyscallN( + v.VTable().GetReadProtectionLevel, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattProtectionLevel + ) + + if hr != 0 { + return GattProtectionLevelPlain, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalDescriptorParameters) SetWriteProtectionLevel(value GattProtectionLevel) error { + hr, _, _ := syscall.SyscallN( + v.VTable().SetWriteProtectionLevel, + uintptr(unsafe.Pointer(v)), // this + uintptr(value), // in GattProtectionLevel + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattLocalDescriptorParameters) GetWriteProtectionLevel() (GattProtectionLevel, error) { + var out GattProtectionLevel + hr, _, _ := syscall.SyscallN( + v.VTable().GetWriteProtectionLevel, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattProtectionLevel + ) + + if hr != 0 { + return GattProtectionLevelPlain, ole.NewError(hr) + } + + return out, nil +} diff --git a/windows/devices/bluetooth/genericattributeprofile/gattlocalservice.go b/windows/devices/bluetooth/genericattributeprofile/gattlocalservice.go new file mode 100644 index 0000000..e31a89b --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattlocalservice.go @@ -0,0 +1,108 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/foundation" + "github.com/saltosystems/winrt-go/windows/foundation/collections" +) + +const SignatureGattLocalService string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalService;{f513e258-f7f7-4902-b803-57fcc7d6fe83})" + +type GattLocalService struct { + ole.IUnknown +} + +func (impl *GattLocalService) GetUuid() (syscall.GUID, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalService)) + defer itf.Release() + v := (*iGattLocalService)(unsafe.Pointer(itf)) + return v.GetUuid() +} + +func (impl *GattLocalService) CreateCharacteristicAsync(characteristicUuid syscall.GUID, parameters *GattLocalCharacteristicParameters) (*foundation.IAsyncOperation, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalService)) + defer itf.Release() + v := (*iGattLocalService)(unsafe.Pointer(itf)) + return v.CreateCharacteristicAsync(characteristicUuid, parameters) +} + +func (impl *GattLocalService) GetCharacteristics() (*collections.IVectorView, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalService)) + defer itf.Release() + v := (*iGattLocalService)(unsafe.Pointer(itf)) + return v.GetCharacteristics() +} + +const GUIDiGattLocalService string = "f513e258-f7f7-4902-b803-57fcc7d6fe83" +const SignatureiGattLocalService string = "{f513e258-f7f7-4902-b803-57fcc7d6fe83}" + +type iGattLocalService struct { + ole.IInspectable +} + +type iGattLocalServiceVtbl struct { + ole.IInspectableVtbl + + GetUuid uintptr + CreateCharacteristicAsync uintptr + GetCharacteristics uintptr +} + +func (v *iGattLocalService) VTable() *iGattLocalServiceVtbl { + return (*iGattLocalServiceVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattLocalService) GetUuid() (syscall.GUID, error) { + var out syscall.GUID + hr, _, _ := syscall.SyscallN( + v.VTable().GetUuid, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out syscall.GUID + ) + + if hr != 0 { + return syscall.GUID{}, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalService) CreateCharacteristicAsync(characteristicUuid syscall.GUID, parameters *GattLocalCharacteristicParameters) (*foundation.IAsyncOperation, error) { + var out *foundation.IAsyncOperation + hr, _, _ := syscall.SyscallN( + v.VTable().CreateCharacteristicAsync, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&characteristicUuid)), // in syscall.GUID + uintptr(unsafe.Pointer(parameters)), // in GattLocalCharacteristicParameters + uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattLocalService) GetCharacteristics() (*collections.IVectorView, error) { + var out *collections.IVectorView + hr, _, _ := syscall.SyscallN( + v.VTable().GetCharacteristics, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out collections.IVectorView + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} diff --git a/windows/devices/bluetooth/genericattributeprofile/gattprotectionlevel.go b/windows/devices/bluetooth/genericattributeprofile/gattprotectionlevel.go new file mode 100644 index 0000000..a1f1804 --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattprotectionlevel.go @@ -0,0 +1,17 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +type GattProtectionLevel int32 + +const SignatureGattProtectionLevel string = "enum(Windows.Devices.Bluetooth.GenericAttributeProfile.GattProtectionLevel;i4)" + +const ( + GattProtectionLevelPlain GattProtectionLevel = 0 + GattProtectionLevelAuthenticationRequired GattProtectionLevel = 1 + GattProtectionLevelEncryptionRequired GattProtectionLevel = 2 + GattProtectionLevelEncryptionAndAuthenticationRequired GattProtectionLevel = 3 +) diff --git a/windows/devices/bluetooth/genericattributeprofile/gattreadrequest.go b/windows/devices/bluetooth/genericattributeprofile/gattreadrequest.go new file mode 100644 index 0000000..5f039e9 --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattreadrequest.go @@ -0,0 +1,196 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/foundation" + "github.com/saltosystems/winrt-go/windows/storage/streams" +) + +const SignatureGattReadRequest string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattReadRequest;{f1dd6535-6acd-42a6-a4bb-d789dae0043e})" + +type GattReadRequest struct { + ole.IUnknown +} + +func (impl *GattReadRequest) GetOffset() (uint32, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadRequest)) + defer itf.Release() + v := (*iGattReadRequest)(unsafe.Pointer(itf)) + return v.GetOffset() +} + +func (impl *GattReadRequest) GetLength() (uint32, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadRequest)) + defer itf.Release() + v := (*iGattReadRequest)(unsafe.Pointer(itf)) + return v.GetLength() +} + +func (impl *GattReadRequest) GetState() (GattRequestState, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadRequest)) + defer itf.Release() + v := (*iGattReadRequest)(unsafe.Pointer(itf)) + return v.GetState() +} + +func (impl *GattReadRequest) AddStateChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadRequest)) + defer itf.Release() + v := (*iGattReadRequest)(unsafe.Pointer(itf)) + return v.AddStateChanged(handler) +} + +func (impl *GattReadRequest) RemoveStateChanged(token foundation.EventRegistrationToken) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadRequest)) + defer itf.Release() + v := (*iGattReadRequest)(unsafe.Pointer(itf)) + return v.RemoveStateChanged(token) +} + +func (impl *GattReadRequest) RespondWithValue(value *streams.IBuffer) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadRequest)) + defer itf.Release() + v := (*iGattReadRequest)(unsafe.Pointer(itf)) + return v.RespondWithValue(value) +} + +func (impl *GattReadRequest) RespondWithProtocolError(protocolError uint8) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadRequest)) + defer itf.Release() + v := (*iGattReadRequest)(unsafe.Pointer(itf)) + return v.RespondWithProtocolError(protocolError) +} + +const GUIDiGattReadRequest string = "f1dd6535-6acd-42a6-a4bb-d789dae0043e" +const SignatureiGattReadRequest string = "{f1dd6535-6acd-42a6-a4bb-d789dae0043e}" + +type iGattReadRequest struct { + ole.IInspectable +} + +type iGattReadRequestVtbl struct { + ole.IInspectableVtbl + + GetOffset uintptr + GetLength uintptr + GetState uintptr + AddStateChanged uintptr + RemoveStateChanged uintptr + RespondWithValue uintptr + RespondWithProtocolError uintptr +} + +func (v *iGattReadRequest) VTable() *iGattReadRequestVtbl { + return (*iGattReadRequestVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattReadRequest) GetOffset() (uint32, error) { + var out uint32 + hr, _, _ := syscall.SyscallN( + v.VTable().GetOffset, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out uint32 + ) + + if hr != 0 { + return 0, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattReadRequest) GetLength() (uint32, error) { + var out uint32 + hr, _, _ := syscall.SyscallN( + v.VTable().GetLength, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out uint32 + ) + + if hr != 0 { + return 0, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattReadRequest) GetState() (GattRequestState, error) { + var out GattRequestState + hr, _, _ := syscall.SyscallN( + v.VTable().GetState, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattRequestState + ) + + if hr != 0 { + return GattRequestStatePending, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattReadRequest) AddStateChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + var out foundation.EventRegistrationToken + hr, _, _ := syscall.SyscallN( + v.VTable().AddStateChanged, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(handler)), // in foundation.TypedEventHandler + uintptr(unsafe.Pointer(&out)), // out foundation.EventRegistrationToken + ) + + if hr != 0 { + return foundation.EventRegistrationToken{}, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattReadRequest) RemoveStateChanged(token foundation.EventRegistrationToken) error { + hr, _, _ := syscall.SyscallN( + v.VTable().RemoveStateChanged, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&token)), // in foundation.EventRegistrationToken + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattReadRequest) RespondWithValue(value *streams.IBuffer) error { + hr, _, _ := syscall.SyscallN( + v.VTable().RespondWithValue, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(value)), // in streams.IBuffer + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattReadRequest) RespondWithProtocolError(protocolError uint8) error { + hr, _, _ := syscall.SyscallN( + v.VTable().RespondWithProtocolError, + uintptr(unsafe.Pointer(v)), // this + uintptr(protocolError), // in uint8 + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} diff --git a/windows/devices/bluetooth/genericattributeprofile/gattreadrequestedeventargs.go b/windows/devices/bluetooth/genericattributeprofile/gattreadrequestedeventargs.go new file mode 100644 index 0000000..aa82a32 --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattreadrequestedeventargs.go @@ -0,0 +1,105 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/foundation" +) + +const SignatureGattReadRequestedEventArgs string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattReadRequestedEventArgs;{93497243-f39c-484b-8ab6-996ba486cfa3})" + +type GattReadRequestedEventArgs struct { + ole.IUnknown +} + +func (impl *GattReadRequestedEventArgs) GetSession() (*GattSession, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadRequestedEventArgs)) + defer itf.Release() + v := (*iGattReadRequestedEventArgs)(unsafe.Pointer(itf)) + return v.GetSession() +} + +func (impl *GattReadRequestedEventArgs) GetDeferral() (*foundation.Deferral, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadRequestedEventArgs)) + defer itf.Release() + v := (*iGattReadRequestedEventArgs)(unsafe.Pointer(itf)) + return v.GetDeferral() +} + +func (impl *GattReadRequestedEventArgs) GetRequestAsync() (*foundation.IAsyncOperation, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattReadRequestedEventArgs)) + defer itf.Release() + v := (*iGattReadRequestedEventArgs)(unsafe.Pointer(itf)) + return v.GetRequestAsync() +} + +const GUIDiGattReadRequestedEventArgs string = "93497243-f39c-484b-8ab6-996ba486cfa3" +const SignatureiGattReadRequestedEventArgs string = "{93497243-f39c-484b-8ab6-996ba486cfa3}" + +type iGattReadRequestedEventArgs struct { + ole.IInspectable +} + +type iGattReadRequestedEventArgsVtbl struct { + ole.IInspectableVtbl + + GetSession uintptr + GetDeferral uintptr + GetRequestAsync uintptr +} + +func (v *iGattReadRequestedEventArgs) VTable() *iGattReadRequestedEventArgsVtbl { + return (*iGattReadRequestedEventArgsVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattReadRequestedEventArgs) GetSession() (*GattSession, error) { + var out *GattSession + hr, _, _ := syscall.SyscallN( + v.VTable().GetSession, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattSession + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattReadRequestedEventArgs) GetDeferral() (*foundation.Deferral, error) { + var out *foundation.Deferral + hr, _, _ := syscall.SyscallN( + v.VTable().GetDeferral, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out foundation.Deferral + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattReadRequestedEventArgs) GetRequestAsync() (*foundation.IAsyncOperation, error) { + var out *foundation.IAsyncOperation + hr, _, _ := syscall.SyscallN( + v.VTable().GetRequestAsync, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} diff --git a/windows/devices/bluetooth/genericattributeprofile/gattrequeststate.go b/windows/devices/bluetooth/genericattributeprofile/gattrequeststate.go new file mode 100644 index 0000000..a340caa --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattrequeststate.go @@ -0,0 +1,16 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +type GattRequestState int32 + +const SignatureGattRequestState string = "enum(Windows.Devices.Bluetooth.GenericAttributeProfile.GattRequestState;i4)" + +const ( + GattRequestStatePending GattRequestState = 0 + GattRequestStateCompleted GattRequestState = 1 + GattRequestStateCanceled GattRequestState = 2 +) diff --git a/windows/devices/bluetooth/genericattributeprofile/gattserviceprovider.go b/windows/devices/bluetooth/genericattributeprofile/gattserviceprovider.go new file mode 100644 index 0000000..9879f15 --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattserviceprovider.go @@ -0,0 +1,231 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/foundation" +) + +const SignatureGattServiceProvider string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattServiceProvider;{7822b3cd-2889-4f86-a051-3f0aed1c2760})" + +type GattServiceProvider struct { + ole.IUnknown +} + +func (impl *GattServiceProvider) GetService() (*GattLocalService, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProvider)) + defer itf.Release() + v := (*iGattServiceProvider)(unsafe.Pointer(itf)) + return v.GetService() +} + +func (impl *GattServiceProvider) GetAdvertisementStatus() (GattServiceProviderAdvertisementStatus, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProvider)) + defer itf.Release() + v := (*iGattServiceProvider)(unsafe.Pointer(itf)) + return v.GetAdvertisementStatus() +} + +func (impl *GattServiceProvider) AddAdvertisementStatusChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProvider)) + defer itf.Release() + v := (*iGattServiceProvider)(unsafe.Pointer(itf)) + return v.AddAdvertisementStatusChanged(handler) +} + +func (impl *GattServiceProvider) RemoveAdvertisementStatusChanged(token foundation.EventRegistrationToken) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProvider)) + defer itf.Release() + v := (*iGattServiceProvider)(unsafe.Pointer(itf)) + return v.RemoveAdvertisementStatusChanged(token) +} + +func (impl *GattServiceProvider) StartAdvertising() error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProvider)) + defer itf.Release() + v := (*iGattServiceProvider)(unsafe.Pointer(itf)) + return v.StartAdvertising() +} + +func (impl *GattServiceProvider) StartAdvertisingWithParameters(parameters *GattServiceProviderAdvertisingParameters) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProvider)) + defer itf.Release() + v := (*iGattServiceProvider)(unsafe.Pointer(itf)) + return v.StartAdvertisingWithParameters(parameters) +} + +func (impl *GattServiceProvider) StopAdvertising() error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProvider)) + defer itf.Release() + v := (*iGattServiceProvider)(unsafe.Pointer(itf)) + return v.StopAdvertising() +} + +const GUIDiGattServiceProvider string = "7822b3cd-2889-4f86-a051-3f0aed1c2760" +const SignatureiGattServiceProvider string = "{7822b3cd-2889-4f86-a051-3f0aed1c2760}" + +type iGattServiceProvider struct { + ole.IInspectable +} + +type iGattServiceProviderVtbl struct { + ole.IInspectableVtbl + + GetService uintptr + GetAdvertisementStatus uintptr + AddAdvertisementStatusChanged uintptr + RemoveAdvertisementStatusChanged uintptr + StartAdvertising uintptr + StartAdvertisingWithParameters uintptr + StopAdvertising uintptr +} + +func (v *iGattServiceProvider) VTable() *iGattServiceProviderVtbl { + return (*iGattServiceProviderVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattServiceProvider) GetService() (*GattLocalService, error) { + var out *GattLocalService + hr, _, _ := syscall.SyscallN( + v.VTable().GetService, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattLocalService + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattServiceProvider) GetAdvertisementStatus() (GattServiceProviderAdvertisementStatus, error) { + var out GattServiceProviderAdvertisementStatus + hr, _, _ := syscall.SyscallN( + v.VTable().GetAdvertisementStatus, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattServiceProviderAdvertisementStatus + ) + + if hr != 0 { + return GattServiceProviderAdvertisementStatusCreated, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattServiceProvider) AddAdvertisementStatusChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + var out foundation.EventRegistrationToken + hr, _, _ := syscall.SyscallN( + v.VTable().AddAdvertisementStatusChanged, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(handler)), // in foundation.TypedEventHandler + uintptr(unsafe.Pointer(&out)), // out foundation.EventRegistrationToken + ) + + if hr != 0 { + return foundation.EventRegistrationToken{}, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattServiceProvider) RemoveAdvertisementStatusChanged(token foundation.EventRegistrationToken) error { + hr, _, _ := syscall.SyscallN( + v.VTable().RemoveAdvertisementStatusChanged, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&token)), // in foundation.EventRegistrationToken + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattServiceProvider) StartAdvertising() error { + hr, _, _ := syscall.SyscallN( + v.VTable().StartAdvertising, + uintptr(unsafe.Pointer(v)), // this + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattServiceProvider) StartAdvertisingWithParameters(parameters *GattServiceProviderAdvertisingParameters) error { + hr, _, _ := syscall.SyscallN( + v.VTable().StartAdvertisingWithParameters, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(parameters)), // in GattServiceProviderAdvertisingParameters + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattServiceProvider) StopAdvertising() error { + hr, _, _ := syscall.SyscallN( + v.VTable().StopAdvertising, + uintptr(unsafe.Pointer(v)), // this + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +const GUIDiGattServiceProviderStatics string = "31794063-5256-4054-a4f4-7bbe7755a57e" +const SignatureiGattServiceProviderStatics string = "{31794063-5256-4054-a4f4-7bbe7755a57e}" + +type iGattServiceProviderStatics struct { + ole.IInspectable +} + +type iGattServiceProviderStaticsVtbl struct { + ole.IInspectableVtbl + + GattServiceProviderCreateAsync uintptr +} + +func (v *iGattServiceProviderStatics) VTable() *iGattServiceProviderStaticsVtbl { + return (*iGattServiceProviderStaticsVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func GattServiceProviderCreateAsync(serviceUuid syscall.GUID) (*foundation.IAsyncOperation, error) { + inspectable, err := ole.RoGetActivationFactory("Windows.Devices.Bluetooth.GenericAttributeProfile.GattServiceProvider", ole.NewGUID(GUIDiGattServiceProviderStatics)) + if err != nil { + return nil, err + } + v := (*iGattServiceProviderStatics)(unsafe.Pointer(inspectable)) + + var out *foundation.IAsyncOperation + hr, _, _ := syscall.SyscallN( + v.VTable().GattServiceProviderCreateAsync, + 0, // this is a static func, so there's no this + uintptr(unsafe.Pointer(&serviceUuid)), // in syscall.GUID + uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} diff --git a/windows/devices/bluetooth/genericattributeprofile/gattserviceprovideradvertisementstatus.go b/windows/devices/bluetooth/genericattributeprofile/gattserviceprovideradvertisementstatus.go new file mode 100644 index 0000000..d72535e --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattserviceprovideradvertisementstatus.go @@ -0,0 +1,18 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +type GattServiceProviderAdvertisementStatus int32 + +const SignatureGattServiceProviderAdvertisementStatus string = "enum(Windows.Devices.Bluetooth.GenericAttributeProfile.GattServiceProviderAdvertisementStatus;i4)" + +const ( + GattServiceProviderAdvertisementStatusCreated GattServiceProviderAdvertisementStatus = 0 + GattServiceProviderAdvertisementStatusStopped GattServiceProviderAdvertisementStatus = 1 + GattServiceProviderAdvertisementStatusStarted GattServiceProviderAdvertisementStatus = 2 + GattServiceProviderAdvertisementStatusAborted GattServiceProviderAdvertisementStatus = 3 + GattServiceProviderAdvertisementStatusStartedWithoutAllAdvertisementData GattServiceProviderAdvertisementStatus = 4 +) diff --git a/windows/devices/bluetooth/genericattributeprofile/gattserviceprovideradvertisingparameters.go b/windows/devices/bluetooth/genericattributeprofile/gattserviceprovideradvertisingparameters.go new file mode 100644 index 0000000..66a5f74 --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattserviceprovideradvertisingparameters.go @@ -0,0 +1,195 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/storage/streams" +) + +const SignatureGattServiceProviderAdvertisingParameters string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattServiceProviderAdvertisingParameters;{e2ce31ab-6315-4c22-9bd7-781dbc3d8d82})" + +type GattServiceProviderAdvertisingParameters struct { + ole.IUnknown +} + +func NewGattServiceProviderAdvertisingParameters() (*GattServiceProviderAdvertisingParameters, error) { + inspectable, err := ole.RoActivateInstance("Windows.Devices.Bluetooth.GenericAttributeProfile.GattServiceProviderAdvertisingParameters") + if err != nil { + return nil, err + } + return (*GattServiceProviderAdvertisingParameters)(unsafe.Pointer(inspectable)), nil +} + +func (impl *GattServiceProviderAdvertisingParameters) SetIsConnectable(value bool) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProviderAdvertisingParameters)) + defer itf.Release() + v := (*iGattServiceProviderAdvertisingParameters)(unsafe.Pointer(itf)) + return v.SetIsConnectable(value) +} + +func (impl *GattServiceProviderAdvertisingParameters) GetIsConnectable() (bool, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProviderAdvertisingParameters)) + defer itf.Release() + v := (*iGattServiceProviderAdvertisingParameters)(unsafe.Pointer(itf)) + return v.GetIsConnectable() +} + +func (impl *GattServiceProviderAdvertisingParameters) SetIsDiscoverable(value bool) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProviderAdvertisingParameters)) + defer itf.Release() + v := (*iGattServiceProviderAdvertisingParameters)(unsafe.Pointer(itf)) + return v.SetIsDiscoverable(value) +} + +func (impl *GattServiceProviderAdvertisingParameters) GetIsDiscoverable() (bool, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProviderAdvertisingParameters)) + defer itf.Release() + v := (*iGattServiceProviderAdvertisingParameters)(unsafe.Pointer(itf)) + return v.GetIsDiscoverable() +} + +func (impl *GattServiceProviderAdvertisingParameters) SetServiceData(value *streams.IBuffer) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProviderAdvertisingParameters2)) + defer itf.Release() + v := (*iGattServiceProviderAdvertisingParameters2)(unsafe.Pointer(itf)) + return v.SetServiceData(value) +} + +func (impl *GattServiceProviderAdvertisingParameters) GetServiceData() (*streams.IBuffer, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProviderAdvertisingParameters2)) + defer itf.Release() + v := (*iGattServiceProviderAdvertisingParameters2)(unsafe.Pointer(itf)) + return v.GetServiceData() +} + +const GUIDiGattServiceProviderAdvertisingParameters string = "e2ce31ab-6315-4c22-9bd7-781dbc3d8d82" +const SignatureiGattServiceProviderAdvertisingParameters string = "{e2ce31ab-6315-4c22-9bd7-781dbc3d8d82}" + +type iGattServiceProviderAdvertisingParameters struct { + ole.IInspectable +} + +type iGattServiceProviderAdvertisingParametersVtbl struct { + ole.IInspectableVtbl + + SetIsConnectable uintptr + GetIsConnectable uintptr + SetIsDiscoverable uintptr + GetIsDiscoverable uintptr +} + +func (v *iGattServiceProviderAdvertisingParameters) VTable() *iGattServiceProviderAdvertisingParametersVtbl { + return (*iGattServiceProviderAdvertisingParametersVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattServiceProviderAdvertisingParameters) SetIsConnectable(value bool) error { + hr, _, _ := syscall.SyscallN( + v.VTable().SetIsConnectable, + uintptr(unsafe.Pointer(v)), // this + uintptr(*(*byte)(unsafe.Pointer(&value))), // in bool + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattServiceProviderAdvertisingParameters) GetIsConnectable() (bool, error) { + var out bool + hr, _, _ := syscall.SyscallN( + v.VTable().GetIsConnectable, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out bool + ) + + if hr != 0 { + return false, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattServiceProviderAdvertisingParameters) SetIsDiscoverable(value bool) error { + hr, _, _ := syscall.SyscallN( + v.VTable().SetIsDiscoverable, + uintptr(unsafe.Pointer(v)), // this + uintptr(*(*byte)(unsafe.Pointer(&value))), // in bool + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattServiceProviderAdvertisingParameters) GetIsDiscoverable() (bool, error) { + var out bool + hr, _, _ := syscall.SyscallN( + v.VTable().GetIsDiscoverable, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out bool + ) + + if hr != 0 { + return false, ole.NewError(hr) + } + + return out, nil +} + +const GUIDiGattServiceProviderAdvertisingParameters2 string = "ff68468d-ca92-4434-9743-0e90988ad879" +const SignatureiGattServiceProviderAdvertisingParameters2 string = "{ff68468d-ca92-4434-9743-0e90988ad879}" + +type iGattServiceProviderAdvertisingParameters2 struct { + ole.IInspectable +} + +type iGattServiceProviderAdvertisingParameters2Vtbl struct { + ole.IInspectableVtbl + + SetServiceData uintptr + GetServiceData uintptr +} + +func (v *iGattServiceProviderAdvertisingParameters2) VTable() *iGattServiceProviderAdvertisingParameters2Vtbl { + return (*iGattServiceProviderAdvertisingParameters2Vtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattServiceProviderAdvertisingParameters2) SetServiceData(value *streams.IBuffer) error { + hr, _, _ := syscall.SyscallN( + v.VTable().SetServiceData, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(value)), // in streams.IBuffer + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattServiceProviderAdvertisingParameters2) GetServiceData() (*streams.IBuffer, error) { + var out *streams.IBuffer + hr, _, _ := syscall.SyscallN( + v.VTable().GetServiceData, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out streams.IBuffer + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} diff --git a/windows/devices/bluetooth/genericattributeprofile/gattserviceproviderresult.go b/windows/devices/bluetooth/genericattributeprofile/gattserviceproviderresult.go new file mode 100644 index 0000000..f704b2f --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattserviceproviderresult.go @@ -0,0 +1,82 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/devices/bluetooth" +) + +const SignatureGattServiceProviderResult string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattServiceProviderResult;{764696d8-c53e-428c-8a48-67afe02c3ae6})" + +type GattServiceProviderResult struct { + ole.IUnknown +} + +func (impl *GattServiceProviderResult) GetError() (bluetooth.BluetoothError, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProviderResult)) + defer itf.Release() + v := (*iGattServiceProviderResult)(unsafe.Pointer(itf)) + return v.GetError() +} + +func (impl *GattServiceProviderResult) GetServiceProvider() (*GattServiceProvider, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattServiceProviderResult)) + defer itf.Release() + v := (*iGattServiceProviderResult)(unsafe.Pointer(itf)) + return v.GetServiceProvider() +} + +const GUIDiGattServiceProviderResult string = "764696d8-c53e-428c-8a48-67afe02c3ae6" +const SignatureiGattServiceProviderResult string = "{764696d8-c53e-428c-8a48-67afe02c3ae6}" + +type iGattServiceProviderResult struct { + ole.IInspectable +} + +type iGattServiceProviderResultVtbl struct { + ole.IInspectableVtbl + + GetError uintptr + GetServiceProvider uintptr +} + +func (v *iGattServiceProviderResult) VTable() *iGattServiceProviderResultVtbl { + return (*iGattServiceProviderResultVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattServiceProviderResult) 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 +} + +func (v *iGattServiceProviderResult) GetServiceProvider() (*GattServiceProvider, error) { + var out *GattServiceProvider + hr, _, _ := syscall.SyscallN( + v.VTable().GetServiceProvider, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattServiceProvider + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} diff --git a/windows/devices/bluetooth/genericattributeprofile/gattsubscribedclient.go b/windows/devices/bluetooth/genericattributeprofile/gattsubscribedclient.go new file mode 100644 index 0000000..7cc5c44 --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattsubscribedclient.go @@ -0,0 +1,128 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/foundation" +) + +const SignatureGattSubscribedClient string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattSubscribedClient;{736e9001-15a4-4ec2-9248-e3f20d463be9})" + +type GattSubscribedClient struct { + ole.IUnknown +} + +func (impl *GattSubscribedClient) GetSession() (*GattSession, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattSubscribedClient)) + defer itf.Release() + v := (*iGattSubscribedClient)(unsafe.Pointer(itf)) + return v.GetSession() +} + +func (impl *GattSubscribedClient) GetMaxNotificationSize() (uint16, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattSubscribedClient)) + defer itf.Release() + v := (*iGattSubscribedClient)(unsafe.Pointer(itf)) + return v.GetMaxNotificationSize() +} + +func (impl *GattSubscribedClient) AddMaxNotificationSizeChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattSubscribedClient)) + defer itf.Release() + v := (*iGattSubscribedClient)(unsafe.Pointer(itf)) + return v.AddMaxNotificationSizeChanged(handler) +} + +func (impl *GattSubscribedClient) RemoveMaxNotificationSizeChanged(token foundation.EventRegistrationToken) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattSubscribedClient)) + defer itf.Release() + v := (*iGattSubscribedClient)(unsafe.Pointer(itf)) + return v.RemoveMaxNotificationSizeChanged(token) +} + +const GUIDiGattSubscribedClient string = "736e9001-15a4-4ec2-9248-e3f20d463be9" +const SignatureiGattSubscribedClient string = "{736e9001-15a4-4ec2-9248-e3f20d463be9}" + +type iGattSubscribedClient struct { + ole.IInspectable +} + +type iGattSubscribedClientVtbl struct { + ole.IInspectableVtbl + + GetSession uintptr + GetMaxNotificationSize uintptr + AddMaxNotificationSizeChanged uintptr + RemoveMaxNotificationSizeChanged uintptr +} + +func (v *iGattSubscribedClient) VTable() *iGattSubscribedClientVtbl { + return (*iGattSubscribedClientVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattSubscribedClient) GetSession() (*GattSession, error) { + var out *GattSession + hr, _, _ := syscall.SyscallN( + v.VTable().GetSession, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattSession + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattSubscribedClient) GetMaxNotificationSize() (uint16, error) { + var out uint16 + hr, _, _ := syscall.SyscallN( + v.VTable().GetMaxNotificationSize, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out uint16 + ) + + if hr != 0 { + return 0, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattSubscribedClient) AddMaxNotificationSizeChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + var out foundation.EventRegistrationToken + hr, _, _ := syscall.SyscallN( + v.VTable().AddMaxNotificationSizeChanged, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(handler)), // in foundation.TypedEventHandler + uintptr(unsafe.Pointer(&out)), // out foundation.EventRegistrationToken + ) + + if hr != 0 { + return foundation.EventRegistrationToken{}, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattSubscribedClient) RemoveMaxNotificationSizeChanged(token foundation.EventRegistrationToken) error { + hr, _, _ := syscall.SyscallN( + v.VTable().RemoveMaxNotificationSizeChanged, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&token)), // in foundation.EventRegistrationToken + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} diff --git a/windows/devices/bluetooth/genericattributeprofile/gattwriterequest.go b/windows/devices/bluetooth/genericattributeprofile/gattwriterequest.go new file mode 100644 index 0000000..150753c --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattwriterequest.go @@ -0,0 +1,218 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/foundation" + "github.com/saltosystems/winrt-go/windows/storage/streams" +) + +const SignatureGattWriteRequest string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattWriteRequest;{aeb6a9ed-de2f-4fc2-a9a8-94ea7844f13d})" + +type GattWriteRequest struct { + ole.IUnknown +} + +func (impl *GattWriteRequest) GetValue() (*streams.IBuffer, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattWriteRequest)) + defer itf.Release() + v := (*iGattWriteRequest)(unsafe.Pointer(itf)) + return v.GetValue() +} + +func (impl *GattWriteRequest) GetOffset() (uint32, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattWriteRequest)) + defer itf.Release() + v := (*iGattWriteRequest)(unsafe.Pointer(itf)) + return v.GetOffset() +} + +func (impl *GattWriteRequest) GetOption() (GattWriteOption, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattWriteRequest)) + defer itf.Release() + v := (*iGattWriteRequest)(unsafe.Pointer(itf)) + return v.GetOption() +} + +func (impl *GattWriteRequest) GetState() (GattRequestState, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattWriteRequest)) + defer itf.Release() + v := (*iGattWriteRequest)(unsafe.Pointer(itf)) + return v.GetState() +} + +func (impl *GattWriteRequest) AddStateChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattWriteRequest)) + defer itf.Release() + v := (*iGattWriteRequest)(unsafe.Pointer(itf)) + return v.AddStateChanged(handler) +} + +func (impl *GattWriteRequest) RemoveStateChanged(token foundation.EventRegistrationToken) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattWriteRequest)) + defer itf.Release() + v := (*iGattWriteRequest)(unsafe.Pointer(itf)) + return v.RemoveStateChanged(token) +} + +func (impl *GattWriteRequest) Respond() error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattWriteRequest)) + defer itf.Release() + v := (*iGattWriteRequest)(unsafe.Pointer(itf)) + return v.Respond() +} + +func (impl *GattWriteRequest) RespondWithProtocolError(protocolError uint8) error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattWriteRequest)) + defer itf.Release() + v := (*iGattWriteRequest)(unsafe.Pointer(itf)) + return v.RespondWithProtocolError(protocolError) +} + +const GUIDiGattWriteRequest string = "aeb6a9ed-de2f-4fc2-a9a8-94ea7844f13d" +const SignatureiGattWriteRequest string = "{aeb6a9ed-de2f-4fc2-a9a8-94ea7844f13d}" + +type iGattWriteRequest struct { + ole.IInspectable +} + +type iGattWriteRequestVtbl struct { + ole.IInspectableVtbl + + GetValue uintptr + GetOffset uintptr + GetOption uintptr + GetState uintptr + AddStateChanged uintptr + RemoveStateChanged uintptr + Respond uintptr + RespondWithProtocolError uintptr +} + +func (v *iGattWriteRequest) VTable() *iGattWriteRequestVtbl { + return (*iGattWriteRequestVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattWriteRequest) GetValue() (*streams.IBuffer, error) { + var out *streams.IBuffer + hr, _, _ := syscall.SyscallN( + v.VTable().GetValue, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out streams.IBuffer + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattWriteRequest) GetOffset() (uint32, error) { + var out uint32 + hr, _, _ := syscall.SyscallN( + v.VTable().GetOffset, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out uint32 + ) + + if hr != 0 { + return 0, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattWriteRequest) GetOption() (GattWriteOption, error) { + var out GattWriteOption + hr, _, _ := syscall.SyscallN( + v.VTable().GetOption, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattWriteOption + ) + + if hr != 0 { + return GattWriteOptionWriteWithResponse, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattWriteRequest) GetState() (GattRequestState, error) { + var out GattRequestState + hr, _, _ := syscall.SyscallN( + v.VTable().GetState, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattRequestState + ) + + if hr != 0 { + return GattRequestStatePending, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattWriteRequest) AddStateChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { + var out foundation.EventRegistrationToken + hr, _, _ := syscall.SyscallN( + v.VTable().AddStateChanged, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(handler)), // in foundation.TypedEventHandler + uintptr(unsafe.Pointer(&out)), // out foundation.EventRegistrationToken + ) + + if hr != 0 { + return foundation.EventRegistrationToken{}, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattWriteRequest) RemoveStateChanged(token foundation.EventRegistrationToken) error { + hr, _, _ := syscall.SyscallN( + v.VTable().RemoveStateChanged, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&token)), // in foundation.EventRegistrationToken + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattWriteRequest) Respond() error { + hr, _, _ := syscall.SyscallN( + v.VTable().Respond, + uintptr(unsafe.Pointer(v)), // this + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +func (v *iGattWriteRequest) RespondWithProtocolError(protocolError uint8) error { + hr, _, _ := syscall.SyscallN( + v.VTable().RespondWithProtocolError, + uintptr(unsafe.Pointer(v)), // this + uintptr(protocolError), // in uint8 + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} diff --git a/windows/devices/bluetooth/genericattributeprofile/gattwriterequestedeventargs.go b/windows/devices/bluetooth/genericattributeprofile/gattwriterequestedeventargs.go new file mode 100644 index 0000000..1cd05d8 --- /dev/null +++ b/windows/devices/bluetooth/genericattributeprofile/gattwriterequestedeventargs.go @@ -0,0 +1,105 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package genericattributeprofile + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/windows/foundation" +) + +const SignatureGattWriteRequestedEventArgs string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattWriteRequestedEventArgs;{2dec8bbe-a73a-471a-94d5-037deadd0806})" + +type GattWriteRequestedEventArgs struct { + ole.IUnknown +} + +func (impl *GattWriteRequestedEventArgs) GetSession() (*GattSession, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattWriteRequestedEventArgs)) + defer itf.Release() + v := (*iGattWriteRequestedEventArgs)(unsafe.Pointer(itf)) + return v.GetSession() +} + +func (impl *GattWriteRequestedEventArgs) GetDeferral() (*foundation.Deferral, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattWriteRequestedEventArgs)) + defer itf.Release() + v := (*iGattWriteRequestedEventArgs)(unsafe.Pointer(itf)) + return v.GetDeferral() +} + +func (impl *GattWriteRequestedEventArgs) GetRequestAsync() (*foundation.IAsyncOperation, error) { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattWriteRequestedEventArgs)) + defer itf.Release() + v := (*iGattWriteRequestedEventArgs)(unsafe.Pointer(itf)) + return v.GetRequestAsync() +} + +const GUIDiGattWriteRequestedEventArgs string = "2dec8bbe-a73a-471a-94d5-037deadd0806" +const SignatureiGattWriteRequestedEventArgs string = "{2dec8bbe-a73a-471a-94d5-037deadd0806}" + +type iGattWriteRequestedEventArgs struct { + ole.IInspectable +} + +type iGattWriteRequestedEventArgsVtbl struct { + ole.IInspectableVtbl + + GetSession uintptr + GetDeferral uintptr + GetRequestAsync uintptr +} + +func (v *iGattWriteRequestedEventArgs) VTable() *iGattWriteRequestedEventArgsVtbl { + return (*iGattWriteRequestedEventArgsVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iGattWriteRequestedEventArgs) GetSession() (*GattSession, error) { + var out *GattSession + hr, _, _ := syscall.SyscallN( + v.VTable().GetSession, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out GattSession + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattWriteRequestedEventArgs) GetDeferral() (*foundation.Deferral, error) { + var out *foundation.Deferral + hr, _, _ := syscall.SyscallN( + v.VTable().GetDeferral, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out foundation.Deferral + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} + +func (v *iGattWriteRequestedEventArgs) GetRequestAsync() (*foundation.IAsyncOperation, error) { + var out *foundation.IAsyncOperation + hr, _, _ := syscall.SyscallN( + v.VTable().GetRequestAsync, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} diff --git a/windows/foundation/deferral.go b/windows/foundation/deferral.go new file mode 100644 index 0000000..5bd42a0 --- /dev/null +++ b/windows/foundation/deferral.go @@ -0,0 +1,102 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package foundation + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" +) + +const SignatureDeferral string = "rc(Windows.Foundation.Deferral;{d6269732-3b7f-46a7-b40b-4fdca2a2c693})" + +type Deferral struct { + ole.IUnknown +} + +func (impl *Deferral) Complete() error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDiDeferral)) + defer itf.Release() + v := (*iDeferral)(unsafe.Pointer(itf)) + return v.Complete() +} + +func (impl *Deferral) Close() error { + itf := impl.MustQueryInterface(ole.NewGUID(GUIDIClosable)) + defer itf.Release() + v := (*IClosable)(unsafe.Pointer(itf)) + return v.Close() +} + +const GUIDiDeferral string = "d6269732-3b7f-46a7-b40b-4fdca2a2c693" +const SignatureiDeferral string = "{d6269732-3b7f-46a7-b40b-4fdca2a2c693}" + +type iDeferral struct { + ole.IInspectable +} + +type iDeferralVtbl struct { + ole.IInspectableVtbl + + Complete uintptr +} + +func (v *iDeferral) VTable() *iDeferralVtbl { + return (*iDeferralVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *iDeferral) Complete() error { + hr, _, _ := syscall.SyscallN( + v.VTable().Complete, + uintptr(unsafe.Pointer(v)), // this + ) + + if hr != 0 { + return ole.NewError(hr) + } + + return nil +} + +const GUIDiDeferralFactory string = "65a1ecc5-3fb5-4832-8ca9-f061b281d13a" +const SignatureiDeferralFactory string = "{65a1ecc5-3fb5-4832-8ca9-f061b281d13a}" + +type iDeferralFactory struct { + ole.IInspectable +} + +type iDeferralFactoryVtbl struct { + ole.IInspectableVtbl + + DeferralCreate uintptr +} + +func (v *iDeferralFactory) VTable() *iDeferralFactoryVtbl { + return (*iDeferralFactoryVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func DeferralCreate(handler *DeferralCompletedHandler) (*Deferral, error) { + inspectable, err := ole.RoGetActivationFactory("Windows.Foundation.Deferral", ole.NewGUID(GUIDiDeferralFactory)) + if err != nil { + return nil, err + } + v := (*iDeferralFactory)(unsafe.Pointer(inspectable)) + + var out *Deferral + hr, _, _ := syscall.SyscallN( + v.VTable().DeferralCreate, + 0, // this is a static func, so there's no this + uintptr(unsafe.Pointer(handler)), // in DeferralCompletedHandler + uintptr(unsafe.Pointer(&out)), // out Deferral + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} diff --git a/windows/foundation/deferralcompletedhandler.go b/windows/foundation/deferralcompletedhandler.go new file mode 100644 index 0000000..9e60a89 --- /dev/null +++ b/windows/foundation/deferralcompletedhandler.go @@ -0,0 +1,195 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package foundation + +import ( + "sync" + "time" + "unsafe" + + "github.com/go-ole/go-ole" + "github.com/saltosystems/winrt-go/internal/delegate" + "github.com/saltosystems/winrt-go/internal/kernel32" +) + +const GUIDDeferralCompletedHandler string = "ed32a372-f3c8-4faa-9cfb-470148da3888" +const SignatureDeferralCompletedHandler string = "delegate({ed32a372-f3c8-4faa-9cfb-470148da3888})" + +type DeferralCompletedHandler struct { + ole.IUnknown + sync.Mutex + refs uint64 + IID ole.GUID +} + +type DeferralCompletedHandlerVtbl struct { + ole.IUnknownVtbl + Invoke uintptr +} + +type DeferralCompletedHandlerCallback func(instance *DeferralCompletedHandler) + +var callbacksDeferralCompletedHandler = &deferralCompletedHandlerCallbacks{ + mu: &sync.Mutex{}, + callbacks: make(map[unsafe.Pointer]DeferralCompletedHandlerCallback), +} + +var releaseChannelsDeferralCompletedHandler = &deferralCompletedHandlerReleaseChannels{ + mu: &sync.Mutex{}, + chans: make(map[unsafe.Pointer]chan struct{}), +} + +func NewDeferralCompletedHandler(iid *ole.GUID, callback DeferralCompletedHandlerCallback) *DeferralCompletedHandler { + size := unsafe.Sizeof(*(*DeferralCompletedHandler)(nil)) + instPtr := kernel32.Malloc(size) + inst := (*DeferralCompletedHandler)(instPtr) + + callbacks := delegate.RegisterCallbacks(instPtr, inst) + + // Initialize all properties: the malloc may contain garbage + inst.RawVTable = (*interface{})(unsafe.Pointer(&DeferralCompletedHandlerVtbl{ + IUnknownVtbl: ole.IUnknownVtbl{ + QueryInterface: callbacks.QueryInterface, + AddRef: callbacks.AddRef, + Release: callbacks.Release, + }, + Invoke: callbacks.Invoke, + })) + inst.IID = *iid // copy contents + inst.Mutex = sync.Mutex{} + inst.refs = 0 + + callbacksDeferralCompletedHandler.add(unsafe.Pointer(inst), callback) + + // See the docs in the releaseChannelsDeferralCompletedHandler struct + releaseChannelsDeferralCompletedHandler.acquire(unsafe.Pointer(inst)) + + inst.addRef() + return inst +} + +func (r *DeferralCompletedHandler) GetIID() *ole.GUID { + return &r.IID +} + +// addRef increments the reference counter by one +func (r *DeferralCompletedHandler) addRef() uint64 { + r.Lock() + defer r.Unlock() + r.refs++ + return r.refs +} + +// removeRef decrements the reference counter by one. If it was already zero, it will just return zero. +func (r *DeferralCompletedHandler) removeRef() uint64 { + r.Lock() + defer r.Unlock() + + if r.refs > 0 { + r.refs-- + } + + return r.refs +} + +func (instance *DeferralCompletedHandler) Invoke(instancePtr, rawArgs0, rawArgs1, rawArgs2, rawArgs3, rawArgs4, rawArgs5, rawArgs6, rawArgs7, rawArgs8 unsafe.Pointer) uintptr { + + // See the quote above. + if callback, ok := callbacksDeferralCompletedHandler.get(instancePtr); ok { + callback(instance) + } + return ole.S_OK +} + +func (instance *DeferralCompletedHandler) AddRef() uint64 { + return instance.addRef() +} + +func (instance *DeferralCompletedHandler) Release() uint64 { + rem := instance.removeRef() + if rem == 0 { + // We're done. + instancePtr := unsafe.Pointer(instance) + callbacksDeferralCompletedHandler.delete(instancePtr) + + // stop release channels used to avoid + // https://github.com/golang/go/issues/55015 + releaseChannelsDeferralCompletedHandler.release(instancePtr) + + kernel32.Free(instancePtr) + } + return rem +} + +type deferralCompletedHandlerCallbacks struct { + mu *sync.Mutex + callbacks map[unsafe.Pointer]DeferralCompletedHandlerCallback +} + +func (m *deferralCompletedHandlerCallbacks) add(p unsafe.Pointer, v DeferralCompletedHandlerCallback) { + m.mu.Lock() + defer m.mu.Unlock() + + m.callbacks[p] = v +} + +func (m *deferralCompletedHandlerCallbacks) get(p unsafe.Pointer) (DeferralCompletedHandlerCallback, bool) { + m.mu.Lock() + defer m.mu.Unlock() + + v, ok := m.callbacks[p] + return v, ok +} + +func (m *deferralCompletedHandlerCallbacks) delete(p unsafe.Pointer) { + m.mu.Lock() + defer m.mu.Unlock() + + delete(m.callbacks, p) +} + +// typedEventHandlerReleaseChannels keeps a map with channels +// used to keep a goroutine alive during the lifecycle of this object. +// This is required to avoid causing a deadlock error. +// See this: https://github.com/golang/go/issues/55015 +type deferralCompletedHandlerReleaseChannels struct { + mu *sync.Mutex + chans map[unsafe.Pointer]chan struct{} +} + +func (m *deferralCompletedHandlerReleaseChannels) acquire(p unsafe.Pointer) { + m.mu.Lock() + defer m.mu.Unlock() + + c := make(chan struct{}) + m.chans[p] = c + + go func() { + // we need a timer to trick the go runtime into + // thinking there's still something going on here + // but we are only really interested in <-c + t := time.NewTimer(time.Minute) + for { + select { + case <-t.C: + t.Reset(time.Minute) + case <-c: + t.Stop() + return + } + } + }() +} + +func (m *deferralCompletedHandlerReleaseChannels) release(p unsafe.Pointer) { + m.mu.Lock() + defer m.mu.Unlock() + + if c, ok := m.chans[p]; ok { + close(c) + delete(m.chans, p) + } +} diff --git a/windows/foundation/ireference.go b/windows/foundation/ireference.go new file mode 100644 index 0000000..016f1b9 --- /dev/null +++ b/windows/foundation/ireference.go @@ -0,0 +1,45 @@ +// Code generated by winrt-go-gen. DO NOT EDIT. + +//go:build windows + +//nolint:all +package foundation + +import ( + "syscall" + "unsafe" + + "github.com/go-ole/go-ole" +) + +const GUIDIReference string = "61c17706-2d65-11e0-9ae8-d48564015472" +const SignatureIReference string = "{61c17706-2d65-11e0-9ae8-d48564015472}" + +type IReference struct { + ole.IInspectable +} + +type IReferenceVtbl struct { + ole.IInspectableVtbl + + GetValue uintptr +} + +func (v *IReference) VTable() *IReferenceVtbl { + return (*IReferenceVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *IReference) GetValue() (unsafe.Pointer, error) { + var out unsafe.Pointer + hr, _, _ := syscall.SyscallN( + v.VTable().GetValue, + uintptr(unsafe.Pointer(v)), // this + uintptr(unsafe.Pointer(&out)), // out unsafe.Pointer + ) + + if hr != 0 { + return nil, ole.NewError(hr) + } + + return out, nil +} diff --git a/winrt.go b/winrt.go index 5a83e76..7ef0efc 100644 --- a/winrt.go +++ b/winrt.go @@ -6,6 +6,9 @@ package winrt //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Foundation.AsyncOperationCompletedHandler`1 //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Foundation.AsyncStatus //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Foundation.DateTime +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Foundation.Deferral +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Foundation.DeferralCompletedHandler +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Foundation.IReference`1 // advertisement //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementWatcherStatus @@ -38,6 +41,23 @@ package winrt //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattReadResult -method-filter !get_ProtocolError //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattClientCharacteristicConfigurationDescriptorValue //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattValueChangedEventArgs +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattClientNotificationResult +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalCharacteristic +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalCharacteristicParameters +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalCharacteristicResult +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalDescriptorParameters +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalService +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattProtectionLevel +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattReadRequest +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattReadRequestedEventArgs +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattRequestState +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattServiceProvider +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattServiceProviderAdvertisementStatus +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattServiceProviderAdvertisingParameters +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattServiceProviderResult +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattSubscribedClient +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattWriteRequest +//go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Devices.Bluetooth.GenericAttributeProfile.GattWriteRequestedEventArgs // event //go:generate go run github.com/saltosystems/winrt-go/cmd/winrt-go-gen -debug -class Windows.Foundation.TypedEventHandler`2