Skip to content

Commit 19a01f7

Browse files
authored
[corebluetooth] Update up to beta 6 and enable it on watchOS (#2540)
macOS 10.13 has finally catch up with iOS and this simplifies the bindings a bit.
1 parent d07572b commit 19a01f7

File tree

12 files changed

+193
-129
lines changed

12 files changed

+193
-129
lines changed

src/Constants.watch.cs.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace ObjCRuntime {
4444
public const string IntentsLibrary = "/System/Library/Frameworks/Intents.framework/Intents";
4545

4646
// WatchOS 4.0
47+
public const string CoreBluetoothLibrary = "/System/Library/Frameworks/CoreBluetooth.framework/CoreBluetooth";
4748
public const string CoreMLLibrary = "/System/Library/Frameworks/CoreML.framework/CoreML";
4849
}
4950
}

src/CoreBluetooth/AdvertisementDataOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace XamCore.CoreBluetooth {
3737
// It's intentionally not called AdvertisementDataOptions because different options
3838
// are valid in different contexts
3939
//
40+
[Watch (4,0)]
4041
[iOS (6,0)]
4142
public class StartAdvertisingOptions : DictionaryContainer
4243
{

src/CoreBluetooth/CBUUID.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,5 +205,15 @@ public unsafe string ToString (bool fullUuid)
205205

206206
return sb.ToString ();
207207
}
208+
209+
#if MONOMAC
210+
// workaround for 27160443 – Trello: https://trello.com/c/oqB27JA6
211+
// try new constant (10.13+) and fallback to the old/misnamed one
212+
public static NSString CharacteristicValidRangeString {
213+
get {
214+
return CBUUIDCharacteristicValidRangeString ?? CBUUIDValidRangeString;
215+
}
216+
}
217+
#endif
208218
}
209219
}

