private async Task <DeviceRegistrationResult> SendDeviceRegistrationRequest(ICumulocityDevice device)
        {
            var body   = new StringContent("{\"id\":\"" + device.ClientId + "\"}");
            var result = await _httpClient.PostAsync(DeviceRegisterPath, body);

            return(JsonConvert.DeserializeObject <DeviceRegistrationResult>(await result.Content.ReadAsStringAsync()));
        }
        public async Task <IMqttClient> RegisterDevice(ICumulocityDevice device)
        {
            IConnectionDetails cDetails = new ConnectionDetailsBuilder()
                                          .WithClientId(device.ClientId)
                                          .WithHost(_baseUrlPath)
                                          .WithCredentials(BootstrapUser, Password)
                                          .WithCleanSession()
                                          .WithProtocol(TransportType.Tcp)
                                          .WithCleanSession()
                                          .Build();
            var client = new MqttClient(cDetails);
            await client.EstablishConnectionAsync();

            await client.SubscribeAsync(new MqttMessageRequest()
            {
                TopicName = "s/dcr"
            });

            client.MessageReceived += (sender, response) =>
            {
                Console.WriteLine(response.MessageContent);
            };
            // var res =  await _httpClient.PostAsync("/s/ucr", new StringContent(""));
            await client.PublishAsync(new MqttMessageRequestBuilder()
                                      .WithTopicName("s/ucr")
                                      .WithQoS(QoS.EXACTLY_ONCE)
                                      .WithMessageContent(string.Empty)
                                      .Build());

            return(null);
        }
        private IConnectionDetails CreateConnectionDetails(ICumulocityDevice device)
        {
            IConnectionDetails connectionDetails = new ConnectionDetailsBuilder()
                                                   .WithClientId(device.ClientId)
                                                   .WithHost(_cumulocityInfo.ServerUrl)
                                                   .WithCredentials(device.User, device.Password)
                                                   .WithCleanSession()
                                                   .WithProtocol(TransportType.Tcp)
                                                   .Build();

            return(connectionDetails);
        }