Skip to content

Commit

Permalink
Merge pull request #47 from uwburn/bthrpfix
Browse files Browse the repository at this point in the history
Bthrpfix
  • Loading branch information
uwburn authored Dec 18, 2022
2 parents 1536609 + 72699b1 commit 05e0f8c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Cardia/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Cardia")]
[assembly: AssemblyCopyright("Copyright © 2013-2018")]
[assembly: AssemblyCopyright("Copyright © 2013-2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.2.0.1")]
//[assembly: AssemblyFileVersion("0.7.*")]
48 changes: 19 additions & 29 deletions HRM/HRP/BtHrp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,45 +263,35 @@ private async Task ConfigureServiceForNotificationsAsync()
#endif
characteristic.ValueChanged += Characteristic_ValueChanged;

// In order to avoid unnecessary communication with the device, determine if the device is already
// correctly configured to send notifications.
// By default ReadClientCharacteristicConfigurationDescriptorAsync will attempt to get the current
// value from the system cache and communication with the device is not typically required.
// Set the Client Characteristic Configuration Descriptor to enable the device to send notifications
// when the Characteristic value changes
#if DEBUG
logger.Debug("Reading GattCharacteristic configuration descriptor");
logger.Debug("Setting GattCharacteristic configuration descriptor to enable notifications");
#endif
var currentDescriptorValue = await characteristic.ReadClientCharacteristicConfigurationDescriptorAsync();

if ((currentDescriptorValue.Status != GattCommunicationStatus.Success) ||
(currentDescriptorValue.ClientCharacteristicConfigurationDescriptor != CHARACTERISTIC_NOTIFICATION_TYPE))
{
// Set the Client Characteristic Configuration Descriptor to enable the device to send notifications
// when the Characteristic value changes
#if DEBUG
logger.Debug("Setting GattCharacteristic configuration descriptor to enable notifications");
#endif

GattCommunicationStatus status =
await characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(
CHARACTERISTIC_NOTIFICATION_TYPE);
GattCommunicationStatus status =
await characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(
CHARACTERISTIC_NOTIFICATION_TYPE);

if (status == GattCommunicationStatus.Unreachable)
{
if (status == GattCommunicationStatus.Unreachable)
{
#if DEBUG
logger.Debug("Device unreachable");
logger.Debug("Device unreachable");
#endif

// Register a PnpObjectWatcher to detect when a connection to the device is established,
// such that the application can retry device configuration.
StartDeviceConnectionWatcher();
}
// Register a PnpObjectWatcher to detect when a connection to the device is established,
// such that the application can retry device configuration.
StartDeviceConnectionWatcher();
}
else
{
#if DEBUG
else if (status == GattCommunicationStatus.Success)
{
logger.Debug("Configuration successfull");
#endif

logger.Debug($"GattSession status = {service.Session.SessionStatus}, " +
$"mantain connection = {service.Session.MaintainConnection}, " +
$"can mantain connection = {service.Session.MaintainConnection}");
}
#endif
}
catch (Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion HRM/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.1")]
[assembly: AssemblyVersion("1.1.0.2")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ If you would like to support me and help me buy the devices to include support f
- - - -

### Changelog
* v1.2.0.1 (2022-08-03)
* Change BT HRP initialization sequence (thanks to [@effgenesis](https://www.github.com/effgenesis))

* v1.2 (2018-12-01)
* Included UDP logging support
* Partial code rewrital to support better modularity
Expand Down

0 comments on commit 05e0f8c

Please sign in to comment.