Connection.setDeviceId()

DESCRIPTION

Set the device id of the device to connect to.

DECLARATION

    public func setDeviceId(id: String) throws 

PARAMETERS

key:
The device id of the target device.

ERRORS

Throws the following errors:

INVALID_STATE:
if connection already established

RETURN VALUES

None.

EXAMPLES

    func invoke() throws {
        let client = NabtoEdgeClient.Client()
        client.enableNsLogLogging()
        try client.setLogLevel(level: "trace")
        let connection = try client.createConnection()
        let privateKey = try client.createPrivateKey()
        try connection.setPrivateKey(key: privateKey)
        try connection.setProductId(id: "pr-fatqcwj9")
        try connection.setDeviceId(id: "de-ijrdq47i")
        try connection.setServerKey(key: "sk-9c826d2ebb4343a789b280fe22b98305")
        try connection.setServerConnectToken(sct: "WzwjoTabnvux")
        try connection.connect()
        let details: NabtoEdgeClient.DeviceDetails = try NabtoEdgeClient.IamUtil.getDeviceDetails(connection: connection)
        DispatchQueue.main.async {
            self.spinner.stopAnimating()
            self.label.text = "Device SDK Version: \(details.NabtoVersion)"
        }
    }