DeviceDelegate
public protocol DeviceDelegate : AnyObject
The HAP Device calls the methods of this delegate to report HAP
related events. Implement this protocol in an app-specific object and use
the methods to update your app. For example, you might want to show the
device’s pairing state, or the value of certain characteristics.
-
characteristicListenerDidSubscribe(_:Default implementationservice: characteristic: ) Tells the delegate that a controller subscribed for updates.
Default Implementation
Declaration
Swift
func characteristicListenerDidSubscribe( _ accessory: Accessory, service: Service, characteristic: AnyCharacteristic)Parameters
accessorythe accessory to which the characteristic’s service belongs
servicethe service to which the characteristic belongs
characteristicthe characteristic that was subscribed to
-
characteristicListenerDidUnsubscribe(_:Default implementationservice: characteristic: ) Tells the delegate that a controller unsubscribed from updates.
Default Implementation
Declaration
Swift
func characteristicListenerDidUnsubscribe( _ accessory: Accessory, service: Service, characteristic: AnyCharacteristic)Parameters
accessorythe accessory to which the characteristic’s service belongs
servicethe service to which the characteristic belongs
characteristicthe characteristic that was unsubscribed from
-
didRequestIdentification()Default implementationTells the delegate that identification of the device was requested.
When the user configures a device, there might be multiple similar devices. In order to identify the individual device, HAP accommodates for an identification event. When possible, you should make the physical device emit sound and/or light for the user to be able to identify the device.
Default Implementation
Declaration
Swift
func didRequestIdentification() -
didRequestIdentificationOf(_:Default implementation) Tells the delegate that identification of an accessory was requested.
When the user configures an accessory, there might be multiple similar accessories. In order to identify the individual accessory, HAP accommodates for an identification event. When possible, you should make the physical accessory emit sound and/or light for the user to be able to identify the accessory.
Default Implementation
Declaration
Swift
func didRequestIdentificationOf(_ accessory: Accessory)Parameters
accessoryaccessory to be identified
-
didChangePairingState(from:Default implementationto: ) Tells the delegate that the Device PairingState has changed.
Default Implementation
Declaration
Swift
func didChangePairingState(from: PairingState, to: PairingState) -
characteristic(_:Default implementationofService: ofAccessory: didChangeValue: ) Tells the delegate that the value of a characteristic has changed.
Default Implementation
Declaration
Swift
func characteristic<T>( _ characteristic: GenericCharacteristic<T>, ofService: Service, ofAccessory: Accessory, didChangeValue: T?)Parameters
accessorythe accessory to which the characteristic’s service belongs
servicethe service to which the characteristic belongs
characteristicthe characteristic that was changed
newValuethe new value of the characteristic
View on GitHub
Install in Dash
DeviceDelegate Protocol Reference