-
Notifications
You must be signed in to change notification settings - Fork 751
Windows.Devices:DeviceInformationCustomPairing.PairAsync() invalid method args #940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Could you try something like |
2 ways: either look at |
Thanks, I tried I checked the
To me it looks like it's expecting an Enum type object passed in but once I've got the instance of the enum it's a python int object and the override choosing mechanism isn't accepting that as a viable option? Is there a different way to pass an enum as an object rather than the int representation of it? Or is there a different way to explicitly choose which override of the bound method to call? |
I just found #935 which appears to be the same problem I'm hitting. My understanding of the suggested fix there still isn't working though
gives |
Hi! I am having the exact same problems, with the exact same results. Where you able to solve it in some way? |
I haven't spent any more time on this myself, though by memory I believe the problem is likely due to it not picking the right override function. A colleague of mine working with an un-related .net library ran into problems with overloads too, they finally got their problem fixed with code to explicitly choose the desired overload function and call it like this >>> Messages.MessageFactory.CreateCommand.Overloads
Communication.Messages.CommandMessage CreateCommand(Communication.Messages.ServiceCode, UInt16)
Communication.Messages.CommandMessage CreateCommand(Communication.Messages.ServiceCode, System.String)
>>> Messages.MessageFactory.CreateCommand.Overloads[Messages.ServiceCode, System.UInt16](Messages.ServiceCode.ManufacturingService, 0X8002)
<Communication.Messages.GetLogStatusCommand object at 0x015BBDF0> In my previous post I wasn't accessing the function via the |
I worked! Thanks for the help! I leave the final version of my code in case it is useful for someone else: ## ble_device: [Windows.Devices.Bluetooth import BluetoothLEDevice] object
device_custom_pair = ble_device.DeviceInformation.Pairing.Custom
def custom_pairing_handler(sender: DeviceInformationCustomPairing,
args: DevicePairingRequestedEventArgs) -> None:
"""
Handle custom pairing. (Design for ConfirmOnly)
Args:
sender [DeviceInformationCustomPairing]
args [DevicePairingRequestedEventArgs]
Return: None
"""
args.Accept()
device_custom_pair.PairingRequested += custom_pairing_handler
custom_pair_result = await wrap_iasync_event(
IAsyncOperation[DevicePairingResult](
device_custom_pair.PairAsync.Overloads[DevicePairingKinds](
DevicePairingKinds.ConfirmOnly
)
),
return_type=DevicePairingResult,
loop=loop,
)
pair_result = custom_pair_result.Status
print(f"pairing_result status -> {pairing_result}")
## OUTPUT: pairing_result status -> 0
## Remember: DevicePairingResultStatus 0 signifies Paired Remember: DevicePairingResultStatus |
That's wonderful, thanks for sharing! |
Environment
Details
https://docs.microsoft.com/en-us/uwp/api/windows.devices.enumeration.deviceinformationcustompairing.pairasync
I'm trying to add pairing support the the
bleak
module (https://github.com/hbldh/bleak)This code runs:
However the basic pairing function used fails to work with most devices.
https://stackoverflow.com/a/41423796
This is a common issue in the library, where the suggested fix is the custom pairing below which is the target of this issue request.
I've tried running
customPairing.PairAsync()
with none, 1, 2 args, passed as the enums shown above and as raw integers (1
) which is what they both resolve to.Is there any way to introspect what the function is expecting to be passed?
There is a third overload of that function listed on the function docs above, with the third arg an interface class
IDevicePairingSettings
. I don't know how to provide an implementation of this, I've tried a third arg ofNone
with no change.The text was updated successfully, but these errors were encountered: