Determine which gateway is used by a given node

Dear all,

As my gateway crashed, I just saw that my application was still receiving packets from my node in the application data page from ttn console.

Is there any way to determine which gateway it is currently using to send the data?

Thanks for your help.

:warning: :warning: :warning:

This post contains references to outdated APIs.

Please read the following for the new APIs: https://www.thethingsnetwork.org/forum/t/new-api-for-gateway-mapping-status-and-info/49778


Get the gateway id(s) from the meta data, like from the MQTT JSON message or by expanding an item in the device’s Data page in TTN Console.

TTN Console example

MQTT example
{
   "app_id":"arjanvanb-app-1",
   "dev_id":"arjanvanb-bb-1",
   "hardware_serial":"70B3D5B020035CD1",
   "port":2,
   "counter":7165,
   "payload_raw":"CWUMqw0LDNM=",
   "metadata":{
      "time":"2017-04-27T10:07:27.207187339Z",
      "frequency":868.1,
      "modulation":"LORA",
      "data_rate":"SF7BW125",
      "coding_rate":"4/5",
      "gateways":[
         {
            "gtw_id":"eui-b827ebffff5fe05c",
            "timestamp":532315708,
            "time":"",
            "channel":0,
            "rssi":-57,
            "snr":9,
            "latitude":52.37447,
            "longitude":4.63576
         },
         {
            "gtw_id":"eui-5ccf7ff42f1970ec",
            "timestamp":1284851361,
            "time":"2017-04-27T10:07:26.494026Z",
            "channel":0,
            "rssi":-49,
            "snr":9,
            "rf_chain":1,
            "latitude":52.374523,
            "longitude":4.635771,
            "altitude":4
         }
      ]
   }
}

Next:

  • Simply find the matching id in the popups of nearby gateways on your local community’s map. This also gives you a link to the owner, if the gateway’s privacy settings allow for that:

    Community map popup

    TTN Console gateway privacy settings

    Note that the community maps show the owner and the id, labeled “Name”. But the global map unfortunately no longer shows ids nor owners. Instead, it shows the description, again labeled “Name”:

    Global map popup

  • Or, use that id in a TTN Mapper URL. If it starts with eui- such as eui-0000024b080606d8 then remove that prefix and uppercase the rest:

    https://ttnmapper.org/colour-radar/?type=radar&hideothers=on&gateway=0000024B080606D8

    Beware that if TTN Mapper does not know the gateway, you’ll see the same map as last time you visited the site. You might want to open the URL in a new private/incognito window.

  • Or, get the specific gateway from, e.g.:

    https://www.thethingsnetwork.org/gateway-data/gateway/eui-0000024b080606d8

    …or get all from:

    https://www.thethingsnetwork.org/gateway-data/ (aside: earlier, this did not need the trailing slash)

    …and search the id (or description, when you want to find the owner using the “Name” in the popup of a gateway on the global map):

    "eui-0000024b080606d8": {
      "id": "eui-0000024b080606d8",
      "description": "City of Haarlem, Publiekshal",
      "owner": "haarlem",
      "owners": [
         "haarlem"
      ],
      "location": {
         "latitude": 52.3816697,
         "longitude": 4.62976785,
         "altitude": 18
      },
      "country_code": "nl",
      "attributes": {
         "brand": "Kerlink",
         "model": "IoT Station",
         "placement": "outdoor"
      },
      "last_seen": "2018-03-09T07:30:28Z"
    }
    

    If this happens to have public contact details, use the value of "owner" in a TTN URL:

    https://www.thethingsnetwork.org/u/haarlem
    https://www.thethingsnetwork.org/u/arjanvanb

    Sometimes, the same username is used on the forum:

    https://www.thethingsnetwork.org/forum/u/arjanvanb

  • Similarly, one could use the id in a NOC URL, yielding slightly different details (beware, this is an HTTP URL; right-clicking and some “open in new incognito window” might help if your browser tries HTTPS instead):

    http://noc.thethingsnetwork.org:8085/api/v2/gateways/eui-0000024b080606d8

    {
       "timestamp": "2018-01-04T17:21:28.496247185Z",
       "uplink": "46859",
       "downlink": "1028",
       "location": {
          "latitude": 52.3817,
          "longitude": 4.6298175,
          "altitude": 21
       },
       "gps": {
          "latitude": 52.3817,
          "longitude": 4.6298175,
          "altitude": 21
       },
       "time": "1515086488496247185",
       "rx_ok": 46859,
       "tx_in": 1028
    }
    
  • Likewise, use the Account Server API, showing different details but still including the owner:

    https://account.thethingsnetwork.org/gateways/eui-0000024b080606d8

    {
      "id": "eui-0000024b080606d8",
      "frequency_plan": "EU_863_870",
      "public_rights": [
        "gateway:location",
        "gateway:owner",
        "gateway:status"
      ],
      "frequency_plan_url": "https://account.thethingsnetwork.org/api/v2/frequency-plans/EU_863_870",
      "location_public": true,
      "status_public": true,
      "owner_public": true,
      "attributes": {
        "model": "IoT Station",
        "brand": "Kerlink",
        "description": "City of Haarlem, Publiekshal",
        "placement": "outdoor"
      },
      "router": {
        "id": "ttn-router-eu",
        "address": "eu.thethings.network:1901",
        "mqtt_address": "mqtts://bridge.eu.thethings.network:8882"
      },
      "fallback_routers": [
        {
          "id": "ttn-router-asia-se",
          "address": "asia-se.thethings.network:1901",
          "mqtt_address": "mqtts://bridge.asia-se.thethings.network"
        },
        {
          "id": "ttn-router-us-west",
          "address": "us-west.thethings.network:1901",
          "mqtt_address": "mqtts://bridge.us-west.thethings.network"
        },
        {
          "id": "ttn-router-brazil",
          "address": "brazil.thethings.network:1901",
          "mqtt_address": "mqtts://bridge.brazil.thethings.network"
        }
      ],
      "antenna_location": {
        "altitude": 18,
        "latitude": 52.3816697,
        "longitude": 4.62976785
      },
      "location": {
        "lng": 4.62976785,
        "lat": 52.3816697,
        "longitude": 4.62976785,
        "latitude": 52.3816697
      },
      "altitude": 18,
      "owner": {
        "id": "59c93464a0134c0031de5f32",
        "username": "haarlem"
      }
    }
    
  • Likewise, use the ttnctl command line interface:

    ttnctl gateways info eui-0000024b080606d8
    
          Gateway ID: eui-0000024b080606d8
      Frequency Plan: EU_863_870
              Router: ttn-router-eu
         Auto Update: on
               Owner: haarlem
        Owner Public: yes
            Location: (52.381670, 4.629768, 18)
     Location Public: yes
       Status Public: yes
    
               Brand: Kerlink
               Model: IoT Station
           Placement: outdoor
         Description: City of Haarlem, Publiekshal
    

    Using the undocumented status in ttnctl gateways status eui-0000024b080606d8 yields some recent status information (and coordinates; see below), but no contact details like with info.

    For Meshed-connected gateways:

  • To get all gateways around some location:

    https://www.thethingsnetwork.org/gateway-data/location?latitude=52.3816697&longitude=4.62976785&distance=1000

  • To get all gateways in some country:

    https://www.thethingsnetwork.org/gateway-data/country/nl

  • To get all gateways of a specific user:

    https://www.thethingsnetwork.org/gateway-data/user/laurens

  • You can paste the coordinates into Google Maps:

    https://www.google.nl/maps/search/52.3817,4.6298175

