diff --git a/internal/backend/semtechudp/packets/push_data.go b/internal/backend/semtechudp/packets/push_data.go index 614c7349..184ddd65 100644 --- a/internal/backend/semtechudp/packets/push_data.go +++ b/internal/backend/semtechudp/packets/push_data.go @@ -61,6 +61,7 @@ func (p PushDataPacket) GetGatewayStats() (*gw.GatewayStats, error) { RxPacketsReceivedOk: p.Payload.Stat.RXOK, TxPacketsEmitted: p.Payload.Stat.TXNb, TxPacketsReceived: p.Payload.Stat.DWNb, + Metadata: p.Payload.Stat.Meta, } // time @@ -331,16 +332,17 @@ type PushDataPayload struct { // Stat contains the status of the gateway. type Stat struct { - Time ExpandedTime `json:"time"` // UTC 'system' time of the gateway, ISO 8601 'expanded' format (e.g 2014-01-12 08:59:28 GMT) - Lati float64 `json:"lati"` // GPS latitude of the gateway in degree (float, N is +) - Long float64 `json:"long"` // GPS latitude of the gateway in degree (float, E is +) - Alti int32 `json:"alti"` // GPS altitude of the gateway in meter RX (integer) - RXNb uint32 `json:"rxnb"` // Number of radio packets received (unsigned integer) - RXOK uint32 `json:"rxok"` // Number of radio packets received with a valid PHY CRC - RXFW uint32 `json:"rxfw"` // Number of radio packets forwarded (unsigned integer) - ACKR float64 `json:"ackr"` // Percentage of upstream datagrams that were acknowledged - DWNb uint32 `json:"dwnb"` // Number of downlink datagrams received (unsigned integer) - TXNb uint32 `json:"txnb"` // Number of packets emitted (unsigned integer) + Time ExpandedTime `json:"time"` // UTC 'system' time of the gateway, ISO 8601 'expanded' format (e.g 2014-01-12 08:59:28 GMT) + Lati float64 `json:"lati"` // GPS latitude of the gateway in degree (float, N is +) + Long float64 `json:"long"` // GPS latitude of the gateway in degree (float, E is +) + Alti int32 `json:"alti"` // GPS altitude of the gateway in meter RX (integer) + RXNb uint32 `json:"rxnb"` // Number of radio packets received (unsigned integer) + RXOK uint32 `json:"rxok"` // Number of radio packets received with a valid PHY CRC + RXFW uint32 `json:"rxfw"` // Number of radio packets forwarded (unsigned integer) + ACKR float64 `json:"ackr"` // Percentage of upstream datagrams that were acknowledged + DWNb uint32 `json:"dwnb"` // Number of downlink datagrams received (unsigned integer) + TXNb uint32 `json:"txnb"` // Number of packets emitted (unsigned integer) + Meta map[string]string `json:"meta"` // Custom meta-data (Optional, not part of PROTOCOL.TXT) } // RXPK contain a RF packet and associated metadata. diff --git a/internal/backend/semtechudp/packets/push_data_test.go b/internal/backend/semtechudp/packets/push_data_test.go index 8f638e33..4c2a5e34 100644 --- a/internal/backend/semtechudp/packets/push_data_test.go +++ b/internal/backend/semtechudp/packets/push_data_test.go @@ -127,6 +127,37 @@ func TestGetGatewayStats(t *testing.T) { TxPacketsEmitted: 6, }, }, + { + PushDataPacket: PushDataPacket{ + ProtocolVersion: ProtocolVersion2, + GatewayMAC: lorawan.EUI64{1, 2, 3, 4, 5, 6, 7, 8}, + Payload: PushDataPayload{ + Stat: &Stat{ + Time: ecNow, + RXNb: 1, + RXOK: 2, + RXFW: 3, + ACKR: 4, + DWNb: 5, + TXNb: 6, + Meta: map[string]string{ + "gateway_name": "test-gateway", + }, + }, + }, + }, + GatewayStats: &gw.GatewayStats{ + GatewayId: "0102030405060708", + Time: pbTime, + RxPacketsReceived: 1, + RxPacketsReceivedOk: 2, + TxPacketsReceived: 5, + TxPacketsEmitted: 6, + Metadata: map[string]string{ + "gateway_name": "test-gateway", + }, + }, + }, } for _, test := range testTable {