简体   繁体   中英

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.

From azure IOT Hub how we can get the IP or the current location of these devices? 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?

Thanks for your answers! I am quite new with azure

Did you try Device telemetry API ?

You can send get/ post request to get telemetry details of the devices. The API will return geo location of the device.

The usage of API is provided at this location on GitHub .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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