From e4237388ba31fd3fd7fc81c97b71329f26cf1e62 Mon Sep 17 00:00:00 2001 From: Ask Bojesen Date: Thu, 16 May 2024 13:24:28 +0200 Subject: [PATCH] Check for SDK Runtime --- .../BLE.Client.WinConsole.Installer.vdproj | 723 ++++++++++++++++++ .../BLE.Client.WinConsole.csproj | 3 +- .../BleAddressSelector.cs | 8 +- .../BLE.Client.WinConsole/PluginDemos.cs | 20 + .../BLE.Client.WinConsole/Program.cs | 6 +- Source/BLE.sln | 31 + Source/Plugin.BLE/Windows/Adapter.cs | 11 +- .../Plugin.BLE/Windows/BleImplementation.cs | 20 + Source/Plugin.BLE/Windows/Device.cs | 4 + 9 files changed, 816 insertions(+), 10 deletions(-) create mode 100644 Source/BLE.Client/BLE.Client.WinConsole.Installer/BLE.Client.WinConsole.Installer.vdproj diff --git a/Source/BLE.Client/BLE.Client.WinConsole.Installer/BLE.Client.WinConsole.Installer.vdproj b/Source/BLE.Client/BLE.Client.WinConsole.Installer/BLE.Client.WinConsole.Installer.vdproj new file mode 100644 index 00000000..e99469ce --- /dev/null +++ b/Source/BLE.Client/BLE.Client.WinConsole.Installer/BLE.Client.WinConsole.Installer.vdproj @@ -0,0 +1,723 @@ +"DeployProject" +{ +"VSVersion" = "3:800" +"ProjectType" = "8:{978C614F-708E-4E1A-B201-565925725DBA}" +"IsWebType" = "8:FALSE" +"ProjectName" = "8:BLE.Client.WinConsole.Installer" +"LanguageId" = "3:1033" +"CodePage" = "3:1252" +"UILanguageId" = "3:1033" +"SccProjectName" = "8:" +"SccLocalPath" = "8:" +"SccAuxPath" = "8:" +"SccProvider" = "8:" + "Hierarchy" + { + "Entry" + { + "MsmKey" = "8:_8A3CB92018754E60ABC94DFEE1EC9976" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + } + "Configurations" + { + "Debug" + { + "DisplayName" = "8:Debug" + "IsDebugOnly" = "11:TRUE" + "IsReleaseOnly" = "11:FALSE" + "OutputFilename" = "8:Debug\\BLE.Client.WinConsole.Installer.msi" + "PackageFilesAs" = "3:2" + "PackageFileSize" = "3:-2147483648" + "CabType" = "3:1" + "Compression" = "3:2" + "SignOutput" = "11:FALSE" + "CertificateFile" = "8:" + "PrivateKeyFile" = "8:" + "TimeStampServer" = "8:" + "InstallerBootstrapper" = "3:2" + "BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}" + { + "Enabled" = "11:TRUE" + "PromptEnabled" = "11:TRUE" + "PrerequisitesLocation" = "2:1" + "Url" = "8:" + "ComponentsUrl" = "8:" + "Items" + { + "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:Microsoft.NetCore.DesktopRuntime.8.0.x64" + { + "Name" = "8:.NET Desktop Runtime 8.0.3 (x64)" + "ProductCode" = "8:Microsoft.NetCore.DesktopRuntime.8.0.x64" + } + } + } + } + "Release" + { + "DisplayName" = "8:Release" + "IsDebugOnly" = "11:FALSE" + "IsReleaseOnly" = "11:TRUE" + "OutputFilename" = "8:Release\\BLE.Client.WinConsole.Installer.msi" + "PackageFilesAs" = "3:2" + "PackageFileSize" = "3:-2147483648" + "CabType" = "3:1" + "Compression" = "3:2" + "SignOutput" = "11:FALSE" + "CertificateFile" = "8:" + "PrivateKeyFile" = "8:" + "TimeStampServer" = "8:" + "InstallerBootstrapper" = "3:2" + } + } + "Deployable" + { + "CustomAction" + { + } + "DefaultFeature" + { + "Name" = "8:DefaultFeature" + "Title" = "8:" + "Description" = "8:" + } + "ExternalPersistence" + { + "LaunchCondition" + { + "{A06ECF26-33A3-4562-8140-9B0E340D4F24}:_B98DDA069ECC4C7BA675DEB168EF4B1B" + { + "Name" = "8:.NET Core" + "Message" = "8:[VSDNETCOREMSG]" + "AllowLaterVersions" = "11:FALSE" + "InstallUrl" = "8:https://dotnet.microsoft.com/download/dotnet-core/[NetCoreVerMajorDotMinor]" + "IsNETCore" = "11:TRUE" + "Architecture" = "2:0" + "Runtime" = "2:0" + } + } + } + "File" + { + } + "FileType" + { + } + "Folder" + { + "{3C67513D-01DD-4637-8A68-80971EB9504F}:_53A832D5D5FC44948044A2EE06375438" + { + "DefaultLocation" = "8:[ProgramFiles64Folder][Manufacturer]\\[ProductName]" + "Name" = "8:#1925" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:TARGETDIR" + "Folders" + { + } + } + "{1525181F-901A-416C-8A58-119130FE478E}:_C8AC3B9072C640BABD8901A312F3D0DC" + { + "Name" = "8:#1916" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:DesktopFolder" + "Folders" + { + } + } + "{1525181F-901A-416C-8A58-119130FE478E}:_DC8C657D40314C6280170FB1216F225B" + { + "Name" = "8:#1919" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:ProgramMenuFolder" + "Folders" + { + } + } + } + "LaunchCondition" + { + } + "Locator" + { + } + "MsiBootstrapper" + { + "LangId" = "3:1033" + "RequiresElevation" = "11:FALSE" + } + "Product" + { + "Name" = "8:Microsoft Visual Studio" + "ProductName" = "8:BLE.Client.WinConsole" + "ProductCode" = "8:{F6BA5731-7436-4762-A612-E16066951342}" + "PackageCode" = "8:{D8837791-AD30-4637-A38E-E4873DBC15A2}" + "UpgradeCode" = "8:{2DC56EBC-822F-4B47-93C7-DCBD97994976}" + "AspNetVersion" = "8:4.0.30319.0" + "RestartWWWService" = "11:FALSE" + "RemovePreviousVersions" = "11:TRUE" + "DetectNewerInstalledVersion" = "11:TRUE" + "InstallAllUsers" = "11:FALSE" + "ProductVersion" = "8:1.0.0" + "Manufacturer" = "8:Plugin.BLE" + "ARPHELPTELEPHONE" = "8:" + "ARPHELPLINK" = "8:" + "Title" = "8:BLE Client WinConsole " + "Subject" = "8:" + "ARPCONTACT" = "8:Ask Bojesen" + "Keywords" = "8:" + "ARPCOMMENTS" = "8:v1.0.0" + "ARPURLINFOABOUT" = "8:https://github.com/dotnet-bluetooth-le/dotnet-bluetooth-le" + "ARPPRODUCTICON" = "8:" + "ARPIconIndex" = "3:0" + "SearchPath" = "8:" + "UseSystemSearchPath" = "11:TRUE" + "TargetPlatform" = "3:1" + "PreBuildEvent" = "8:" + "PostBuildEvent" = "8:" + "RunPostBuildEvent" = "3:0" + } + "Registry" + { + "HKLM" + { + "Keys" + { + "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_4B206CDA93494F9587D66B1F4B24AA4C" + { + "Name" = "8:Software" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_8C2BD607D2084C3392D722606F6A9DDC" + { + "Name" = "8:[Manufacturer]" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + } + "Values" + { + } + } + } + "Values" + { + } + } + } + } + "HKCU" + { + "Keys" + { + "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_78ACCAEA90F94E7CBF01E36BF39F774E" + { + "Name" = "8:Software" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_8AE3135316C441A6A428CDE2BC1A21E3" + { + "Name" = "8:[Manufacturer]" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + } + "Values" + { + } + } + } + "Values" + { + } + } + } + } + "HKCR" + { + "Keys" + { + } + } + "HKU" + { + "Keys" + { + } + } + "HKPU" + { + "Keys" + { + } + } + } + "Sequences" + { + } + "Shortcut" + { + "{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_B6412D24240749AC80FE5779DD1FAE72" + { + "Name" = "8:BLE.Client.WinConsole" + "Arguments" = "8:" + "Description" = "8:" + "ShowCmd" = "3:1" + "IconIndex" = "3:0" + "Transitive" = "11:FALSE" + "Target" = "8:_8A3CB92018754E60ABC94DFEE1EC9976" + "Folder" = "8:_C8AC3B9072C640BABD8901A312F3D0DC" + "WorkingFolder" = "8:_53A832D5D5FC44948044A2EE06375438" + "Icon" = "8:" + "Feature" = "8:" + } + } + "UserInterface" + { + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_173BC258F76A4A6DBCAA6935B64EF703" + { + "Name" = "8:#1900" + "Sequence" = "3:1" + "Attributes" = "3:1" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_773BB445D0FA45F8B95F54A1E476F735" + { + "Sequence" = "3:100" + "DisplayName" = "8:Welcome" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdWelcomeDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "CopyrightWarning" + { + "Name" = "8:CopyrightWarning" + "DisplayName" = "8:#1002" + "Description" = "8:#1102" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1202" + "DefaultValue" = "8:#1202" + "UsePlugInResources" = "11:TRUE" + } + "Welcome" + { + "Name" = "8:Welcome" + "DisplayName" = "8:#1003" + "Description" = "8:#1103" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1203" + "DefaultValue" = "8:#1203" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_F5FD36DE78A84787B02785A1FAFB99FC" + { + "Sequence" = "3:200" + "DisplayName" = "8:Installation Folder" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdFolderDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "InstallAllUsersVisible" + { + "Name" = "8:InstallAllUsersVisible" + "DisplayName" = "8:#1059" + "Description" = "8:#1159" + "Type" = "3:5" + "ContextData" = "8:1;True=1;False=0" + "Attributes" = "3:0" + "Setting" = "3:0" + "Value" = "3:1" + "DefaultValue" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_FCCE4F694F7A48829140DD6439FE50A2" + { + "Sequence" = "3:300" + "DisplayName" = "8:Confirm Installation" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdConfirmDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_3737EBE5CA6D4104B13CBF871F5BB05D" + { + "Name" = "8:#1901" + "Sequence" = "3:1" + "Attributes" = "3:2" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_D63A3BFF9CA24CDB85DC4AD6D6941B2E" + { + "Sequence" = "3:100" + "DisplayName" = "8:Progress" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdProgressDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "ShowProgress" + { + "Name" = "8:ShowProgress" + "DisplayName" = "8:#1009" + "Description" = "8:#1109" + "Type" = "3:5" + "ContextData" = "8:1;True=1;False=0" + "Attributes" = "3:0" + "Setting" = "3:0" + "Value" = "3:1" + "DefaultValue" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_4939CDFA026E46F388FBA537AB2CC845" + { + "Name" = "8:#1900" + "Sequence" = "3:2" + "Attributes" = "3:1" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_9306FE08876C4DD0979CCE592FE51882" + { + "Sequence" = "3:200" + "DisplayName" = "8:Installation Folder" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminFolderDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_D86ADB6FDDD14E86BE4F44E78D3D31B8" + { + "Sequence" = "3:300" + "DisplayName" = "8:Confirm Installation" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminConfirmDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_D8EC8F2720834F9FB304E10AF1F7687C" + { + "Sequence" = "3:100" + "DisplayName" = "8:Welcome" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminWelcomeDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "CopyrightWarning" + { + "Name" = "8:CopyrightWarning" + "DisplayName" = "8:#1002" + "Description" = "8:#1102" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1202" + "DefaultValue" = "8:#1202" + "UsePlugInResources" = "11:TRUE" + } + "Welcome" + { + "Name" = "8:Welcome" + "DisplayName" = "8:#1003" + "Description" = "8:#1103" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1203" + "DefaultValue" = "8:#1203" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_574AFB5E74304D999110525E6333460E" + { + "Name" = "8:#1902" + "Sequence" = "3:1" + "Attributes" = "3:3" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_E453D62D238E4572A71FD8E553406181" + { + "Sequence" = "3:100" + "DisplayName" = "8:Finished" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdFinishedDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "UpdateText" + { + "Name" = "8:UpdateText" + "DisplayName" = "8:#1058" + "Description" = "8:#1158" + "Type" = "3:15" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1258" + "DefaultValue" = "8:#1258" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{2479F3F5-0309-486D-8047-8187E2CE5BA0}:_577EC3D50B084F5B864E1A2DFB5B3BF5" + { + "UseDynamicProperties" = "11:FALSE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdBasicDialogs.wim" + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_8AFD094F6D3E47CF8105BFAB4C3AA967" + { + "Name" = "8:#1902" + "Sequence" = "3:2" + "Attributes" = "3:3" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_8DB9DB0F41D94153B1E65C511D46CFB4" + { + "Sequence" = "3:100" + "DisplayName" = "8:Finished" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminFinishedDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_AC604DF7CFEE44A5B8C66E51F5CDB0AB" + { + "Name" = "8:#1901" + "Sequence" = "3:2" + "Attributes" = "3:2" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_B7CA052E0E894BA9A06C5AD6C2821A5D" + { + "Sequence" = "3:100" + "DisplayName" = "8:Progress" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminProgressDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "ShowProgress" + { + "Name" = "8:ShowProgress" + "DisplayName" = "8:#1009" + "Description" = "8:#1109" + "Type" = "3:5" + "ContextData" = "8:1;True=1;False=0" + "Attributes" = "3:0" + "Setting" = "3:0" + "Value" = "3:1" + "DefaultValue" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{2479F3F5-0309-486D-8047-8187E2CE5BA0}:_D3F3E5884DCD4727B97DDB31EC46F3DC" + { + "UseDynamicProperties" = "11:FALSE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdUserInterface.wim" + } + } + "MergeModule" + { + } + "ProjectOutput" + { + "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_8A3CB92018754E60ABC94DFEE1EC9976" + { + "SourcePath" = "8:..\\BLE.Client.WinConsole\\obj\\Release\\net8.0-windows10.0.22621.0\\apphost.exe" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_53A832D5D5FC44948044A2EE06375438" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + "ProjectOutputGroupRegister" = "3:1" + "OutputConfiguration" = "8:" + "OutputGroupCanonicalName" = "8:PublishItems" + "OutputProjectGuid" = "8:{39287F60-65DE-4077-90F2-57CF725E92B6}" + "ShowKeyOutput" = "11:TRUE" + "ExcludeFilters" + { + } + } + } + } +} diff --git a/Source/BLE.Client/BLE.Client.WinConsole/BLE.Client.WinConsole.csproj b/Source/BLE.Client/BLE.Client.WinConsole/BLE.Client.WinConsole.csproj index 45e83446..82eb346e 100644 --- a/Source/BLE.Client/BLE.Client.WinConsole/BLE.Client.WinConsole.csproj +++ b/Source/BLE.Client/BLE.Client.WinConsole/BLE.Client.WinConsole.csproj @@ -1,10 +1,11 @@ - + Exe net8.0-windows10.0.22621.0 disable enable + 1.0.0 diff --git a/Source/BLE.Client/BLE.Client.WinConsole/BleAddressSelector.cs b/Source/BLE.Client/BLE.Client.WinConsole/BleAddressSelector.cs index 8369099d..fdbac410 100644 --- a/Source/BLE.Client/BLE.Client.WinConsole/BleAddressSelector.cs +++ b/Source/BLE.Client/BLE.Client.WinConsole/BleAddressSelector.cs @@ -9,7 +9,7 @@ namespace BLE.Client.WinConsole { public static class BleAddressSelector { - static string bleaddressTxtPath = "bleaddress.txt"; + static string bleaddressTxtPath = Path.Combine(Path.GetTempPath(), "bleaddress.txt"); static string? bleaddress = null; public static bool DoesBleAddressExists() @@ -23,7 +23,7 @@ public static bool DoesBleAddressExists() } public static string GetBleAddress() - { + { if (bleaddress is null) { if (File.Exists(bleaddressTxtPath)) @@ -55,8 +55,8 @@ public static void SetBleAddress(string? bleaddressIn) public static Task NewBleAddress() { - Console.Write("Enter BLE Address (12 hex chars): "); - SetBleAddress(Console.ReadLine()); + Console.Write("Enter BLE Address (12 hex chars): "); + SetBleAddress(Console.ReadLine()); return Task.CompletedTask; } } diff --git a/Source/BLE.Client/BLE.Client.WinConsole/PluginDemos.cs b/Source/BLE.Client/BLE.Client.WinConsole/PluginDemos.cs index 22998461..d1ef8980 100644 --- a/Source/BLE.Client/BLE.Client.WinConsole/PluginDemos.cs +++ b/Source/BLE.Client/BLE.Client.WinConsole/PluginDemos.cs @@ -59,6 +59,16 @@ private void Write(string format, params object[] args) writer?.Invoke(format, args); } + public async Task TurnBluetoothOn() + { + await bluetoothLE.TrySetStateAsync(true); + } + + public async Task TurnBluetoothOff() + { + await bluetoothLE.TrySetStateAsync(false); + } + public IDevice ConnectToKnown(Guid id) { IDevice dev = Adapter.ConnectToKnownDeviceAsync(id).Result; @@ -338,6 +348,11 @@ public async Task DoTheScanning(ScanMode scanMode = ScanMode.LowPower, int time_ internal async Task DiscoverAndSelect() { + if (!bluetoothLE.IsOn) + { + Console.WriteLine("Bluetooth is off - cannot discover"); + return; + } await DoTheScanning(); int index = 1; await Task.Delay(200); @@ -346,6 +361,11 @@ internal async Task DiscoverAndSelect() { Console.WriteLine($"{index++}: {dev.Id.ToHexBleAddress()} with Name = {dev.Name}"); } + if (discoveredDevices.Count == 0) + { + Console.Write("NO BLE Devices discovered"); + return; + } Console.WriteLine(); Console.Write($"Select BLE address index with value {1} to {discoveredDevices.Count}: "); if (int.TryParse(Console.ReadLine(), out int selectedIndex)) diff --git a/Source/BLE.Client/BLE.Client.WinConsole/Program.cs b/Source/BLE.Client/BLE.Client.WinConsole/Program.cs index 073edb14..830de1bb 100644 --- a/Source/BLE.Client/BLE.Client.WinConsole/Program.cs +++ b/Source/BLE.Client/BLE.Client.WinConsole/Program.cs @@ -7,6 +7,7 @@ using Windows.Media.Capture; Console.WriteLine("Hello, BLE World!"); +Console.WriteLine($"BleImplementation.OsRuntimeBuildNumber: {BleImplementation.OsRuntimeBuildNumber}"); using (var ct = new ConsoleTracer()) { @@ -16,6 +17,8 @@ var demoDict = new Dictionary { + {ConsoleKey.B, new Demo("Turn Bluetooth ON", ppemos.TurnBluetoothOn) }, + {ConsoleKey.N, new Demo("Turn Bluetooth OFF", ppemos.TurnBluetoothOff) }, {ConsoleKey.D1, new Demo("Discover and set the BleAddress", ppemos.DiscoverAndSelect) }, {ConsoleKey.D2, new Demo("Set the BleAddress", BleAddressSelector.NewBleAddress) }, {ConsoleKey.D3, new Demo("Connect -> Disconnect", ppemos.Connect_Disconnect) }, @@ -62,6 +65,7 @@ { Console.WriteLine(); Console.WriteLine($"Running: {chosendemo.Description}"); + Console.WriteLine("-------------------------------------------------------"); if (chosendemo is null) { throw new Exception("No such demo!"); @@ -73,7 +77,7 @@ Console.WriteLine($"{key} -> No such test. Remember {ConsoleKey.Escape} -> Quit!"); } await Task.Delay(200); - Console.WriteLine("---------------------------------------------"); + Console.WriteLine("-------------------------------------------------------"); } } diff --git a/Source/BLE.sln b/Source/BLE.sln index df37cd88..ad7021e7 100644 --- a/Source/BLE.sln +++ b/Source/BLE.sln @@ -48,6 +48,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLE.Client.Maui", "BLE.Clie EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLE.Client.WinConsole", "BLE.Client\BLE.Client.WinConsole\BLE.Client.WinConsole.csproj", "{39287F60-65DE-4077-90F2-57CF725E92B6}" EndProject +Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "BLE.Client.WinConsole.Installer", "BLE.Client\BLE.Client.WinConsole.Installer\BLE.Client.WinConsole.Installer.vdproj", "{14D4A306-E53A-40A5-9427-5CA068B1CB5F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Ad-Hoc|Any CPU = Ad-Hoc|Any CPU @@ -666,6 +668,34 @@ Global {39287F60-65DE-4077-90F2-57CF725E92B6}.Release|x64.Build.0 = Release|Any CPU {39287F60-65DE-4077-90F2-57CF725E92B6}.Release|x86.ActiveCfg = Release|Any CPU {39287F60-65DE-4077-90F2-57CF725E92B6}.Release|x86.Build.0 = Release|Any CPU + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Ad-Hoc|Any CPU.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Ad-Hoc|ARM.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Ad-Hoc|ARM64.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Ad-Hoc|iPhone.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Ad-Hoc|x64.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Ad-Hoc|x86.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.AppStore|Any CPU.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.AppStore|ARM.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.AppStore|ARM64.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.AppStore|iPhone.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.AppStore|iPhoneSimulator.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.AppStore|x64.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.AppStore|x86.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Debug|Any CPU.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Debug|ARM.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Debug|ARM64.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Debug|iPhone.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Debug|iPhoneSimulator.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Debug|x64.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Debug|x86.ActiveCfg = Debug + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Release|Any CPU.ActiveCfg = Release + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Release|ARM.ActiveCfg = Release + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Release|ARM64.ActiveCfg = Release + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Release|iPhone.ActiveCfg = Release + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Release|iPhoneSimulator.ActiveCfg = Release + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Release|x64.ActiveCfg = Release + {14D4A306-E53A-40A5-9427-5CA068B1CB5F}.Release|x86.ActiveCfg = Release EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -678,6 +708,7 @@ Global {25E04E05-F867-4F64-813D-AAFE0BA171B0} = {A06042F5-F69D-4191-875E-5ADE9CF42075} {D04F2D04-A33F-4E09-9EE2-29D7B2A6CD4E} = {A06042F5-F69D-4191-875E-5ADE9CF42075} {39287F60-65DE-4077-90F2-57CF725E92B6} = {A06042F5-F69D-4191-875E-5ADE9CF42075} + {14D4A306-E53A-40A5-9427-5CA068B1CB5F} = {A06042F5-F69D-4191-875E-5ADE9CF42075} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B5D5105C-EA52-467B-8CCC-6777900C3B95} diff --git a/Source/Plugin.BLE/Windows/Adapter.cs b/Source/Plugin.BLE/Windows/Adapter.cs index 1c8d9257..e2d8a2c0 100644 --- a/Source/Plugin.BLE/Windows/Adapter.cs +++ b/Source/Plugin.BLE/Windows/Adapter.cs @@ -138,10 +138,13 @@ private void Device_ConnectionStatusChanged(BluetoothLEDevice nativeDevice, obje && ConnectedDeviceRegistry.TryGetValue(id, out var connectedDevice)) { #if WINDOWS10_0_22000_0_OR_GREATER - var conpar = nativeDevice.GetConnectionParameters(); - Trace.Message( - $"Connected with Latency = {conpar.ConnectionLatency}, " - + $"Interval = {conpar.ConnectionInterval}, Timeout = {conpar.LinkTimeout}"); + if (BleImplementation.OsRuntimeBuildNumber >= 22000) + { + var conpar = nativeDevice.GetConnectionParameters(); + Trace.Message( + $"Connected with Latency = {conpar.ConnectionLatency}, " + + $"Interval = {conpar.ConnectionInterval}, Timeout = {conpar.LinkTimeout}"); + } #endif HandleConnectedDevice(connectedDevice); return; diff --git a/Source/Plugin.BLE/Windows/BleImplementation.cs b/Source/Plugin.BLE/Windows/BleImplementation.cs index 9df8c411..22d3de50 100644 --- a/Source/Plugin.BLE/Windows/BleImplementation.cs +++ b/Source/Plugin.BLE/Windows/BleImplementation.cs @@ -20,6 +20,26 @@ public class BleImplementation : BleImplementationBase public static BluetoothCacheMode CacheModeGetCharacteristics { get; set; } = BluetoothCacheMode.Cached; public static BluetoothCacheMode CacheModeGetServices { get; set; } = BluetoothCacheMode.Cached; + private static int? runtimeBuildNumber = null; + + /// + /// Get the Windows runtime build number + /// Eg running on Windows 10 gives 19041 even though it is executing an application compiled as eg net8.0-windows10.0.22621.0 + /// ref https://learn.microsoft.com/en-us/windows/release-health/release-information + /// ref https://learn.microsoft.com/en-us/windows/release-health/windows11-release-information + /// + public static int OsRuntimeBuildNumber + { + get + { + if (runtimeBuildNumber is null) + { + runtimeBuildNumber = Environment.OSVersion.Version.Build; + } + return runtimeBuildNumber.Value; + } + } + protected override IAdapter CreateNativeAdapter() { return new Adapter(btAdapter); diff --git a/Source/Plugin.BLE/Windows/Device.cs b/Source/Plugin.BLE/Windows/Device.cs index 3b111991..c40c8b85 100644 --- a/Source/Plugin.BLE/Windows/Device.cs +++ b/Source/Plugin.BLE/Windows/Device.cs @@ -131,6 +131,10 @@ protected override bool UpdateConnectionIntervalNative(ConnectionInterval interv static bool MaybeRequestPreferredConnectionParameters(BluetoothLEDevice device, ConnectParameters connectParameters) { #if WINDOWS10_0_22000_0_OR_GREATER + if (BleImplementation.OsRuntimeBuildNumber < 22000) + { + return false; + } BluetoothLEPreferredConnectionParameters parameters = null; switch(connectParameters.ConnectionParameterSet) {