|
| 1 | +#if NET |
| 2 | +using System; |
| 3 | + |
| 4 | +using CoreBluetooth; |
| 5 | +using CoreFoundation; |
| 6 | +using Foundation; |
| 7 | +using ObjCRuntime; |
| 8 | +using UIKit; |
| 9 | + |
| 10 | +namespace AccessorySetupKit { |
| 11 | + [Native] |
| 12 | + [iOS (18, 0)] |
| 13 | + public enum ASAccessoryState : long { |
| 14 | + Unauthorized = 0, |
| 15 | + AwaitingAuthorization = 10, |
| 16 | + Authorized = 20, |
| 17 | + } |
| 18 | + |
| 19 | + [Flags] |
| 20 | + [Native] |
| 21 | + [iOS (18, 0)] |
| 22 | + public enum ASAccessoryRenameOptions : ulong { |
| 23 | + Ssid = 1U << 0, |
| 24 | + } |
| 25 | + |
| 26 | + [Flags] |
| 27 | + [Native] |
| 28 | + [iOS (18, 0)] |
| 29 | + public enum ASAccessorySupportOptions : ulong { |
| 30 | + BluetoothPairingLE = 1U << 1, |
| 31 | + BluetoothTransportBridging = 1U << 2, |
| 32 | + } |
| 33 | + |
| 34 | + [Native] |
| 35 | + [iOS (18, 0)] |
| 36 | + public enum ASDiscoveryDescriptorRange : long { |
| 37 | + Default = 0, |
| 38 | + Immediate = 10, |
| 39 | + } |
| 40 | + |
| 41 | + [Flags] |
| 42 | + [Native] |
| 43 | + [iOS (18, 0)] |
| 44 | + public enum ASPickerDisplayItemSetupOptions : long { |
| 45 | + Rename = 1 << 0, |
| 46 | + ConfirmAuthorization = 1 << 1, |
| 47 | + FinishInApp = 1 << 2, |
| 48 | + } |
| 49 | + |
| 50 | + [BaseType (typeof (NSObject))] |
| 51 | + [iOS (18, 0)] |
| 52 | + [DisableDefaultCtor] |
| 53 | + interface ASAccessory { |
| 54 | + [Export ("state", ArgumentSemantic.Assign)] |
| 55 | + ASAccessoryState State { get; } |
| 56 | + |
| 57 | + [Export ("bluetoothIdentifier", ArgumentSemantic.Copy), NullAllowed] |
| 58 | + NSUuid BluetoothIdentifier { get; } |
| 59 | + |
| 60 | + [Export ("displayName", ArgumentSemantic.Copy)] |
| 61 | + string DisplayName { get; } |
| 62 | + |
| 63 | + [Export ("SSID", ArgumentSemantic.Copy), NullAllowed] |
| 64 | + string Ssid { get; } |
| 65 | + |
| 66 | + [Export ("descriptor", ArgumentSemantic.Copy)] |
| 67 | + ASDiscoveryDescriptor Descriptor { get; } |
| 68 | + |
| 69 | + [Export ("bluetoothTransportBridgingIdentifier", ArgumentSemantic.Copy), NullAllowed] |
| 70 | + NSData BluetoothTransportBridgingIdentifier { get; } |
| 71 | + } |
| 72 | + |
| 73 | + [Native] |
| 74 | + [iOS (18, 0)] |
| 75 | + public enum ASAccessoryEventType : long { |
| 76 | + Unknown = 0, |
| 77 | + Activated = 10, |
| 78 | + Invalidated = 11, |
| 79 | + MigrationComplete = 20, |
| 80 | + AccessoryAdded = 30, |
| 81 | + AccessoryRemoved = 31, |
| 82 | + AccessoryChanged = 32, |
| 83 | + PickerDidPresent = 40, |
| 84 | + PickerDidDismiss = 50, |
| 85 | + PickerSetupBridging = 60, |
| 86 | + PickerSetupFailed = 70, |
| 87 | + PickerSetupPairing = 80, |
| 88 | + PickerSetupRename = 90, |
| 89 | + } |
| 90 | + |
| 91 | + [BaseType (typeof (NSObject))] |
| 92 | + [iOS (18, 0)] |
| 93 | + [DisableDefaultCtor] |
| 94 | + interface ASAccessoryEvent { |
| 95 | + [Export ("eventType", ArgumentSemantic.Assign)] |
| 96 | + ASAccessoryEventType EventType { get; } |
| 97 | + |
| 98 | + [Export ("accessory", ArgumentSemantic.Copy), NullAllowed] |
| 99 | + ASAccessory Accessory { get; } |
| 100 | + |
| 101 | + [Export ("error", ArgumentSemantic.Copy), NullAllowed] |
| 102 | + NSError Error { get; } |
| 103 | + } |
| 104 | + |
| 105 | + delegate void ASAccessorySessionCompletionHandler ([NullAllowed] NSError error); |
| 106 | + |
| 107 | + [BaseType (typeof (NSObject))] |
| 108 | + [iOS (18, 0)] |
| 109 | + [DisableDefaultCtor] |
| 110 | + interface ASAccessorySession { |
| 111 | + [Export ("accessories", ArgumentSemantic.Copy)] |
| 112 | + ASAccessory [] Accessories { get; } |
| 113 | + |
| 114 | + [Export ("activateWithQueue:eventHandler:")] |
| 115 | + void Activate (DispatchQueue queue, Action<ASAccessoryEvent> eventHandler); |
| 116 | + |
| 117 | + [Export ("invalidate")] |
| 118 | + void Invalidate (); |
| 119 | + |
| 120 | + [Async] |
| 121 | + [Export ("showPickerWithCompletionHandler:")] |
| 122 | + void ShowPicker (ASAccessorySessionCompletionHandler completionHandler); |
| 123 | + |
| 124 | + [Async] |
| 125 | + [Export ("showPickerForDisplayItems:completionHandler:")] |
| 126 | + void ShowPicker (ASPickerDisplayItem [] displayItems, ASAccessorySessionCompletionHandler completionHandler); |
| 127 | + |
| 128 | + [Async] |
| 129 | + [Export ("finishAuthorization:settings:completionHandler:")] |
| 130 | + void FinishAuthorization (ASAccessory accessory, ASAccessorySettings settings, ASAccessorySessionCompletionHandler completionHandler); |
| 131 | + |
| 132 | + [Async] |
| 133 | + [Export ("removeAccessory:completionHandler:")] |
| 134 | + void RemoveAccessory (ASAccessory accessory, ASAccessorySessionCompletionHandler completionHandler); |
| 135 | + |
| 136 | + [Async] |
| 137 | + [Export ("renameAccessory:options:completionHandler:")] |
| 138 | + void RenameAccessory (ASAccessory accessory, ASAccessoryRenameOptions renameOptions, ASAccessorySessionCompletionHandler completionHandler); |
| 139 | + |
| 140 | + [Async] |
| 141 | + [Export ("failAuthorization:completionHandler:")] |
| 142 | + void FailAuthorization (ASAccessory accessory, ASAccessorySessionCompletionHandler completionHandler); |
| 143 | + } |
| 144 | + |
| 145 | + [BaseType (typeof (NSObject))] |
| 146 | + [iOS (18, 0)] |
| 147 | + [DisableDefaultCtor] |
| 148 | + interface ASAccessorySettings { |
| 149 | + [Export ("defaultSettings")] |
| 150 | + [Static] |
| 151 | + ASAccessorySettings DefaultSettings { get; } |
| 152 | + |
| 153 | + [Export ("SSID", ArgumentSemantic.Copy), NullAllowed] |
| 154 | + string Ssid { get; set; } |
| 155 | + |
| 156 | + [Export ("bluetoothTransportBridgingIdentifier", ArgumentSemantic.Copy), NullAllowed] |
| 157 | + NSData BluetoothTransportBridgingIdentifier { get; set; } |
| 158 | + } |
| 159 | + |
| 160 | + [BaseType (typeof (NSObject))] |
| 161 | + [iOS (18, 0)] |
| 162 | + [DisableDefaultCtor] |
| 163 | + interface ASDiscoveryDescriptor { |
| 164 | + [Export ("supportedOptions", ArgumentSemantic.Assign)] |
| 165 | + ASAccessorySupportOptions SupportedOptions { get; set; } |
| 166 | + |
| 167 | + [Export ("bluetoothCompanyIdentifier", ArgumentSemantic.Assign)] |
| 168 | + ushort /* ASBluetoothCompanyIdentifier */ BluetoothCompanyIdentifier { get; set; } |
| 169 | + |
| 170 | + [Export ("bluetoothManufacturerDataBlob", ArgumentSemantic.Copy), NullAllowed] |
| 171 | + NSData BluetoothManufacturerDataBlob { get; set; } |
| 172 | + |
| 173 | + [Export ("bluetoothManufacturerDataMask", ArgumentSemantic.Copy), NullAllowed] |
| 174 | + NSData BluetoothManufacturerDataMask { get; set; } |
| 175 | + |
| 176 | + [Export ("bluetoothNameSubstring", ArgumentSemantic.Copy), NullAllowed] |
| 177 | + string BluetoothNameSubstring { get; set; } |
| 178 | + |
| 179 | + [Export ("bluetoothRange", ArgumentSemantic.Assign)] |
| 180 | + ASDiscoveryDescriptorRange BluetoothRange { get; set; } |
| 181 | + |
| 182 | + [Export ("bluetoothServiceDataBlob", ArgumentSemantic.Copy), NullAllowed] |
| 183 | + NSData BluetoothServiceDataBlob { get; set; } |
| 184 | + |
| 185 | + [Export ("bluetoothServiceDataMask", ArgumentSemantic.Copy), NullAllowed] |
| 186 | + NSData BluetoothServiceDataMask { get; set; } |
| 187 | + |
| 188 | + [Export ("bluetoothServiceUUID", ArgumentSemantic.Copy), NullAllowed] |
| 189 | + CBUUID BluetoothServiceUuid { get; set; } |
| 190 | + [Export ("SSID", ArgumentSemantic.Copy), NullAllowed] |
| 191 | + string Ssid { get; set; } |
| 192 | + |
| 193 | + [Export ("SSIDPrefix", ArgumentSemantic.Copy), NullAllowed] |
| 194 | + string SsidPrefix { get; set; } |
| 195 | + } |
| 196 | + |
| 197 | + [Native] |
| 198 | + [iOS (18, 0)] |
| 199 | + [ErrorDomain ("ASErrorDomain")] |
| 200 | + enum ASErrorCode : long { |
| 201 | + Success = 0, |
| 202 | + Unknown = 1, |
| 203 | + ActivationFailed = 100, |
| 204 | + ConnectionFailed = 150, |
| 205 | + DiscoveryTimeout = 200, |
| 206 | + ExtensionNotFound = 300, |
| 207 | + Invalidated = 400, |
| 208 | + InvalidRequest = 450, |
| 209 | + PickerAlreadyActive = 500, |
| 210 | + PickerRestricted = 550, |
| 211 | + UserCancelled = 700, |
| 212 | + UserRestricted = 750, |
| 213 | + } |
| 214 | + |
| 215 | + [BaseType (typeof (NSObject))] |
| 216 | + [iOS (18, 0)] |
| 217 | + [DisableDefaultCtor] |
| 218 | + interface ASPickerDisplayItem { |
| 219 | + [Export ("name", ArgumentSemantic.Copy)] |
| 220 | + string Name { get; } |
| 221 | + |
| 222 | + [Export ("productImage", ArgumentSemantic.Copy)] |
| 223 | + UIImage ProductImage { get; } |
| 224 | + |
| 225 | + [Export ("descriptor", ArgumentSemantic.Copy)] |
| 226 | + ASDiscoveryDescriptor Descriptor { get; set; } |
| 227 | + |
| 228 | + [Export ("renameOptions", ArgumentSemantic.Assign)] |
| 229 | + ASAccessoryRenameOptions RenameOptions { get; set; } |
| 230 | + |
| 231 | + [Export ("setupOptions", ArgumentSemantic.Assign)] |
| 232 | + ASPickerDisplayItemSetupOptions SetupOptions { get; set; } |
| 233 | + |
| 234 | + [Export ("initWithName:productImage:descriptor:")] |
| 235 | + [DesignatedInitializer] |
| 236 | + NativeHandle Constructor (string name, UIImage productImage, ASDiscoveryDescriptor descriptor); |
| 237 | + } |
| 238 | + |
| 239 | + [BaseType (typeof (ASPickerDisplayItem))] |
| 240 | + [iOS (18, 0)] |
| 241 | + [DisableDefaultCtor] |
| 242 | + interface ASMigrationDisplayItem { |
| 243 | + [Export ("peripheralIdentifier", ArgumentSemantic.Copy), NullAllowed] |
| 244 | + NSUuid PeripheralIdentifier { get; set; } |
| 245 | + |
| 246 | + [Export ("hotspotSSID", ArgumentSemantic.Copy), NullAllowed] |
| 247 | + string HotspotSsid { get; set; } |
| 248 | + |
| 249 | + // re-exposed from base |
| 250 | + [Export ("initWithName:productImage:descriptor:")] |
| 251 | + [DesignatedInitializer] |
| 252 | + NativeHandle Constructor (string name, UIImage productImage, ASDiscoveryDescriptor descriptor); |
| 253 | + } |
| 254 | +} |
| 255 | + |
| 256 | +#endif // !NET |
0 commit comments