GET /api/gateways/{gateway_id}/pings/last - Object does not exist

I am getting the below when using valid Gateway IDs on the GET /api/gateways/{gateway_id}/pings/last API.

{
“error”: “object does not exist”,
“message”: “object does not exist”,
“code”: 5,
“details”: []
}

I am able to GET using api/gateways without any issue. I have tried with multiple Gateway IDs which have been returned using the api/gateways. Just for clarity I have been using single Gateway IDs e.g. c0ee40ffff294cf5

Has anyone seen this before or have I missed something obvious?

The gateway may exist, but last ping may not. This is the function that tries to retrieve the last ping:

func GetLastGatewayPingAndRX(db sqlx.Queryer, mac lorawan.EUI64) (GatewayPing, []GatewayPingRX, error) {
	gw, err := GetGateway(db, mac, false)
	if err != nil {
		return GatewayPing{}, nil, errors.Wrap(err, "get gateway error")
	}

	if gw.LastPingID == nil {
		return GatewayPing{}, nil, ErrDoesNotExist
	}

	ping, err := GetGatewayPing(db, *gw.LastPingID)
	if err != nil {
		return GatewayPing{}, nil, errors.Wrap(err, "get gateway ping error")
	}

	rx, err := GetGatewayPingRXForPingID(db, ping.ID)
	if err != nil {
		return GatewayPing{}, nil, errors.Wrap(err, "get gateway ping rx for ping id error")
	}

	return ping, rx, nil
}

In particular, this part returns “object does not exist” when there’s no ping:

if gw.LastPingID == nil {
	return GatewayPing{}, nil, ErrDoesNotExist
}

So check your DB to be sure?

Thanks for your reply - I am assuming that ‘last seen’ time in the main application server portal is pulling the last ping time? In the portal all the Gateway IDs I have been testing have been seen in ‘a few seconds ago’

I am trying to pull the ‘last seen’ for each Gateway into a clients Portal. Maybe this is the wrong way to be doing it?

The ping you are trying to get isn’t related to gateway stats, is related to gateway discovery. On the other hand, just getting a gateway will give you a lastSeenAt with the response, while /api/gateways/{gateway_id}/stats lets you retrieve stats.

Thank you @iegomez - is there an API I can get the ‘lastSeeAt’ value from? I have been looking and can’t seem to find it!

Forget that last message - I have got it sorted. I misread what you had said. Many Thanks.

2 Likes