src/CoreBluetooth/CoreBluetooth.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ public CBPeer ()
113113
}
114114
}
115115
#endif
116-
#if !MONOMAC && !XAMCORE_4_0
116+
#if !WATCH && !XAMCORE_4_0
117117
public partial class CBCentralManager {
118118

119-
public virtual CBCentralManagerState State {
119+
public new virtual CBCentralManagerState State {
120120
get {
121121
return (CBCentralManagerState)base.State;
122122
}

src/CoreBluetooth/Enums.cs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313

1414
namespace XamCore.CoreBluetooth {
1515

16-
#if !MONOMAC
16+
[Mac (10,13)]
17+
[Watch (4,0)]
1718
[iOS (10,0)]
1819
[Native]
1920
public enum CBManagerState : nint {
20-
#else
21-
internal enum CBManagerState {
22-
#endif
2321
Unknown = 0,
2422
Resetting,
2523
Unsupported,
@@ -31,6 +29,7 @@ internal enum CBManagerState {
3129
// NSInteger -> CBCentralManager.h
3230
[Introduced (PlatformName.iOS, 5, 0)]
3331
[Deprecated (PlatformName.iOS, 10, 0, message: "Use 'CBManagerState' instead.")]
32+
[NoWatch]
3433
[Native]
3534
public enum CBCentralManagerState : nint {
3635
Unknown = CBManagerState.Unknown,
@@ -44,6 +43,7 @@ public enum CBCentralManagerState : nint {
4443
// NSInteger -> CBPeripheralManager.h
4544
[Introduced (PlatformName.iOS, 6, 0)]
4645
[Deprecated (PlatformName.iOS, 10, 0, message: "Use 'CBManagerState' instead.")]
46+
[NoWatch]
4747
[Native]
4848
public enum CBPeripheralManagerState : nint {
4949
Unknown = CBManagerState.Unknown,
@@ -55,16 +55,19 @@ public enum CBPeripheralManagerState : nint {
5555
}
5656

5757
// NSInteger -> CBPeripheralManager.h
58+
[Watch (4,0)]
5859
[Native]
5960
public enum CBPeripheralState : nint {
6061
Disconnected,
6162
Connecting,
6263
Connected,
63-
Disconnecting
64+
[iOS (9,0)][Mac (10,13)]
65+
Disconnecting,
6466
}
6567

6668
#if !XAMCORE_4_0
6769
// NSInteger -> CBPeripheralManager.h
70+
[Watch (4,0)]
6871
[Native]
6972
public enum CBPeripheralManagerAuthorizationStatus : nint {
7073
NotDetermined,
@@ -75,6 +78,7 @@ public enum CBPeripheralManagerAuthorizationStatus : nint {
7578
#endif
7679

7780
// NSUInteger -> CBCharacteristic.h
81+
[Watch (4,0)]
7882
[Flags]
7983
[Native]
8084
public enum CBCharacteristicProperties : nuint_compat_int {
@@ -86,10 +90,13 @@ public enum CBCharacteristicProperties : nuint_compat_int {
8690
Indicate = 32,
8791
AuthenticatedSignedWrites = 64,
8892
ExtendedProperties = 128,
93+
[Mac (10,9)]
8994
NotifyEncryptionRequired = 0x100,
95+
[Mac (10,9)]
9096
IndicateEncryptionRequired = 0x200
9197
}
9298

99+
[Watch (4,0)]
93100
[ErrorDomain ("CBErrorDomain")]
94101
[Native] // NSInteger -> CBError.h
95102
public enum CBError : nint {
@@ -104,12 +111,15 @@ public enum CBError : nint {
104111
PeripheralDisconnected,
105112
UUIDNotAllowed,
106113
AlreadyAdvertising,
107-
// iOS7.1
114+
[iOS (7,1)][Mac (10,13)]
108115
ConnectionFailed,
109-
// iOS 9
110-
ConnectionLimitReached
116+
[iOS (9,0)][Mac (10,13)]
117+
ConnectionLimitReached,
118+
[iOS (11,0)][TV (11,0)][Mac (10,13)]
119+
UnknownDevice,
111120
}
112121

122+
[Watch (4,0)]
113123
[ErrorDomain ("CBATTErrorDomain")]
114124
[Native] // NSInteger -> CBError.h
115125
public enum CBATTError : nint {
@@ -134,13 +144,16 @@ public enum CBATTError : nint {
134144
}
135145

136146
// NSInteger -> CBPeripheral.h
147+
[Watch (4,0)]
137148
[Native]
138149
public enum CBCharacteristicWriteType : nint {
139150
WithResponse,
140151
WithoutResponse
141152
}
142153

143154
// NSUInteger -> CBCharacteristic.h
155+
[Mac (10,9)]
156+
[Watch (4,0)]
144157
[Flags]
145158
[Native]
146159
public enum CBAttributePermissions : nuint_compat_int {
@@ -151,6 +164,7 @@ public enum CBAttributePermissions : nuint_compat_int {
151164
}
152165

153166
// NSInteger -> CBPeripheralManager.h
167+
[Watch (4,0)]
154168
[Native]
155169
public enum CBPeripheralManagerConnectionLatency : nint {
156170
Low = 0,

src/CoreBluetooth/GuidWrapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void ConnectPeripheral (CBPeripheral peripheral, PeripheralConnectionOpti
5858
ConnectPeripheral (peripheral, options == null ? null : options.Dictionary);
5959
}
6060

61-
#if !TVOS
61+
#if !TVOS && !WATCH
6262
[Availability (Introduced = Platform.iOS_5_0, Deprecated = Platform.iOS_7_0, Obsoleted = Platform.iOS_9_0, Message = "Use 'RetrievePeripheralsWithIdentifiers' instead.")]
6363
public void RetrievePeripherals (CBUUID [] peripheralUuids)
6464
{

src/CoreBluetooth/PeripheralConnectionOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
namespace XamCore.CoreBluetooth {
3535

36+
[Watch (4,0)]
3637
public class PeripheralConnectionOptions : DictionaryContainer
3738
{
3839
#if !COREBUILD

0 commit comments

Comments
 (0)