|
| 1 | +// |
| 2 | +// BluetoothGattStatus.swift |
| 3 | +// AndroidBluetooth |
| 4 | +// |
| 5 | +// Created by Alsey Coleman Miller on 7/13/25. |
| 6 | +// |
| 7 | + |
| 8 | +import JavaKit |
| 9 | + |
| 10 | +public extension BluetoothGatt { |
| 11 | + |
| 12 | + /// Bluetooth Gatt Status |
| 13 | + struct Status: RawRepresentable, Equatable, Hashable, Sendable { |
| 14 | + |
| 15 | + public let rawValue: Int32 |
| 16 | + |
| 17 | + public init(rawValue: Int32) { |
| 18 | + self.rawValue = rawValue |
| 19 | + } |
| 20 | + |
| 21 | + private init(_ raw: Int32) { |
| 22 | + self.init(rawValue: raw) |
| 23 | + } |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +internal extension BluetoothGatt.Status { |
| 28 | + |
| 29 | + static let javaClass = try! JavaClass<BluetoothGatt>() |
| 30 | +} |
| 31 | + |
| 32 | +public extension BluetoothGatt.Status { |
| 33 | + |
| 34 | + /** |
| 35 | + * A remote device connection is congested. |
| 36 | + */ |
| 37 | + static let connectionCongested = BluetoothGatt.Status(javaClass.GATT_CONNECTION_CONGESTED) |
| 38 | + |
| 39 | + /** |
| 40 | + * A GATT operation failed, errors other than the above |
| 41 | + */ |
| 42 | + static let failure = BluetoothGatt.Status(javaClass.GATT_FAILURE) |
| 43 | + |
| 44 | + /** |
| 45 | + * Insufficient authentication for a given operation |
| 46 | + */ |
| 47 | + static let insufficientAuthentication = BluetoothGatt.Status(javaClass.GATT_INSUFFICIENT_AUTHENTICATION) |
| 48 | + |
| 49 | + /** |
| 50 | + * Insufficient encryption for a given operation |
| 51 | + */ |
| 52 | + static let insufficientEncryption = BluetoothGatt.Status(javaClass.GATT_INSUFFICIENT_ENCRYPTION) |
| 53 | + |
| 54 | + /** |
| 55 | + * A write operation exceeds the maximum length of the attribute |
| 56 | + */ |
| 57 | + static let invalidAttibuteLength = BluetoothGatt.Status(javaClass.GATT_INVALID_ATTRIBUTE_LENGTH) |
| 58 | + |
| 59 | + /** |
| 60 | + * A read or write operation was requested with an invalid offset |
| 61 | + */ |
| 62 | + static let invalidOffset = BluetoothGatt.Status(javaClass.GATT_INVALID_OFFSET) |
| 63 | + |
| 64 | + /** |
| 65 | + * GATT read operation is not permitted |
| 66 | + */ |
| 67 | + static let readNotPermitted = BluetoothGatt.Status(javaClass.GATT_READ_NOT_PERMITTED) |
| 68 | + |
| 69 | + /** |
| 70 | + * The given request is not supported |
| 71 | + */ |
| 72 | + static let requestNotSupported = BluetoothGatt.Status(javaClass.GATT_REQUEST_NOT_SUPPORTED) |
| 73 | + |
| 74 | + /** |
| 75 | + * A GATT operation completed successfully |
| 76 | + */ |
| 77 | + static let success = BluetoothGatt.Status(javaClass.GATT_SUCCESS) |
| 78 | + |
| 79 | + /** |
| 80 | + * GATT write operation is not permitted |
| 81 | + */ |
| 82 | + static let writeNotPermitted = BluetoothGatt.Status(javaClass.GATT_WRITE_NOT_PERMITTED) |
| 83 | +} |
0 commit comments