UWP项目用azure iot你们可以吗?

weixin_38048553 2017-03-11 05:13:13
  deviceClient = DeviceClient.Create("*******.azure-devices.net", new DeviceAuthenticationWithRegistrySymmetricKey("test1", "********"));
           Message re = await deviceClient.ReceiveAsync();
             
  while (true)
            {
                try
                {
                            //这里会出错,提示没有     错误信息是, * 号 我 替换 的, 绝对 正确, 用 winform 项目 就 完美 运行, uwp 项目 不行,为什么      "Message":"ErrorCode:IotHubUnauthorizedAccess;Unauthorized","ExceptionMessage":"Tracking
ID:1768b326ef8a4a5aad3cb28d7ed91c65-G:0-TimeStamp:03/11/2017 17:12:20"}
                     Microsoft.Azure.Devices.Client.Message re = await deviceClient.ReceiveAsync();
                    if (re == null)
                    {
                        continue;
                    }
                    string msg = Encoding.ASCII.GetString(re.GetBytes());
                    if (msg == "on")
                    {
                        GpioController.GetDefault().OpenPin(10).Write(GpioPinValue.High);
                    }
                    else if (msg == "off")
                    {
                        GpioController.GetDefault().OpenPin(10).Write(GpioPinValue.Low);
                    }
                }
                catch (Exception   ex)
                {

                    Debug.WriteLine(ex.Message);
                }

...全文
18 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