Issues with BLE Gatt Services

Ben Steele 0 Reputation points
2024-02-12T16:40:02.2933333+00:00

Hi guys, We are using the BLE GATT services supplied by the Windows CSWinRT nuget package in a .net 6 WPF application. Two issues have raised their heads and I'm hoping someone could point me in the right direction. The main issue we have been facing is with the GATT service suddenly stop advertising. We receive no status update via the AdvertisementStatusChanged event handler nor by polling the state constantly. We have worked around the issue by Stopping /Starting the Bluetooth radio which has minimized the occurrence of this issue, as upon the Bluetooth radio coming on, the GATT service returns the started event. The secondary issue, is that we have had an issue when calling StartAdvertising method on the GattServiceProvider object. There has been a couple of instances where a COM exception was thrown:

System.Runtime.InteropServices.COMException (0x800706BE) at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr) at ABI.Windows.Devices.Bluetooth.GenericAttributeProfile.IGattServiceProviderMethods.StartAdvertising(IObjectReference _obj, GattServiceProviderAdvertisingParameters parameters) 

This issue has not be persistent, and seems to clear after the application restarts. I have checked the EventViewer for any potential issues but have turned up nothing so far. Is there any additional debugging i can deploy to work out these issues? Thanks in advance Ben

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,708 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,601 questions
{count} votes