//根据设备的唯一标识IotId获取设备详细信息
        public void TestQueryDeviceByIotId()
        {
            DefaultAcsClient acsClient = Demo.IotClient.GetClient();

            QueryDeviceDetailRequest request = new QueryDeviceDetailRequest();

            request.ProductKey = "<productKey>";
            request.DeviceName = "device0821";

            QueryDeviceDetailResponse response = acsClient.GetAcsResponse(request);

            Console.WriteLine(response.Success);
            Console.WriteLine(response.ErrorMessage);

            QueryDeviceDetailResponse.QueryDeviceDetail_Data DeviceInfo = response.Data;


            QueryDeviceDetailRequest anotherRequest = new QueryDeviceDetailRequest();

            anotherRequest.IotId = DeviceInfo.IotId;

            QueryDeviceDetailResponse anotherResponse = acsClient.GetAcsResponse(anotherRequest);

            QueryDeviceDetailResponse.QueryDeviceDetail_Data DeviceInfo2 = anotherResponse.Data;

            Console.WriteLine("productKey: " + DeviceInfo2.ProductKey);
            Console.WriteLine("deviceName: " + DeviceInfo2.DeviceName);
            Console.WriteLine("iotId: " + DeviceInfo2.IotId);
        }
Beispiel #2
0
        public static QueryDeviceDetailResponse Unmarshall(UnmarshallerContext context)
        {
            QueryDeviceDetailResponse queryDeviceDetailResponse = new QueryDeviceDetailResponse();

            queryDeviceDetailResponse.HttpResponse = context.HttpResponse;
            queryDeviceDetailResponse.RequestId    = context.StringValue("QueryDeviceDetail.RequestId");
            queryDeviceDetailResponse.Success      = context.BooleanValue("QueryDeviceDetail.Success");
            queryDeviceDetailResponse.Code         = context.StringValue("QueryDeviceDetail.Code");
            queryDeviceDetailResponse.ErrorMessage = context.StringValue("QueryDeviceDetail.ErrorMessage");

            QueryDeviceDetailResponse.QueryDeviceDetail_Data data = new QueryDeviceDetailResponse.QueryDeviceDetail_Data();
            data.IotId                     = context.StringValue("QueryDeviceDetail.Data.IotId");
            data.ProductKey                = context.StringValue("QueryDeviceDetail.Data.ProductKey");
            data.ProductName               = context.StringValue("QueryDeviceDetail.Data.ProductName");
            data.DeviceName                = context.StringValue("QueryDeviceDetail.Data.DeviceName");
            data.DeviceSecret              = context.StringValue("QueryDeviceDetail.Data.DeviceSecret");
            data.FirmwareVersion           = context.StringValue("QueryDeviceDetail.Data.FirmwareVersion");
            data.GmtCreate                 = context.StringValue("QueryDeviceDetail.Data.GmtCreate");
            data.UtcCreate                 = context.StringValue("QueryDeviceDetail.Data.UtcCreate");
            data.GmtActive                 = context.StringValue("QueryDeviceDetail.Data.GmtActive");
            data.UtcActive                 = context.StringValue("QueryDeviceDetail.Data.UtcActive");
            data.GmtOnline                 = context.StringValue("QueryDeviceDetail.Data.GmtOnline");
            data.UtcOnline                 = context.StringValue("QueryDeviceDetail.Data.UtcOnline");
            data.Status                    = context.StringValue("QueryDeviceDetail.Data.Status");
            data.IpAddress                 = context.StringValue("QueryDeviceDetail.Data.IpAddress");
            data.NodeType                  = context.IntegerValue("QueryDeviceDetail.Data.NodeType");
            data.Region                    = context.StringValue("QueryDeviceDetail.Data.Region");
            queryDeviceDetailResponse.Data = data;

            return(queryDeviceDetailResponse);
        }
        //批量更新多个设备的nickname
        public void TestBatchUpdateDeviceNickname()
        {
            DefaultAcsClient acsClient = Demo.IotClient.GetClient();

            String productKey = "<productKey>";
            BatchUpdateDeviceNicknameRequest request1 = new BatchUpdateDeviceNicknameRequest();

            List <BatchUpdateDeviceNicknameRequest.DeviceNicknameInfo> DeviceNicknameInfos = new List <BatchUpdateDeviceNicknameRequest.DeviceNicknameInfo>();

            BatchUpdateDeviceNicknameRequest.DeviceNicknameInfo deviceNickname1 = new BatchUpdateDeviceNicknameRequest.DeviceNicknameInfo();
            deviceNickname1.ProductKey = productKey;
            deviceNickname1.DeviceName = "device_0821_147";
            deviceNickname1.Nickname   = "nick147";
            DeviceNicknameInfos.Add(deviceNickname1);


            BatchUpdateDeviceNicknameRequest.DeviceNicknameInfo deviceNickname2 = new BatchUpdateDeviceNicknameRequest.DeviceNicknameInfo();
            deviceNickname2.ProductKey = productKey;
            deviceNickname2.DeviceName = "device_0821_148";
            deviceNickname2.Nickname   = "nick148";
            DeviceNicknameInfos.Add(deviceNickname2);
            request1.DeviceNicknameInfos = DeviceNicknameInfos;


            BatchUpdateDeviceNicknameResponse response1 = acsClient.GetAcsResponse(request1);

            Console.WriteLine("Update DeviceNickname: " + response1.Success);
            if (!(bool)response1.Success)
            {
                Console.WriteLine(response1.Code + ", " + response1.ErrorMessage);
            }

            QueryDeviceDetailRequest request2 = new QueryDeviceDetailRequest();

            request2.ProductKey = productKey;
            request2.DeviceName = deviceNickname1.DeviceName;

            QueryDeviceDetailResponse response2 = acsClient.GetAcsResponse(request2);

            Console.WriteLine(response2.Success);
            Console.WriteLine(response2.ErrorMessage);

            QueryDeviceDetailResponse.QueryDeviceDetail_Data DeviceInfo = response2.Data;
            Console.WriteLine("productKey: " + DeviceInfo.ProductKey);
            Console.WriteLine("deviceName: " + DeviceInfo.DeviceName);
            Console.WriteLine("iotId: " + DeviceInfo.IotId);
            Console.WriteLine("Nickname: " + DeviceInfo.Nickname);
        }