Skip to content

Commit

Permalink
feat: BTdevice structs
Browse files Browse the repository at this point in the history
  • Loading branch information
pkar70 committed Apr 5, 2022
1 parent 5e0c381 commit ecfbbe1
Show file tree
Hide file tree
Showing 34 changed files with 296 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;

namespace Windows.Devices.Bluetooth.Advertisement
{
public partial class BluetoothLEAdvertisement
{
public string LocalName { get; set; }
public BluetoothLEAdvertisementFlags? Flags { get; set; }
public IList<BluetoothLEAdvertisementDataSection> DataSections { get; internal set; }
public IList<BluetoothLEManufacturerData> ManufacturerData { get; internal set; }
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

namespace Windows.Devices.Bluetooth.Advertisement
{
public partial class BluetoothLEAdvertisementDataSection
{
public byte DataType { get; set; }
public Storage.Streams.IBuffer Data { get; set; }
public BluetoothLEAdvertisementDataSection(byte dataType, Storage.Streams.IBuffer data)
{
DataType = dataType;
Data = data;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

namespace Windows.Devices.Bluetooth.Advertisement
{
public enum BluetoothLEAdvertisementFlags : uint
{
None = 0,
LimitedDiscoverableMode = 1,
GeneralDiscoverableMode = 2,
ClassicNotSupported = 4,
DualModeControllerCapable = 8,
DualModeHostCapable = 16,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

namespace Windows.Devices.Bluetooth.Advertisement
{
public partial class BluetoothLEManufacturerData
{
public Storage.Streams.IBuffer Data { get; set; }
public ushort CompanyId { get; set; }
public BluetoothLEManufacturerData( ushort companyId, Storage.Streams.IBuffer data)
{
CompanyId = companyId;
Data = data;
}

}
}
31 changes: 21 additions & 10 deletions src/Uno.UWP/Devices/Bluetooth/BluetoothLEDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ namespace Windows.Devices.Bluetooth
{
public partial class BluetoothLEDevice : global::System.IDisposable
{

public ulong BluetoothAddress { get; internal set; }
public BluetoothAddressType BluetoothAddressType { get; internal set; }
public BluetoothConnectionStatus ConnectionStatus { get; internal set; }
public string Name { get; internal set; }
public BluetoothLEAppearance Appearance { get; internal set; }

#region "device selectors"

private static string _deviceSelectorPrefix = "System.Devices.DevObjectType:=5 AND System.Devices.Aep.ProtocolId:=\"{BB7BB05E-5972-42B5-94FC-76EAA7084D49}\" AND ";
private static string _deviceSelectorIssueInquiry = "System.Devices.Aep.Bluetooth.IssueInquiry:=System.StructuredQueryType.Boolean";

Expand All @@ -14,8 +23,8 @@ public static string GetDeviceSelector()
return _deviceSelectorPrefix + "(System.Devices.Aep.IsPaired:=System.StructuredQueryType.Boolean#True OR " + _deviceSelectorIssueInquiry + "#False)";
}

public static string GetDeviceSelectorFromPairingState( bool pairingState)
{
public static string GetDeviceSelectorFromPairingState(bool pairingState)
{
if (pairingState)
{
return _deviceSelectorPrefix + "(System.Devices.Aep.IsPaired:=System.StructuredQueryType.Boolean#True OR " + _deviceSelectorIssueInquiry + "#False)";
Expand All @@ -26,8 +35,8 @@ public static string GetDeviceSelectorFromPairingState( bool pairingState)
}
}

public static string GetDeviceSelectorFromConnectionStatus( BluetoothConnectionStatus connectionStatus)
{
public static string GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus connectionStatus)
{
if (connectionStatus == BluetoothConnectionStatus.Connected)
{
return _deviceSelectorPrefix + "(System.Devices.Aep.IsConnected:=System.StructuredQueryType.Boolean#True OR " + _deviceSelectorIssueInquiry + "#False)";
Expand All @@ -38,20 +47,20 @@ public static string GetDeviceSelectorFromConnectionStatus( BluetoothConnectionS
}
}

public static string GetDeviceSelectorFromDeviceName( string deviceName)
public static string GetDeviceSelectorFromDeviceName(string deviceName)
{
return _deviceSelectorPrefix + "(System.ItemNameDisplay:=\"" + deviceName + "\" OR " + _deviceSelectorIssueInquiry + "#True)";
}

public static string GetDeviceSelectorFromBluetoothAddress( ulong bluetoothAddress)
public static string GetDeviceSelectorFromBluetoothAddress(ulong bluetoothAddress)
{
string macAddr = string.Format("{0:x12}", bluetoothAddress);
return _deviceSelectorPrefix + "(System.DeviceInterface.Bluetooth.DeviceAddress:=\"" + macAddr + "\" OR " + _deviceSelectorIssueInquiry + "#True)";
}

public static string GetDeviceSelectorFromBluetoothAddress( ulong bluetoothAddress, BluetoothAddressType bluetoothAddressType)
public static string GetDeviceSelectorFromBluetoothAddress(ulong bluetoothAddress, BluetoothAddressType bluetoothAddressType)
{
if(bluetoothAddressType == BluetoothAddressType.Unspecified)
if (bluetoothAddressType == BluetoothAddressType.Unspecified)
{
return GetDeviceSelectorFromBluetoothAddress(bluetoothAddress);
}
Expand All @@ -60,7 +69,7 @@ public static string GetDeviceSelectorFromBluetoothAddress( ulong bluetoothAddre
string selector = _deviceSelectorPrefix + "((System.DeviceInterface.Bluetooth.DeviceAddress:=\"" + macAddr + "\"" +
"AND System.Devices.Aep.Bluetooth.Le.AddressType:=System.Devices.Aep.Bluetooth.Le.AddressType#";

if(bluetoothAddressType== BluetoothAddressType.Public)
if (bluetoothAddressType == BluetoothAddressType.Public)
{
selector += "Public";
}
Expand All @@ -73,13 +82,15 @@ public static string GetDeviceSelectorFromBluetoothAddress( ulong bluetoothAddre
return selector;
}

public static string GetDeviceSelectorFromAppearance( BluetoothLEAppearance appearance)
public static string GetDeviceSelectorFromAppearance(BluetoothLEAppearance appearance)
{
return _deviceSelectorPrefix +
"((System.Devices.Aep.Bluetooth.Le.Appearance.Category:=" + appearance.Category.ToString() +
"AND System.Devices.Aep.Bluetooth.Le.Appearance.Subcategory:=" + appearance.SubCategory.ToString() +
_deviceSelectorIssueInquiry + "#True";
}

#endregion

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

using System;

namespace Windows.Devices.Bluetooth.GenericAttributeProfile
{
public partial class GattCharacteristic
{
public GattCharacteristicProperties CharacteristicProperties { get; internal set; }
public Guid Uuid { get; internal set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

namespace Windows.Devices.Bluetooth.GenericAttributeProfile
{
public enum GattCharacteristicProperties : uint
{
None = 0,
Broadcast = 1,
Read = 2,
WriteWithoutResponse = 4,
Write = 8,
Notify = 16,
Indicate = 32,
AuthenticatedSignedWrites = 64,
ExtendedProperties = 128,
ReliableWrites = 256,
WritableAuxiliaries = 512,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

using System.Collections.Generic;

namespace Windows.Devices.Bluetooth.GenericAttributeProfile
{
public partial class GattCharacteristicsResult
{
public IReadOnlyList<GattCharacteristic> Characteristics { get; internal set; }
public byte? ProtocolError { get; internal set; }
public GattCommunicationStatus Status { get; internal set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

namespace Windows.Devices.Bluetooth.GenericAttributeProfile
{
public enum GattCommunicationStatus
{
Success = 0,
Unreachable = 1,
ProtocolError = 2,
AccessDenied = 3,
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace Windows.Devices.Bluetooth.GenericAttributeProfile
{
public partial class GattDescriptor
{
public Guid Uuid { get; internal set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections.Generic;

namespace Windows.Devices.Bluetooth.GenericAttributeProfile
{
public partial class GattDescriptorsResult
{
public IReadOnlyList<GattDescriptor> Descriptors { get; internal set; }
public byte? ProtocolError { get; internal set; }
public GattCommunicationStatus Status { get; internal set; }
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

using System;

namespace Windows.Devices.Bluetooth.GenericAttributeProfile
{
public partial class GattDeviceService : IDisposable
{
public Guid Uuid { get; internal set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Windows.Devices.Bluetooth.GenericAttributeProfile
{
public partial class GattDeviceServicesResult
{
public byte? ProtocolError { get; internal set; }
public IReadOnlyList<GattDeviceService> Services { get; internal set; }
public GattCommunicationStatus Status { get; internal set; }
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

namespace Windows.Devices.Bluetooth.GenericAttributeProfile
{
public static partial class GattProtocolError
{
public static byte AttributeNotFound => 10;
public static byte AttributeNotLong => 11;
public static byte InsufficientAuthentication => 5;
public static byte InsufficientAuthorization => 8;
public static byte InsufficientEncryption => 15;
public static byte InsufficientEncryptionKeySize => 12;
public static byte InsufficientResources => 17;
public static byte InvalidAttributeValueLength => 13;
public static byte InvalidHandle => 1;
public static byte InvalidOffset => 7;
public static byte InvalidPdu => 4;
public static byte PrepareQueueFull => 9;
public static byte ReadNotPermitted => 2;
public static byte RequestNotSupported => 6;
public static byte UnlikelyError => 14;
public static byte UnsupportedGroupType => 15;
public static byte WriteNotPermitted => 3;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

namespace Windows.Devices.Bluetooth.GenericAttributeProfile
{
public partial class GattReadResult
{
public GattCommunicationStatus Status { get; internal set; }
public Storage.Streams.IBuffer Value { get; internal set; }
public byte? ProtocolError { get; internal set; }
}
}
9 changes: 9 additions & 0 deletions src/Uno.UWP/Devices/Enumeration/DeviceAccessInformation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

namespace Windows.Devices.Enumeration
{
public partial class DeviceAccessInformation
{
public DeviceAccessStatus CurrentStatus { get; internal set; }

}
}
13 changes: 13 additions & 0 deletions src/Uno.UWP/Devices/Enumeration/DeviceAccessStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#pragma warning disable 108 // new keyword hiding
#pragma warning disable 114 // new keyword hiding
namespace Windows.Devices.Enumeration
{
public enum DeviceAccessStatus
{
Unspecified = 0,
Allowed = 1,
DeniedByUser = 2,
DeniedBySystem = 3,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Windows.Devices.Bluetooth.Advertisement
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class BluetoothLEAdvertisement
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public string LocalName
{
Expand All @@ -21,7 +21,7 @@ public string LocalName
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementFlags? Flags
{
Expand All @@ -35,7 +35,7 @@ public string LocalName
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::System.Collections.Generic.IList<global::Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementDataSection> DataSections
{
Expand All @@ -45,7 +45,7 @@ public string LocalName
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::System.Collections.Generic.IList<global::Windows.Devices.Bluetooth.Advertisement.BluetoothLEManufacturerData> ManufacturerData
{
Expand All @@ -55,7 +55,7 @@ public string LocalName
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::System.Collections.Generic.IList<global::System.Guid> ServiceUuids
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Windows.Devices.Bluetooth.Advertisement
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class BluetoothLEAdvertisementDataSection
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public byte DataType
{
Expand All @@ -21,7 +21,7 @@ public byte DataType
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.Storage.Streams.IBuffer Data
{
Expand All @@ -43,7 +43,7 @@ public BluetoothLEAdvertisementDataSection()
}
#endif
// Forced skipping of method Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementDataSection.BluetoothLEAdvertisementDataSection()
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public BluetoothLEAdvertisementDataSection( byte dataType, global::Windows.Storage.Streams.IBuffer data)
{
Expand Down
Loading

0 comments on commit ecfbbe1

Please sign in to comment.