ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

使用Visual Studio Code 的 Azure IoT Tools在设备和 IoT Hub之间发送和接收消息

2020-11-30 13:06:07  阅读:243  来源: 互联网

标签:Code String Hub IoT Azure 设备


 

实验目的:

  • 使用适用于 Visual Studio Code 的 Azure IoT 工具来监视设备到云消息。

  • 使用适用于 Visual Studio Code 的 Azure IoT 工具来发送云到设备消息。

复制此 URL 并将其粘贴到浏览器窗口中,打开VS Code:vscode:extension/vsciot-vscode.azure-iot-tools

 

实验过程:

登录以访问 IoT 中心

  1. 在 VS Code 的“资源管理器” 视图中,展开左下角的“Azure IoT HUB” 部分。

  2. 在上下文菜单中单击“选择 IoT hub” 。

  3. 弹出窗口将显示在右下角,以便让你首次登录 Azure。

  4. 登录后,将显示 Azure 订阅列表,然后选择“Azure 订阅和 IoT Hub”。

  5. 几秒钟后,设备列表将显示在“Azure IoT 中心设备” 选项卡中。

     备注

    也可以选择“设置 IoT 中心连接字符串”来完成设置。 在弹出窗口中输入 IoT 设备连接到的 IoT 中心的 iothubowner 策略连接字符串。

Setup Azure IoT Hub through Connection String

You can use IoT Hub connection string to setup your IoT Hub

  1. In Explorer of VS Code, click "Azure IoT Hub Devices" in the bottom left corner.

  2. Click "Set IoT Hub Connection String" in context menu.

  3. An input box will pop up, then enter your IoT Hub Connection String (It is one-time configuration, and please make sure it is IoT Hub Connection String and not Device Connection String. The format is HostName=<my-hub>.azure-devices.net;SharedAccessKeyName=<my-policy>;SharedAccessKey=<my-policy-key>).

  4. The device list will be shown.

  5. Then you can manage your devices and interact with Azure IoT Hub through context menu.

NOTE: You can also go to File > Preferences > Settings (Code > Preferences > Settings), and update the configuration of azure-iot-toolkit.iotHubConnectionString to change your IoT Hub Connection String.

 

监视设备到云的消息

若要监视设备发送到 IoT 中心的消息,请执行以下步骤:

  1. 右键单击设备,然后选择“开始监视内置事件终结点” 。

  2. 受监视的消息将显示在“输出” > “Azure IoT Hub” 视图中。

  3. 若要停止监视,请右键单击“输出” 视图,然后选择“停止监视内置事件终结点” 。

发送“云到设备”消息

要将消息从 IoT 中心发送到设备,请执行以下步骤:

  1. 右键单击设备,然后选择“将 C2D 消息发送到设备” 。

  2. 在输入框中输入消息。

  3. 结果将显示在“输出” > “Azure IoT Hub” 视图中。

 

参照:https://docs.microsoft.com/zh-cn/azure/iot-hub/iot-hub-vscode-iot-toolkit-cloud-device-messaging 使用适用于 Visual Studio Code 的 Azure IoT 工具在设备和 IoT 中心之间发送和接收消息

标签:Code,String,Hub,IoT,Azure,设备
来源: https://blog.csdn.net/figosoar/article/details/110384870

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有