简体   繁体   English

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

[英]How to get current location of device with Azure Iot

We are using IOT Hub of azure to connect our devices with it, currently, these devices are connected to a pc. 我们正在使用IOT Azure的Hub来连接我们的设备,目前,这些设备已连接到PC。

From azure IOT Hub how we can get the IP or the current location of these devices? 从azure IOT集线器,我们如何获得这些设备的IP或当前位置? Any suggestion or recommendation to do it? 有任何建议或建议吗?

It's possible to connect IOT Hub with azure function to get the IP and after with azure maps gets the country to insert in a azure sql database? 可以将具有Izure功能的IOT Hub连接到IP,然后使用Azure Maps将国家插入到Azure SQL数据库中?

Thanks for your answers! 感谢您的回答! I am quite new with azure 我对天青很陌生

Did you try Device telemetry API ? 您是否尝试过设备遥测API?

You can send get/ post request to get telemetry details of the devices. 您可以发送获取/发布请求以获取设备的遥测详细信息。 The API will return geo location of the device. API将返回设备的地理位置。

The usage of API is provided at this location on GitHub . 在GitHub的此位置提供了API的用法。

Sample Get Request: 样品获取请求:

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

Sample Post Request: 样品后请求:

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, ... ]
}

Sample Response: 样本响应:

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

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM