【问题标题】:How to get current location of device with Azure Iot如何使用 Azure IoT 获取设备的当前位置
【发布时间】:2019-04-08 18:15:46
【问题描述】:

我们正在使用 azure 的 IOT Hub 来连接我们的设备,目前,这些设备已连接到 PC。

我们如何从 azure IOT Hub 获取这些设备的 IP 或当前位置?有什么建议或建议吗?

是否可以通过 azure 功能连接 IOT Hub 以获取 IP,然后使用 azure maps 获取国家/地区以插入 azure sql 数据库?

感谢您的回答!我对 azure 很陌生

【问题讨论】:

    标签: c# .net function azure iot


    【解决方案1】:

    您尝试过设备遥测 API 吗?

    您可以发送 get/post 请求以获取设备的遥测详细信息。 API 将返回设备的地理位置。

    API的使用提供at this location on GitHub

    样品获取请求:

    GET {Device Telemetry endpoint}/messages?from={time}&to={time}&order=desc&grouplimit=1&devices=id1,id2,id3,...
    

    示例发布请求:

    POST {Device Telemetry endpoint}/messages-query
    Content-Type: application/json; charset=utf-8
    
    {
        From: {time}
        To: {time}
        Order: desc
        GroupLimit: 1
        Devices: [ id1, id2, id3, ... ]
    }
    

    示例响应:

    Content-Type: application/json; charset=utf-8
    
    {
        Items: [
            {
                deviceid
                time
                value 1
                value 2
                value N
                $metadata
            },
            {
                deviceid
                time
                value 1
                value 2
                value N
                $metadata
            },
            ...
        ],
        "$metadata": {
            $type: MessagesList;1
            $uri: ...
        }
    }
    

    希望这会有所帮助。

    【讨论】:

    • 感谢您的回答!我会试试!我必须在 azure 中部署一个 web api 才能做到这一点?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-08
    • 2012-03-19
    • 1970-01-01
    • 2017-09-27
    • 1970-01-01
    相关资源
    最近更新 更多