private async Task Connect(string thingName, bool isConnected) { try { string jsonStr = string.Format(CONNECT_JSON_TEMPLATE, isConnected ? "true" : "false"); UpdateThingShadowRequest req = new UpdateThingShadowRequest(); req.ThingName = thingName; req.Payload = new MemoryStream(Encoding.UTF8.GetBytes(jsonStr)); UpdateThingShadowResponse res = await _client.UpdateThingShadowAsync(req); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void UpdateDevice(string location, string payload) { UpdateThingShadowRequest updateRequest = new UpdateThingShadowRequest(); updateRequest.Payload = new MemoryStream(Encoding.UTF8.GetBytes(payload)); // "store1_aisle1" updateRequest.ThingName = GetIotDeviceName(location); var response = _client.UpdateThingShadowAsync(updateRequest, new System.Threading.CancellationToken()); response.Wait(); }