GatewayDevice
public class GatewayDevice : DirectlyConnectedDevice
A GatewayDevice is capable of registering indirectly–connected devices and proxies messages for indirectly-connected devices.
-
The
manufacturerattribute. This attribute is to be used when setting themanufacturervalue in the meta-data.Declaration
Swift
public static let MANUFACTURER: String -
The
modelNumberattribute. This attribute is to be used when setting themodelNumbervalue in the meta-data.Declaration
Swift
public static let MODEL_NUMBER: String -
The
serialNumberattribute. This attribute is to be used when setting theserialNumbervalue in the meta-data.Declaration
Swift
public static let SERIAL_NUMBER: String -
The
deviceClassattribute. This attribute is to be used when setting thedeviceClassvalue in the meta-data.Declaration
Swift
public static let DEVICE_CLASS: String -
The
protocolattribute. This attribute is to be used when setting theprotocolvalue in the meta-data.Declaration
Swift
public static let PROTOCOL: String -
The
protocolDeviceClassattribute. This attribute is to be used when setting theprotocolDeviceClassvalue in the meta-data.Declaration
Swift
public static let PROTOCOL_DEVICE_CLASS: String -
The
protocolDeviceIdattribute. This attribute is to be used when setting theprotocolDeviceIdvalue in the meta-data.Declaration
Swift
public static let PROTOCOL_DEVICE_ID: String -
Constructs a new
GatewayDeviceinstance that will use the given path and password to provision aGatewayDeviceinstanceThrows
ClientError.fileif the provisioning file is not presentClientError.securityif the provisioning file cannot be decrypted or there is invalid information in the file
Declaration
Swift
public init(path: String, password: String) throwsParameters
paththe path to the provisioning file
passwordthe password to protect the provisioning file during the creation of the file
-
Register an indirectly-connected device with the cloud service and specifiy whether the gateway device is required to have the appropriate credentials for activating the indirectly-connected device.
The
restrictedparameter controls whether or not the client library is required to supply credentials for activating the indirectly-connected device. The client library will always supply credentials for an indirectly-connected device whose trusted assets have been provisioned to the client. If, however, the trusted assets of the indirectly-connected device have not been provisioned to the client, the client library can create credentials that attempt to restrict the indirectly connected device to this gateway device.Pass
truefor therestrictedparameter to ensure the indirectly-connected device cannot be activated by this gateway device without presenting credentials. Ifrestrictedistrue, the client library will provide credentials to the server. The server will reject the activation request if the indirectly connected device is not allowed to roam to this gateway device.Pass
falseto allow the indirectly-connected device to be activated without presenting credentials if the trusted assets of the indirectly-connected device have not been provisioned to the client. Ifrestrictedisfalse, the client library will provide credentials if, and only if, the credentials have been provisioned to the client. The server will reject the activation if credentials are required but not supplied, or if the provisioned credentials do not allow the indirectly connected device to roam to this gateway device.The
hardwareIdis a unique identifier within the cloud service instance and may not benil. If one is not present for the device, it should be generated based on other metadata such as: model, manufacturer, serial number, etc.The
metaDataMap should typically contain all the standard metadata (the constants documented in this class) along with any other vendor defined metadata.Throws
throws:
ClientError.stateif device is already activated or the shared secret has not been set for the deviceClientError.networkif there was a problem with the network call
Declaration
Swift
public func registerDevice(restricted: Bool = false, hardwareId: String, metaData: [String:String], deviceModels: String..., callback: @escaping (String?, ClientError?) -> ()) throwsParameters
restrictedindicate whether or not credentials are required for activating the indirectly connected device This is an optional parameter, the default is
false.hardwareIdan identifier unique within the cloud service instance
metaDataThe meta-data of the device
deviceModelsshould contain the device model type URNs supported by the indirectly connected device
callbackclosure to be called after registration with the endpoint id of the indirectly-connected device If registration is not successful then the object will be
niland an error object is passed in the formcallback(endpointId, error)and the reason can be taken from error
GatewayDevice Class Reference