Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong test in func UpdateGatewayState to see if gateway coordinates should be updated #588

Open
2 tasks done
yguel opened this issue Jun 13, 2022 · 0 comments
Open
2 tasks done

Comments

@yguel
Copy link

yguel commented Jun 13, 2022

  • The issue is present in master and 3.16.2, I do not know if master is the latest release
  • I have searched the issues of this repository and believe that this is not a duplicate.

What happened?

When a gateway has an altitude of 0m, its other coordinates are not updated, even if they are not zeroes.
It looks logical from the code:
in chirpstack-network-server/internal/storage/gateway.go
around line 366

// UpdateGatewayState updates the location of the gateway and last seen ts.
func UpdateGatewayState(ctx context.Context, db sqlx.Execer, id lorawan.EUI64, lat, lon, alt float64) error {
	var loc *GPSPoint
	var altt *float64

	if lat != 0 && lon != 0 && alt != 0 {
		loc = &GPSPoint{
			Latitude:  lat,
			Longitude: lon,
		}
		altt = &alt
	}

	now := time.Now()

	// * only update first_seen_at when the current value is NULL
	// * only update the location when the given value is not NULL
	// * only update the altitude when the given value is not NULL

What did you expect?

I expect that an altitude of 0m does not prevent a gateway gps coordinates to be updated.
So I expect to have OR and not AND in the test:

if lat != 0 || lon != 0 || alt != 0 {

since I would expect that only the default coordinates (0,0,0) will cause coordinates not to be updated [poor ships cruising the Gulf of Guinea by the way ...]
And as altitude is coded as an integer (if I read correctly the packet_forwarder protocol) it might even be the case for a gateway 40cm above sea level (a buoy for instance).

Steps to reproduce this issue

Steps:

  1. Make a gateway publish stats like that: {"stat":{"time":"2022-06-13 12:46:27 GMT","lati":48.5777965,"long":7.7497201,"alti":0,"rxnb":0,"rxok":0,"rxfw":0,"ackr":0,"dwnb":3,"txnb":0}}
  2. gateway latitude and longitude won't be updated.

Your Environment

Component Version
Application Server v3.15.0
Network Server v3.13.0
Gateway Bridge v3.11.0
Chirpstack API
Geolocation Not installed
Concentratord Not installed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant