Skip to content

enforce field limits - #228

Merged
centic9 merged 4 commits into
openambitproject:masterfrom
gustavo-iniguez-goya:enforce_limits
Nov 12, 2019
Merged

enforce field limits#228
centic9 merged 4 commits into
openambitproject:masterfrom
gustavo-iniguez-goya:enforce_limits

Conversation

@gustavo-iniguez-goya

Copy link
Copy Markdown
Contributor

As explained here #218
sometimes we get wrong values from the watches, and when uploading the
move, movescount reject it. So avoid to post wrong values to movescount.

As explained here openambitproject#218
sometimes we get wrong values from the watches, and when uploading the
move, movescount reject it. So avoid to post wrong values to movescount.
@jadahl

jadahl commented May 20, 2019

Copy link
Copy Markdown
Contributor

Are you sure you shouldn't just "overflow" the values instead of dropping them?

@gustavo-iniguez-goya

gustavo-iniguez-goya commented May 20, 2019

Copy link
Copy Markdown
Contributor Author

Well, as far as I can tell, dropping speed, vertical speed, energyconsumption and bike power fixes the problem, so those fields looks optional.
However I have my doubts about latitude and longitude fields. Movescount might ignore that track point or fail the upload. I don't know because I haven't had such errors with my Ambit 2.

That's why I sent a PR to display errors uploading moves, to see this kind of problems.

@centic9 centic9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some checks seem to not have any effect, can you review if these are false positives in CLion or really not changing behavior?

Comment thread src/movescount/movescountjson.cpp Outdated
Comment thread src/movescount/movescountjson.cpp Outdated
break;
case ambit_log_sample_periodic_type_longitude:
output.insert("Longitude", (double)value->u.longitude/10000000);
if (value->u.longitude != 0xffffffff && value->u.longitude <= 180 && value->u.longitude >= -180){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same warning about comparison to 0xff...

Comment thread src/movescount/movescountjson.cpp Outdated
Comment thread src/movescount/movescountjson.cpp Outdated
Comment thread src/movescount/movescountjson.cpp Outdated
break;
case ambit_log_sample_periodic_type_bikepower:
if (value->u.bikepower != 0xffff) {
if (value->u.bikepower != 0xffff && value->u.bikepower <= 2000) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLion reports a reduntant check on the comparison to 0xff..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case the idea is to check if bikepower is present and if it is, include it only if it's lower than 2000. Sometimes I get >= 3000 values.

E.g. values of type unit8_t it cannot be higher than 255 anyway
Remove some unused includes
If we check for >=, the check for 0xfffffff is not necessary any longer
@centic9
centic9 merged commit a925cfd into openambitproject:master Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants