Link is a representation of a connection between a device and a vehicle.
It enables sending commands to vehicles as well as receiving them through it's delegate. Furthermore, it handles the connection flow and authentication protocols required by HMKit.
Note that it's only allowed to send one command at a time. Queueing of several commands in a sequence has to be done on the application level.
Finally, an HMLink is not initialised by the developer, but received through the HMLocalDevice's delegate.
Disconnect the connection of the HMLink
import HMKit /* HMLink-object received through HMLocalDevice's delegate beforehand */ link.disconnect()
Send a command to the HMLink
send<C>(command: C, contentType: HMContainerContentType = .autoAPI, requestID: [UInt8] = , completion: @escaping HMLinkCommandCompletionBlock) throws where C : Collection, C.Element == UInt8
(UInt8 Collection) binary of the command to send
(HMContainerContentType) Type of data sent as content - defaults to .autoAPI
([UInt8]) ID to keep track of a specific command (response will contain the same ID)
(HMLinkCommandCompletionBlock) Block that gets called when this command is done
The command is encrypted and stored inside a tamper-proof secure container.
Send the revoke command to the HMLink
func sendRevoke() throws
Revoke is used to remove the certificates for 'this' device from the connected one.
After the revoke is received by the connected device, it deletes the certificates and disconnects.
As it's last act it might send back some data with the completion of the revoke.
import HMKit /* HMLink-object received through HMLocalDevice's delegate beforehand */ try link.sendRevoke()
typealias HMLinkCommandCompletionBlock = (Result<Void, HMLinkError>) -> Void
HMLinkCommandCompletionBlock is a typealias for
Result that gets called when a command succeeds or fails.
A type that can be compared for value equality.