如何使用Azure Iot获取设备的当前位置

时间:2019-04-08 18:15:46

标签: c# .net function azure iot

我们正在使用azure的IOT集线器与其连接设备,目前,这些设备已连接到PC。

如何从azure IOT集线器获取这些设备的IP或当前位置?有任何建议或建议吗?

是否可以将具有Izure功能的IOT Hub连接到IP,然后再使用Izure Maps将国家插入到Azure SQL数据库中?

感谢您的回答!我对天青很新

1 个答案:

答案 0 :(得分:0)

您尝试过设备遥测API吗?

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

at this location on GitHub提供了API的用法。

示例获取请求:

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: ...
    }
}

希望这会有所帮助。