Add Pair Method for Windows
@Sunbreak Added Pair method for Windows Platform , Thanks to kinyoklion it will throw Unimplemented Error for Other Platforms also update Example to show Pair button for Windows Platform
I prefer add BIG features into https://github.com/woodemi/quick.flutter
https://pub.dev/packages/quick_notify/versions/0.3.0-dev.0 has been released within quick.flutter
https://pub.dev/packages/quick_notify/versions/0.3.0-dev.0
when are you planning to release quick_blue from quick.flutter ??
@rohitsangwan01 device disconnects while pairing in windows... in rohitsangwan01:add_pairAsync branch example [+7106 ms] flutter: _handleConnectionChange 259603888117496, connected after clicking pair button, this log comes : [+6697 ms] flutter: _handleConnectionChange 259603888117496, disconnected
@rohitsangwan01 device disconnects while pairing in windows... in rohitsangwan01:add_pairAsync branch example [+7106 ms] flutter: _handleConnectionChange 259603888117496, connected after clicking pair button, this log comes : [+6697 ms] flutter: _handleConnectionChange 259603888117496, disconnected
probably because this device does not supports pairing , can you confirm
@rohitsangwan01 device supports pairing. It pairs successfully with microsoft https://github.com/microsoft/BluetoothLEExplorer app. My device requests a pin while pairing and hardware using BGX13P.
@rohitsangwan01 device supports pairing. It pairs successfully with microsoft https://github.com/microsoft/BluetoothLEExplorer app. My device requests a pin while pairing and hardware using BGX13P.
Can you check from Windows setting , after clicking on Pair from App , your device will disconnect from QuickBlue , and when you go to windows settings , it will appear there as Paired , you can now connect back again to the device in QuickBlue i faced this behaviour with a device i used which does not supports pairing , you can try to play with the PairAsync options in Windows native code
I have checked the code and confirm it is an issue when we are using a device with pin..
I have used following code in my device and its working... If you can test this please confirm.
We have to use DevicePairingKinds : ProvidePin with args.Accept(winrt::to_hstring(L" YOUR DEVICE PIN "));
winrt::fire_and_forget QuickBlueWindowsPlugin::PairAsync(uint64_t bluetoothAddress, DevicePairingProtectionLevel level) {
auto device = co_await BluetoothLEDevice::FromBluetoothAddressAsync(bluetoothAddress);
if(device != nullptr) {
if(device.DeviceInformation().Pairing().CanPair()) {
try {
device.DeviceInformation().Pairing().Custom().PairingRequested({ this, &QuickBlueWindowsPlugin::BluetoothLEDevice_PairingRequested });
auto result = co_await device.DeviceInformation().Pairing().Custom().PairAsync(DevicePairingKinds::ProvidePin);
if(result.Status() != DevicePairingResultStatus::Paired && result.Status() != DevicePairingResultStatus::AlreadyPaired) {
OutputDebugString((L"PairAsync error: " + winrt::to_hstring((int32_t)result.Status()) + L"\n").c_str());
}
} catch(winrt::hresult_error const& ex) {
OutputDebugString((L"PairAsync " + ex.message() + L"\n").c_str());
}
}
}
co_return;
}
void QuickBlueWindowsPlugin::BluetoothLEDevice_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args) {
args.Accept(winrt::to_hstring(L"000000")); //DEVICE PIN IS ENTERED AS ARGUMENT
}
void QuickBlueWindowsPlugin::BluetoothLEDevice_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args) { args.Accept(winrt::to_hstring(L"000000")); //DEVICE PIN IS ENTERED AS ARGUMENT }
Got it , and some device paired without Pin , we need to find a way to fix this , btw can you test Pair method in new QucikBlue.flutter , here i added a PR , added Pair method in Windows and Android
I tested https://github.com/woodemi/quick.flutter/pull/33 also and the same error occurs in windows..
Android pairing code works fine btw
@Vishavjeet-clarity can you add this comment on That PR, it will be easy to track and fix
Done