Skip to content

Conversation

@gutierrezps
Copy link
Contributor

Hi. Upon inspection of the source code, I saw you were checking if the tag was still near by setting _next_read_ms to a future value. This is not a good approach since millis() overflows every 50 days. The appropriate approach is to mark a previous millis and compare with the current value, as shown on this StackOverflow answer and also used on the BlinkWithoutDelay Arduino example.

So what I did was change _next_read_ms to _last_read_ms and update is_tag_near() to see if millis() - _last_read_ms < RDM6300_NEXT_READ_MS.

@arduino12 arduino12 merged commit fdf5221 into arduino12:master Jun 4, 2019
@arduino12
Copy link
Owner

Thanks @gutierrezps, I just learned something new thanks to you!

@gutierrezps gutierrezps deleted the fix-millis-rollover branch June 4, 2019 17:36
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

Successfully merging this pull request may close these issues.

2 participants