public static string CreateWithDeviceInfo(string host, string device, string sharedaccesskey) { DeviceConnectionStringBuilder devbuild = new DeviceConnectionStringBuilder { SharedAccessKey = sharedaccesskey, DeviceId = device, HostName = host }; return(devbuild.ToString()); }
/// <summary> /// Attempt to create a deviceclient/instance of AzureIoTHub with credentials given. /// If instantiation fails, then the login page will be shown, with an error message /// </summary> /// <returns>the page to load</returns> private async Task <string> LoginWithCredentials(string host, string device, string shared) { string html = ""; string connectionString = DeviceConnectionStringBuilder.CreateWithDeviceInfo(host, device, shared); if (msgHub.Connect(connectionString)) { html = await LoadPage(NavConstants.DEFAULT_PAGE); string loc = await lp.GetLocation(); devloc = "Device Location: " + loc; html = await LoadandUpdateStatus("Device Location: #location#", devloc, NavConstants.DEFAULT_PAGE); originalPages[NavConstants.DEFAULT_PAGE] = html; } else { html = await LoadandUpdateStatus(loginStatus, Constants.LOGIN_ERROR, NavConstants.LOGIN); loginStatus = Constants.LOGIN_ERROR; } return(html); }