helium / helium-packet-router

Apache License 2.0
8 stars 8 forks source link

Metadata for gateway in Chirpstack #285

Open jpmeijers opened 9 months ago

jpmeijers commented 9 months ago

This is both a question and a feature request.

In ChirpStack I see the following Up Event:

{
    "deduplicationId": "e3eb5131-fb38-481a-b9df-003d0bee6c93",
    "time": "2023-12-22T11:56:17.743353+00:00",
    "deviceInfo": {
        "tenantId": "<REDACTED>",
        "tenantName": "JP Meijers",
        "applicationId": "<REDACTED>",
        "applicationName": "JP Sensecap T1000",
        "deviceProfileId": "<REDACTED>",
        "deviceProfileName": "SenseCap T1000 Roaming",
        "deviceName": "JP T1000",
        "devEui": "<REDACTED>",
        "deviceClassEnabled": "CLASS_A",
        "tags": {}
    },
    "devAddr": "fe00483c",
    "adr": true,
    "dr": 5,
    "fCnt": 463,
    "fPort": 0,
    "confirmed": false,
    "data": "",
    "rxInfo": [
        {
            "gatewayId": "3133303748005c00",
            "uplinkId": 45825,
            "gwTime": "2023-12-22T11:56:17.743353+00:00",
            "nsTime": "2023-12-22T11:56:28.549616823+00:00",
            "rssi": -67,
            "snr": 9.5,
            "channel": 6,
            "location": {
                "latitude": -33.95476966725685,
                "longitude": 22.434511184692386
            },
            "context": "rxh28g==",
            "metadata": {
                "region_config_id": "eu868",
                "region_common_name": "EU868"
            },
            "crcStatus": "CRC_OK"
        },
        {
            "gatewayId": "2eccbd518b5ad386",
            "uplinkId": 38534,
            "gwTime": "2023-12-22T11:56:28+00:00",
            "nsTime": "2023-12-22T11:56:28.710719511+00:00",
            "rssi": -67,
            "snr": 9.5,
            "context": "rxh28g==",
            "metadata": {
                "region_config_id": "eu868",
                "gateway_h3index": "8cbc4571e64d3ff",
                "regi": "EU868",
                "region_common_name": "EU868",
                "gateway_name": "nice-silver-shell",
                "gateway_id": "14U81Dp3D3jWFiQb6qJrCTRD3DBnii9Q9QGS6pWrNUuoV4bZn8D",
                "gateway_lat": "-33.954563040285272",
                "gateway_long": "22.434591229611467"
            },
            "crcStatus": "CRC_OK"
        }
    ],
    "txInfo": {
        "frequency": 867700000,
        "modulation": {
            "lora": {
                "bandwidth": 125000,
                "spreadingFactor": 7,
                "codeRate": "CR_4_5"
            }
        }
    }
}

Under rxInfo, the second object is a Helium IoT Hotspot, while the first one is directly connected to Chirpstack.

Under metadata for the Helium hotspot, there are a couple of fields, all pretty self explanatory.

Questions:

Requests:

michaeldjeffrey commented 9 months ago

Q1: Where are the field names for the Helium hotspot's metadata defined? Is it in https://github.com/helium/helium-packet-router/blob/b06b2758f443c04079e74daf809a156f281162bd/src/protocols/gwmp/hpr_gwmp_worker.erl#L240-L244 ?

Those are the Meta fields that will always exist. https://github.com/helium/helium-packet-router/blob/b06b2758f443c04079e74daf809a156f281162bd/src/protocols/gwmp/hpr_gwmp_worker.erl#L251-L255 These fields will be added if the gateways has a location.

michaeldjeffrey commented 9 months ago

Q2: "gatewayId": "2eccbd518b5ad386",, from the sourcecode above this looks like it's the Base58 of the Helium Gateway ID (aka PubKey). But I can't reproduce this. Can anyone help/explain please?

There are 2 gateway ids.

The MAC cannot be reversed into the b58, which is why it's also provided.

michaeldjeffrey commented 9 months ago

Request 1: Can we add a field in the metadata that explicitly states this gateway is part of Helium? Something like "network": "helium_iot",

Thanks for the PR 👍

michaeldjeffrey commented 9 months ago

Request 2: Can we populate the proper rxInfo->location object with the Hotspot's coordinates, so we can rely on standard ChirpStack endpoints to consume the location?

rxInfo->location is populated by the stat object in a PUSH_DATA frame.

The Packet Routers cannot fill out a stat object, and the location information are the only optional fields in the object, so it was removed. https://github.com/helium/helium-packet-router/pull/271