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
Infer location from decoded payload and publish location solved #4311
Infer location from decoded payload and publish location solved #4311
Conversation
pkg/applicationserver/payload.go
Outdated
{"latitudeDeg", "longitudeDeg", "altitude"}, | ||
{"latitudeDeg", "longitudeDeg", "height"}, | ||
{"gps_lat", "gps_lng", "gps_alt"}, | ||
{"gps_lat", "gps_lng", "gpsalt"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand this code correctly, this will only allow these 9 possible sets of keys, and no other combinations of them. Won't it be better to check one field at a time, trying all it's possibilities, before checking the next field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ie, say I have the fields latitude
, long
and altitude
, then this algorithm won't accept it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes indeed. I wanted to make this explicit, to not trigger magic behavior when these keys aren't really consistent (like latitudeDeg
and gps_lng
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I see your point. My opinion is slightly different: I try my best to obtain a valid location, no matter how "broken" the payload parser may be.
From TTN Mapper's side we recommend a specific set of keys:
https://docs.ttnmapper.org/FAQ.html#using-a-gps-tracker-device-transmitting-gps-coordinates-in-the-lora-payload
The JSON object should contain the keys “latitude”, “longitude” and “altitude” and one of “hdop”, “accuracy” or “sats”
Something more to note here is that sats, hdop and accuracy are handled as three different things. They are inherently three different ways to indicate how reliable the gps location is. Putting hdop into a field called "accuracy" can cause confusion, as an accuracy of 3 metres is good, but an hdop of 3 is bad.
I still think we should split the parsing of the decoded payload out into a module which we can share, and I can help maintain. There are some edge cases that are currently not handled here. For example a Digital Matter Yabby or Oyster device sends a https://github.com/ttnmapper/ingress-api/blob/master/utils/payload_fields_parser.go#L195-L197 and https://github.com/ttnmapper/ingress-api/blob/master/utils/payload_fields_parser.go#L213-216 If we don't handle edge cases like these in the TTI location inference, the |
Right. I see also that this codec is in the device repository; https://github.com/TheThingsNetwork/lorawan-devices/blob/master/vendor/digital-matter/oyster.js. Now, isn't that an issue with this codec? Shouldn't it become |
Yes agreed. But that means we need to lecture codec writers on properly naming fields. Digital Matter isn't the first, and won't be the last that does something like this. The second example was Tabs - one that can be seen as a reference implementation by some. |
OK, there will be a module that we can both import. I'll change this PR to use that module. I really want to avoid more magic in there that checks arbitrary fields whether the location is valid or not. In the particular case of Oyster and Yabby, I would strongly prefer putting coordinates under |
410748b
to
edc16cd
Compare
@jpmeijers please see https://pkg.go.dev/go.thethings.network/lorawan-application-payload. I welcome any suggestions in https://github.com/TheThingsNetwork/lorawan-application-payload. |
Summary
Closes #4176
cc @jpmeijers
Changes
Testing
Unit testing
Regressions
None expected
Notes for Reviewers
Only functional change is in b6863bb
Checklist
README.md
for the chosen target branch.CHANGELOG.md
.CONTRIBUTING.md
, there are no fixup commits left.