Beware:

  • :warning: The http://noc.thethingsnetwork.org:8085 endpoint is known to be unreliable.

  • :warning: The endpoints starting with https://www.thethingsnetwork.org/gateway-data/ might not be officially supported APIs. As for validity/caching of that specific endpoint, @htdvisser wrote on Slack:

    2020-07-01 9:40 AM
    It updates live information from the NOC every minute. If the NOC is down, it serves old data for 6 hours

  • :warning: The coordinates in an uplink’s metadata may be different from what is reported using the methods above. Presumably that is caused by a gateway including GPS/GNSS coordinates, or fake GPS/GNSS coordinates (which it should not do) in its messages. It seems ttnctl gateways status uses the coordinates from the last uplink’s metadata, while ttnctl gateways info reports whatever is configured in TTN Console.

2 Likes

Hi @arjanvanb, unfortunately my gateway doesn’t show up on TTN Mapper. Do you know how can I get it added? Should I necessarily map its coverage for the gateway to show up?

Thanks for your help.

@BoRRoZ thanks for your help too.

1 Like

To get your gateway in TTN Mapper, go mapping already! :slight_smile:

https://ttnmapper.org/faq/

Thanks a lot for your detailed answer. I discovered plenty of useful tools thanks to you :slight_smile:

I’m also trying to get in touch with @jpmeijers to try adding my gateway using a node with GPS.

2 posts were merged into an existing topic: Limitations: data rate, packet size, 30 seconds uplink and 10 messages downlink per day Fair Access Policy

When I check the details of a message, I see just “packetbroker” as the gateway_id.
I have read that this has something to do with a migration of protocols.

Can someone help my finding the “real” gateway id that one of my LoRa devices uses?

Not possible at this point in time. The information you are looking for is hidden by the packetbroker.