CGA_Bluetooth_Characteristic

public class CGA_Bluetooth_Characteristic : CGA_Bluetooth_Characteristic_Protocol_Internal, CGA_Bluetooth_Writable
extension CGA_Bluetooth_Characteristic: CGA_Class_Protocol_UpdateDescriptor
extension CGA_Bluetooth_Characteristic: CGA_CharacteristicFactory

This class “wraps” instances of CBCharacteristic, adding some functionality, and linking the hierarchy.

  • This is used to “aggregate” our data. If concatenateValue is true, then we append new data onto old.

    Declaration

    Swift

    internal var _value: Data? { get set }
  • This is the type we’re aggregating. We aggregate the public face of the Descriptors.

    Declaration

    Swift

    public typealias Element = CGA_Bluetooth_Descriptor_Protocol
  • This is our main cache Array. It contains wrapped instances of our aggregate CB type.

    Declaration

    Swift

    public var sequence_contents: Array<Element>
  • If this is set to true, then new data (value) will be appended to existing data.

    Changing the value of this property to false will invalidate any aggregated data (set _value to nil).

    Declaration

    Swift

    public var concatenateValue: Bool { get set }
  • This is used to reference an “owning instance” of this instance, and it should be a CGA_Bluetooth_Characteristic

    Declaration

    Swift

    public weak var parent: CGA_Class_Protocol?
  • This holds the instance of CBCharacteristic that is used by this instance.

    Declaration

    Swift

    public weak var cbElementInstance: CBCharacteristic?
  • id

    The UUID of this Characteristic.

    Declaration

    Swift

    public var id: String { get }
  • Returns true, if the Characteristic can write (eithe with or without response).

    Declaration

    Swift

    public var canWrite: Bool { get }
  • Returns true, if the Characteristic can write, and returns a receipt response.

    Declaration

    Swift

    public var canWriteWithResponse: Bool { get }
  • Returns true, if the Characteristic can write, and does not return a response.

    Declaration

    Swift

    public var canWriteWithoutResponse: Bool { get }
  • Returns true, if the Characteristic can be read.

    Declaration

    Swift

    public var canRead: Bool { get }
  • Returns true, if the Characteristic can notify.

    Declaration

    Swift

    public var canNotify: Bool { get }
  • Returns true, if the Characteristic can broadcast.

    Declaration

    Swift

    public var canBroadcast: Bool { get }
  • Returns true, if the Characteristic can indicate.

    Declaration

    Swift

    public var canIndicate: Bool { get }
  • Returns true, if the Characteristic is currently notifying.

    Declaration

    Swift

    public var isNotifying: Bool { get }
  • Returns the maximum number of bytes that can be written for this Peripheral.

    Declaration

    Swift

    public var maximumWriteLength: Int { get }
  • Returns true, if the Characteristic requires authenticated writes.

    Declaration

    Swift

    public var requiresAuthenticatedSignedWrites: Bool { get }
  • Returns true, if the Characteristic requires encrypted notification.

    Declaration

    Swift

    public var requiresNotifyEncryption: Bool { get }
  • Returns true, if the Characteristic requires encrypted indicates.

    Declaration

    Swift

    public var requiresIndicateEncryption: Bool { get }
  • Returns true, if the Characteristic has extension properties.

    Declaration

    Swift

    public var hasExtendedProperties: Bool { get }
  • If the Characteristic has a value, and that value can be expressed as a String, it is returned here. This computed property is defined here, so it can be overridden by subclasses.

    Declaration

    Swift

    public var stringValue: String? { get }
  • Returns the number (if possible) as an Int64. This assumes littlendian. This computed property is defined here, so it can be overridden by subclasses.

    Declaration

    Swift

    public var intValue: Int64? { get }
  • Returns the value as a Boolean. It should be noted that ANY non-zero number will return true. This computed property is defined here, so it can be overridden by subclasses.

    Declaration

    Swift

    public var boolValue: Bool? { get }
  • Returns the value as a Double. This computed property is defined here, so it can be overridden by subclasses.

    Declaration

    Swift

    public var doubleValue: Double? { get }
  • This will return any extension properties, as a simple tuple, or nil, if there are none.

    Declaration

    Swift

    public var extendedProperties: (isReliableWriteEnabled: Bool, isWritableAuxiliariesEnabled: Bool)? { get }
  • If the Characteristic has a value, it is returned here.

    Declaration

    Swift

    public var value: Data? { get }
  • This returns the parent Central Manager

    Declaration

    Swift

    public var central: RVS_BlueThoth? { get }
  • If we have read permission, the Peripheral is asked to read our value.

    Declaration

    Swift

    public func readValue()
  • Tells the Peripheral to start notifying on this Characteristic.

    Declaration

    Swift

    @discardableResult
    public func startNotifying() -> Bool

    Return Value

    True, if the request was made (not a guarantee of success, though). Can be ignored.

  • Tells the Peripheral to stop notifying on this Characteristic.

    Declaration

    Swift

    @discardableResult
    public func stopNotifying() -> Bool

    Return Value

    True, if the request was made (not a guarantee of success, though). Can be ignored.

  • This clears the concatenated value.

    Declaration

    Swift

    @discardableResult
    public func clearConcatenate(newValue inNewValue: Bool? = nil) -> Bool

    Parameters

    newValue

    If provided (default is none), then the given value is set as the new value.

    Return Value

    The original value. This can be ignored.

  • The required init, with a “primed” sequence.

    Declaration

    Swift

    public required init(sequence_contents inSequence_Contents: [CGA_Bluetooth_Descriptor_Protocol])

    Parameters

    sequence_contents

    The initial value of the Array cache.

  • If we have write permission, the Peripheral is asked to write the given data into its value.

    Declaration

    Swift

    public func writeValue(_ inData: Data, withResponseIfPossible inWithResponse: Bool = false)

    Parameters

    inData

    The Data instance to write.

    withResponseIfPossible

    Optional. If True (default is false), then with response is preferred. Otherwise, without response (if available) will be used.

  • If we have write permission, the Peripheral is asked to write the given data into its value. It will avoid responsibility. This variant of the method is to satisfy the protocol.

    Declaration

    Swift

    public func writeValue(_ inData: Data)

    Parameters

    inData

    The Data instance to write.

Internal Properties (Declared here, so it can be overridden).

  • Root class does nothing.

    Declaration

    Swift

    internal class var uuid: String { get }
  • This is the init that should always be used.

    Declaration

    Swift

    internal required convenience init(parent inParent: CGA_Bluetooth_Service, cbElementInstance inCBharacteristic: CBCharacteristic)

    Parameters

    parent

    The Service instance that “owns” this instance.

    cbElementInstance

    This is the actual CBharacteristic instance to be associated with this instance.

CGA_Class_UpdateDescriptor Conformance

  • This eliminates all of the stored Descriptors.

    Declaration

    Swift

    public func clear()
  • This eliminates all of the stored results, and asks the Bluetooth subsystem to start over from scratch.

    Declaration

    Swift

    public func startOver()

Internal Computed Properties and Methods

  • This casts the parent as a Service Wrapper.

    Declaration

    Swift

    public var service: CGA_Bluetooth_Service? { get }
  • This will contain any required scan criteria. It simply passes on the Central criteria.

    Declaration

    Swift

    internal var scanCriteria: RVS_BlueThoth.ScanCriteria? { get }
  • Called to add a Descriptor to our main Array.

    Declaration

    Swift

    internal func addDescriptor(_ inDescriptor: CGA_Bluetooth_Descriptor)

    Parameters

    inDescriptor

    The Descriptor to add.

CGA_Class_Protocol Conformance

  • This searches the hierarchy, and will return any instance that has an ID that matches the string passed in. This could be a Peripheral, Service, Characteristic or Descriptor. The response will need to be cast.

    Declaration

    Swift

    public func findEntityByUUIDString(_ inUUIDString: String) -> CGA_Class_Protocol?

    Parameters

    inUUIDString

    The String for the UUID for which we are searching.

    Return Value

    Any element in the hierarchy with a UUID that matches the one passed in, or nil.

CGA_CharacteristicFactory Conformance

  • This instantiates an instance of this class.

    Declaration

    Swift

    internal class func createInstance(parent inParent: CGA_Bluetooth_Service, cbElementInstance inCBCharacteristic: CBCharacteristic) -> CGA_Bluetooth_Characteristic?

    Parameters

    parent

    The Service instance that “owns” this Characteristic.

    cbElementInstance

    The CBCharacteristic instance that will be applied to the factory.

    Return Value

    A new instance of CGA_Bluetooth_Characteristic, or a subclass, thereof. Nil, if it fails.